Files
nanguangszwlback/mhd_bms/src/main/resources/mapper/BmsInvoiceListMapper.xml
T
2026-04-17 09:29:27 +08:00

171 lines
8.6 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mhd.bms.domain.bmsInvoiceList.repository.mapper.BmsInvoiceListMapper">
<select id="queryList" parameterType="java.lang.String" resultType="com.mhd.bms.domain.bmsInvoiceList.repository.vo.BmsInvoiceListVO">
select
<include refid="field_where"></include>
FROM
bms_invoice_list a left join BILL_MANAGE b on a.apply_number = b.apply_number
where a.is_delete = 0
<include refid="common_where"></include>
group by a.id
order by a.create_time desc
</select>
<select id="getById" parameterType="java.lang.String" resultType="com.mhd.bms.domain.bmsInvoiceList.repository.vo.BmsInvoiceListDetailsVO">
select
<include refid="field_where2"></include>
from
bms_invoice_list a
LEFT JOIN bms_invoice_info b
ON a.invoice_title = b.invoice_title
where a.id = #{id} and a.is_delete = 0
group by a.id
</select>
<select id="getByApplyNumber" parameterType="java.lang.String" resultType="com.mhd.bms.domain.bmsInvoiceList.repository.vo.BmsInvoiceListDetailsVO">
select
<include refid="field_where2"></include>
from
bms_invoice_list a
LEFT JOIN bms_invoice_info b
ON a.invoice_title = b.invoice_title
where a.apply_number = #{applyNumber} and a.is_delete = 0
group by a.id
</select>
<sql id="common_where">
<if test="bmsInvoiceListQueryDTO.id !=null and bmsInvoiceListQueryDTO.id != ''"> and a.id = #{bmsInvoiceListQueryDTO.id} </if>
<if test="bmsInvoiceListQueryDTO.billNumber !=null and bmsInvoiceListQueryDTO.billNumber != ''"> and b.bill_number like concat('%', #{bmsInvoiceListQueryDTO.billNumber}, '%') </if>
<if test="bmsInvoiceListQueryDTO.id!=null and bmsInvoiceListQueryDTO.id!=''"> and instr(a.id ,#{bmsInvoiceListQueryDTO.id}) > 0 </if>
<if test="bmsInvoiceListQueryDTO.invoiceState!=null"> and instr(a.invoice_state ,#{bmsInvoiceListQueryDTO.invoiceState}) > 0 </if>
<if test="bmsInvoiceListQueryDTO.createStartTime!=null and bmsInvoiceListQueryDTO.createEndTime!=null ">
and DATE_FORMAT(a.invoice_apply_time,'%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{bmsInvoiceListQueryDTO.createStartTime},'%Y-%m-%d')
and DATE_FORMAT(a.invoice_apply_time,'%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{bmsInvoiceListQueryDTO.createEndTime},'%Y-%m-%d')
</if>
<if test="bmsInvoiceListQueryDTO.invoiceMakeTimeStart!=null and bmsInvoiceListQueryDTO.invoiceMakeTimeEnd!=null ">
and DATE_FORMAT(a.invoice_make_time,'%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{bmsInvoiceListQueryDTO.invoiceMakeTimeStart},'%Y-%m-%d')
and DATE_FORMAT(a.invoice_make_time,'%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{bmsInvoiceListQueryDTO.invoiceMakeTimeEnd},'%Y-%m-%d')
</if>
<if test="bmsInvoiceListQueryDTO.managerTimeStart!=null and bmsInvoiceListQueryDTO.managerTimeEnd!=null ">
and DATE_FORMAT(a.manager_time,'%Y-%m-%d') <![CDATA[>=]]> DATE_FORMAT(#{bmsInvoiceListQueryDTO.managerTimeeStart},'%Y-%m-%d')
and DATE_FORMAT(a.manager_time,'%Y-%m-%d') <![CDATA[<=]]> DATE_FORMAT(#{bmsInvoiceListQueryDTO.managerTimeTimeEnd},'%Y-%m-%d')
</if>
<if test="bmsInvoiceListQueryDTO.remark !=null and bmsInvoiceListQueryDTO.remark != ''">
and a.remark LIKE CONCAT('%',#{bmsInvoiceListQueryDTO.remark},'%')
</if>
<if test="bmsInvoiceListQueryDTO.actualInvoiceCustomerName != null and bmsInvoiceListQueryDTO.actualInvoiceCustomerName != ''">
and (SELECT
LISTAGG(ACTUAL_INVOICE_CUSTOMER_NAME, ', ') WITHIN GROUP (ORDER BY ACTUAL_INVOICE_CUSTOMER_NAME) as name
FROM BMS_MAKE_OUT_INVOICE
WHERE
INVOICE_ID = a.id) LIKE CONCAT('%',#{bmsInvoiceListQueryDTO.actualInvoiceCustomerName},'%')
</if>
<if test="bmsInvoiceListQueryDTO.createBy !=null and bmsInvoiceListQueryDTO.createBy != ''"> and a.create_by = #{bmsInvoiceListQueryDTO.createBy} </if>
<!-- 部门 -->
<if test="bmsInvoiceListQueryDTO.sysOrgCode!=null and bmsInvoiceListQueryDTO.sysOrgCode!=''">
and a.sys_org_code = #{bmsInvoiceListQueryDTO.sysOrgCode}
</if>
<if test="bmsInvoiceListQueryDTO.applyNumber != null and bmsInvoiceListQueryDTO.applyNumber != ''">
and a.apply_number LIKE CONCAT('%',#{bmsInvoiceListQueryDTO.applyNumber},'%')
</if>
<if test="bmsInvoiceListQueryDTO.shipperName != null and bmsInvoiceListQueryDTO.shipperName != ''">
and a.shipper_name LIKE CONCAT('%',#{bmsInvoiceListQueryDTO.shipperName},'%')
</if>
<if test="bmsInvoiceListQueryDTO.shipperId != null and bmsInvoiceListQueryDTO.shipperId != ''">
and a.shipper_id = #{bmsInvoiceListQueryDTO.shipperId}
</if>
<if test="bmsInvoiceListQueryDTO.companyName != null and bmsInvoiceListQueryDTO.companyName != ''">
and a.company_name LIKE CONCAT('%',#{bmsInvoiceListQueryDTO.companyName},'%')
</if>
<if test="bmsInvoiceListQueryDTO.invoiceTitle != null and bmsInvoiceListQueryDTO.invoiceTitle != ''">
and a.invoice_title LIKE CONCAT('%',#{bmsInvoiceListQueryDTO.invoiceTitle},'%')
</if>
<if test="bmsInvoiceListQueryDTO.organizationId != null ">
and a.organization_id = #{bmsInvoiceListQueryDTO.organizationId}
and a.organization_name IS NOT NULL
</if>
<if test="bmsInvoiceListQueryDTO.topOrganizationId != null ">
and a.top_organization_id = #{bmsInvoiceListQueryDTO.topOrganizationId}
<if test="bmsInvoiceListQueryDTO.organizationId == null">
and a.organization_name IS NOT NULL
</if>
</if>
<if test="bmsInvoiceListQueryDTO.organizationName != null and bmsInvoiceListQueryDTO.organizationName != ''">
and a.organization_name LIKE CONCAT('%',#{bmsInvoiceListQueryDTO.organizationName},'%')
</if>
</sql>
<sql id="field_where">
a.id,
a.invoice_title,
a.invoice_value,
a.remark,
a.invoice_state,
(CASE
a.invoice_state
WHEN 0 THEN
'未开票'
WHEN 1 THEN
'已取消申请'
WHEN 2 THEN
'已开票'
WHEN 3 THEN
'已驳回'
WHEN 4 THEN
'已寄出'
WHEN 5 THEN
'已作废' ELSE NULL
END
) AS invoice_state_name,
a.invoice_apply_time,
a.applicant_id,
a.reject_reason,
a.transportation_ids,
a.refund_remark,
a.manager_id,
a.manager_time,
a.send_by_id,
a.send_time,
a.send_postage,
a.courier_services_company,
a.receiving_address_id,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.is_delete,
a.sys_org_code,
a.invoice_type,
a.invoice_nature,
a.invoice_number,
a.invoice_code,
a.tracking_number,
a.apply_number,
a.company_name as companyName,
-- b.bill_number as billNumber,
-- b.bill_manage_id as billManageId,
(SELECT LISTAGG(bill_number, ', ') WITHIN GROUP (ORDER BY bill_number)
FROM BILL_MANAGE b_sub
WHERE b_sub.apply_number = a.apply_number) as billNumber,
(SELECT LISTAGG(bill_manage_id, ', ') WITHIN GROUP (ORDER BY bill_manage_id)
FROM BILL_MANAGE b_sub
WHERE b_sub.apply_number = a.apply_number) as billManageId,
a.SETTLEMENT_CURRENCY as settlementCurrency,
a.organization_id AS organizationId,
a.organization_name AS organizationName,
a.tax_reg_account AS taxRegAccount,
(SELECT
LISTAGG(ACTUAL_INVOICE_CUSTOMER_NAME, ', ') WITHIN GROUP (ORDER BY ACTUAL_INVOICE_CUSTOMER_NAME) as name
FROM BMS_MAKE_OUT_INVOICE
WHERE
INVOICE_ID = a.id) as actualInvoiceCustomerName,
a.top_organization_id AS topOrganizationId
</sql>
<sql id="field_where2">
a.id,a.invoice_title,a.invoice_value,a.remark,a.invoice_state,a.invoice_apply_time,a.applicant_id,a.reject_reason,a.manager_id,a.manager_time,
a.send_by_id,a.send_time,a.send_postage, a.courier_services_company,a.receiving_address_id,a.create_time,b.tax_reg_account,a.transportation_ids,
b.tax_reg_account,b.invoice_title,a.shipper_id,a.shipper_name,a.company_name,a.invoice_make_time,a.tax_reg_account reg_account
</sql>
</mapper>