From 5e3d62bcb106c73646426fb9007e368be7e82c1f Mon Sep 17 00:00:00 2001
From: aike <17730485278@139.com>
Date: Thu, 8 Jan 2026 11:11:30 +0800
Subject: [PATCH] =?UTF-8?q?demand:=20=20TMS=E7=B3=BB=E7=BB=9F=20-=20?=
=?UTF-8?q?=E5=AE=A2=E6=88=B7=E8=B4=A6=E5=8D=95=E7=AE=A1=E7=90=86=20-=20?=
=?UTF-8?q?=E8=B4=A2=E5=8A=A1=E6=94=B6=E6=AC=BE=E7=BB=9F=E8=AE=A1=20-=20?=
=?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=94=B6=E6=AC=BE=E7=BB=9F=E8=AE=A1=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E6=8E=A5=E5=8F=A3=E9=80=82=E5=BA=94=E6=96=B0=E7=AE=97?=
=?UTF-8?q?=E6=B3=95=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4=20=20TMS=E7=B3=BB?=
=?UTF-8?q?=E7=BB=9F=20-=20=E5=AE=A2=E6=88=B7=E8=B4=A6=E5=8D=95=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=20-=20=E8=B4=A2=E5=8A=A1=E6=94=B6=E6=AC=BE=E7=BB=9F?=
=?UTF-8?q?=E8=AE=A1=20-=20=E6=9F=A5=E8=AF=A2=E6=94=B6=E6=AC=BE=E8=AF=A6?=
=?UTF-8?q?=E6=83=85=E6=8E=A5=E5=8F=A3=E9=80=82=E5=BA=94=E6=96=B0=E7=AE=97?=
=?UTF-8?q?=E6=B3=95=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4=20=20TMS=E7=B3=BB?=
=?UTF-8?q?=E7=BB=9F=20-=20=E5=AE=A2=E6=88=B7=E8=B4=A6=E5=8D=95=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=20-=20=E9=94=80=E5=94=AE=E5=9B=9E=E6=AC=BE=E7=8E=87?=
=?UTF-8?q?=E7=BB=9F=E8=AE=A1=20-=20=E6=9F=A5=E8=AF=A2=E5=9B=9E=E6=AC=BE?=
=?UTF-8?q?=E7=8E=87=E7=BB=9F=E8=AE=A1=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=E9=80=82=E5=BA=94=E6=96=B0=E7=AE=97=E6=B3=95=E9=80=BB=E8=BE=91?=
=?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../resources/mapper/EmisSettleBillMapper.xml | 238 +++++++++++---
.../mapper/EmisSettlePayRecordMapper.xml | 296 ++++++++++++++----
2 files changed, 434 insertions(+), 100 deletions(-)
diff --git a/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml
index 95556e2e5..f3a7f8cfd 100644
--- a/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml
+++ b/emis-biz/src/main/resources/mapper/EmisSettleBillMapper.xml
@@ -314,7 +314,8 @@
end
)
)
- and b.trade_date
+ then case
+ when 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)
@@ -323,25 +324,79 @@
else a.payment_due_date
end
)
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when a.settle_type = '2'
+ and a.credit_period in (30,60,90)
+ and a.settle_day = '1'
+ then case
+ when b.trade_date
+ (
+ case
+ when a.credit_period = 30 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period = 60 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)
+ end
+ )
then ifnull(d.pay_money,0)
- when b.trade_date a.payment_due_date then ifnull(d.pay_money,0)
else 0
+ end
+ else case
+ when b.trade_date a.payment_due_date then ifnull(d.pay_money,0)
+ else 0
+ end
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 = 30
+ and a.settle_day = '1'
+ and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ and b.trade_date DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ 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'
+ 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
+ )
+ )
+ 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 ]]> 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'
+ 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
+ )
+ )
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ ) AS recdPayMoney60D,
sum(
case
when a.settle_type = '2'
@@ -362,7 +417,8 @@
end
)
)
- and b.trade_date = ]]>
+ then case
+ when 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)
@@ -371,9 +427,34 @@
else a.payment_due_date
end
)
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when a.settle_type = '2'
+ and a.credit_period in (30,60,90)
+ and a.settle_day = '1'
+ then case
+ when (
+ (a.credit_period = 30 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH))
+ or (a.credit_period = 60 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH))
+ or (a.credit_period = 90 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH))
+ )
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
+ when a.settle_type='2'
+ and a.credit_period = ]]> 30
+ then case
+ when b.trade_date ]]> a.payment_due_date
+ and b.trade_date = ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY )
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when ( (a.settle_type='2' and a.credit_period 30) or a.settle_type='1' )
+ then case
+ when b.trade_date ]]> a.payment_due_date then ifnull(d.pay_money,0)
+ else 0
+ end
else 0
end
) AS recdPayMoneyGreat60D
@@ -933,7 +1014,8 @@
end
)
)
- and b.trade_date
+ then case
+ when 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)
@@ -942,25 +1024,79 @@
else a.payment_due_date
end
)
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when a.settle_type = '2'
+ and a.credit_period in (30,60,90)
+ and a.settle_day = '1'
+ then case
+ when b.trade_date
+ (
+ case
+ when a.credit_period = 30 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when a.credit_period = 60 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)
+ end
+ )
then ifnull(d.pay_money,0)
- when b.trade_date a.payment_due_date then ifnull(d.pay_money,0)
else 0
+ end
+ else case
+ when b.trade_date a.payment_due_date then ifnull(d.pay_money,0)
+ else 0
+ end
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 = 30
+ and a.settle_day = '1'
+ and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ and b.trade_date DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ 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'
+ 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
+ )
+ )
+ 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 ]]> 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'
+ 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
+ )
+ )
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ ) AS recdPayMoney60D,
sum(
case
when a.settle_type = '2'
@@ -981,7 +1117,8 @@
end
)
)
- and b.trade_date = ]]>
+ then case
+ when 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)
@@ -990,9 +1127,34 @@
else a.payment_due_date
end
)
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when a.settle_type = '2'
+ and a.credit_period in (30,60,90)
+ and a.settle_day = '1'
+ then case
+ when (
+ (a.credit_period = 30 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH))
+ or (a.credit_period = 60 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH))
+ or (a.credit_period = 90 and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH))
+ )
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
+ when a.settle_type='2'
+ and a.credit_period = ]]> 30
+ then case
+ when b.trade_date ]]> a.payment_due_date
+ and b.trade_date = ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY )
+ then ifnull(d.pay_money,0)
+ else 0
+ end
+ when ( (a.settle_type='2' and a.credit_period 30) or a.settle_type='1' )
+ then case
+ when b.trade_date ]]> a.payment_due_date then ifnull(d.pay_money,0)
+ else 0
+ end
else 0
end
) AS recdPayMoneyGreat60D
diff --git a/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml
index 7edd839ad..daccddf6e 100644
--- a/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml
+++ b/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml
@@ -333,76 +333,248 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and espbr.settle_bill_no=esb.settle_bill_no
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
+
+ (
+ 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
+ )
)
- ) or b.trade_date esb.payment_due_date
+ 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
+ (
+ 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 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 esb.settle_type = '2'
+ and esb.credit_period in (30,60,90)
+ and esb.settle_day = '1'
+ and b.trade_date
+ (
+ case
+ when esb.credit_period = 30 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ when esb.credit_period = 60 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)
+ end
+ )
+ )
+
+ OR
+ (
+ 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 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 NOT (
+ esb.settle_type = '2'
+ and esb.credit_period in (30,60,90)
+ and esb.settle_day = '1'
+ )
+ and 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 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 esb.settle_day = '1'
+ and b.trade_date = ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
+ and b.trade_date DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ 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'
+ AND f.apply_date
+ (
+ case
+ when esb.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 esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
+ else NULL
+ end
+ )
+ )
+ )
+ OR
+ (
+ NOT (
+ esb.settle_type = '2'
+ and esb.credit_period = 30
+ and esb.settle_day = '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 )
+ 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'
+ AND f.apply_date
+ (
+ case
+ when esb.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 esb.credit_period in (60,75) then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.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 (
- ( 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
+ (
+ 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
+ )
)
- ) 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 ) )
+ 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
+ (
+ 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 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 esb.settle_type = '2'
+ and esb.credit_period in (30,60,90)
+ and esb.settle_day = '1'
+ and b.trade_date = ]]>
+ (
+ case
+ when esb.credit_period = 30 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
+ when esb.credit_period = 60 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)
+ end
+ )
+ )
+ OR
+ (
+ 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 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 NOT (
+ esb.settle_type = '2'
+ and esb.credit_period in (30,60,90)
+ and esb.settle_day = '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 )
+ )
)