Files
nanguangszwlback/mhd_finance/src/main/resources/mapper/loanManage/LoanManageMapper.xml
T
2025-11-20 10:45:16 +08:00

1318 lines
72 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.loanManage.repository.mapper.LoanManageMapper">
<resultMap type="com.linke.finance.domain.loanManage.repository.po.LoanManagePo" id="LoanManageResult">
<result property="loanManageId" column="loan_manage_id" />
<result property="branchId" column="branch_id" />
<result property="loanNumber" column="loan_number" />
<result property="loanType" column="loan_type" />
<result property="collectionStatus" column="collection_status" />
<result property="grantStatus" column="grant_status" />
<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="loanMoney" column="loan_money" />
<result property="payPerson" column="pay_person" />
<result property="innerNumber" column="inner_number" />
<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="collectionRemark" column="collection_remark" />
<result property="waybillId" column="waybill_id" />
<result property="waybillNumber" column="waybill_number" />
<result property="waybillSource" column="waybill_source" />
<result property="waybillSourceName" column="waybill_source_name" />
<result property="cancelAfterVerificationId" column="cancel_after_verification_id" />
<result property="cancelAfterVerificationName" column="cancel_after_verification_name" />
<result property="cancelAfterVerificationTime" column="cancel_after_verification_time" />
<result property="cancelAfterVerificationType" column="cancel_after_verification_type" />
<result property="collectionId" column="collection_id" />
<result property="collectionName" column="collection_name" />
<result property="collectionTime" column="collection_time" />
<result property="serviceCharge" column="service_charge" />
<result property="loanRequest" column="loan_request" />
<result property="accountHolderName" column="account_holder_name" />
<result property="accountHolderBank" column="account_holder_bank" />
<result property="bankAccount" column="bank_account" />
<result property="signStatus" column="sign_status" />
<result property="waybillRemark" column="waybill_remark" />
<result property="loanId" column="loan_id" />
<result property="loanName" column="loan_name" />
<result property="loanTime" column="loan_time" />
<result property="payPassword" column="pay_password" />
<result property="digitalReceiptStatus" column="digital_receipt_status" />
<result property="cancelRemark" column="cancel_remark" />
<result property="cancelAfterVerificationRemark" column="cancel_after_verification_remark" />
<result property="cancelCancelAfterVerificationRemark" column="cancel_cancel_after_verification_remark" />
<result property="cancelCollectionRemark" column="cancel_collection_remark" />
<result property="loanRemark" column="loan_remark" />
<result property="withholdPayment" column="withhold_payment" />
<result property="commissionCharges" column="commission_charges" />
<result property="collectionInnerNumber" column="collection_inner_number" />
<result property="commissionChargesStatus" column="commission_charges_status" />
<result property="reportLossStatus" column="report_loss_status" />
<result property="reportLossId" column="report_loss_id" />
<result property="reportLossName" column="report_loss_name" />
<result property="reportLossTime" column="report_loss_time" />
<result property="reportLossRemark" column="report_loss_remark" />
<result property="cancelReportLossRemark" column="cancel_report_loss_remark" />
<result property="mailBranch" column="mail_branch" />
<result property="arriveBranch" column="arrive_branch" />
<result property="images" column="images" />
<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" />
</resultMap>
<sql id="selectLoanManageVo">
SELECT
loan_manage_id,
branch_id,
loan_number,
loan_type,
collection_status,
grant_status,
first_subject,
second_subject,
first_subject_name,
second_subject_name,
loan_money,
pay_person,
inner_number,
pay_channel,
pay_channel_name,
pay_way,
pay_way_name,
bank_number,
receipt_number,
collection_remark,
waybill_id,
waybill_number,
waybill_source,
waybill_source_name,
cancel_after_verification_id,
cancel_after_verification_name,
cancel_after_verification_time,
cancel_after_verification_type,
collection_id,
collection_name,
collection_time,
service_charge,
loan_request,
account_holder_name,
account_holder_bank,
bank_account,
sign_status,
waybill_remark,
loan_id,
loan_name,
loan_time,
pay_password,
digital_receipt_status,
cancel_remark,
cancel_after_verification_remark,
cancel_cancel_after_verification_remark,
cancel_collection_remark,
loan_remark,
withhold_payment,
commission_charges,
collection_inner_number,
commission_charges_status,
report_loss_status,
report_loss_id,
report_loss_name,
report_loss_time,
report_loss_remark,
cancel_report_loss_remark,
mail_branch,
arrive_branch,
images,
create_time,
create_by,
create_by_name,
update_time,
update_by,
update_by_name,
del_flag
FROM
loan_manage
</sql>
<sql id="selectLoanManageVo1">
SELECT a.loan_manage_id,
a.branch_id,
a.mail_branch,
a.arrive_branch,
a.loan_number,
a.loan_type,
a.first_subject,
a.first_subject_name,
a.second_subject,
a.second_subject_name,
a.loan_money,
a.pay_person,
a.inner_number,
a.bank_number,
a.receipt_number,
a.waybill_id,
a.waybill_number,
a.pay_channel,
a.pay_channel_name,
a.cancel_after_verification_id,
a.cancel_after_verification_name,
a.cancel_after_verification_time,
a.cancel_after_verification_type,
a.cancel_after_verification_remark,
a.cancel_cancel_after_verification_remark,
a.service_charge,
a.loan_request,
a.account_holder_name,
a.account_holder_bank,
a.bank_account,
a.sign_status,
a.waybill_remark,
a.loan_id,
a.loan_name,
a.loan_time,
a.grant_status,
a.cancel_remark,
a.loan_remark,
a.pay_password,
a.digital_receipt_status,
a.withhold_payment,
a.commission_charges,
a.commission_charges_status,
a.report_loss_status,
a.report_loss_id,
a.report_loss_name,
a.report_loss_time,
a.report_loss_remark,
a.cancel_report_loss_remark,
a.create_time,
a.create_by,
a.create_by_name,
a.update_time,
a.update_by,
a.update_by_name,
a.del_flag,
a.images,
a.pay_way,
a.pay_way_name,
a.waybill_source,
a.waybill_source_name,
b.collection_id,
b.collection_name,
b.collection_time,
b.collection_status,
b.collection_remark,
b.cancel_collection_remark,
b.collection_inner_number
FROM loan_manage a
left join loan_manage b on a.loan_number = b.loan_number and b.loan_type = 1 and b.del_flag = 1
</sql>
<sql id="queryConditions">
<where>
and del_flag = 1
<if test="isFund != null and isFund == '1'.toString()"> and grant_status <![CDATA[<=]]> 2</if>
<if test="loanType != null "> and loan_type = #{loanType}</if>
<if test="branchId != null "> and branch_id = #{branchId}</if>
<if test="mailBranch != null "> and mail_branch = #{mailBranch}</if>
<if test="arriveBranch != null and arriveBranch !=''"> and arrive_branch = #{arriveBranch}</if>
<if test="loanNumber != null and loanNumber != ''"> and loan_number like concat('%', #{loanNumber}, '%')</if>
<if test="collectionStatus != null and collectionStatus != '0'.toString()"> and collection_status = #{collectionStatus}</if>
<if test="grantStatus != null and grantStatus != '0'.toString()"> and grant_status = #{grantStatus}</if>
<if test="reportLossStatus != null"> and report_loss_status = #{reportLossStatus}</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="loanMoney != null "> and loan_money = #{loanMoney}</if>
<if test="payPerson != null and payPerson != ''"> and pay_person = #{payPerson}</if>
<if test="innerNumber != null and innerNumber != ''"> and inner_number = #{innerNumber}</if>
<if test="collectionInnerNumber != null and collectionInnerNumber != ''"> and collection_inner_number like concat('%', #{collectionInnerNumber}, '%')</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="waybillSource != null and waybillSource != '' and waybillSource != '0'.toString()"> and waybill_source = #{waybillSource}</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="cancelAfterVerificationType != null and cancelAfterVerificationType != '' and cancelAfterVerificationType != '0'.toString()"> and cancel_after_verification_type = #{cancelAfterVerificationType}</if>
<if test="collectionId != null "> and collection_id = #{collectionId}</if>
<if test="collectionName != null and collectionName != ''"> and collection_name like concat('%', #{collectionName}, '%')</if>
<if test="collectionTime != null "> and collection_time = #{collectionTime}</if>
<if test="serviceCharge != null "> and service_charge = #{serviceCharge}</if>
<if test="loanRequest != null and loanRequest != '0'.toString()"> and loan_request = #{loanRequest}</if>
<if test="accountHolderName != null and accountHolderName != ''"> and account_holder_name like concat('%', #{accountHolderName}, '%')</if>
<if test="accountHolderBank != null and accountHolderBank != '0'.toString()"> and account_holder_bank = #{accountHolderBank}</if>
<if test="bankAccount != null and bankAccount != ''"> and bank_account = #{bankAccount}</if>
<if test="signStatus != null and signStatus != '0'.toString()"> and sign_status = #{signStatus}</if>
<if test="waybillRemark != null and waybillRemark != ''"> and waybill_remark = #{waybillRemark}</if>
<if test="loanId != null "> and loan_id = #{loanId}</if>
<if test="loanName != null and loanName != ''"> and loan_name like concat('%', #{loanName}, '%')</if>
<if test="loanTime != null "> and loan_time = #{loanTime}</if>
<if test="payPassword != null and payPassword != ''"> and pay_password = #{payPassword}</if>
<if test="digitalReceiptStatus != null and signStatus != '0'.toString()"> and digital_receipt_status = #{digitalReceiptStatus}</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="collectionTimeStart != null and collectionTimeStart != ''">
AND date_format(collection_time,'%Y-%m-%d') >= #{collectionTimeStart}
</if>
<if test="collectionTimeEnd != null and collectionTimeEnd != ''">
AND date_format(collection_time,'%Y-%m-%d') <![CDATA[<=]]> #{collectionTimeEnd}
</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="loanTimeStart != null and loanTimeStart != ''">
AND date_format(loan_time,'%Y-%m-%d') >= #{loanTimeStart}
</if>
<if test="loanTimeEnd != null and loanTimeEnd != ''">
AND date_format(loan_time,'%Y-%m-%d') <![CDATA[<=]]> #{loanTimeEnd}
</if>
<if test="commissionChargesStatus != null "> and commission_charges_status = #{commissionChargesStatus}</if>
<if test="reportLossId != null "> and report_loss_id = #{reportLossId}</if>
<if test="reportLossName != null and reportLossName != ''"> and report_loss_name like concat('%', #{reportLossName}, '%')</if>
<if test="reportLossTimeStart != null and reportLossTimeStart != ''">
AND date_format(report_loss_time,'%Y-%m-%d') >= #{reportLossTimeStart}
</if>
<if test="reportLossTimeEnd != null and reportLossTimeEnd != ''">
AND date_format(report_loss_time,'%Y-%m-%d') <![CDATA[<=]]> #{reportLossTimeEnd}
</if>
<if test="cancelAfterVerificationRemark != null and cancelAfterVerificationRemark != ''">
AND cancel_after_verification_remark = #{cancelAfterVerificationRemark}
</if>
<if test="cancelCancelAfterVerificationRemark != null and cancelCancelAfterVerificationRemark != ''">
AND cancel_cancel_after_verification_remark = #{cancelCancelAfterVerificationRemark}
</if>
<if test="cancelCollectionRemark != null and cancelCollectionRemark != ''">
AND cancel_collection_remark = #{cancelCollectionRemark}
</if>
<if test="loanRemark != null and loanRemark != ''">
AND loan_remark = #{loanRemark}
</if>
<if test="reportLossRemark != null and reportLossRemark != ''">
AND report_loss_remark = #{reportLossRemark}
</if>
<if test="cancelReportLossRemark != null and cancelReportLossRemark != ''">
AND cancel_report_loss_remark = #{cancelReportLossRemark}
</if>
<if test="branchIdList != null ">
AND branch_id in
<foreach item="id" collection="branchIdList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
</sql>
<select id="selectLoanManageList" parameterType="com.linke.finance.domain.loanManage.repository.todo.LoanManageDo"
resultMap="LoanManageResult">
<include refid="selectLoanManageVo"/>
<where>
and del_flag = 1
<if test="isFund != null and isFund == '1'.toString()"> and grant_status <![CDATA[<=]]> 2</if>
<if test="loanType != null "> and loan_type = #{loanType}</if>
<if test="branchId != null "> and branch_id = #{branchId}</if>
<if test="mailBranch != null "> and mail_branch = #{mailBranch}</if>
<if test="arriveBranch != null and arriveBranch !=''"> and arrive_branch = #{arriveBranch}</if>
<if test="loanNumber != null and loanNumber != ''"> and loan_number like concat('%', #{loanNumber}, '%')</if>
<if test="collectionStatus != null and collectionStatus != '0'.toString()"> and collection_status = #{collectionStatus}</if>
<if test="grantStatus != null and grantStatus != '0'.toString()"> and grant_status = #{grantStatus}</if>
<if test="reportLossStatus != null"> and report_loss_status = #{reportLossStatus}</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="loanMoney != null "> and loan_money = #{loanMoney}</if>
<if test="payPerson != null and payPerson != ''"> and pay_person = #{payPerson}</if>
<if test="innerNumber != null and innerNumber != ''"> and inner_number = #{innerNumber}</if>
<if test="collectionInnerNumber != null and collectionInnerNumber != ''"> and collection_inner_number like concat('%', #{collectionInnerNumber}, '%')</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="waybillSource != null and waybillSource != '' and waybillSource != '0'.toString()"> and waybill_source = #{waybillSource}</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="cancelAfterVerificationType != null and cancelAfterVerificationType != '' and cancelAfterVerificationType != '0'.toString()"> and cancel_after_verification_type = #{cancelAfterVerificationType}</if>
<if test="collectionId != null "> and collection_id = #{collectionId}</if>
<if test="collectionName != null and collectionName != ''"> and collection_name like concat('%', #{collectionName}, '%')</if>
<if test="collectionTime != null "> and collection_time = #{collectionTime}</if>
<if test="serviceCharge != null "> and service_charge = #{serviceCharge}</if>
<if test="loanRequest != null and loanRequest != '0'.toString()"> and loan_request = #{loanRequest}</if>
<if test="accountHolderName != null and accountHolderName != ''"> and account_holder_name like concat('%', #{accountHolderName}, '%')</if>
<if test="accountHolderBank != null and accountHolderBank != '0'.toString()"> and account_holder_bank = #{accountHolderBank}</if>
<if test="bankAccount != null and bankAccount != ''"> and bank_account = #{bankAccount}</if>
<if test="signStatus != null and signStatus != '0'.toString()"> and sign_status = #{signStatus}</if>
<if test="waybillRemark != null and waybillRemark != ''"> and waybill_remark = #{waybillRemark}</if>
<if test="loanId != null "> and loan_id = #{loanId}</if>
<if test="loanName != null and loanName != ''"> and loan_name like concat('%', #{loanName}, '%')</if>
<if test="loanTime != null "> and loan_time = #{loanTime}</if>
<if test="payPassword != null and payPassword != ''"> and pay_password = #{payPassword}</if>
<if test="digitalReceiptStatus != null and signStatus != '0'.toString()"> and digital_receipt_status = #{digitalReceiptStatus}</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="collectionTimeStart != null and collectionTimeStart != ''">
AND date_format(collection_time,'%Y-%m-%d') >= #{collectionTimeStart}
</if>
<if test="collectionTimeEnd != null and collectionTimeEnd != ''">
AND date_format(collection_time,'%Y-%m-%d') <![CDATA[<=]]> #{collectionTimeEnd}
</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="loanTimeStart != null and loanTimeStart != ''">
AND date_format(loan_time,'%Y-%m-%d') >= #{loanTimeStart}
</if>
<if test="loanTimeEnd != null and loanTimeEnd != ''">
AND date_format(loan_time,'%Y-%m-%d') <![CDATA[<=]]> #{loanTimeEnd}
</if>
<if test="commissionChargesStatus != null "> and commission_charges_status = #{commissionChargesStatus}</if>
<if test="reportLossId != null "> and report_loss_id = #{reportLossId}</if>
<if test="reportLossName != null and reportLossName != ''"> and report_loss_name like concat('%', #{reportLossName}, '%')</if>
<if test="reportLossTimeStart != null and reportLossTimeStart != ''">
AND date_format(report_loss_time,'%Y-%m-%d') >= #{reportLossTimeStart}
</if>
<if test="reportLossTimeEnd != null and reportLossTimeEnd != ''">
AND date_format(report_loss_time,'%Y-%m-%d') <![CDATA[<=]]> #{reportLossTimeEnd}
</if>
<if test="cancelAfterVerificationRemark != null and cancelAfterVerificationRemark != ''">
AND cancel_after_verification_remark = #{cancelAfterVerificationRemark}
</if>
<if test="cancelCancelAfterVerificationRemark != null and cancelCancelAfterVerificationRemark != ''">
AND cancel_cancel_after_verification_remark = #{cancelCancelAfterVerificationRemark}
</if>
<if test="cancelCollectionRemark != null and cancelCollectionRemark != ''">
AND cancel_collection_remark = #{cancelCollectionRemark}
</if>
<if test="loanRemark != null and loanRemark != ''">
AND loan_remark = #{loanRemark}
</if>
<if test="reportLossRemark != null and reportLossRemark != ''">
AND report_loss_remark = #{reportLossRemark}
</if>
<if test="cancelReportLossRemark != null and cancelReportLossRemark != ''">
AND cancel_report_loss_remark = #{cancelReportLossRemark}
</if>
<if test="branchIdList != null ">
AND branch_id in
<foreach item="id" collection="branchIdList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="waybillNumberList != null and waybillNumberList.size() != 0">
AND waybill_number in
<foreach item="waybill" collection="waybillNumberList" open="(" separator="," close=")">
#{waybill}
</foreach>
</if>
</where>
order by create_time desc
</select>
<select id="selectLoanManageprovideList"
parameterType="com.linke.finance.domain.loanManage.repository.todo.LoanManageDo"
resultMap="LoanManageResult">
<include refid="selectLoanManageVo1"/>
<where>
a.loan_type = 2
and a.del_flag = 1
<if test="branchIdList != null ">
and a.branch_id in
<foreach item="id" collection="branchIdList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="collectionStatus != null and collectionStatus != '' ">and b.collection_status =
#{collectionStatus}
</if>
<if test="disLoan != null and disLoan == '1'.toString()">
and ((a.loan_request in (1,2) and b.collection_status = 3) or a.loan_request = 3)
</if>
<if test="loanNumber != null and loanNumber != ''">and a.loan_number like concat('%', #{loanNumber}, '%')
</if>
<if test="waybillNumber != null and waybillNumber != ''">and a.waybill_number like concat('%',
#{waybillNumber}, '%')
</if>
<if test="signStatus != null and signStatus != '' ">and a.sign_status = #{signStatus}</if>
<if test="branchId != null ">and a.branch_id = #{branchId}</if>
<if test="payChannel != null and payChannel != ''"> and a.pay_channel = #{payChannel}</if>
<if test="grantStatus != null and grantStatus != '0'.toString()"> and a.grant_status = #{grantStatus}</if>
<if test="loanTimeStart != null and loanTimeStart != ''">
and date_format(a.loan_time,'%Y-%m-%d') >= #{loanTimeStart}
</if>
<if test="loanTimeEnd != null and loanTimeEnd != ''">
and date_format(a.loan_time,'%Y-%m-%d') <![CDATA[<=]]> #{loanTimeEnd}
</if>
<if test="reportLossStatus != null">and a.report_loss_status = #{reportLossStatus}</if>
<if test="collectionInnerNumber != null and collectionInnerNumber != ''">
and b.collection_inner_number like concat('%',#{collectionInnerNumber}, '%')
</if>
<if test="innerNumber != null and innerNumber != ''">
and a.inner_number like concat('%',#{innerNumber}, '%')
</if>
<if test="waybillSource != null and waybillSource != ''">
and a.waybill_source = #{waybillSource}
</if>
<if test="collectionTimeStart != null and collectionTimeStart != ''">
and date_format(b.collection_time,'%Y-%m-%d') >= #{collectionTimeStart}
</if>
<if test="collectionTimeEnd != null and collectionTimeEnd != ''">
and date_format(b.collection_time,'%Y-%m-%d') <![CDATA[<=]]> #{collectionTimeEnd}
</if>
<if test="collectionName != null and collectionName != ''">
and b.collection_name like concat('%',#{collectionName}, '%')
</if>
<if test="loanName != null and loanName != ''">
and a.loan_name like concat('%',#{loanName}, '%')
</if>
</where>
order by create_time desc
</select>
<select id="selectLoanManageByLoanManageId" parameterType="Long" resultMap="LoanManageResult">
<include refid="selectLoanManageVo"/>
where loan_manage_id = #{loanManageId} and del_flag = 1
</select>
<select id="selectLoanManageInfo" parameterType="Long" resultMap="LoanManageResult">
<include refid="selectLoanManageVo"/>
<include refid="queryConditions"/>
</select>
<select id="selectLoanImageByLoanId" parameterType="java.lang.Long" resultType="java.lang.String">
SELECT
image_url
FROM
`loan_image`
WHERE
loan_id = #{values} and del_flag = 1
</select>
<select id="selectLoanOneStatusNum" parameterType="com.linke.finance.domain.loanManage.repository.todo.LoanManageDo" 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.collection_status,
COUNT(r.collection_status) AS num
FROM
loan_manage r
where
r.loan_type = 1
and r.del_flag = 1
<if test="branchId != null ">and r.branch_id = #{branchId}</if>
<if test="branchIdList != null ">
and r.branch_id in
<foreach item="id" collection="branchIdList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
GROUP BY
r.collection_status) r
ON r.collection_status = s.receipt_status_id
WHERE
s.type = 8
</select>
<select id="selectLoanTwoStatusNum" 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.grant_status,
COUNT(r.grant_status) AS num
FROM
loan_manage r
left join loan_manage b on r.loan_number = b.loan_number and b.loan_type = 1 and b.del_flag = 1
where r.loan_type = 2
and r.del_flag = 1
and ((b.loan_request in (1, 2) and b.collection_status = 3) or b.loan_request = 3)
<if test="branchId != null ">and r.branch_id = #{branchId}</if>
<if test="branchIdList != null ">
and r.branch_id in
<foreach item="id" collection="branchIdList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
GROUP BY
r.grant_status) r
ON r.grant_status = s.receipt_status_id
WHERE
s.type = 9
</select>
<select id="selectLoanThreeStatusNum" 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.grant_status,
COUNT(r.grant_status) AS num
FROM
loan_manage r
where loan_type = 2
and r.del_flag = 1
<if test="branchId != null ">and r.branch_id = #{branchId}</if>
<if test="branchIdList != null ">
and r.branch_id in
<foreach item="id" collection="branchIdList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
GROUP BY
r.grant_status) r
ON r.grant_status = s.receipt_status_id
WHERE
s.type = 14)
UNION
(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.report_loss_status,
COUNT(r.report_loss_status) AS num
FROM
loan_manage r
where loan_type = 2
and r.del_flag = 1
<if test="branchId != null ">and r.branch_id = #{branchId}</if>
<if test="branchIdList != null ">
and r.branch_id in
<foreach item="id" collection="branchIdList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
GROUP BY
r.report_loss_status) r
ON r.report_loss_status = s.receipt_status_id
WHERE
s.type = 15)
</select>
<insert id="batchAddLoanImage" parameterType="java.util.List">
insert into loan_image
<trim prefix="(" suffix=")" suffixOverrides=",">
loan_id,
image_url,
create_time,
create_by,
create_by_name,
</trim>
values
<foreach collection="list" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{item.loanId},
#{item.imageUrl},
#{item.createTime},
#{item.createBy},
#{item.createByName},
</trim>
</foreach>
</insert>
<insert id="insertLoanManage" parameterType="com.linke.finance.domain.loanManage.entity.LoanManage" useGeneratedKeys="true" keyProperty="loanManageId">
insert into loan_manage
<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="loanNumber != null">loan_number,</if>
<if test="loanType != null">loan_type,</if>
<if test="collectionStatus != null">collection_status,</if>
<if test="grantStatus != null">grant_status,</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="loanMoney != null">loan_money,</if>
<if test="payPerson != null">pay_person,</if>
<if test="innerNumber != null">inner_number,</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="waybillId != null">waybill_id,</if>
<if test="waybillNumber != null">waybill_number,</if>
<if test="waybillSource != null">waybill_source,</if>
<if test="waybillSourceName != null">waybill_source_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="collectionId != null">collection_id,</if>
<if test="collectionName != null">collection_name,</if>
<if test="collectionTime != null">collection_time,</if>
<if test="serviceCharge != null">service_charge,</if>
<if test="loanRequest != null">loan_request,</if>
<if test="accountHolderName != null">account_holder_name,</if>
<if test="accountHolderBank != null">account_holder_bank,</if>
<if test="bankAccount != null">bank_account,</if>
<if test="signStatus != null">sign_status,</if>
<if test="waybillRemark != null">waybill_remark,</if>
<if test="loanId != null">loan_id,</if>
<if test="loanName != null">loan_name,</if>
<if test="loanTime != null">loan_time,</if>
<if test="payPassword != null">pay_password,</if>
<if test="digitalReceiptStatus != null">digital_receipt_status,</if>
<if test="cancelRemark != null">cancel_remark,</if>
<if test="cancelAfterVerificationRemark != null">cancel_after_verification_remark,</if>
<if test="cancelCancelAfterVerificationRemark != null">cancel_cancel_after_verification_remark,</if>
<if test="cancelCollectionRemark != null">cancel_collection_remark,</if>
<if test="loanRemark != null">loan_remark,</if>
<if test="withholdPayment != null">withhold_payment,</if>
<if test="commissionCharges != null">commission_charges,</if>
<if test="collectionInnerNumber != null">collection_inner_number,</if>
<if test="commissionChargesStatus != null">commission_charges_status,</if>
<if test="reportLossStatus != null">report_loss_status,</if>
<if test="reportLossId != null">report_loss_id,</if>
<if test="reportLossName != null">report_loss_name,</if>
<if test="reportLossTime != null">report_loss_remark,</if>
<if test="reportLossRemark != null">report_loss_time,</if>
<if test="cancelReportLossRemark != null">cancel_report_loss_remark,</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="loanNumber != null">#{loanNumber},</if>
<if test="loanType != null">#{loanType},</if>
<if test="collectionStatus != null">#{collectionStatus},</if>
<if test="grantStatus != null">#{grantStatus},</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="loanMoney != null">#{loanMoney},</if>
<if test="payPerson != null">#{payPerson},</if>
<if test="innerNumber != null">#{innerNumber},</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="waybillId != null">#{waybillId},</if>
<if test="waybillNumber != null">#{waybillNumber},</if>
<if test="waybillSource != null">#{waybillSource},</if>
<if test="waybillSourceName != null">#{waybillSourceName},</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="collectionId != null">#{collectionId},</if>
<if test="collectionName != null">#{collectionName},</if>
<if test="collectionTime != null">#{collectionTime},</if>
<if test="serviceCharge != null">#{serviceCharge},</if>
<if test="loanRequest != null">#{loanRequest},</if>
<if test="accountHolderName != null">#{accountHolderName},</if>
<if test="accountHolderBank != null">#{accountHolderBank},</if>
<if test="bankAccount != null">#{bankAccount},</if>
<if test="signStatus != null">#{signStatus},</if>
<if test="waybillRemark != null">#{waybillRemark},</if>
<if test="loanId != null">#{loanId},</if>
<if test="loanName != null">#{loanName},</if>
<if test="loanTime != null">#{loanTime},</if>
<if test="payPassword != null">#{payPassword},</if>
<if test="digitalReceiptStatus != null">#{digitalReceiptStatus},</if>
<if test="cancelRemark != null">#{cancelRemark},</if>
<if test="cancelAfterVerificationRemark != null">#{cancelAfterVerificationRemark},</if>
<if test="cancelCancelAfterVerificationRemark != null">#{cancelCancelAfterVerificationRemark},</if>
<if test="cancelCollectionRemark != null">#{cancelCollectionRemark},</if>
<if test="loanRemark != null">#{loanRemark},</if>
<if test="withholdPayment != null">#{withholdPayment},</if>
<if test="commissionCharges != null">#{commissionCharges},</if>
<if test="collectionInnerNumber != null">#{collectionInnerNumber},</if>
<if test="commissionChargesStatus != null">#{commissionChargesStatus},</if>
<if test="reportLossStatus != null">#{reportLossStatus},</if>
<if test="reportLossId != null">#{reportLossId},</if>
<if test="reportLossName != null">#{reportLossName},</if>
<if test="reportLossTime != null">#{reportLossTime},</if>
<if test="reportLossRemark != null">#{reportLossRemark},</if>
<if test="cancelReportLossRemark != null">#{cancelReportLossRemark},</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="batchAddLoanManage" parameterType="java.util.List">
insert into loan_manage
<trim prefix="(" suffix=")" suffixOverrides=",">
branch_id,
mail_branch,
arrive_branch,
loan_number,
loan_type,
collection_status,
grant_status,
first_subject,
second_subject,
first_subject_name,
second_subject_name,
loan_money,
pay_person,
inner_number,
pay_channel,
pay_channel_name,
pay_way,
pay_way_name,
bank_number,
receipt_number,
collection_remark,
waybill_id,
waybill_number,
waybill_source,
waybill_source_name,
cancel_after_verification_id,
cancel_after_verification_name,
cancel_after_verification_time,
cancel_after_verification_type,
collection_id,
collection_name,
collection_time,
service_charge,
loan_request,
account_holder_name,
account_holder_bank,
bank_account,
sign_status,
waybill_remark,
loan_id,
loan_name,
loan_time,
pay_password,
digital_receipt_status,
cancel_remark,
cancel_after_verification_remark,
cancel_cancel_after_verification_remark,
cancel_collection_remark,
loan_remark,
withhold_payment,
commission_charges,
collection_inner_number,
commission_charges_status,
report_loss_status,
report_loss_id,
report_loss_name,
report_loss_remark,
report_loss_time,
cancel_report_loss_remark,
images,
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.branchId},
#{item.mailBranch},
#{item.arriveBranch},
#{item.loanNumber},
#{item.loanType},
#{item.collectionStatus},
#{item.grantStatus},
#{item.firstSubject},
#{item.secondSubject},
#{item.firstSubjectName},
#{item.secondSubjectName},
#{item.loanMoney},
#{item.payPerson},
#{item.innerNumber},
#{item.payChannel},
#{item.payChannelName},
#{item.payWay},
#{item.payWayName},
#{item.bankNumber},
#{item.receiptNumber},
#{item.collectionRemark},
#{item.waybillId},
#{item.waybillNumber},
#{item.waybillSource},
#{item.waybillSourceName},
#{item.cancelAfterVerificationId},
#{item.cancelAfterVerificationName},
#{item.cancelAfterVerificationTime},
#{item.cancelAfterVerificationType},
#{item.collectionId},
#{item.collectionName},
#{item.collectionTime},
#{item.serviceCharge},
#{item.loanRequest},
#{item.accountHolderName},
#{item.accountHolderBank},
#{item.bankAccount},
#{item.signStatus},
#{item.waybillRemark},
#{item.loanId},
#{item.loanName},
#{item.loanTime},
#{item.payPassword},
#{item.digitalReceiptStatus},
#{item.cancelRemark},
#{item.cancelAfterVerificationRemark},
#{item.cancelCancelAfterVerificationRemark},
#{item.cancelCollectionRemark},
#{item.loanRemark},
#{item.withholdPayment},
#{item.commissionCharges},
#{item.collectionInnerNumber},
#{item.commissionChargesStatus},
#{item.reportLossStatus},
#{item.reportLossId},
#{item.reportLossName},
#{item.reportLossTime},
#{item.reportLossRemark},
#{item.cancelReportLossRemark},
#{item.images},
#{item.createTime},
#{item.createBy},
#{item.createByName},
#{item.updateTime},
#{item.updateBy},
#{item.updateByName},
#{item.delFlag},
</trim>
</foreach>
</insert>
<update id="updateLoanManage" parameterType="com.linke.finance.domain.loanManage.entity.LoanManage">
update loan_manage
<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="loanNumber != null">loan_number = #{loanNumber},</if>
<if test="loanType != null">loan_type = #{loanType},</if>
<if test="collectionStatus != null">collection_status = #{collectionStatus},</if>
<if test="grantStatus != null">grant_status = #{grantStatus},</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="loanMoney != null">loan_money = #{loanMoney},</if>
<if test="payPerson != null">pay_person = #{payPerson},</if>
<if test="innerNumber != null">inner_number = #{innerNumber},</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="waybillId != null">waybill_id = #{waybillId},</if>
<if test="waybillNumber != null">waybill_number = #{waybillNumber},</if>
<if test="waybillSource != null">waybill_source = #{waybillSource},</if>
<if test="waybillSourceName != null">waybill_source_name = #{waybillSourceName},</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="collectionId != null">collection_id = #{collectionId},</if>
<if test="collectionName != null">collection_name = #{collectionName},</if>
<if test="collectionTime != null">collection_time = #{collectionTime},</if>
<if test="serviceCharge != null">service_charge = #{serviceCharge},</if>
<if test="loanRequest != null">loan_request = #{loanRequest},</if>
<if test="accountHolderName != null">account_holder_name = #{accountHolderName},</if>
<if test="accountHolderBank != null">account_holder_bank = #{accountHolderBank},</if>
<if test="bankAccount != null">bank_account = #{bankAccount},</if>
<if test="signStatus != null">sign_status = #{signStatus},</if>
<if test="waybillRemark != null">waybill_remark = #{waybillRemark},</if>
<if test="loanId != null">loan_id = #{loanId},</if>
<if test="loanName != null">loan_name = #{loanName},</if>
<if test="loanTime != null">loan_time = #{loanTime},</if>
<if test="payPassword != null">pay_password = #{payPassword},</if>
<if test="digitalReceiptStatus != null">digital_receipt_status = #{digitalReceiptStatus},</if>
<if test="cancelRemark != null">cancel_remark = #{cancelRemark},</if>
<if test="cancelAfterVerificationRemark != null">cancel_after_verification_remark = #{cancelAfterVerificationRemark},</if>
<if test="cancelCancelAfterVerificationRemark != null">cancel_cancel_after_verification_remark = #{cancelCancelAfterVerificationRemark},</if>
<if test="cancelCollectionRemark != null">cancel_collection_remark = #{cancelCollectionRemark},</if>
<if test="loanRemark != null">loan_remark = #{loanRemark},</if>
<if test="withholdPayment != null">withhold_payment = #{withholdPayment},</if>
<if test="commissionCharges != null">commission_charges = #{commissionCharges},</if>
<if test="collectionInnerNumber != null and collectionInnerNumber != ''">collection_inner_number = #{collectionInnerNumber},</if>
<if test="commissionChargesStatus != null">commission_charges_status = #{commissionChargesStatus},</if>
<if test="reportLossStatus != null">report_loss_status = #{reportLossStatus},</if>
<if test="reportLossId != null">report_loss_id = #{reportLossId},</if>
<if test="reportLossName != null and reportLossName != ''">report_loss_name = #{reportLossName},</if>
<if test="reportLossTime != null">report_loss_time = #{reportLossTime},</if>
<if test="reportLossRemark != null">report_loss_remark = #{reportLossRemark},</if>
<if test="cancelReportLossRemark != null">cancel_report_loss_remark = #{cancelReportLossRemark},</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 loan_manage_id = #{loanManageId}
</update>
<update id="updateLoanManages" parameterType="com.linke.finance.domain.loanManage.repository.po.LoanManagePo">
update loan_manage
<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="loanNumber != null">loan_number = #{loanNumber},</if>
<if test="loanType != null">loan_type = #{loanType},</if>
<if test="collectionStatus != null">collection_status = #{collectionStatus},</if>
<if test="grantStatus != null">grant_status = #{grantStatus},</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="loanMoney != null">loan_money = #{loanMoney},</if>
<if test="payPerson != null">pay_person = #{payPerson},</if>
<if test="innerNumber != null">inner_number = #{innerNumber},</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="waybillId != null">waybill_id = #{waybillId},</if>
<if test="waybillNumber != null">waybill_number = #{waybillNumber},</if>
<if test="waybillSource != null">waybill_source = #{waybillSource},</if>
<if test="waybillSourceName != null">waybill_source_name = #{waybillSourceName},</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="collectionId != null">collection_id = #{collectionId},</if>
<if test="collectionName != null">collection_name = #{collectionName},</if>
<if test="collectionTime != null">collection_time = #{collectionTime},</if>
<if test="serviceCharge != null">service_charge = #{serviceCharge},</if>
<if test="loanRequest != null">loan_request = #{loanRequest},</if>
<if test="accountHolderName != null">account_holder_name = #{accountHolderName},</if>
<if test="accountHolderBank != null">account_holder_bank = #{accountHolderBank},</if>
<if test="bankAccount != null">bank_account = #{bankAccount},</if>
<if test="signStatus != null">sign_status = #{signStatus},</if>
<if test="waybillRemark != null">waybill_remark = #{waybillRemark},</if>
<if test="loanId != null">loan_id = #{loanId},</if>
<if test="loanName != null">loan_name = #{loanName},</if>
<if test="loanTime != null">loan_time = #{loanTime},</if>
<if test="payPassword != null">pay_password = #{payPassword},</if>
<if test="digitalReceiptStatus != null">digital_receipt_status = #{digitalReceiptStatus},</if>
<if test="cancelRemark != null">cancel_remark = #{cancelRemark},</if>
<if test="cancelAfterVerificationRemark != null">cancel_after_verification_remark = #{cancelAfterVerificationRemark},</if>
<if test="cancelCancelAfterVerificationRemark != null">cancel_cancel_after_verification_remark = #{cancelCancelAfterVerificationRemark},</if>
<if test="cancelCollectionRemark != null">cancel_collection_remark = #{cancelCollectionRemark},</if>
<if test="loanRemark != null">loan_remark = #{loanRemark},</if>
<if test="withholdPayment != null">withhold_payment = #{withholdPayment},</if>
<if test="commissionCharges != null">commission_charges = #{commissionCharges},</if>
<if test="collectionInnerNumber != null and collectionInnerNumber != ''">collection_inner_number = #{collectionInnerNumber},</if>
<if test="commissionChargesStatus != null">commission_charges_status = #{commissionChargesStatus},</if>
<if test="reportLossStatus != null">report_loss_status = #{reportLossStatus},</if>
<if test="reportLossId != null">report_loss_id = #{reportLossId},</if>
<if test="reportLossName != null and reportLossName != ''">report_loss_name = #{reportLossName},</if>
<if test="reportLossTime != null">report_loss_time = #{reportLossTime},</if>
<if test="reportLossRemark != null">report_loss_remark = #{reportLossRemark},</if>
<if test="cancelReportLossRemark != null">cancel_report_loss_remark = #{cancelReportLossRemark},</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 loan_manage_id in
<foreach item="loanManageId" collection="loanManageIds" open="(" separator="," close=")">
#{loanManageId}
</foreach>
</update>
<delete id="deleteLoanManageByLoanManageId" parameterType="java.lang.Long">
delete from loan_manage where loan_manage_id = #{loanManageId}
</delete>
<delete id="deleteLoanImageByLoanId" parameterType="java.lang.Long">
delete from loan_image where loan_id = #{loanId}
</delete>
<delete id="deleteLoanManageByLoanManageIds" parameterType="java.lang.String">
delete from loan_manage where loan_manage_id in
<foreach item="loanManageId" collection="array" open="(" separator="," close=")">
#{loanManageId}
</foreach>
</delete>
<select id="collectionStatistics" parameterType="com.linke.finance.interfaces.dto.report.ReportDTO" resultType="com.linke.finance.domain.report.repository.po.CollectionStatisticsPO">
select
branch_id,
ifnull(sum(lm.loan_money), 0) as totalPayment,
ifnull(sum(case when lm.loan_request = 1 then loan_money end), 0) as cashPayment,
ifnull(sum(case when lm.loan_request = 1 then commission_charges end), 0) as cashServiceCharge,
ifnull(sum(case when lm.loan_request = 1 then withhold_payment end), 0) as cashWithholdPayment,
ifnull(sum(case when lm.loan_request = 2 then loan_money end), 0) as bankCardPayment,
ifnull(sum(case when lm.loan_request = 2 then commission_charges end), 0) as bankCardServiceCharge,
ifnull(sum(case when lm.loan_request = 2 then withhold_payment end), 0) as bankCardWithholdPayment,
ifnull(sum(case when lm.loan_request = 3 then loan_money end), 0) as advancePayment,
ifnull(sum(case when lm.loan_request = 3 then commission_charges end), 0) as advanceServiceCharge
from loan_manage lm
<where>
lm.loan_type = 2
and lm.del_flag = 1
<if test="branchId != null"> and lm.branch_id = #{branchId}</if>
<if test="branchIdList != null ">
and lm.branch_id in
<foreach item="id" collection="branchIdList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="startTime != null and startTime != ''">
AND date_format(lm.create_time,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND date_format(lm.create_time,'%Y-%m-%d') &lt;= #{endTime}
</if>
</where>
group by lm.branch_id
</select>
<select id="loanStatistics" parameterType="com.linke.finance.interfaces.dto.report.ReportDTO" resultType="com.linke.finance.domain.report.repository.po.LoanStatisticsPO">
select
a.branch_id,
ifnull(sum(case when a.grant_status = 2 then a.loan_money end), 0) as totalPayment,
ifnull(sum(case when a.loan_request = 1 and a.grant_status = 2 then a.loan_money end), 0) as cashPayment,
ifnull(sum(case when a.loan_request = 1 and a.grant_status = 2 then a.commission_charges end), 0) as cashServiceCharge,
ifnull(sum(case when a.loan_request = 1 and a.grant_status = 2 then a.withhold_payment end), 0) as cashWithholdPayment,
ifnull(sum(case when a.loan_request = 2 and a.grant_status = 2 then a.loan_money end), 0) as bankCardPayment,
ifnull(sum(case when a.loan_request = 2 and a.grant_status = 2 then a.commission_charges end), 0) as bankCardServiceCharge,
ifnull(sum(case when a.loan_request = 2 and a.grant_status = 2 then a.withhold_payment end), 0) as bankCardWithholdPayment,
ifnull(sum(case when a.loan_request = 3 and a.grant_status = 2 then a.loan_money end), 0) as advancePayment,
ifnull(sum(case when a.loan_request = 3 and a.grant_status = 2 then a.commission_charges end), 0) as advanceServiceCharge,
ifnull(sum(case when b.collection_status = 3 and a.grant_status = 1 then a.loan_money end), 0) as inventoryAmount
from loan_manage a
left join loan_manage b on a.waybill_number = b.waybill_number and b.loan_type = 1 and b.del_flag = 1
<where>
a.loan_type = 2
and a.del_flag = 1
<if test="branchId != null">and a.branch_id = #{branchId}</if>
<if test="branchIdList != null ">
and a.branch_id in
<foreach item="id" collection="branchIdList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="startTime != null and startTime != ''">
AND date_format(a.create_time,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND date_format(a.create_time,'%Y-%m-%d') &lt;= #{endTime}
</if>
</where>
group by a.branch_id
</select>
<select id="unrepairedStatistics" parameterType="com.linke.finance.interfaces.dto.report.ReportDTO" resultType="com.linke.finance.domain.report.repository.po.CollectionStatisticsPO">
select
branch_id,
ifnull(sum(lm.loan_money), 0) as totalPayment,
ifnull(sum(case when lm.loan_request = 1 then loan_money end), 0) as cashPayment,
ifnull(sum(case when lm.loan_request = 1 then commission_charges end), 0) as cashServiceCharge,
ifnull(sum(case when lm.loan_request = 1 then withhold_payment end), 0) as cashWithholdPayment,
ifnull(sum(case when lm.loan_request = 2 then loan_money end), 0) as bankCardPayment,
ifnull(sum(case when lm.loan_request = 2 then commission_charges end), 0) as bankCardServiceCharge,
ifnull(sum(case when lm.loan_request = 2 then withhold_payment end), 0) as bankCardWithholdPayment,
ifnull(sum(case when lm.loan_request = 3 then loan_money end), 0) as advancePayment,
ifnull(sum(case when lm.loan_request = 3 then commission_charges end), 0) as advanceServiceCharge
from loan_manage lm
<where>
lm.loan_type = 2
and lm.del_flag = 1
and lm.grant_status = 1
<if test="branchId != null"> and lm.branch_id = #{branchId}</if>
<if test="branchIdList != null ">
and lm.branch_id in
<foreach item="id" collection="branchIdList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="startTime != null and startTime != ''">
AND date_format(lm.create_time,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND date_format(lm.create_time,'%Y-%m-%d') &lt;= #{endTime}
</if>
</where>
group by lm.branch_id
</select>
<select id="collectionStatisticsInfoList" parameterType="com.linke.finance.interfaces.dto.report.ReportDTO" resultType="com.linke.finance.domain.loanManage.repository.po.LoanManagePo">
<include refid="selectLoanManageVo"/>
<where>
del_flag = 1
and loan_type = 2
and branch_id = #{branchId}
<if test="startTime != null and startTime != ''">
AND date_format(create_time,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND date_format(create_time,'%Y-%m-%d') &lt;= #{endTime}
</if>
</where>
</select>
<select id="loanStatisticsInfoList" parameterType="com.linke.finance.interfaces.dto.report.ReportDTO" resultType="com.linke.finance.domain.loanManage.repository.po.LoanManagePo">
<include refid="reportIssuePo"/>
<where>
a.loan_type = 2
and a.del_flag = 1
and (a.grant_status = 2 or (b.collection_status = 3 and a.grant_status = 1))
and a.branch_id = #{branchId}
<if test="startTime != null and startTime != ''">
AND date_format(a.create_time,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND date_format(a.create_time,'%Y-%m-%d') &lt;= #{endTime}
</if>
</where>
</select>
<select id="unrepairedStatisticsInfoList" parameterType="com.linke.finance.interfaces.dto.report.ReportDTO" resultType="com.linke.finance.domain.loanManage.repository.po.LoanManagePo">
<include refid="reportIssuePo"/>
<where>
a.loan_type = 2
and a.del_flag = 1
and a.grant_status = 1
and a.branch_id = #{branchId}
<if test="startTime != null and startTime != ''">
AND date_format(a.create_time,'%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND date_format(a.create_time,'%Y-%m-%d') &lt;= #{endTime}
</if>
</where>
</select>
<sql id="reportIssuePo">
select a.loan_manage_id,
a.branch_id,
a.mail_branch,
a.arrive_branch,
a.loan_number,
a.loan_type,
a.first_subject,
a.first_subject_name,
a.second_subject,
a.second_subject_name,
a.loan_money,
a.pay_person,
a.inner_number,
a.collection_inner_number,
a.bank_number,
a.waybill_id,
a.waybill_number,
a.pay_channel,
a.pay_channel_name,
a.cancel_after_verification_id,
a.cancel_after_verification_name,
a.cancel_after_verification_time,
a.cancel_after_verification_type,
a.cancel_collection_remark,
a.service_charge,
a.loan_request,
a.account_holder_name,
a.account_holder_bank,
a.bank_account,
a.sign_status,
a.waybill_remark,
a.loan_id,
a.loan_name,
a.loan_time,
a.grant_status,
a.cancel_remark,
a.loan_remark,
a.digital_receipt_status,
a.withhold_payment,
a.commission_charges,
a.commission_charges_status,
a.report_loss_status,
a.report_loss_id,
a.report_loss_name,
a.report_loss_time,
a.report_loss_remark,
a.cancel_report_loss_remark,
a.create_time,
a.create_by,
a.create_by_name,
a.update_time,
a.update_by,
a.update_by_name,
a.images,
a.pay_way,
a.pay_way_name,
a.waybill_source,
a.waybill_source_name,
b.collection_id,
b.collection_name,
b.receipt_number
from loan_manage a
left join loan_manage b on a.waybill_number = b.waybill_number and b.loan_type = 1 and b.del_flag = 1
</sql>
</mapper>