demand: TMS系统 - 客户账单管理 - 财务收款统计 - 查询收款统计列表接口适应新算法逻辑调整 TMS系统 - 客户账单管理 - 财务收款统计 - 查询收款详情接口适应新算法逻辑调整 TMS系统 - 客户账单管理 - 销售回款率统计 - 查询回款率统计列表接口适应新算法逻辑调整

This commit is contained in:
aike 2026-01-08 11:11:30 +08:00
parent ea03c30f1c
commit 5e3d62bcb1
2 changed files with 434 additions and 100 deletions

View File

@ -314,7 +314,8 @@
end end
) )
) )
and b.trade_date <![CDATA[ < ]]> then case
when b.trade_date <![CDATA[ < ]]>
( (
case 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 (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 else a.payment_due_date
end 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 <![CDATA[ < ]]>
(
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) then ifnull(d.pay_money,0)
when b.trade_date <![CDATA[ <= ]]> a.payment_due_date then ifnull(d.pay_money,0)
else 0 else 0
end
else case
when b.trade_date <![CDATA[ <= ]]> a.payment_due_date then ifnull(d.pay_money,0)
else 0
end
end end
) AS recdMoneyIn, ) AS recdMoneyIn,
sum( if( sum(
a.settle_type='2' case
and a.credit_period <![CDATA[ >= ]]> 30 when a.settle_type = '2'
and b.trade_date <![CDATA[ > ]]> a.payment_due_date and a.credit_period = 30
and b.trade_date <![CDATA[ > ]]> a.payment_due_date and a.settle_day = '1'
and b.trade_date <![CDATA[ < ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) and b.trade_date <![CDATA[ >= ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
and NOT EXISTS ( and b.trade_date <![CDATA[ < ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
SELECT 1 and NOT EXISTS (
FROM emis_settle_invoice_record f SELECT 1
WHERE f.del_flag='0' FROM emis_settle_invoice_record f
AND f.settle_bill_no = a.settle_bill_no WHERE f.del_flag = '0'
AND f.bl_delay = '1' AND f.settle_bill_no = a.settle_bill_no
) AND f.bl_delay = '1'
,ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D, AND f.apply_date <![CDATA[ < ]]>
(
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 <![CDATA[ >= ]]> 30
and b.trade_date <![CDATA[ > ]]> a.payment_due_date
and b.trade_date <![CDATA[ > ]]> a.payment_due_date
and b.trade_date <![CDATA[ < ]]> 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 <![CDATA[ < ]]>
(
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( sum(
case case
when a.settle_type = '2' when a.settle_type = '2'
@ -362,7 +417,8 @@
end end
) )
) )
and b.trade_date <![CDATA[ >= ]]> then case
when b.trade_date <![CDATA[ >= ]]>
( (
case 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 (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 else a.payment_due_date
end 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 <![CDATA[ >= ]]> 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 <![CDATA[ >= ]]> 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 <![CDATA[ >= ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH))
)
then ifnull(d.pay_money,0) then ifnull(d.pay_money,0)
when (a.settle_type='2' and a.credit_period <![CDATA[ >= ]]> 30 and b.trade_date <![CDATA[ > ]]> a.payment_due_date and b.trade_date <![CDATA[ >= ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) ) or ( ( (a.settle_type='2' and a.credit_period <![CDATA[ < ]]> 30) or a.settle_type='1' ) and b.trade_date <![CDATA[ > ]]> a.payment_due_date ) else 0
then ifnull(d.pay_money,0) end
when a.settle_type='2'
and a.credit_period <![CDATA[ >= ]]> 30
then case
when b.trade_date <![CDATA[ > ]]> a.payment_due_date
and b.trade_date <![CDATA[ >= ]]> 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 <![CDATA[ < ]]> 30) or a.settle_type='1' )
then case
when b.trade_date <![CDATA[ > ]]> a.payment_due_date then ifnull(d.pay_money,0)
else 0
end
else 0 else 0
end end
) AS recdPayMoneyGreat60D ) AS recdPayMoneyGreat60D
@ -933,7 +1014,8 @@
end end
) )
) )
and b.trade_date <![CDATA[ < ]]> then case
when b.trade_date <![CDATA[ < ]]>
( (
case 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 (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 else a.payment_due_date
end 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 <![CDATA[ < ]]>
(
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) then ifnull(d.pay_money,0)
when b.trade_date <![CDATA[ <= ]]> a.payment_due_date then ifnull(d.pay_money,0)
else 0 else 0
end
else case
when b.trade_date <![CDATA[ <= ]]> a.payment_due_date then ifnull(d.pay_money,0)
else 0
end
end end
) AS recdMoneyIn, ) AS recdMoneyIn,
sum( if( sum(
a.settle_type='2' case
and a.credit_period <![CDATA[ >= ]]> 30 when a.settle_type = '2'
and b.trade_date <![CDATA[ > ]]> a.payment_due_date and a.credit_period = 30
and b.trade_date <![CDATA[ > ]]> a.payment_due_date and a.settle_day = '1'
and b.trade_date <![CDATA[ < ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) and b.trade_date <![CDATA[ >= ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
and NOT EXISTS ( and b.trade_date <![CDATA[ < ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 3 MONTH)
SELECT 1 and NOT EXISTS (
FROM emis_settle_invoice_record f SELECT 1
WHERE f.del_flag='0' FROM emis_settle_invoice_record f
AND f.settle_bill_no = a.settle_bill_no WHERE f.del_flag = '0'
AND f.bl_delay = '1' AND f.settle_bill_no = a.settle_bill_no
) AND f.bl_delay = '1'
,ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D, AND f.apply_date <![CDATA[ < ]]>
(
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 <![CDATA[ >= ]]> 30
and b.trade_date <![CDATA[ > ]]> a.payment_due_date
and b.trade_date <![CDATA[ > ]]> a.payment_due_date
and b.trade_date <![CDATA[ < ]]> 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 <![CDATA[ < ]]>
(
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( sum(
case case
when a.settle_type = '2' when a.settle_type = '2'
@ -981,7 +1117,8 @@
end end
) )
) )
and b.trade_date <![CDATA[ >= ]]> then case
when b.trade_date <![CDATA[ >= ]]>
( (
case 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 (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 else a.payment_due_date
end 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 <![CDATA[ >= ]]> 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 <![CDATA[ >= ]]> 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 <![CDATA[ >= ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(a.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 5 MONTH))
)
then ifnull(d.pay_money,0) then ifnull(d.pay_money,0)
when (a.settle_type='2' and a.credit_period <![CDATA[ >= ]]> 30 and b.trade_date <![CDATA[ > ]]> a.payment_due_date and b.trade_date <![CDATA[ >= ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) ) or ( ( (a.settle_type='2' and a.credit_period <![CDATA[ < ]]> 30) or a.settle_type='1' ) and b.trade_date <![CDATA[ > ]]> a.payment_due_date ) else 0
then ifnull(d.pay_money,0) end
when a.settle_type='2'
and a.credit_period <![CDATA[ >= ]]> 30
then case
when b.trade_date <![CDATA[ > ]]> a.payment_due_date
and b.trade_date <![CDATA[ >= ]]> 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 <![CDATA[ < ]]> 30) or a.settle_type='1' )
then case
when b.trade_date <![CDATA[ > ]]> a.payment_due_date then ifnull(d.pay_money,0)
else 0
end
else 0 else 0
end end
) AS recdPayMoneyGreat60D ) AS recdPayMoneyGreat60D

View File

@ -333,76 +333,248 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and espbr.settle_bill_no=esb.settle_bill_no and espbr.settle_bill_no=esb.settle_bill_no
<if test="params.queryDataType != null and params.queryDataType == 1"> <if test="params.queryDataType != null and params.queryDataType == 1">
and ( and (
( esb.settle_type = '2' <!-- 优先级1:延期账单,账期内收款 -->
and esb.credit_period in (30,35,45,60,75,90) (
and EXISTS( esb.settle_type = '2'
SELECT 1 and esb.credit_period in (30,35,45,60,75,90)
FROM emis_settle_invoice_record f and EXISTS(
WHERE f.del_flag = '0' SELECT 1
AND f.settle_bill_no = esb.settle_bill_no FROM emis_settle_invoice_record f
AND f.bl_delay = '1' WHERE f.del_flag = '0'
AND f.apply_date <![CDATA[ < ]]> AND f.settle_bill_no = esb.settle_bill_no
( AND f.bl_delay = '1'
case AND f.apply_date <![CDATA[ < ]]>
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) case
when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH) 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)
else NULL 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)
end 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 <![CDATA[ < ]]> )
(
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 <![CDATA[ <= ]]> esb.payment_due_date and b.trade_date <![CDATA[ < ]]>
(
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
)
)
<!-- 优先级2:月结且固定结算日 -->
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 <![CDATA[ < ]]>
(
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 <![CDATA[ < ]]>
(
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
)
)
<!-- 优先级3:普通账期内收款 -->
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 <![CDATA[ < ]]>
(
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 <![CDATA[ <= ]]> esb.payment_due_date
)
) )
</if> </if>
<if test="params.queryDataType != null and params.queryDataType == 2"> <if test="params.queryDataType != null and params.queryDataType == 2">
and ( esb.settle_type='2' and esb.credit_period <![CDATA[ >= ]]> 30 and b.trade_date <![CDATA[ > ]]> esb.payment_due_date and b.trade_date <![CDATA[ > ]]> esb.payment_due_date and b.trade_date <![CDATA[ < ]]> DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY ) and (
and NOT EXISTS ( (
SELECT 1 esb.settle_type = '2'
FROM emis_settle_invoice_record f and esb.credit_period = 30
WHERE f.del_flag='0' and esb.settle_day = '1'
AND f.settle_bill_no = esb.settle_bill_no and b.trade_date <![CDATA[ >= ]]> DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 2 MONTH)
AND f.bl_delay = '1' and b.trade_date <![CDATA[ < ]]> 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 <![CDATA[ < ]]>
(
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 <![CDATA[ >= ]]> 30
and b.trade_date <![CDATA[ > ]]> esb.payment_due_date
and b.trade_date <![CDATA[ < ]]> 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 <![CDATA[ < ]]>
(
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
)
)
)
)
</if> </if>
<if test="params.queryDataType != null and params.queryDataType == 3"> <if test="params.queryDataType != null and params.queryDataType == 3">
and ( and (
( esb.settle_type = '2' (
and esb.credit_period in (30,35,45,60,75,90) esb.settle_type = '2'
and EXISTS( and esb.credit_period in (30,35,45,60,75,90)
SELECT 1 and EXISTS(
FROM emis_settle_invoice_record f SELECT 1
WHERE f.del_flag = '0' FROM emis_settle_invoice_record f
AND f.settle_bill_no = esb.settle_bill_no WHERE f.del_flag = '0'
AND f.bl_delay = '1' AND f.settle_bill_no = esb.settle_bill_no
AND f.apply_date <![CDATA[ < ]]> AND f.bl_delay = '1'
( AND f.apply_date <![CDATA[ < ]]>
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) case
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 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 = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 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)
else NULL when esb.credit_period = 90 then DATE_ADD(STR_TO_DATE(CONCAT(REPLACE(esb.bill_month,'-',''),'01'),'%Y%m%d'), INTERVAL 4 MONTH)
end else NULL
) end
) )
and b.trade_date <![CDATA[ >= ]]>
(
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 <![CDATA[ >= ]]> 30 and b.trade_date <![CDATA[ > ]]> esb.payment_due_date and b.trade_date <![CDATA[ >= ]]> DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY ) ) or ( ( (esb.settle_type='2' and esb.credit_period <![CDATA[ < ]]> 30) or esb.settle_type='1' ) and b.trade_date <![CDATA[ > ]]> esb.payment_due_date ) ) and b.trade_date <![CDATA[ >= ]]>
(
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 <![CDATA[ < ]]>
(
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 <![CDATA[ >= ]]>
(
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 <![CDATA[ < ]]>
(
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 <![CDATA[ >= ]]> 30
and b.trade_date <![CDATA[ > ]]> esb.payment_due_date
and b.trade_date <![CDATA[ >= ]]> DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY )
)
) )
</if> </if>