Files
nanguangszwlback/mhd_finance/src/main/resources/mapper/businessDocument/BusinessDocumentMapper.xml
T
2026-01-15 11:45:33 +08:00

300 lines
14 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.linke.finance.domain.businessDocument.repository.mapper.BusinessDocumentMapper">
<resultMap type="com.linke.finance.domain.businessDocument.repository.po.BusinessDocumentPO" id="BusinessDocumentResult">
<result property="businessDocumentId" column="business_document_id" />
<result property="reconciliationId" column="reconciliation_id" />
<result property="verificationMoney" column="verification_money" />
<result property="userId" column="user_id" />
<result property="waybillNumber" column="waybill_number" />
<result property="waybillSource" column="waybill_source" />
<result property="waybillSourceName" column="waybill_source_name" />
<result property="receivableType" column="receivable_type" />
<result property="loadingAdress" column="loading_adress" />
<result property="unloadAdress" column="unload_adress" />
<result property="payableAmount" column="payable_amount" />
<result property="receivableAmount" column="receivable_amount" />
<result property="carrierName" column="carrier_name" />
<result property="driverName" column="driver_name" />
<result property="shipperName" column="shipper_name" />
<result property="vehicleLicensePlateNumber" column="vehicle_license_plate_number" />
<result property="receptionTime" column="reception_time" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="createByName" column="create_by_name" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="updateByName" column="update_by_name" />
<result property="delFlag" column="del_flag" />
<result property="organizationId" column="organization_id" />
<result property="topOrganizationId" column="top_organization_id" />
</resultMap>
<sql id="selectBusinessDocumentPo">
select * from business_document
</sql>
<sql id="selectBusinessDocumentPo1">
<if test="reconciliationId != null ">
and reconciliation_id = #{reconciliationId}
</if>
<if test="auditStatus != null ">
and audit_status = #{auditStatus}
</if>
<if test="verificationMoney != null ">
and verification_money = #{verificationMoney}
</if>
<if test="userId != null ">
and user_id = #{userId}
</if>
<if test="waybillNumber != null and waybillNumber != ''">
and waybill_number = #{waybillNumber}
</if>
<if test="waybillSource != null and waybillSource != ''">
and waybill_source = #{waybillSource}
</if>
<if test="waybillSourceName != null and waybillSourceName != ''">
and waybill_source_name like concat('%', #{waybillSourceName}, '%')
</if>
<if test="receivableType != null ">
and receivable_type = #{receivableType}
</if>
<if test="payStatus != null ">
and pay_status = #{payStatus}
</if>
<if test="loadingAdress != null and loadingAdress != ''">
and loading_adress = #{loadingAdress}
</if>
<if test="unloadAdress != null and unloadAdress != ''">
and unload_adress = #{unloadAdress}
</if>
<if test="payableAmount != null ">
and payable_amount = #{payableAmount}
</if>
<if test="receivableAmount != null ">
and receivable_amount = #{receivableAmount}
</if>
<if test="carrierName != null and carrierName != ''">
and carrier_name like concat('%', #{carrierName}, '%')
</if>
<if test="driverName != null and driverName != ''">
and driver_name like concat('%', #{driverName}, '%')
</if>
<if test="shipperName != null and shipperName != ''">
and shipper_name like concat('%', #{shipperName}, '%')
</if>
<if test="shipperInfo != null and shipperInfo != ''">
and (shipper_name like concat('%', #{shipperInfo}, '%')
or phone like concat('%', #{shipperInfo}, '%'))
</if>
<if test="vehicleLicensePlateNumber != null and vehicleLicensePlateNumber != ''">
and vehicle_license_plate_number = #{vehicleLicensePlateNumber}
</if>
<if test="receptionTime != null ">
and reception_time = #{receptionTime}
</if>
<if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="updateByName != null and updateByName != ''">
and update_by_name like concat('%', #{updateByName}, '%')
</if>
<if test="organizationId != null ">
and organization_id = #{organizationId}
</if>
<if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId}
</if>
<if test="waybillNoList != null and waybillNoList.size() > 0">
and waybill_number in
<foreach item="waybillNo" index="index" collection="waybillNoList" open="(" separator=" , " close=")">
#{waybillNo}
</foreach>
</if>
<if test="createTimeStart != null and createTimeStart != ''">
AND date_format(create_time,'%Y-%m-%d') >= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''">
AND date_format(create_time,'%Y-%m-%d') <![CDATA[<=]]> #{createTimeEnd}
</if>
</sql>
<select id="queryList" parameterType="com.linke.finance.domain.businessDocument.repository.todo.BusinessDocumentDO" resultMap="BusinessDocumentResult">
<include refid="selectBusinessDocumentPo"/>
where del_flag = 1
<include refid="selectBusinessDocumentPo1"/>
</select>
<select id="getFeeList" parameterType="java.lang.String" resultType="java.util.Map">
SELECT
SUBJECT_NAME,max(AMOUNT) as AMOUNT
FROM
RECONCILIATION r left join RECONCILIATION_ACCOUNT acc on acc.RECONCILIATION_ID = r.RECONCILIATION_ID left join NGWL_TEST_WLHY.TMS_INVOICE_LIST tms on r.APPLY_NUMBER = tms.APPLY_NUMBER
WHERE
tms.ID = #{invoiceId} group by SUBJECT_NAME
</select>
<select id="queryInvoiceList" resultType="com.linke.finance.domain.businessDocument.repository.po.BusinessDocumentPO" parameterType="com.linke.finance.domain.businessDocument.repository.todo.BusinessDocumentDO">
<include refid="selectBusinessDocumentPo"/>
where del_flag = 1
<include refid="common_where_one"></include>
</select>
<select id="initiateReconciliation"
resultType="com.linke.finance.domain.businessDocument.repository.po.BusinessDocumentPO">
SELECT
user_id,
organization_name,
shipper_name,
phone,
SUM( receivable_amount ) receivable_amount,
COUNT( 1 ) waybillCount,
waybill_source_name
FROM
business_document
where del_flag = 1
<include refid="selectBusinessDocumentPo1"/>
GROUP BY
user_id,waybill_source
</select>
<select id="queryListByInvoiceId" resultType="com.linke.finance.domain.businessDocument.repository.po.BusinessDocumentAppPO" parameterType="java.lang.Long">
<include refid="selectBusinessDocumentPo"/>
where del_flag = 1
and invoice_info_id = #{invoiceInfoId}
</select>
<select id="businessDocumentList" resultType="com.linke.finance.domain.businessDocument.repository.po.AccountsReceivableAppPO" parameterType="com.linke.finance.domain.businessDocumentDetali.repository.todo.BusinessDocumentDetaliDO">
SELECT
bdd.*
FROM
business_document_detali bdd
<!-- LEFT JOIN business_document bd ON bdd.business_document_id = bd.business_document_id-->
WHERE
bdd.del_flag = 1
AND bdd.payment_status = 1
<include refid="common_where_two"></include>
ORDER BY bdd.create_time DESC
</select>
<select id="queryListByReconciliation"
resultType="com.linke.finance.domain.businessDocument.repository.po.BusinessDocumentPO">
SELECT
a.*
FROM
business_document a
LEFT JOIN reconciliation_business_document c ON a.business_document_id = c.business_document_id
LEFT JOIN reconciliation d ON c.reconciliation_id = d.reconciliation_id
WHERE
a.del_flag = 1
AND d.del_flag = 1
AND d.inner_number IN
<foreach item="waybillNo" collection="waybillNoList" open="(" separator="," close=")">
#{waybillNo}
</foreach>
</select>
<sql id="common_where_two">
<if test="businessDocumentDO.carrierId != null ">
AND bdd.pay_id = #{businessDocumentDO.carrierId}
</if>
<if test="businessDocumentDO.receptionTimeStart != null and businessDocumentDO.receptionTimeStart != ''">
AND date_format(bdd.create_time,'%Y-%m-%d') >= #{businessDocumentDO.receptionTimeStart}
</if>
<if test="businessDocumentDO.receptionTimeEnd != null and businessDocumentDO.receptionTimeEnd != ''">
AND date_format(bdd.create_time,'%Y-%m-%d') <![CDATA[<=]]> #{businessDocumentDO.receptionTimeEnd}
</if>
</sql>
<sql id="common_where_one">
<if test="businessDocumentDO.userId != null ">
and user_id = #{businessDocumentDO.userId}
</if>
<if test="businessDocumentDO.receivableType != null ">
and receivable_type = #{businessDocumentDO.receivableType}
</if>
<if test="businessDocumentDO.waybillVerifyFlag != null ">
and waybill_verify_flag = #{businessDocumentDO.waybillVerifyFlag}
</if>
<if test="businessDocumentDO.invoiceApplyStatus != null ">
and invoice_apply_status = #{businessDocumentDO.invoiceApplyStatus}
</if>
<if test="businessDocumentDO.payStatus != null ">
and pay_status = #{businessDocumentDO.payStatus}
</if>
<if test="businessDocumentDO.payStatusShipper != null ">
and pay_status_shipper = #{businessDocumentDO.payStatusShipper}
</if>
<if test="businessDocumentDO.organizationId != null ">
and organization_id = #{businessDocumentDO.organizationId}
</if>
<if test="businessDocumentDO.topOrganizationId != null ">
and top_organization_id = #{businessDocumentDO.topOrganizationId}
</if>
<if test="businessDocumentDO.createTimeStart != null and businessDocumentDO.createTimeStart != ''">
AND date_format(create_time,'%Y-%m-%d') >= #{businessDocumentDO.createTimeStart}
</if>
<if test="businessDocumentDO.createTimeEnd != null and businessDocumentDO.createTimeEnd != ''">
AND date_format(create_time,'%Y-%m-%d') <![CDATA[<=]]> #{businessDocumentDO.createTimeEnd}
</if>
<if test="businessDocumentDO.payTimeStart != null and businessDocumentDO.payTimeStart != ''">
AND date_format(pay_time,'%Y-%m-%d') >= #{businessDocumentDO.payTimeStart}
</if>
<if test="businessDocumentDO.payTimeEnd != null and businessDocumentDO.payTimeEnd != ''">
AND date_format(pay_time,'%Y-%m-%d') <![CDATA[<=]]> #{businessDocumentDO.payTimeEnd}
</if>
<if test="businessDocumentDO.payTimeShipperStart != null and businessDocumentDO.payTimeShipperStart != ''">
AND date_format(pay_time_shipper,'%Y-%m-%d') >= #{businessDocumentDO.payTimeShipperStart}
</if>
<if test="businessDocumentDO.payTimeShipperEnd != null and businessDocumentDO.payTimeShipperEnd != ''">
AND date_format(pay_time_shipper,'%Y-%m-%d') <![CDATA[<=]]> #{businessDocumentDO.payTimeShipperEnd}
</if>
<if test="businessDocumentDO.createByName != null and businessDocumentDO.createByName != ''">
AND create_by_name like concat('%', #{businessDocumentDO.createByName}, '%')
</if>
<if test="businessDocumentDO.waybillNumber != null and businessDocumentDO.waybillNumber != ''">
AND waybill_number like concat('%', #{businessDocumentDO.waybillNumber}, '%')
</if>
</sql>
<select id="querySettlementList" resultType="com.linke.finance.domain.businessDocumentDetali.repository.po.BusinessDocumentDetaliPO" parameterType="com.linke.finance.domain.businessDocument.repository.todo.BusinessDocumentDO">
SELECT
amount,
first_subject,
first_subject_name,
second_subject,
second_subject_name,
pay_time,
update_by_name,
service
FROM
business_document_detali
WHERE
del_flag = 1
AND audit_status = 2
<include refid="common_where_three"></include>
</select>
<sql id="common_where_three">
<if test="businessDocumentDO.topOrganizationId != null ">
and top_organization_id = #{businessDocumentDO.topOrganizationId}
</if>
<if test="businessDocumentDO.waybillNumber != null and businessDocumentDO.waybillNumber != ''">
AND waybill_number = #{businessDocumentDO.waybillNumber}
</if>
<if test="businessDocumentDO.queryType != null and businessDocumentDO.queryType==1">
AND pay_status_shipper = 1
</if>
<if test="businessDocumentDO.queryType != null and businessDocumentDO.queryType==2">
AND pay_status = 1
</if>
</sql>
</mapper>