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
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
and del_flag = 1
and grant_status 2
and loan_type = #{loanType}
and branch_id = #{branchId}
and mail_branch = #{mailBranch}
and arrive_branch = #{arriveBranch}
and loan_number like concat('%', #{loanNumber}, '%')
and collection_status = #{collectionStatus}
and grant_status = #{grantStatus}
and report_loss_status = #{reportLossStatus}
and first_subject = #{firstSubject}
and second_subject = #{secondSubject}
and loan_money = #{loanMoney}
and pay_person = #{payPerson}
and inner_number = #{innerNumber}
and collection_inner_number like concat('%', #{collectionInnerNumber}, '%')
and pay_channel = #{payChannel}
and bank_number = #{bankNumber}
and receipt_number = #{receiptNumber}
and collection_remark = #{collectionRemark}
and waybill_id = #{waybillId}
and waybill_number like concat('%', #{waybillNumber}, '%')
and waybill_source = #{waybillSource}
and cancel_after_verification_id = #{cancelAfterVerificationId}
and cancel_after_verification_name like concat('%', #{cancelAfterVerificationName}, '%')
and cancel_after_verification_time = #{cancelAfterVerificationTime}
and cancel_after_verification_type = #{cancelAfterVerificationType}
and collection_id = #{collectionId}
and collection_name like concat('%', #{collectionName}, '%')
and collection_time = #{collectionTime}
and service_charge = #{serviceCharge}
and loan_request = #{loanRequest}
and account_holder_name like concat('%', #{accountHolderName}, '%')
and account_holder_bank = #{accountHolderBank}
and bank_account = #{bankAccount}
and sign_status = #{signStatus}
and waybill_remark = #{waybillRemark}
and loan_id = #{loanId}
and loan_name like concat('%', #{loanName}, '%')
and loan_time = #{loanTime}
and pay_password = #{payPassword}
and digital_receipt_status = #{digitalReceiptStatus}
and create_by_name like concat('%', #{createByName}, '%')
and update_by_name like concat('%', #{updateByName}, '%')
AND date_format(collection_time,'%Y-%m-%d') >= #{collectionTimeStart}
AND date_format(collection_time,'%Y-%m-%d') #{collectionTimeEnd}
AND date_format(cancel_after_verification_time,'%Y-%m-%d') >= #{cancelAfterVerificationTimeStart}
AND date_format(cancel_after_verification_time,'%Y-%m-%d') #{cancelAfterVerificationTimeEnd}
AND date_format(loan_time,'%Y-%m-%d') >= #{loanTimeStart}
AND date_format(loan_time,'%Y-%m-%d') #{loanTimeEnd}
and commission_charges_status = #{commissionChargesStatus}
and report_loss_id = #{reportLossId}
and report_loss_name like concat('%', #{reportLossName}, '%')
AND date_format(report_loss_time,'%Y-%m-%d') >= #{reportLossTimeStart}
AND date_format(report_loss_time,'%Y-%m-%d') #{reportLossTimeEnd}
AND cancel_after_verification_remark = #{cancelAfterVerificationRemark}
AND cancel_cancel_after_verification_remark = #{cancelCancelAfterVerificationRemark}
AND cancel_collection_remark = #{cancelCollectionRemark}
AND loan_remark = #{loanRemark}
AND report_loss_remark = #{reportLossRemark}
AND cancel_report_loss_remark = #{cancelReportLossRemark}
AND branch_id in
#{id}
insert into loan_image
loan_id,
image_url,
create_time,
create_by,
create_by_name,
values
#{item.loanId},
#{item.imageUrl},
#{item.createTime},
#{item.createBy},
#{item.createByName},
insert into loan_manage
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,
#{branchId},
#{mailBranch},
#{arriveBranch},
#{loanNumber},
#{loanType},
#{collectionStatus},
#{grantStatus},
#{firstSubject},
#{secondSubject},
#{firstSubjectName},
#{secondSubjectName},
#{loanMoney},
#{payPerson},
#{innerNumber},
#{payChannel},
#{payChannelName},
#{payWay},
#{payWayName},
#{bankNumber},
#{receiptNumber},
#{collectionRemark},
#{waybillId},
#{waybillNumber},
#{waybillSource},
#{waybillSourceName},
#{cancelAfterVerificationId},
#{cancelAfterVerificationName},
#{cancelAfterVerificationTime},
#{cancelAfterVerificationType},
#{collectionId},
#{collectionName},
#{collectionTime},
#{serviceCharge},
#{loanRequest},
#{accountHolderName},
#{accountHolderBank},
#{bankAccount},
#{signStatus},
#{waybillRemark},
#{loanId},
#{loanName},
#{loanTime},
#{payPassword},
#{digitalReceiptStatus},
#{cancelRemark},
#{cancelAfterVerificationRemark},
#{cancelCancelAfterVerificationRemark},
#{cancelCollectionRemark},
#{loanRemark},
#{withholdPayment},
#{commissionCharges},
#{collectionInnerNumber},
#{commissionChargesStatus},
#{reportLossStatus},
#{reportLossId},
#{reportLossName},
#{reportLossTime},
#{reportLossRemark},
#{cancelReportLossRemark},
#{images},
#{createTime},
#{createBy},
#{createByName},
#{updateTime},
#{updateBy},
#{updateByName},
#{delFlag},
insert into loan_manage
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,
values
#{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},
update loan_manage
branch_id = #{branchId},
mail_branch = #{mailBranch},
arrive_branch = #{arriveBranch},
loan_number = #{loanNumber},
loan_type = #{loanType},
collection_status = #{collectionStatus},
grant_status = #{grantStatus},
first_subject = #{firstSubject},
second_subject = #{secondSubject},
first_subject_name = #{firstSubjectName},
second_subject_name = #{secondSubjectName},
loan_money = #{loanMoney},
pay_person = #{payPerson},
inner_number = #{innerNumber},
pay_channel = #{payChannel},
pay_channel_name = #{payChannelName},
pay_way = #{payWay},
pay_way_name = #{payWayName},
bank_number = #{bankNumber},
receipt_number = #{receiptNumber},
collection_remark = #{collectionRemark},
waybill_id = #{waybillId},
waybill_number = #{waybillNumber},
waybill_source = #{waybillSource},
waybill_source_name = #{waybillSourceName},
cancel_after_verification_id = #{cancelAfterVerificationId},
cancel_after_verification_name = #{cancelAfterVerificationName},
cancel_after_verification_time = #{cancelAfterVerificationTime},
cancel_after_verification_type = #{cancelAfterVerificationType},
collection_id = #{collectionId},
collection_name = #{collectionName},
collection_time = #{collectionTime},
service_charge = #{serviceCharge},
loan_request = #{loanRequest},
account_holder_name = #{accountHolderName},
account_holder_bank = #{accountHolderBank},
bank_account = #{bankAccount},
sign_status = #{signStatus},
waybill_remark = #{waybillRemark},
loan_id = #{loanId},
loan_name = #{loanName},
loan_time = #{loanTime},
pay_password = #{payPassword},
digital_receipt_status = #{digitalReceiptStatus},
cancel_remark = #{cancelRemark},
cancel_after_verification_remark = #{cancelAfterVerificationRemark},
cancel_cancel_after_verification_remark = #{cancelCancelAfterVerificationRemark},
cancel_collection_remark = #{cancelCollectionRemark},
loan_remark = #{loanRemark},
withhold_payment = #{withholdPayment},
commission_charges = #{commissionCharges},
collection_inner_number = #{collectionInnerNumber},
commission_charges_status = #{commissionChargesStatus},
report_loss_status = #{reportLossStatus},
report_loss_id = #{reportLossId},
report_loss_name = #{reportLossName},
report_loss_time = #{reportLossTime},
report_loss_remark = #{reportLossRemark},
cancel_report_loss_remark = #{cancelReportLossRemark},
images = #{images},
create_time = #{createTime},
create_by = #{createBy},
create_by_name = #{createByName},
update_time = #{updateTime},
update_by = #{updateBy},
update_by_name = #{updateByName},
del_flag = #{delFlag},
where loan_manage_id = #{loanManageId}
update loan_manage
branch_id = #{branchId},
mail_branch = #{mailBranch},
arrive_branch = #{arriveBranch},
loan_number = #{loanNumber},
loan_type = #{loanType},
collection_status = #{collectionStatus},
grant_status = #{grantStatus},
first_subject = #{firstSubject},
second_subject = #{secondSubject},
first_subject_name = #{firstSubjectName},
second_subject_name = #{secondSubjectName},
loan_money = #{loanMoney},
pay_person = #{payPerson},
inner_number = #{innerNumber},
pay_channel = #{payChannel},
pay_channel_name = #{payChannelName},
pay_Way = #{payWay},
pay_way_name = #{payWayName},
bank_number = #{bankNumber},
receipt_number = #{receiptNumber},
collection_remark = #{collectionRemark},
waybill_id = #{waybillId},
waybill_number = #{waybillNumber},
waybill_source = #{waybillSource},
waybill_source_name = #{waybillSourceName},
cancel_after_verification_id = #{cancelAfterVerificationId},
cancel_after_verification_name = #{cancelAfterVerificationName},
cancel_after_verification_time = #{cancelAfterVerificationTime},
cancel_after_verification_type = #{cancelAfterVerificationType},
collection_id = #{collectionId},
collection_name = #{collectionName},
collection_time = #{collectionTime},
service_charge = #{serviceCharge},
loan_request = #{loanRequest},
account_holder_name = #{accountHolderName},
account_holder_bank = #{accountHolderBank},
bank_account = #{bankAccount},
sign_status = #{signStatus},
waybill_remark = #{waybillRemark},
loan_id = #{loanId},
loan_name = #{loanName},
loan_time = #{loanTime},
pay_password = #{payPassword},
digital_receipt_status = #{digitalReceiptStatus},
cancel_remark = #{cancelRemark},
cancel_after_verification_remark = #{cancelAfterVerificationRemark},
cancel_cancel_after_verification_remark = #{cancelCancelAfterVerificationRemark},
cancel_collection_remark = #{cancelCollectionRemark},
loan_remark = #{loanRemark},
withhold_payment = #{withholdPayment},
commission_charges = #{commissionCharges},
collection_inner_number = #{collectionInnerNumber},
commission_charges_status = #{commissionChargesStatus},
report_loss_status = #{reportLossStatus},
report_loss_id = #{reportLossId},
report_loss_name = #{reportLossName},
report_loss_time = #{reportLossTime},
report_loss_remark = #{reportLossRemark},
cancel_report_loss_remark = #{cancelReportLossRemark},
images = #{images},
create_time = #{createTime},
create_by = #{createBy},
create_by_name = #{createByName},
update_time = #{updateTime},
update_by = #{updateBy},
update_by_name = #{updateByName},
del_flag = #{delFlag},
where loan_manage_id in
#{loanManageId}
delete from loan_manage where loan_manage_id = #{loanManageId}
delete from loan_image where loan_id = #{loanId}
delete from loan_manage where loan_manage_id in
#{loanManageId}
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