Files
nanguangszwlback/mhd_finance/src/main/resources/mapper/verification/VerificationMapper.xml
T

1199 lines
71 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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.verification.repository.mapper.VerificationMapper">
<resultMap type="com.mhd.common.core.domain.po.VerificationPo" id="VerificationResult">
<result property="verificationId" column="verification_id" />
<result property="verificationStatus" column="verification_status" />
<result property="businessDocumentId" column="business_document_id" />
<result property="businessDocumentNumber" column="business_document_number" />
<result property="businessType" column="business_type" />
<result property="innerNumber" column="inner_number" />
<result property="enterAccountTime" column="enter_account_time" />
<result property="expenseItem" column="expense_item" />
<result property="firstSubject" column="first_subject" />
<result property="secondSubject" column="second_subject" />
<result property="firstSubjectName" column="first_subject_name" />
<result property="secondSubjectName" column="second_subject_name" />
<result property="verificationMoney" column="verification_money" />
<result property="payPerson" column="pay_person" />
<result property="payChannel" column="pay_channel" />
<result property="payChannelName" column="pay_channel_name" />
<result property="payWay" column="pay_way" />
<result property="payWayName" column="pay_way_name" />
<result property="bankNumber" column="bank_number" />
<result property="receiptNumber" column="receipt_number" />
<result property="departmentId" column="department_id" />
<result property="departmentName" column="department_name" />
<result property="payee" column="payee" />
<result property="payType" column="pay_type" />
<result property="payId" column="pay_id" />
<result property="payName" column="pay_name" />
<result property="licenseNumber" column="license_number" />
<result property="auditRemark" column="audit_remark" />
<result property="accountHolderBank" column="account_holder_bank" />
<result property="accountHolderName" column="account_holder_name" />
<result property="bankAccount" column="bank_account" />
<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" />
<result property="organizationName" column="organization_name" />
</resultMap>
<sql id="selectVerificationVo">
SELECT
v.verification_id,
v.verification_status,
v.business_document_detali_id,
v.business_document_detali_number,
v.business_document_id,
v.business_document_number,
v.business_type,
v.inner_number,
v.enter_account_time,
v.expense_item,
v.first_subject,
v.first_subject_name,
v.second_subject,
v.second_subject_name,
v.verification_money,
v.pay_id,
v.pay_person,
v.pay_channel,
v.pay_channel_name,
v.bank_number,
v.receipt_number,
v.pay_remark,
v.account_holder_name,
v.account_holder_bank,
v.bank_account,
v.images,
v.audit_remark,
v.create_time,
v.create_by,
v.create_by_name,
v.update_time,
v.update_by,
v.update_by_name,
v.del_flag,
v.pay_way,
v.pay_way_name,
v.organization_id,
v.top_organization_id,
v.receivable_type,
v.department_id,
v.department_name,
v.payee,
v.pay_type,
v.license_number,
v.pay_name,
v.bill_remarks,
v.payment_method,
v.fuel_card_number,
v.organization_name
FROM
verification v
</sql>
<select id="selectVerificationOneList" parameterType="com.mhd.common.core.domain.po.VerificationPo" resultMap="VerificationResult">
SELECT
verification_id,
verification_status,
business_document_id,
business_document_number,
inner_number,
enter_account_time,
first_subject,
first_subject_name,
second_subject,
second_subject_name,
verification_money,
pay_id,
pay_person,
pay_channel,
pay_channel_name,
bank_number,
receipt_number,
pay_remark,
account_holder_name,
account_holder_bank,
bank_account,
images,
audit_remark,
create_time,
create_by,
create_by_name,
update_time,
update_by,
update_by_name,
del_flag,
pay_way,
pay_way_name,
organization_id,
top_organization_id,
receivable_type,
department_id,
department_name,
payee,
pay_type,
license_number
FROM
verification
<where>
and del_flag = 1
<if test="branchId != null or organizationIdList != null">
and (branch_id = #{branchId} or
organization_id in
<foreach item="organizationId" collection="organizationIdList" open="(" separator="," close=")">
#{organizationId}
</foreach>)
</if>
<if test="payId != null">
and pay_id = #{payId}
</if>
<!-- <if test="enterAccountTimeStart != null and enterAccountTimeStart != ''">-->
<!-- AND date_format(enter_account_time,'%Y-%m-%d') >= #{enterAccountTimeStart}-->
<!-- </if>-->
<!-- <if test="enterAccountTimeEnd != null and enterAccountTimeEnd != ''">-->
<!-- AND date_format(enter_account_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}-->
<!-- </if>-->
<if test="enterAccountTimeStart != null and enterAccountTimeStart != ''">
AND date_format(create_time,'%Y-%m-%d') >= #{enterAccountTimeStart}
</if>
<if test="enterAccountTimeEnd != null and enterAccountTimeEnd != ''">
AND date_format(create_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}
</if>
<if test="cancelAfterVerificationTimeStart != null and cancelAfterVerificationTimeStart != ''">
AND date_format(cancel_after_verification_time,'%Y-%m-%d') >= #{cancelAfterVerificationTimeStart}
</if>
<if test="cancelAfterVerificationTimeEnd != null and cancelAfterVerificationTimeEnd != ''">
AND date_format(cancel_after_verification_time,'%Y-%m-%d') <![CDATA[<=]]> #{cancelAfterVerificationTimeEnd}
</if>
<if test="cancelAfterVerificationType != null"> and cancel_after_verification_type = #{cancelAfterVerificationType}</if>
<if test="mailBranch != null"> and mail_branch = #{mailBranch}</if>
<if test="accountHolderBank != null and accountHolderBank != ''"> and account_holder_bank = #{accountHolderBank}</if>
<if test="accountHolderName != null and accountHolderName != ''"> and account_holder_name = #{accountHolderName}</if>
<if test="bankAccount != null and bankAccount != ''"> and bank_account = #{bankAccount}</if>
<if test="arriveBranch != null"> and arrive_branch = #{arriveBranch}</if>
<if test="verificationType != null "> and verification_type = #{verificationType}</if>
<if test="verificationStatusOne != null and verificationStatusOne != '0'.toString()"> and verification_status = #{verificationStatusOne}</if>
<!-- <if test="verificationStatus != null and verificationStatus == '5'.toString()"> and verification_status <![CDATA[<=]]> #{verificationStatus}</if>-->
<!-- <if test="verificationStatus != null and verificationStatus == '6'.toString()"> and verification_status = #{verificationStatus}</if>-->
<if test="verificationStatus != null and verificationStatus != '' "> and verification_status = #{verificationStatus}</if>
<if test="innerNumber != null and innerNumber != ''"> and inner_number like concat('%', #{innerNumber}, '%')</if>
<if test="enterAccountTime != null "> and enter_account_time = #{enterAccountTime}</if>
<if test="firstSubject != null and firstSubject != ''"> and first_subject = #{firstSubject}</if>
<if test="secondSubject != null and secondSubject != ''"> and second_subject = #{secondSubject}</if>
<if test="verificationMoney != null "> and verification_money = #{verificationMoney}</if>
<if test="payPerson != null and payPerson != ''"> and pay_person = #{payPerson}</if>
<if test="payChannel != null and payChannel != ''"> and pay_channel = #{payChannel}</if>
<if test="bankNumber != null and bankNumber != ''"> and bank_number = #{bankNumber}</if>
<if test="receiptNumber != null and receiptNumber != ''"> and receipt_number = #{receiptNumber}</if>
<if test="collectionRemark != null and collectionRemark != ''"> and collection_remark = #{collectionRemark}</if>
<if test="waybillId != null "> and waybill_id = #{waybillId}</if>
<if test="waybillNumber != null and waybillNumber != ''"> and waybill_number like concat('%', #{waybillNumber}, '%')</if>
<if test="waybillRemark != null and waybillRemark != ''"> and waybill_remark = #{waybillRemark}</if>
<if test="waybillSource != null and waybillSource != ''"> and waybill_source = #{waybillSource}</if>
<if test="revenueExpensesNumber != null and revenueExpensesNumber != ''"> and revenue_expenses_number = #{revenueExpensesNumber}</if>
<if test="enterAccountId != null "> and enter_account_id = #{enterAccountId}</if>
<if test="enterAccountName != null and enterAccountName != ''"> and enter_account_name like concat('%', #{enterAccountName}, '%')</if>
<if test="cancelAfterVerificationId != null "> and cancel_after_verification_id = #{cancelAfterVerificationId}</if>
<if test="cancelAfterVerificationName != null and cancelAfterVerificationName != ''"> and cancel_after_verification_name like concat('%', #{cancelAfterVerificationName}, '%')</if>
<if test="cancelAfterVerificationTime != null "> and cancel_after_verification_time = #{cancelAfterVerificationTime}</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="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '5'.toString()"> and verification_status in (1,2,3,4,5)</if>
<if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '6'.toString()"> and verification_status = 6</if>
<!-- 是否展示扣付数据 -->
<if test="hideDeduction != null and hideDeduction == '1'.toString()"> and second_subject != 'withhold_payment'</if>
<if test="businessDocumentNumberList != null and businessDocumentNumberList.size() != 0">
AND business_document_number in
<foreach item="waybill" collection="businessDocumentNumberList" open="(" separator="," close=")">
#{waybill}
</foreach>
</if>
</where>
order by create_time desc
</select>
<select id="shipperPayList" parameterType="com.mhd.common.core.domain.po.VerificationPo" resultMap="VerificationResult">
SELECT
verification_id,
verification_status,
business_document_id,
business_document_number,
inner_number,
enter_account_time,
first_subject,
first_subject_name,
second_subject,
second_subject_name,
verification_money,
pay_id,
pay_person,
pay_channel,
pay_channel_name,
bank_number,
receipt_number,
pay_remark,
account_holder_name,
account_holder_bank,
bank_account,
images,
audit_remark,
create_time,
create_by,
create_by_name,
update_time,
update_by,
update_by_name,
del_flag,
pay_way,
pay_way_name,
organization_id,
top_organization_id,
receivable_type,
department_id,
department_name,
payee,
pay_type,
license_number
FROM
verification
<where>
and del_flag = 1
and verification_status in (4,6)
<if test="payId != null">
and pay_id = #{payId}
</if>
<!-- <if test="enterAccountTimeStart != null and enterAccountTimeStart != ''">-->
<!-- AND date_format(enter_account_time,'%Y-%m-%d') >= #{enterAccountTimeStart}-->
<!-- </if>-->
<!-- <if test="enterAccountTimeEnd != null and enterAccountTimeEnd != ''">-->
<!-- AND date_format(enter_account_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}-->
<!-- </if>-->
<if test="enterAccountTimeStart != null and enterAccountTimeStart != ''">
AND date_format(create_time,'%Y-%m-%d') >= #{enterAccountTimeStart}
</if>
<if test="enterAccountTimeEnd != null and enterAccountTimeEnd != ''">
AND date_format(create_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}
</if>
<if test="cancelAfterVerificationTimeStart != null and cancelAfterVerificationTimeStart != ''">
AND date_format(cancel_after_verification_time,'%Y-%m-%d') >= #{cancelAfterVerificationTimeStart}
</if>
<if test="cancelAfterVerificationTimeEnd != null and cancelAfterVerificationTimeEnd != ''">
AND date_format(cancel_after_verification_time,'%Y-%m-%d') <![CDATA[<=]]> #{cancelAfterVerificationTimeEnd}
</if>
<if test="cancelAfterVerificationType != null"> and cancel_after_verification_type = #{cancelAfterVerificationType}</if>
<if test="mailBranch != null"> and mail_branch = #{mailBranch}</if>
<if test="accountHolderBank != null and accountHolderBank != ''"> and account_holder_bank = #{accountHolderBank}</if>
<if test="accountHolderName != null and accountHolderName != ''"> and account_holder_name = #{accountHolderName}</if>
<if test="bankAccount != null and bankAccount != ''"> and bank_account = #{bankAccount}</if>
<if test="arriveBranch != null"> and arrive_branch = #{arriveBranch}</if>
<if test="verificationType != null "> and verification_type = #{verificationType}</if>
<if test="verificationStatusOne != null and verificationStatusOne != '0'.toString()"> and verification_status = #{verificationStatusOne}</if>
<!-- <if test="verificationStatus != null and verificationStatus == '5'.toString()"> and verification_status <![CDATA[<=]]> #{verificationStatus}</if>-->
<!-- <if test="verificationStatus != null and verificationStatus == '6'.toString()"> and verification_status = #{verificationStatus}</if>-->
<if test="verificationStatus != null and verificationStatus != '' "> and verification_status = #{verificationStatus}</if>
<if test="innerNumber != null and innerNumber != ''"> and inner_number like concat('%', #{innerNumber}, '%')</if>
<if test="enterAccountTime != null "> and enter_account_time = #{enterAccountTime}</if>
<if test="firstSubject != null and firstSubject != ''"> and first_subject = #{firstSubject}</if>
<if test="secondSubject != null and secondSubject != ''"> and second_subject = #{secondSubject}</if>
<if test="verificationMoney != null "> and verification_money = #{verificationMoney}</if>
<if test="payPerson != null and payPerson != ''"> and pay_person = #{payPerson}</if>
<if test="payChannel != null and payChannel != ''"> and pay_channel = #{payChannel}</if>
<if test="bankNumber != null and bankNumber != ''"> and bank_number = #{bankNumber}</if>
<if test="receiptNumber != null and receiptNumber != ''"> and receipt_number = #{receiptNumber}</if>
<if test="collectionRemark != null and collectionRemark != ''"> and collection_remark = #{collectionRemark}</if>
<if test="waybillId != null "> and waybill_id = #{waybillId}</if>
<if test="waybillNumber != null and waybillNumber != ''"> and waybill_number like concat('%', #{waybillNumber}, '%')</if>
<if test="waybillRemark != null and waybillRemark != ''"> and waybill_remark = #{waybillRemark}</if>
<if test="waybillSource != null and waybillSource != ''"> and waybill_source = #{waybillSource}</if>
<if test="revenueExpensesNumber != null and revenueExpensesNumber != ''"> and revenue_expenses_number = #{revenueExpensesNumber}</if>
<if test="enterAccountId != null "> and enter_account_id = #{enterAccountId}</if>
<if test="enterAccountName != null and enterAccountName != ''"> and enter_account_name like concat('%', #{enterAccountName}, '%')</if>
<if test="cancelAfterVerificationId != null "> and cancel_after_verification_id = #{cancelAfterVerificationId}</if>
<if test="cancelAfterVerificationName != null and cancelAfterVerificationName != ''"> and cancel_after_verification_name like concat('%', #{cancelAfterVerificationName}, '%')</if>
<if test="cancelAfterVerificationTime != null "> and cancel_after_verification_time = #{cancelAfterVerificationTime}</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="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '5'.toString()"> and verification_status in (1,2,3,4,5)</if>
<if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '6'.toString()"> and verification_status = 6</if>
<!-- 是否展示扣付数据 -->
<if test="hideDeduction != null and hideDeduction == '1'.toString()"> and second_subject != 'withhold_payment'</if>
<if test="businessDocumentNumberList != null and businessDocumentNumberList.size() != 0">
AND business_document_number in
<foreach item="waybill" collection="businessDocumentNumberList" open="(" separator="," close=")">
#{waybill}
</foreach>
</if>
</where>
order by create_time desc
</select>
<select id="selectVerificationList" parameterType="com.mhd.common.core.domain.po.VerificationPo" resultMap="VerificationResult">
<include refid="selectVerificationVo"/>
<where>
and v.del_flag = 1
<!-- 组织查询条件:南光组织查所有,其他组织查自己 -->
<if test="organizationId != null">
<choose>
<!-- 南光组织判断:如果topOrganizationId为null,则为顶级组织(南光组织),查所有 -->
<when test="topOrganizationId == null">
<!-- 南光组织查所有数据,不添加组织过滤条件 -->
<!-- 如果organizationName为null,根据组织ID查询时不显示organizationName为null的数据 -->
<if test="organizationName == null or organizationName == ''">
AND v.organization_name IS NOT NULL
</if>
</when>
<otherwise>
<!-- 其他组织只查自己组织的数据 -->
AND v.organization_id = #{organizationId}
<!-- organizationName为null时,根据组织ID查询时不显示organizationName为null的数据 -->
<if test="organizationName == null or organizationName == ''">
AND v.organization_name IS NOT NULL
</if>
</otherwise>
</choose>
</if>
<if test="businessDocumentNumberList != null and businessDocumentNumberList.size() != 0">
AND v.business_document_number in
<foreach item="waybill" collection="businessDocumentNumberList" open="(" separator="," close=")">
#{waybill}
</foreach>
</if>
<!-- <if test="branchId != null or organizationIdList != null">-->
<!-- and (branch_id = #{branchId} or-->
<!-- organization_id in-->
<!-- <foreach item="organizationId" collection="organizationIdList" open="(" separator="," close=")">-->
<!-- #{organizationId}-->
<!-- </foreach>)-->
<!-- </if>-->
<!-- <if test="branchIdList != null">and-->
<!-- (branch_id in-->
<!-- <foreach item="branchId" collection="branchIdList" open="(" separator="," close=")">-->
<!-- #{branchId}-->
<!-- </foreach>-->
<!-- or organization_id in-->
<!-- <foreach item="organizationId" collection="organizationIdList" open="(" separator="," close=")">-->
<!-- #{organizationId}-->
<!-- </foreach>-->
<!-- )-->
<!-- </if>-->
<if test="enterAccountTimeStart != null">
AND date_format(v.create_time,'%Y-%m-%d') >= #{enterAccountTimeStart}
</if>
<if test="enterAccountTimeEnd != null">
AND date_format(v.create_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}
</if>
<if test="cancelAfterVerificationTimeStart != null and cancelAfterVerificationTimeStart != ''">
AND date_format(v.cancel_after_verification_time,'%Y-%m-%d') >= #{cancelAfterVerificationTimeStart}
</if>
<if test="cancelAfterVerificationTimeEnd != null and cancelAfterVerificationTimeEnd != ''">
AND date_format(v.cancel_after_verification_time,'%Y-%m-%d') <![CDATA[<=]]> #{cancelAfterVerificationTimeEnd}
</if>
<if test="cancelAfterVerificationType != null"> and v.cancel_after_verification_type = #{cancelAfterVerificationType}</if>
<if test="mailBranch != null"> and v.mail_branch = #{mailBranch}</if>
<if test="accountHolderBank != null and accountHolderBank != ''"> and v.account_holder_bank = #{accountHolderBank}</if>
<if test="accountHolderName != null and accountHolderName != ''"> and v.account_holder_name = #{accountHolderName}</if>
<if test="bankAccount != null and bankAccount != ''"> and v.bank_account = #{bankAccount}</if>
<if test="arriveBranch != null"> and v.arrive_branch = #{arriveBranch}</if>
<if test="verificationType != null "> and v.verification_type = #{verificationType}</if>
<if test="verificationStatusOne != null and verificationStatusOne != '0'.toString()"> and v.verification_status = #{verificationStatusOne}</if>
<if test="verificationStatus != null and verificationStatus == '5'.toString()"> and v.verification_status <![CDATA[<=]]> #{verificationStatus}</if>
<if test="verificationStatus != null and verificationStatus == '6'.toString()"> and v.verification_status = #{verificationStatus}</if>
<if test="innerNumber != null and innerNumber != ''"> and v.inner_number like concat('%', #{innerNumber}, '%')</if>
<if test="enterAccountTime != null "> and v.enter_account_time = #{enterAccountTime}</if>
<if test="firstSubject != null and firstSubject != ''"> and v.first_subject = #{firstSubject}</if>
<if test="secondSubject != null and secondSubject != ''"> and v.second_subject = #{secondSubject}</if>
<if test="verificationMoney != null "> and v.verification_money = #{verificationMoney}</if>
<if test="payPerson != null and payPerson != ''"> and v.pay_person = #{payPerson}</if>
<if test="payChannel != null and payChannel != ''"> and v.pay_channel = #{payChannel}</if>
<if test="bankNumber != null and bankNumber != ''"> and v.bank_number = #{bankNumber}</if>
<if test="receiptNumber != null and receiptNumber != ''"> and v.receipt_number = #{receiptNumber}</if>
<if test="collectionRemark != null and collectionRemark != ''"> and v.collection_remark = #{collectionRemark}</if>
<if test="waybillId != null "> and v.waybill_id = #{waybillId}</if>
<if test="waybillNumber != null and waybillNumber != ''"> and v.waybill_number like concat('%', #{waybillNumber}, '%')</if>
<if test="waybillRemark != null and waybillRemark != ''"> and v.waybill_remark = #{waybillRemark}</if>
<if test="waybillSource != null and waybillSource != ''"> and v.waybill_source = #{waybillSource}</if>
<if test="revenueExpensesNumber != null and revenueExpensesNumber != ''"> and v.revenue_expenses_number = #{revenueExpensesNumber}</if>
<if test="enterAccountId != null "> and v.enter_account_id = #{enterAccountId}</if>
<if test="enterAccountName != null and enterAccountName != ''"> and v.enter_account_name like concat('%', #{enterAccountName}, '%')</if>
<if test="cancelAfterVerificationId != null "> and v.cancel_after_verification_id = #{cancelAfterVerificationId}</if>
<if test="cancelAfterVerificationName != null and cancelAfterVerificationName != ''"> and v.cancel_after_verification_name like concat('%', #{cancelAfterVerificationName}, '%')</if>
<if test="cancelAfterVerificationTime != null "> and v.cancel_after_verification_time = #{cancelAfterVerificationTime}</if>
<if test="createByName != null and createByName != ''"> and v.create_by_name like concat('%', #{createByName}, '%')</if>
<if test="updateByName != null and updateByName != ''"> and v.update_by_name like concat('%', #{updateByName}, '%')</if>
<if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '5'.toString()"> and v.verification_status in (1,2,3,4,5)</if>
<if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '6'.toString()"> and v.verification_status = 6</if>
<if test="inVerificationStatus != null"> and v.in_verification_status = #{inVerificationStatus}</if>
<if test="uuidCode != null"> and v.uuid_code = #{uuidCode}</if>
</where>
order by v.create_time desc
</select>
<select id="selectVerificationByVerificationId" parameterType="java.lang.Long" resultMap="VerificationResult">
<include refid="selectVerificationVo"/>
where verification_id = #{verificationId} and del_flag = 1
</select>
<select id="selectVerificationStatusNum" parameterType="java.lang.Long" resultType="java.util.HashMap">
SELECT
s.receipt_status_id AS id,
CONCAT(s.receipt_status_name,' ',IFNULL(r.num,0)) AS name
FROM
receipt_status s
LEFT JOIN
(SELECT
r.verification_status,
COUNT(r.verification_status) AS num
FROM
(SELECT
verification_id,
verification_status,
verification_type,
branch_id,
mail_branch,
arrive_branch,
inner_number,
enter_account_time,
first_subject,
second_subject,
verification_money,
pay_person,
pay_channel,
bank_number,
receipt_number,
collection_remark,
waybill_id,
waybill_number,
waybill_remark,
waybill_source,
revenue_expenses_number,
enter_account_id,
enter_account_name,
cancel_after_verification_id,
cancel_after_verification_name,
cancel_after_verification_time,
vehicle_id,
vehicle_license_plate_number,
driver_name,
create_time,
create_by,
create_by_name,
update_time,
update_by,
update_by_name,
del_flag
FROM
verification
WHERE
del_flag = 1
and verification_type = 1
and second_subject != 'withhold_payment'
<!-- <if test="branchId != null or organizationIdList != null">-->
<!-- and (branch_id = #{branchId} or-->
<!-- organization_id in-->
<!-- <foreach item="organizationId" collection="organizationIdList" open="(" separator="," close=")">-->
<!-- #{organizationId}-->
<!-- </foreach>)-->
<!-- </if>-->
<if test="payId != null">
and pay_id = #{payId}
</if>
<if test="enterAccountTimeStart != null">
AND date_format(create_time,'%Y-%m-%d') >= #{enterAccountTimeStart}
</if>
<if test="enterAccountTimeEnd != null">
AND date_format(create_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}
</if>
)r
GROUP
BY
r.verification_status) r
ON r.verification_status = s.receipt_status_id
WHERE
s.type = 10
</select>
<select id="selectVerificationStatusNumTwo" parameterType="java.lang.Long" resultType="java.util.HashMap">
SELECT
s.receipt_status_id AS id,
CONCAT(s.receipt_status_name,' ',IFNULL(r.num,0)) AS name
FROM
receipt_status s
LEFT JOIN
(SELECT
r.verification_status,
COUNT(r.verification_status) AS num
FROM
(SELECT
IF(verification_status <![CDATA[<=]]> 5,5,verification_status) as verification_status
FROM
verification
WHERE
del_flag = 1
and verification_type = 2
and in_verification_status != 4
<!-- <if test="branchId != null or organizationIdList != null">-->
<!-- and (branch_id = #{branchId} or-->
<!-- organization_id in-->
<!-- <foreach item="organizationId" collection="organizationIdList" open="(" separator="," close=")">-->
<!-- #{organizationId}-->
<!-- </foreach>)-->
<!-- </if>-->
<if test="enterAccountTimeStart != null">
AND date_format(create_time,'%Y-%m-%d') >= #{enterAccountTimeStart}
</if>
<if test="enterAccountTimeEnd != null">
AND date_format(create_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}
</if>
) r
GROUP BY
r.verification_status) r
ON r.verification_status = s.receipt_status_id
WHERE
s.type = 13
</select>
<select id="selectVerificationListByIds" resultType="com.mhd.common.core.domain.po.VerificationPo" parameterType="java.util.List">
<include refid="selectVerificationVo"/>
where
del_flag = 1
and verification_id in
<foreach item="verificationIds" collection="verificationIds" open="(" separator="," close=")">
#{verificationIds}
</foreach>
</select>
<select id="selectVerificationBankList" resultType="com.mhd.common.core.domain.po.VerificationPo" parameterType="com.mhd.common.core.domain.po.VerificationPo">
select
v.*,
a.bank_card_number,
a.bank_binding_name,
a.bank_name_code
from verification v
left join account_bank_card a on v.enter_account_id = a.user_id and a.del_flag = 1
<where>
v.del_flag = 1
<if test="verificationType != null "> and v.verification_type = #{verificationType}</if>
<if test="waybillNumber != null and waybillNumber != ''"> and v.waybill_number = #{waybillNumber}</if>
<if test="waybillSource != null and waybillSource != ''"> and v.waybill_source = #{waybillSource}</if>
<if test="firstSubject != null and firstSubject != ''"> and v.first_subject = #{firstSubject}</if>
<if test="secondSubject != null and secondSubject != ''"> and v.second_subject = #{secondSubject}</if>
</where>
</select>
<insert id="batchAddVerificationImage" parameterType="java.util.List">
insert into verification_image
<trim prefix="(" suffix=")" suffixOverrides=",">
verification_id,
image_url,
create_time,
create_by,
create_by_name,
</trim>
values
<foreach collection="list" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{item.verificationId},
#{item.imageUrl},
#{item.createTime},
#{item.createBy},
#{item.createByName},
</trim>
</foreach>
</insert>
<insert id="insertVerification" parameterType="com.mhd.common.core.domain.entity.Verification" useGeneratedKeys="true" keyProperty="verificationId">
insert into verification
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- <if test="branchId != null">branch_id,</if>-->
<!-- <if test="mailBranch != null">mail_branch,</if>-->
<!-- <if test="arriveBranch != null">arrive_branch,</if>-->
<if test="verificationStatus != null">verification_status,</if>
<if test="innerNumber != null">inner_number,</if>
<if test="enterAccountTime != null">enter_account_time,</if>
<if test="firstSubject != null">first_subject,</if>
<if test="secondSubject != null">second_subject,</if>
<if test="firstSubjectName != null">first_subject_name,</if>
<if test="secondSubjectName != null">second_subject_name,</if>
<if test="verificationMoney != null">verification_money,</if>
<if test="payPerson != null">pay_person,</if>
<if test="payChannel != null">pay_channel,</if>
<if test="payChannelName != null">pay_channel_name,</if>
<if test="payWay != null">pay_way,</if>
<if test="payWayName != null">pay_way_name,</if>
<if test="bankNumber != null">bank_number,</if>
<if test="receiptNumber != null">receipt_number,</if>
<if test="collectionRemark != null">collection_remark,</if>
<if test="cancelCollectionRemark != null">cancel_collection_remark,</if>
<if test="payRemark != null">pay_remark,</if>
<!-- <if test="waybillId != null">waybill_id,</if>-->
<!-- <if test="waybillNumber != null">waybill_number,</if>-->
<!-- <if test="waybillRemark != null">waybill_remark,</if>-->
<!-- <if test="waybillSource != null">waybill_source,</if>-->
<!-- <if test="waybillSourceName != null">waybill_source_name,</if>-->
<if test="revenueExpensesNumber != null">revenue_expenses_number,</if>
<if test="enterAccountId != null">enter_account_id,</if>
<if test="enterAccountName != null">enter_account_name,</if>
<if test="cancelAfterVerificationId != null">cancel_after_verification_id,</if>
<if test="cancelAfterVerificationName != null">cancel_after_verification_name,</if>
<if test="cancelAfterVerificationTime != null">cancel_after_verification_time,</if>
<if test="cancelAfterVerificationType != null">cancel_after_verification_type,</if>
<if test="verificationType != null">verification_type,</if>
<if test="vehicleId != null">vehicle_id,</if>
<if test="vehicleLicensePlateNumber != null">vehicle_license_plate_number,</if>
<if test="driverName != null">driver_name,</if>
<if test="images != null">images,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="createByName != null">create_by_name,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateByName != null">update_by_name,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="branchId != null">#{branchId},</if>
<if test="mailBranch != null">#{mailBranch},</if>
<if test="arriveBranch != null">#{arriveBranch},</if>
<if test="verificationStatus != null">#{verificationStatus},</if>
<if test="innerNumber != null">#{innerNumber},</if>
<if test="enterAccountTime != null">#{enterAccountTime},</if>
<if test="firstSubject != null">#{firstSubject},</if>
<if test="secondSubject != null">#{secondSubject},</if>
<if test="firstSubjectName != null">#{firstSubjectName},</if>
<if test="secondSubjectName != null">#{secondSubjectName},</if>
<if test="verificationMoney != null">#{verificationMoney},</if>
<if test="payPerson != null">#{payPerson},</if>
<if test="payChannel != null">#{payChannel},</if>
<if test="payChannelName != null">#{payChannelName},</if>
<if test="payWay != null">#{payWay},</if>
<if test="payWayName != null">#{payWayName},</if>
<if test="bankNumber != null">#{bankNumber},</if>
<if test="receiptNumber != null">#{receiptNumber},</if>
<if test="collectionRemark != null">#{collectionRemark},</if>
<if test="cancelCollectionRemark != null">#{cancelCollectionRemark},</if>
<if test="payRemark != null">#{payRemark},</if>
<if test="waybillId != null">#{waybillId},</if>
<if test="waybillNumber != null">#{waybillNumber},</if>
<if test="waybillRemark != null">#{waybillRemark},</if>
<if test="waybillSource != null">#{waybillSource},</if>
<if test="waybillSourceName != null">#{waybillSourceName},</if>
<if test="revenueExpensesNumber != null">#{revenueExpensesNumber},</if>
<if test="enterAccountId != null">#{enterAccountId},</if>
<if test="enterAccountName != null">#{enterAccountName},</if>
<if test="cancelAfterVerificationId != null">#{cancelAfterVerificationId},</if>
<if test="cancelAfterVerificationName != null">#{cancelAfterVerificationName},</if>
<if test="cancelAfterVerificationTime != null">#{cancelAfterVerificationTime},</if>
<if test="cancelAfterVerificationType != null">#{cancelAfterVerificationType},</if>
<if test="verificationType != null">#{verificationType},</if>
<if test="vehicleId != null">#{vehicleId},</if>
<if test="vehicleLicensePlateNumber != null">#{vehicleLicensePlateNumber},</if>
<if test="driverName != null">#{driverName},</if>
<if test="images != null">#{images},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createByName != null">#{createByName},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateByName != null">#{updateByName},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<insert id="batchAddVerification" parameterType="java.util.List">
insert into verification
<trim prefix="(" suffix=")" suffixOverrides=",">
verification_status,
business_document_detali_id,
business_document_detali_number,
business_document_id,
business_document_number,
business_type,
inner_number,
enter_account_time,
expense_item,
first_subject,
second_subject,
first_subject_name,
second_subject_name,
verification_money,
audit_remark,
pay_id,
pay_person,
pay_channel,
pay_channel_name,
pay_way,
pay_way_name,
bank_number,
receipt_number,
pay_remark,
account_holder_bank,
organization_id,
top_organization_id,
organization_name,
department_id,
department_name,
payee,
pay_name,
pay_type,
license_number,
bill_remarks,
payment_method,
fuel_card_number,
create_time,
create_by,
create_by_name,
update_time,
update_by,
update_by_name,
del_flag,
</trim>
values
<foreach collection="list" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{item.verificationStatus},
#{item.businessDocumentDetaliId},
#{item.businessDocumentDetaliNumber},
#{item.businessDocumentId},
#{item.businessDocumentNumber},
#{item.businessType},
#{item.innerNumber},
#{item.enterAccountTime},
#{item.expenseItem},
#{item.firstSubject},
#{item.secondSubject},
#{item.firstSubjectName},
#{item.secondSubjectName},
#{item.verificationMoney},
#{item.auditRemark},
#{item.payId},
#{item.payPerson},
#{item.payChannel},
#{item.payChannelName},
#{item.payWay},
#{item.payWayName},
#{item.bankNumber},
#{item.receiptNumber},
#{item.payRemark},
#{item.accountHolderBank},
#{item.organizationId},
#{item.topOrganizationId},
#{item.organizationName},
#{item.departmentId},
#{item.departmentName},
#{item.payee},
#{item.payName},
#{item.payType},
#{item.licenseNumber},
#{item.billRemarks},
#{item.paymentMethod},
#{item.fuelCardNumber},
#{item.createTime},
#{item.createBy},
#{item.createByName},
#{item.updateTime},
#{item.updateBy},
#{item.updateByName},
#{item.delFlag},
</trim>
</foreach>
</insert>
<update id="updateVerification" parameterType="com.mhd.common.core.domain.entity.Verification">
update verification
<trim prefix="SET" suffixOverrides=",">
<if test="branchId != null">branch_id = #{branchId},</if>
<if test="mailBranch != null">mail_branch = #{mailBranch},</if>
<if test="arriveBranch != null">arrive_branch = #{arriveBranch},</if>
<if test="verificationStatus != null">verification_status = #{verificationStatus},</if>
<if test="innerNumber != null">inner_number = #{innerNumber},</if>
<if test="enterAccountTime != null">enter_account_time = #{enterAccountTime},</if>
<if test="firstSubject != null">first_subject = #{firstSubject},</if>
<if test="secondSubject != null">second_subject = #{secondSubject},</if>
<if test="firstSubjectName != null">first_subject_name = #{firstSubjectName},</if>
<if test="secondSubjectName != null">second_subject_name = #{secondSubjectName},</if>
<if test="verificationMoney != null">verification_money = #{verificationMoney},</if>
<if test="payPerson != null">pay_person = #{payPerson},</if>
<if test="payChannel != null">pay_channel = #{payChannel},</if>
<if test="payChannelName != null">pay_channel_name = #{payChannelName},</if>
<if test="payWay != null">pay_way = #{payWay},</if>
<if test="payWayName != null">pay_way_name = #{payWayName},</if>
<if test="bankNumber != null">bank_number = #{bankNumber},</if>
<if test="receiptNumber != null">receipt_number = #{receiptNumber},</if>
<if test="collectionRemark != null">collection_remark = #{collectionRemark},</if>
<if test="cancelCollectionRemark != null">cancel_collection_remark = #{cancelCollectionRemark},</if>
<if test="payRemark != null">pay_remark = #{payRemark},</if>
<if test="waybillId != null">waybill_id = #{waybillId},</if>
<if test="waybillNumber != null">waybill_number = #{waybillNumber},</if>
<if test="waybillRemark != null">waybill_remark = #{waybillRemark},</if>
<if test="waybillSource != null">waybill_source = #{waybillSource},</if>
<if test="waybillSourceName != null">waybill_source_name = #{waybillSourceName},</if>
<if test="revenueExpensesNumber != null">revenue_expenses_number = #{revenueExpensesNumber},</if>
<if test="enterAccountId != null">enter_account_id = #{enterAccountId},</if>
<if test="enterAccountName != null">enter_account_name = #{enterAccountName},</if>
<if test="cancelAfterVerificationId != null">cancel_after_verification_id = #{cancelAfterVerificationId},</if>
<if test="cancelAfterVerificationName != null">cancel_after_verification_name = #{cancelAfterVerificationName},</if>
<if test="cancelAfterVerificationTime != null">cancel_after_verification_time = #{cancelAfterVerificationTime},</if>
<if test="cancelAfterVerificationType != null">cancel_after_verification_type = #{cancelAfterVerificationType},</if>
<if test="verificationType != null">verification_type = #{verificationType},</if>
<if test="vehicleId != null">vehicle_id = #{vehicleId},</if>
<if test="vehicleLicensePlateNumber != null">vehicle_license_plate_number = #{vehicleLicensePlateNumber},</if>
<if test="driverName != null">driver_name = #{driverName},</if>
<if test="images != null">images = #{images},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createByName != null">create_by_name = #{createByName},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateByName != null">update_by_name = #{updateByName},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where verification_id = #{verificationId}
</update>
<update id="updateVerificationByWaybillId" parameterType="com.mhd.common.core.domain.entity.Verification">
update verification
<trim prefix="SET" suffixOverrides=",">
<if test="branchId != null">branch_id = #{branchId},</if>
<if test="mailBranch != null">mail_branch = #{mailBranch},</if>
<if test="arriveBranch != null">arrive_branch = #{arriveBranch},</if>
<if test="verificationStatus != null">verification_status = #{verificationStatus},</if>
<if test="innerNumber != null">inner_number = #{innerNumber},</if>
<if test="enterAccountTime != null">enter_account_time = #{enterAccountTime},</if>
<if test="firstSubject != null">first_subject = #{firstSubject},</if>
<if test="secondSubject != null">second_subject = #{secondSubject},</if>
<if test="firstSubjectName != null">first_subject_name = #{firstSubjectName},</if>
<if test="secondSubjectName != null">second_subject_name = #{secondSubjectName},</if>
<if test="verificationMoney != null">verification_money = #{verificationMoney},</if>
<if test="payPerson != null">pay_person = #{payPerson},</if>
<if test="payChannel != null">pay_channel = #{payChannel},</if>
<if test="payChannelName != null">pay_channel_name = #{payChannelName},</if>
<if test="payWay != null">pay_way = #{payWay},</if>
<if test="payWayName != null">pay_way_name = #{payWayName},</if>
<if test="bankNumber != null">bank_number = #{bankNumber},</if>
<if test="receiptNumber != null">receipt_number = #{receiptNumber},</if>
<if test="collectionRemark != null">collection_remark = #{collectionRemark},</if>
<if test="cancelCollectionRemark != null">cancel_collection_remark = #{cancelCollectionRemark},</if>
<if test="payRemark != null">pay_remark = #{payRemark},</if>
<if test="waybillId != null">waybill_id = #{waybillId},</if>
<if test="waybillNumber != null">waybill_number = #{waybillNumber},</if>
<if test="waybillRemark != null">waybill_remark = #{waybillRemark},</if>
<if test="waybillSource != null">waybill_source = #{waybillSource},</if>
<if test="waybillSourceName != null">waybill_source_name = #{waybillSourceName},</if>
<if test="revenueExpensesNumber != null">revenue_expenses_number = #{revenueExpensesNumber},</if>
<if test="enterAccountId != null">enter_account_id = #{enterAccountId},</if>
<if test="enterAccountName != null">enter_account_name = #{enterAccountName},</if>
<if test="cancelAfterVerificationId != null">cancel_after_verification_id = #{cancelAfterVerificationId},</if>
<if test="cancelAfterVerificationName != null">cancel_after_verification_name = #{cancelAfterVerificationName},</if>
<if test="cancelAfterVerificationTime != null">cancel_after_verification_time = #{cancelAfterVerificationTime},</if>
<if test="cancelAfterVerificationType != null">cancel_after_verification_type = #{cancelAfterVerificationType},</if>
<if test="verificationType != null">verification_type = #{verificationType},</if>
<if test="vehicleId != null">vehicle_id = #{vehicleId},</if>
<if test="vehicleLicensePlateNumber != null">vehicle_license_plate_number = #{vehicleLicensePlateNumber},</if>
<if test="driverName != null">driver_name = #{driverName},</if>
<if test="images != null">images = #{images},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createByName != null">create_by_name = #{createByName},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateByName != null">update_by_name = #{updateByName},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where waybill_id = #{waybillId}
</update>
<update id="updateVerifications" parameterType="com.mhd.common.core.domain.po.VerificationPo">
update verification
<trim prefix="SET" suffixOverrides=",">
<if test="branchId != null">branch_id = #{branchId},</if>
<if test="mailBranch != null">mail_branch = #{mailBranch},</if>
<if test="arriveBranch != null">arrive_branch = #{arriveBranch},</if>
<if test="verificationStatus != null">verification_status = #{verificationStatus},</if>
<if test="innerNumber != null">inner_number = #{innerNumber},</if>
<if test="enterAccountTime != null">enter_account_time = #{enterAccountTime},</if>
<if test="firstSubject != null">first_subject = #{firstSubject},</if>
<if test="secondSubject != null">second_subject = #{secondSubject},</if>
<if test="firstSubjectName != null">first_subject_name = #{firstSubjectName},</if>
<if test="secondSubjectName != null">second_subject_name = #{secondSubjectName},</if>
<if test="verificationMoney != null">verification_money = #{verificationMoney},</if>
<if test="payPerson != null">pay_person = #{payPerson},</if>
<if test="payChannel != null">pay_channel = #{payChannel},</if>
<if test="payChannelName != null">pay_channel_name = #{payChannelName},</if>
<if test="payWay != null">pay_way = #{payWay},</if>
<if test="payWayName != null">pay_way_name = #{payWayName},</if>
<if test="bankNumber != null">bank_number = #{bankNumber},</if>
<if test="receiptNumber != null">receipt_number = #{receiptNumber},</if>
<if test="collectionRemark != null">collection_remark = #{collectionRemark},</if>
<if test="cancelCollectionRemark != null">cancel_collection_remark = #{cancelCollectionRemark},</if>
<if test="payRemark != null">pay_remark = #{payRemark},</if>
<if test="waybillId != null">waybill_id = #{waybillId},</if>
<if test="waybillNumber != null">waybill_number = #{waybillNumber},</if>
<if test="waybillRemark != null">waybill_remark = #{waybillRemark},</if>
<if test="waybillSource != null">waybill_source = #{waybillSource},</if>
<if test="waybillSourceName != null">waybill_source_name = #{waybillSourceName},</if>
<if test="revenueExpensesNumber != null">revenue_expenses_number = #{revenueExpensesNumber},</if>
<if test="enterAccountId != null">enter_account_id = #{enterAccountId},</if>
<if test="enterAccountName != null">enter_account_name = #{enterAccountName},</if>
<if test="cancelAfterVerificationId != null">cancel_after_verification_id = #{cancelAfterVerificationId},</if>
<if test="cancelAfterVerificationName != null">cancel_after_verification_name = #{cancelAfterVerificationName},</if>
<if test="cancelAfterVerificationTime != null">cancel_after_verification_time = #{cancelAfterVerificationTime},</if>
<if test="cancelAfterVerificationType != null">cancel_after_verification_type = #{cancelAfterVerificationType},</if>
<if test="verificationType != null">verification_type = #{verificationType},</if>
<if test="vehicleId != null">vehicle_id = #{vehicleId},</if>
<if test="vehicleLicensePlateNumber != null">vehicle_license_plate_number = #{vehicleLicensePlateNumber},</if>
<if test="driverName != null">driver_name = #{driverName},</if>
<if test="images != null">images = #{images},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createByName != null">create_by_name = #{createByName},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateByName != null">update_by_name = #{updateByName},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where verification_id in
<foreach item="verificationId" collection="verificationIds" open="(" separator="," close=")">
#{verificationId}
</foreach>
</update>
<select id="receivablePayableStatistics" parameterType="com.linke.finance.domain.verification.repository.todo.VerificationDO" resultType="com.linke.finance.domain.report.repository.po.ReceivablePayableStatisticsPO">
SELECT
a.branch_id,
IFNULL(SUM(IF(a.verification_type = 1, a.verification_money, NULL)), 0) AS receivable_amount,
IFNULL(SUM(IF(a.verification_type = 1 and a.verification_status = 6, a.verification_money, NULL)), 0) AS received_amount,
IFNULL(SUM(IF(a.verification_type = 1 and a.verification_status = 5, a.verification_money, NULL)), 0) AS no_received_amount,
COUNT(IF(a.verification_type = 1, 1, NULL)) receivable_num,
IFNULL(SUM(IF(a.verification_type = 2, a.verification_money, NULL)), 0) AS payable_amount,
IFNULL(SUM(IF(a.verification_type = 2 and a.verification_status = 6, a.verification_money, NULL)), 0) AS paid_amount,
IFNULL(SUM(IF(a.verification_type = 2 and a.verification_status = 5, a.verification_money, NULL)), 0) AS no_paid_amount,
COUNT(IF(a.verification_type = 2, 1, NULL)) payable_num
FROM
verification a
<where>
a.verification_status IN (5, 6)
<if test="branchId != null and branchId != '' "> AND a.branch_id = #{branchId}</if>
<if test="branchIdList != null and branchIdList.size() > 0 ">
AND a.branch_id IN
<foreach collection="branchIdList" item="branchId" index="index" open="(" separator="," close=")">
#{branchId}
</foreach>
</if>
<if test="createTimeStart != null and createTimeStart != ''">
AND date_format(a.create_time,'%Y-%m-%d') &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''">
AND date_format(a.create_time,'%Y-%m-%d') &lt;= #{createTimeEnd}
</if>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
</where>
GROUP BY
a.branch_id
ORDER BY
a.create_time DESC, a.verification_id DESC
</select>
<select id="selectOutVerificationList" parameterType="com.mhd.common.core.domain.po.VerificationPo" resultMap="VerificationResult">
<include refid="selectVerificationVo"/>
<where>
and v.del_flag = 1
<!-- 组织查询条件:南光组织(organizationId=2827)查所有,其他组织查自己 -->
<if test="organizationId != null">
<choose>
<!-- 南光组织查询所有数据:topOrganizationId为null且organizationId=2827(这种情况不应该出现,因为查询所有时organizationId为null -->
<!-- 但为了兼容性,保留此判断 -->
<when test="topOrganizationId == null and organizationId == 2827">
<!-- 南光组织查询所有数据,不添加组织过滤条件 -->
<!-- 如果organizationName为null,根据组织ID查询时不显示organizationName为null的数据 -->
<if test="organizationName == null or organizationName == ''">
AND v.organization_name IS NOT NULL
</if>
</when>
<otherwise>
<!-- 其他情况:查询指定组织的数据(包括南光组织查询指定组织的情况,此时topOrganizationId=-1 -->
AND v.organization_id = #{organizationId}
<!-- organizationName为null时,根据组织ID查询时不显示organizationName为null的数据 -->
<if test="organizationName == null or organizationName == ''">
AND v.organization_name IS NOT NULL
</if>
</otherwise>
</choose>
</if>
<!-- 如果 organizationId 为 null,表示查询所有组织的数据(南光组织查询全部) -->
<if test="organizationId == null">
<!-- 查询所有组织的数据,只过滤 organization_name 不为 null 的数据 -->
AND v.organization_name IS NOT NULL
</if>
<if test="businessDocumentNumberList != null and businessDocumentNumberList.size() != 0">
AND v.business_document_number in
<foreach item="waybill" collection="businessDocumentNumberList" open="(" separator="," close=")">
#{waybill}
</foreach>
</if>
<!-- <if test="branchId != null or organizationIdList != null">-->
<!-- and (branch_id = #{branchId} or-->
<!-- organization_id in-->
<!-- <foreach item="organizationId" collection="organizationIdList" open="(" separator="," close=")">-->
<!-- #{organizationId}-->
<!-- </foreach>)-->
<!-- </if>-->
<!-- <if test="branchIdList != null">and-->
<!-- (branch_id in-->
<!-- <foreach item="branchId" collection="branchIdList" open="(" separator="," close=")">-->
<!-- #{branchId}-->
<!-- </foreach>-->
<!-- or organization_id in-->
<!-- <foreach item="organizationId" collection="organizationIdList" open="(" separator="," close=")">-->
<!-- #{organizationId}-->
<!-- </foreach>-->
<!-- )-->
<!-- </if>-->
<if test="enterAccountTimeStart != null">
AND date_format(v.create_time,'%Y-%m-%d') >= #{enterAccountTimeStart}
</if>
<if test="enterAccountTimeEnd != null">
AND date_format(v.create_time,'%Y-%m-%d') <![CDATA[<=]]> #{enterAccountTimeEnd}
</if>
<if test="paymentMethod != null ">
and v.payment_method = #{paymentMethod}
</if>
<if test="cancelAfterVerificationTimeStart != null and cancelAfterVerificationTimeStart != ''">
AND date_format(v.cancel_after_verification_time,'%Y-%m-%d') >= #{cancelAfterVerificationTimeStart}
</if>
<if test="cancelAfterVerificationTimeEnd != null and cancelAfterVerificationTimeEnd != ''">
AND date_format(v.cancel_after_verification_time,'%Y-%m-%d') <![CDATA[<=]]> #{cancelAfterVerificationTimeEnd}
</if>
<!-- <if test="cancelAfterVerificationType != null"> and cancel_after_verification_type = #{cancelAfterVerificationType}</if>-->
<!-- <if test="mailBranch != null"> and mail_branch = #{mailBranch}</if>-->
<if test="accountHolderBank != null and accountHolderBank != ''"> and v.account_holder_bank = #{accountHolderBank}</if>
<if test="businessDocumentDetaliNumber != null and businessDocumentDetaliNumber != ''"> and v.business_document_detali_number like concat('%', #{businessDocumentDetaliNumber}, '%')</if>
<if test="accountHolderName != null and accountHolderName != ''"> and v.account_holder_name = #{accountHolderName}</if>
<if test="bankAccount != null and bankAccount != ''"> and v.bank_account = #{bankAccount}</if>
<!-- <if test="arriveBranch != null"> and arrive_branch = #{arriveBranch}</if>-->
<!-- <if test="verificationType != null "> and verification_type = #{verificationType}</if>-->
<!-- <if test="verificationStatusOne != null and verificationStatusOne != '0'.toString()"> and verification_status = #{verificationStatusOne}</if>-->
<!-- <if test="verificationStatus != null and verificationStatus == '5'.toString()"> and verification_status <![CDATA[<=]]> #{verificationStatus}</if>-->
<if test="verificationStatus != null "> and v.verification_status = #{verificationStatus}</if>
<if test="businessType != null "> and v.business_type = #{businessType}</if>
<if test="innerNumber != null and innerNumber != ''"> and v.inner_number like concat('%', #{innerNumber}, '%')</if>
<if test="businessDocumentNumber != null and businessDocumentNumber != ''"> and v.business_document_number = #{businessDocumentNumber} </if>
<if test="expenseItem != null and expenseItem != ''"> and v.expense_item = #{expenseItem} </if>
<if test="enterAccountTime != null "> and v.enter_account_time = #{enterAccountTime}</if>
<if test="firstSubject != null and firstSubject != ''"> and v.first_subject = #{firstSubject}</if>
<if test="secondSubject != null and secondSubject != ''"> and v.second_subject = #{secondSubject}</if>
<if test="payType != null and payType != ''"> and v.pay_type = #{payType}</if>
<if test="payee != null and payee != ''"> and v.payee like concat('%', #{payee}, '%')</if>
<if test="payName != null and payName != ''"> and v.pay_name like concat('%', #{payName}, '%')</if>
<if test="licenseNumber != null and licenseNumber != ''"> and v.license_number like concat('%', #{licenseNumber}, '%')</if>
<if test="departmentName != null and departmentName != ''"> and v.department_name like concat('%', #{departmentName}, '%')</if>
<if test="verificationMoney != null "> and v.verification_money = #{verificationMoney}</if>
<if test="payPerson != null and payPerson != ''"> and v.pay_person = #{payPerson}</if>
<if test="payChannel != null and payChannel != ''"> and v.pay_channel = #{payChannel}</if>
<if test="bankNumber != null and bankNumber != ''"> and v.bank_number = #{bankNumber}</if>
<if test="receiptNumber != null and receiptNumber != ''"> and v.receipt_number = #{receiptNumber}</if>
<!-- <if test="collectionRemark != null and collectionRemark != ''"> and collection_remark = #{collectionRemark}</if>-->
<!-- <if test="waybillId != null "> and waybill_id = #{waybillId}</if>-->
<!-- <if test="waybillNumber != null and waybillNumber != ''"> and waybill_number like concat('%', #{waybillNumber}, '%')</if>-->
<!-- <if test="waybillRemark != null and waybillRemark != ''"> and waybill_remark = #{waybillRemark}</if>-->
<!-- <if test="waybillSource != null and waybillSource != ''"> and waybill_source = #{waybillSource}</if>-->
<!-- <if test="revenueExpensesNumber != null and revenueExpensesNumber != ''"> and revenue_expenses_number = #{revenueExpensesNumber}</if>-->
<!-- <if test="enterAccountId != null "> and enter_account_id = #{enterAccountId}</if>-->
<!-- <if test="enterAccountName != null and enterAccountName != ''"> and enter_account_name like concat('%', #{enterAccountName}, '%')</if>-->
<!-- <if test="cancelAfterVerificationId != null "> and cancel_after_verification_id = #{cancelAfterVerificationId}</if>-->
<!-- <if test="cancelAfterVerificationName != null and cancelAfterVerificationName != ''"> and cancel_after_verification_name like concat('%', #{cancelAfterVerificationName}, '%')</if>-->
<!-- <if test="cancelAfterVerificationTime != null "> and cancel_after_verification_time = #{cancelAfterVerificationTime}</if>-->
<if test="createByName != null and createByName != ''"> and v.create_by_name like concat('%', #{createByName}, '%')</if>
<if test="updateByName != null and updateByName != ''"> and v.update_by_name like concat('%', #{updateByName}, '%')</if>
<!-- <if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '5'.toString()"> and verification_status in (1,2,3,4,5)</if>-->
<!-- <if test="cancelAfterVerificationStatus != null and cancelAfterVerificationStatus == '6'.toString()"> and verification_status = 6</if>-->
</where>
order by v.create_time desc
</select>
<delete id="deleteVerificationByVerificationId" parameterType="java.lang.Long">
delete from verification where verification_id = #{verificationId}
</delete>
<delete id="deleteVerificationByWaybillId" parameterType="java.lang.Long">
delete from verification where waybill_id = #{waybillId} and verification_type = 2
</delete>
<delete id="deleteVerificationImageByVerificationId" parameterType="java.lang.Long">
delete from verification_image where verification_id = #{verificationId}
</delete>
<delete id="deleteVerificationByVerificationIds" parameterType="java.lang.String">
delete from verification where verification_id in
<foreach item="verificationId" collection="array" open="(" separator="," close=")">
#{verificationId}
</foreach>
</delete>
<select id="paymentStatementList" resultType="com.mhd.common.core.domain.po.VerificationPo">
SELECT
a.create_time,
a.business_document_number,
a.pay_name,
a.business_document_detali_number,
b.pay_type,
a.verification_money,
a.first_subject_name,
a.second_subject_name,
a.create_by_name,
b.create_by_name record_create_by_name,
a.verification_status
FROM
verification a
LEFT JOIN revenue_expenses_record b ON a.bank_number=b.bank_number
where a.del_flag=1
<if test="createTimeStart != null and createTimeStart != ''">
AND date_format(a.create_time,'%Y-%m-%d') >= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''">
AND date_format(a.create_time,'%Y-%m-%d') <![CDATA[<=]]> #{createTimeEnd}
</if>
<if test="businessDocumentNumber != null and businessDocumentNumber != ''">
and a.business_document_number like concat('%', #{businessDocumentNumber}, '%')
</if>
<if test="payName != null and payName != ''">
and a.pay_name like concat('%', #{payName}, '%')
</if>
<if test="businessDocumentDetaliNumber != null and businessDocumentDetaliNumber != ''">
and a.business_document_detali_number like concat('%', #{businessDocumentDetaliNumber}, '%')
</if>
<if test="payType != null and payType != ''">
and b.pay_type =#{payType}
</if>
<if test="createByName != null and createByName != ''">
and a.create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="recordCreateByName != null and recordCreateByName != ''">
and b.create_by_name like concat('%', #{recordCreateByName}, '%')
</if>
<if test="verificationStatus != null ">
and a.verification_status = #{verificationStatus}
</if>
order by a.create_time desc
</select>
</mapper>