From 362740d90310ce6f9e203a271c730ee5a3ecc7d2 Mon Sep 17 00:00:00 2001
From: aike <17730485278@139.com>
Date: Tue, 18 Nov 2025 18:05:43 +0800
Subject: [PATCH] =?UTF-8?q?demand:=20=20=20=20TMS=E7=B3=BB=E7=BB=9F=20-=20?=
=?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8=20-=20=E9=94=80=E5=94=AE?=
=?UTF-8?q?=E5=9B=9E=E6=AC=BE=E7=8E=87=E7=BB=9F=E8=AE=A1=20-=20=E6=9C=88?=
=?UTF-8?q?=E7=BB=93=E8=B4=A6=E5=8D=95=E5=9B=9E=E6=AC=BE=E7=8E=87=E8=AE=A1?=
=?UTF-8?q?=E7=AE=97=E9=80=BB=E8=BE=91=E9=80=82=E5=BA=94=E5=8F=91=E7=A5=A8?=
=?UTF-8?q?=E5=BB=B6=E6=9C=9F=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4=20=20TMS?=
=?UTF-8?q?=E7=B3=BB=E7=BB=9F=20-=20=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8?=
=?UTF-8?q?=20-=E8=B4=A2=E5=8A=A1=E6=94=B6=E6=AC=BE=E7=BB=9F=E8=AE=A1=20-?=
=?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=E9=80=82=E5=BA=94=E5=8F=91?=
=?UTF-8?q?=E7=A5=A8=E5=BB=B6=E6=9C=9F=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4?=
=?UTF-8?q?=20committer:=20heyu?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../resources/mapper/EmisSettleBillMapper.xml | 172 +++++++++++++++++-
.../mapper/EmisSettlePayRecordMapper.xml | 71 +++++++-
2 files changed, 234 insertions(+), 9 deletions(-)
diff --git a/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml
index d1e658bee..c6780d11b 100644
--- a/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml
+++ b/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml
@@ -294,9 +294,89 @@
SELECT
a.settle_bill_no,
sum( ifnull(d.pay_money,0) ) AS totalPayMoney,
- sum( if(b.trade_date a.payment_due_date,ifnull(d.pay_money,0) ,0) ) AS recdMoneyIn,
- sum( if(a.settle_type='2' and a.credit_period = ]]> 30 and b.trade_date ]]> a.payment_due_date and b.trade_date ]]> a.payment_due_date and b.trade_date DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ),ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D,
- sum( if( (a.settle_type='2' and a.credit_period = ]]> 30 and b.trade_date ]]> a.payment_due_date and b.trade_date = ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) ) or ( ( (a.settle_type='2' and a.credit_period 30) or a.settle_type='1' ) and b.trade_date ]]> a.payment_due_date ),ifnull(d.pay_money,0) ,0) ) AS recdPayMoneyGreat60D
+ sum(
+ case
+ when a.settle_type = '2'
+ and a.credit_period in (30,35,45,60,75,90)
+ and EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ and b.trade_date
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
+ else a.payment_due_date
+ end
+ )
+ then ifnull(d.pay_money,0)
+ when b.trade_date a.payment_due_date then ifnull(d.pay_money,0)
+ else 0
+ end
+ ) AS recdMoneyIn,
+ sum( if(
+ a.settle_type='2'
+ and a.credit_period = ]]> 30
+ and b.trade_date ]]> a.payment_due_date
+ and b.trade_date ]]> a.payment_due_date
+ and b.trade_date DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY )
+ and NOT EXISTS (
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag='0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ )
+ ,ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D,
+ sum(
+ case
+ when a.settle_type = '2'
+ and a.credit_period in (30,35,45,60,75,90)
+ and EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ and b.trade_date = ]]>
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
+ else a.payment_due_date
+ end
+ )
+ then ifnull(d.pay_money,0)
+ when (a.settle_type='2' and a.credit_period = ]]> 30 and b.trade_date ]]> a.payment_due_date and b.trade_date = ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) ) or ( ( (a.settle_type='2' and a.credit_period 30) or a.settle_type='1' ) and b.trade_date ]]> a.payment_due_date )
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ ) AS recdPayMoneyGreat60D
FROM
emis_settle_bill a,
emis_settle_pay_record b,
@@ -833,9 +913,89 @@
SELECT
a.settle_bill_no,
sum( ifnull(d.pay_money,0) ) AS totalPayMoney,
- sum( if(b.trade_date a.payment_due_date,ifnull(d.pay_money,0) ,0) ) AS recdMoneyIn,
- sum( if(a.settle_type='2' and a.credit_period = ]]> 30 and b.trade_date ]]> a.payment_due_date and b.trade_date ]]> a.payment_due_date and b.trade_date DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ),ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D,
- sum( if( (a.settle_type='2' and a.credit_period = ]]> 30 and b.trade_date ]]> a.payment_due_date and b.trade_date = ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) ) or ( ( (a.settle_type='2' and a.credit_period 30) or a.settle_type='1' ) and b.trade_date ]]> a.payment_due_date ),ifnull(d.pay_money,0) ,0) ) AS recdPayMoneyGreat60D
+ sum(
+ case
+ when a.settle_type = '2'
+ and a.credit_period in (30,35,45,60,75,90)
+ and EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ and b.trade_date
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
+ else a.payment_due_date
+ end
+ )
+ then ifnull(d.pay_money,0)
+ when b.trade_date a.payment_due_date then ifnull(d.pay_money,0)
+ else 0
+ end
+ ) AS recdMoneyIn,
+ sum( if(
+ a.settle_type='2'
+ and a.credit_period = ]]> 30
+ and b.trade_date ]]> a.payment_due_date
+ and b.trade_date ]]> a.payment_due_date
+ and b.trade_date DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY )
+ and NOT EXISTS (
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag='0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ )
+ ,ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D,
+ sum(
+ case
+ when a.settle_type = '2'
+ and a.credit_period in (30,35,45,60,75,90)
+ and EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = a.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ and b.trade_date = ]]>
+ (
+ case
+ when a.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when a.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ when a.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
+ else a.payment_due_date
+ end
+ )
+ then ifnull(d.pay_money,0)
+ when (a.settle_type='2' and a.credit_period = ]]> 30 and b.trade_date ]]> a.payment_due_date and b.trade_date = ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) ) or ( ( (a.settle_type='2' and a.credit_period 30) or a.settle_type='1' ) and b.trade_date ]]> a.payment_due_date )
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ ) AS recdPayMoneyGreat60D
FROM
emis_settle_bill a,
emis_settle_pay_record b,
diff --git a/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml
index be3282d31..7edd839ad 100644
--- a/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml
+++ b/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml
@@ -332,13 +332,78 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE espbr.del_flag=0 and esb.del_flag=0
and espbr.settle_bill_no=esb.settle_bill_no
- and b.trade_date esb.payment_due_date
+ and (
+ ( esb.settle_type = '2'
+ and esb.credit_period in (30,35,45,60,75,90)
+ and EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = esb.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ and b.trade_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
+ else esb.payment_due_date
+ end
+ )
+ ) or b.trade_date esb.payment_due_date
+ )
- and ( esb.settle_type='2' and esb.credit_period = ]]> 30 and b.trade_date ]]> esb.payment_due_date and b.trade_date ]]> esb.payment_due_date and b.trade_date DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY ) )
+ and ( esb.settle_type='2' and esb.credit_period = ]]> 30 and b.trade_date ]]> esb.payment_due_date and b.trade_date ]]> esb.payment_due_date and b.trade_date DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY )
+ and NOT EXISTS (
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag='0'
+ AND f.settle_bill_no = esb.settle_bill_no
+ AND f.bl_delay = '1'
+ ) )
- and ( ( esb.settle_type='2' and esb.credit_period = ]]> 30 and b.trade_date ]]> esb.payment_due_date and b.trade_date = ]]> DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY ) ) or ( ( (esb.settle_type='2' and esb.credit_period 30) or esb.settle_type='1' ) and b.trade_date ]]> esb.payment_due_date ) )
+ and (
+ ( esb.settle_type = '2'
+ and esb.credit_period in (30,35,45,60,75,90)
+ and EXISTS(
+ SELECT 1
+ FROM emis_settle_invoice_record f
+ WHERE f.del_flag = '0'
+ AND f.settle_bill_no = esb.settle_bill_no
+ AND f.bl_delay = '1'
+ AND f.apply_date
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ and b.trade_date = ]]>
+ (
+ case
+ when esb.credit_period in (30,35,45) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH)
+ else esb.payment_due_date
+ end
+ )
+ ) or ( ( esb.settle_type='2' and esb.credit_period = ]]> 30 and b.trade_date ]]> esb.payment_due_date and b.trade_date = ]]> DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY ) ) or ( ( (esb.settle_type='2' and esb.credit_period 30) or esb.settle_type='1' ) and b.trade_date ]]> esb.payment_due_date ) )
+ )