From 883099679a6032c5d5577dfe72c2b8e9d77f08d7 Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Mon, 26 May 2025 14:41:38 +0800 Subject: [PATCH] =?UTF-8?q?demand:=20=20=E4=BF=9D=E7=95=99=E5=8E=9Fsql?= =?UTF-8?q?=E9=87=8D=E8=B5=B7=E4=B8=80=E4=B8=AAsql=20committer:=20heyu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EmisSettleInvoiceChRecordMapper.java | 8 + .../EmisSettleInvoiceChRecordServiceImpl.java | 2 +- .../EmisSettleInvoiceChRecordMapper.xml | 209 +++++++++++++++++- 3 files changed, 217 insertions(+), 2 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisSettleInvoiceChRecordMapper.java b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisSettleInvoiceChRecordMapper.java index f4c0bf4de..cd1d4886a 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisSettleInvoiceChRecordMapper.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisSettleInvoiceChRecordMapper.java @@ -41,6 +41,14 @@ public interface EmisSettleInvoiceChRecordMapper extends BaseMapper selectEmisSettleInvoiceChRecordList(EmisSettleInvoiceChRecord emisSettleInvoiceChRecord); + /** + * 查询列表 + * + * @param emisSettleInvoiceChRecord + * @return 集合 + */ + public List selectEmisSettleInvoiceChRecordListAll(EmisSettleInvoiceChRecord emisSettleInvoiceChRecord); + /** * 获取待查询状态的数据 diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettleInvoiceChRecordServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettleInvoiceChRecordServiceImpl.java index afc21add0..45247fc17 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettleInvoiceChRecordServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettleInvoiceChRecordServiceImpl.java @@ -111,7 +111,7 @@ public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implem public List selectEmisSettleInvoiceChRecordList(EmisSettleInvoiceChRecord emisSettleInvoiceChRecord) { long startTime = System.currentTimeMillis(); - List emisSettleInvoiceChRecords = emisSettleInvoiceChRecordMapper.selectEmisSettleInvoiceChRecordList(emisSettleInvoiceChRecord); + List emisSettleInvoiceChRecords = emisSettleInvoiceChRecordMapper.selectEmisSettleInvoiceChRecordListAll(emisSettleInvoiceChRecord); long endTime = System.currentTimeMillis(); log.info("查询渠道开票记录列表完成, 耗时: {}ms", (endTime - startTime)); return emisSettleInvoiceChRecords; diff --git a/emis-biz/src/main/resources/mapper/EmisSettleInvoiceChRecordMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettleInvoiceChRecordMapper.xml index 8722f2a56..5e3e753ab 100644 --- a/emis-biz/src/main/resources/mapper/EmisSettleInvoiceChRecordMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisSettleInvoiceChRecordMapper.xml @@ -111,7 +111,214 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select id, req_no, apply_seq_no, bl_ecinv, invoice_type, real_invoice_type, company_name, company_tax_no, company_tel, company_address, bank_name, bank_acc_no, contact, phone, tax_rate, open_money, email, saler_company_name, saler_company_tax_no, saler_company_tel, saler_company_address, saler_bank_name, saler_bank_acc_no, saler_contact, saler_phone, saler_checker, saler_payee, invoice_no, file_path, qr_path, op_man_code, op_date, op_site_code, open_ch_id, open_ch_status, open_ch_status_desc, open_com_code, ext_data, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_settle_invoice_ch_record - + SELECT + a.id, a.req_no, a.apply_seq_no, a.bl_ecinv, a.invoice_type, a.real_invoice_type, a.company_name, a.company_tax_no, a.company_tel, + a.company_address, a.bank_name, a.bank_acc_no, a.contact, a.phone, a.tax_rate, a.open_money, a.email, a.saler_company_name, a.saler_company_tax_no, + a.saler_company_tel, a.saler_company_address, a.saler_bank_name, a.saler_bank_acc_no, a.saler_contact, a.saler_phone, a.saler_checker, a.saler_payee, + a.invoice_no, a.file_path, a.qr_path, a.op_man_code, a.op_date, a.op_site_code, a.open_ch_id, a.open_ch_status, a.open_ch_status_desc, a.open_com_code, + a.ext_data, a.remark, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time, a.create_site, a.update_site, + (SELECT GROUP_CONCAT(DISTINCT CONCAT(SUBSTRING(DATE_FORMAT(w.send_date, '%Y'), 3, 2), DATE_FORMAT(w.send_date, '%m'))) + FROM emis_waybill w + INNER JOIN emis_settle_invoice_rel ir ON w.bill_code = ir.bill_no + WHERE ir.apply_seq_no = a.apply_seq_no) as send_month, + (SELECT b.settle_type + FROM emis_settle_bill b + INNER JOIN emis_settle_invoice_bill_rel r ON b.settle_bill_no = r.settle_bill_no + WHERE r.apply_seq_no = a.apply_seq_no + LIMIT 1) as settle_type, + CASE + WHEN (SELECT b.settle_type + FROM emis_settle_bill b + INNER JOIN emis_settle_invoice_bill_rel r ON b.settle_bill_no = r.settle_bill_no + WHERE r.apply_seq_no = a.apply_seq_no + LIMIT 1) = '2' + THEN ( + SELECT GROUP_CONCAT(DISTINCT + CONCAT( + CONCAT(SUBSTRING(DATE_FORMAT(w.send_date, '%Y'), 3, 2), DATE_FORMAT(w.send_date, '%m ')), + b.cust_name + ) SEPARATOR '-' + ) + FROM emis_waybill w + INNER JOIN emis_settle_invoice_rel ir ON w.bill_code = ir.bill_no + INNER JOIN emis_settle_invoice_bill_rel r ON ir.apply_seq_no = r.apply_seq_no + INNER JOIN emis_settle_bill b ON r.settle_bill_no = b.settle_bill_no + WHERE ir.apply_seq_no = a.apply_seq_no + ) + ELSE ( + SELECT GROUP_CONCAT(DISTINCT + CONCAT( + DATE_FORMAT(w.send_date, '%m%d '), + w.send_company + ) SEPARATOR '-' + ) + FROM emis_waybill w + INNER JOIN emis_settle_invoice_rel ir ON w.bill_code = ir.bill_no + WHERE ir.apply_seq_no = a.apply_seq_no + ) + END as open_bill_remark, + (SELECT GROUP_CONCAT(DISTINCT + CONCAT( + DATE_FORMAT(pr.trade_date, '%m/%d'), + ' 已付(', + CASE pr.pay_type + WHEN '1' THEN '企业微信收款' + WHEN '2' THEN '工行汇款3890' + WHEN '3' THEN '微信支付' + WHEN '4' THEN '支付宝' + WHEN '5' THEN '其他' + WHEN '6' THEN '招行付款' + ELSE pr.pay_type + END, + ')' + ) + ) + FROM emis_settle_pay_record pr + INNER JOIN emis_settle_pay_bill_rel pbr ON pr.pay_id = pbr.pay_id + INNER JOIN emis_settle_invoice_bill_rel ibr ON ibr.settle_bill_no = pbr.settle_bill_no + WHERE ibr.apply_seq_no = a.apply_seq_no) as pay_days + FROM emis_settle_invoice_ch_record a + + del_flag='0' + and id = #{id} + and req_no = #{reqNo} + and apply_seq_no = #{applySeqNo} + and bl_ecinv = #{blEcinv} + and invoice_type = #{invoiceType} + and real_invoice_type = #{realInvoiceType} + and company_name = #{companyName} + and company_tax_no = #{companyTaxNo} + and company_tel = #{companyTel} + and company_address = #{companyAddress} + and bank_name = #{bankName} + and bank_acc_no = #{bankAccNo} + and contact = #{contact} + and phone = #{phone} + and tax_rate = #{taxRate} + and open_money = #{openMoney} + and email = #{email} + and saler_company_name = #{salerCompanyName} + and saler_company_tax_no = #{salerCompanyTaxNo} + and saler_company_tel = #{salerCompanyTel} + and saler_company_address = #{salerCompanyAddress} + and saler_bank_name = #{salerBankName} + and saler_bank_acc_no = #{salerBankAccNo} + and saler_contact = #{salerContact} + and saler_phone = #{salerPhone} + and invoice_no = #{invoiceNo} + and file_path like concat('%', #{filePath}, '%') + and qr_path like concat('%', #{qrPath}, '%') + and op_man_code = #{opManCode} + and op_date = #{opDate} + and op_site_code = #{opSiteCode} + and open_ch_id = #{openChId} + and open_ch_status = #{openChStatus} + and open_ch_status_desc like concat('%', #{openChStatusDesc}, '%') + and open_com_code = #{openComCode} + and ext_data like concat('%', #{extData}, '%') + and remark like concat('%', #{remark}, '%') + and del_flag like concat('%', #{delFlag}, '%') + and create_by like concat('%', #{createBy}, '%') + and create_time = #{createTime} + and update_by like concat('%', #{updateBy}, '%') + and update_time = #{updateTime} + and create_site like concat('%', #{createSite}, '%') + and update_site like concat('%', #{updateSite}, '%') + + + and create_time = ]]> #{params.beginCreateTime} + + + and create_time #{params.endCreateTime} + + + + + and EXISTS( + select 1 from emis_settle_bill x2,emis_settle_invoice_bill_rel x3,emis_settle_sub_bill x4 + where x2.del_flag = '0' and x3.del_flag = '0' and x4.del_flag='0' + and a.apply_seq_no=x3.apply_seq_no + and x2.settle_bill_no=x3.settle_bill_no + and x4.settle_bill_no=x2.settle_bill_no + and FIND_IN_SET(x4.`bill_code`,#{params.billCode}) + ) + + + + + + and EXISTS( + select 1 from emis_settle_invoice_bill_rel x3 + where x3.del_flag = '0' + and a.apply_seq_no=x3.apply_seq_no + AND FIND_IN_SET(x3.settle_bill_no, #{settleBillNo}) + ) + + + + + and EXISTS( + select 1 from emis_settle_bill x2,emis_settle_invoice_bill_rel x3 + where x2.del_flag = '0' and x3.del_flag = '0' + and a.apply_seq_no=x3.apply_seq_no and x2.settle_bill_no=x3.settle_bill_no + AND ( + x2.salesmen = #{params.privEmpName} + OR x2.payee = #{params.privEmpName} + OR x2.salesmen IN ( + SELECT salesmen + FROM emis_salesmen_rel esr + where esr.del_flag='0' and esr.bl_open='1' + and now() = ]]> esr.start_date and now() esr.end_date + and esr.sales_ass = #{params.privEmpName} + ) + ) + ) + + + + + + order by create_time desc + + +