|
|
@ -25,42 +25,43 @@ |
|
|
|
<select id="getPaymentDetailsList" |
|
|
|
resultType="com.yxt.anrui.fin.api.finuncollectedreceivablesdetailed.AppFinUncollectedReceivablesDetailedVo"> |
|
|
|
SELECT distinct furd.sid, |
|
|
|
furd.contractNo AS contractId, |
|
|
|
furd.receivablesName AS projectName, |
|
|
|
furd.customerPhone AS mobile, |
|
|
|
furd.customerName AS `name`, |
|
|
|
furd.contractNo AS contractId, |
|
|
|
furd.receivablesName AS projectName, |
|
|
|
furd.customerPhone AS mobile, |
|
|
|
furd.customerName AS `name`, |
|
|
|
furd.customerSid, |
|
|
|
furd.useOrgSid, |
|
|
|
cast((furd.`reveivableMoney` - COALESCE(df.dbalance, 0)) AS DECIMAL(10, 2)) AS receivable, |
|
|
|
COALESCE(SUM(df.dbalance), 0) AS realMoney, |
|
|
|
cast((furd.`reveivableMoney` - COALESCE(SUM(df.dbalance), 0)) AS DECIMAL(10, 2)) AS receivable, |
|
|
|
furd.contractSid, |
|
|
|
if(bv.linkNo is null or LENGTH(trim(bv.linkNo)) < 1, |
|
|
|
if(furd.payTypeKey = 2, RIGHT(bv.temporaryNo, 2), bv.temporaryNo), |
|
|
|
RIGHT(bv.linkNo, 8)) as vin, |
|
|
|
RIGHT(bv.linkNo, 8)) as vin, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
0 as subscribedOf, |
|
|
|
furd.sid as receivablesSid, |
|
|
|
CURRENT_DATE() as confirmDate, |
|
|
|
0 as subscribedOf, |
|
|
|
furd.sid as receivablesSid, |
|
|
|
CURRENT_DATE() as confirmDate, |
|
|
|
furd.purchaseSystemSid |
|
|
|
FROM fin_uncollected_receivables_detailed furd |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.sid = furd.busVinSid |
|
|
|
LEFT JOIN (select sum(dbalance) as dbalance, d.receivablesSid |
|
|
|
from (SELECT d.sid, |
|
|
|
d.receivablesSid, |
|
|
|
d.`collSid`, |
|
|
|
cast(( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 0) + |
|
|
|
COALESCE(ffa.`useMoney`, 0)) AS DECIMAL(10, 2)) AS dbalance |
|
|
|
FROM fin_selected_receivables_detailed d |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` f ON f.`busSid` = d.`sid` |
|
|
|
LEFT JOIN (SELECT fa.sid, ff.busSid, ff.thisUseMoney as useMoney |
|
|
|
FROM fin_funds_carried_forward_apply fa |
|
|
|
LEFT JOIN fin_funds_carried_forward_veh ff ON ff.mainSid = fa.sid |
|
|
|
WHERE fa.nodeState = '终止') ffa on ffa.busSid = d.sid |
|
|
|
WHERE (d.auditState = 1 OR d.auditState = 3) |
|
|
|
GROUP BY d.`sid`) d |
|
|
|
group by d.receivablesSid |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT d.sid, |
|
|
|
d.`receivablesSid`, |
|
|
|
( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 0)) AS dbalance |
|
|
|
FROM fin_selected_receivables_detailed d |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT f.busSid, |
|
|
|
f.thisUseMoney |
|
|
|
FROM fin_funds_carried_forward_veh f |
|
|
|
JOIN `fin_funds_carried_forward_apply` fa ON f.mainSid = fa.sid |
|
|
|
WHERE fa.`nodeState` != '终止' |
|
|
|
) f ON f.`busSid` = d.`sid` |
|
|
|
WHERE d.`auditState` = 3 |
|
|
|
or d.auditState = 1 |
|
|
|
GROUP BY d.`sid` |
|
|
|
) df ON df.receivablesSid = furd.`sid` |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
@ -77,6 +78,7 @@ |
|
|
|
and length(furd.busVinSid) |
|
|
|
>0 |
|
|
|
</where> |
|
|
|
group by furd.sid |
|
|
|
having receivable>0 |
|
|
|
order by furd.contractNo desc |
|
|
|
</select> |
|
|
@ -176,20 +178,17 @@ |
|
|
|
<select id="selectListByVin" |
|
|
|
resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailedVo"> |
|
|
|
select ifnull(sum(dbalance), 0) as subscriptionMoney |
|
|
|
from (SELECT d.sid, |
|
|
|
d.receivablesSid, |
|
|
|
d.`collSid`, |
|
|
|
d.auditState, |
|
|
|
cast(( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 0) + |
|
|
|
COALESCE(ffa.`useMoney`, 0)) AS DECIMAL(10, 2)) AS dbalance |
|
|
|
from (SELECT cast(( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 0)) AS DECIMAL(10, 2)) AS dbalance |
|
|
|
FROM fin_selected_receivables_detailed d |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` f ON f.`busSid` = d.`sid` |
|
|
|
left join fin_uncollected_receivables_detailed ff on ff.sid = d.receivablesSid |
|
|
|
LEFT JOIN (SELECT fa.sid, ff.busSid, ff.thisUseMoney as useMoney |
|
|
|
FROM fin_funds_carried_forward_apply fa |
|
|
|
LEFT JOIN fin_funds_carried_forward_veh ff ON ff.mainSid = fa.sid |
|
|
|
WHERE fa.nodeState = '终止') ffa on ffa.busSid = d.sid |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT f.busSid, |
|
|
|
f.thisUseMoney |
|
|
|
FROM fin_funds_carried_forward_veh f |
|
|
|
JOIN `fin_funds_carried_forward_apply` fa ON f.mainSid = fa.sid |
|
|
|
WHERE fa.`nodeState` != '终止' |
|
|
|
) f ON f.`busSid` = d.`sid` |
|
|
|
WHERE d.auditState = #{state} |
|
|
|
and ff.busVinSid = #{busVinSid} |
|
|
|
and d.contractNo = #{contractNo} |
|
|
@ -303,20 +302,18 @@ |
|
|
|
|
|
|
|
<select id="selectByVinSid" resultType="java.lang.String"> |
|
|
|
select ifnull(sum(dbalance), 0) as subscriptionMoney |
|
|
|
from (SELECT d.sid, |
|
|
|
d.receivablesSid, |
|
|
|
d.`collSid`, |
|
|
|
d.auditState, |
|
|
|
cast(( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 0) + |
|
|
|
COALESCE(ffa.`useMoney`, 0)) AS DECIMAL(10, 2)) AS dbalance |
|
|
|
from (SELECT cast(( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 0)) AS DECIMAL(10, 2)) AS dbalance |
|
|
|
FROM fin_selected_receivables_detailed d |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` f ON f.`busSid` = d.`sid` |
|
|
|
left join fin_uncollected_receivables_detailed ff on ff.sid = d.receivablesSid |
|
|
|
LEFT JOIN (SELECT fa.sid, ff.busSid, ff.thisUseMoney as useMoney |
|
|
|
FROM fin_funds_carried_forward_apply fa |
|
|
|
LEFT JOIN fin_funds_carried_forward_veh ff ON ff.mainSid = fa.sid |
|
|
|
WHERE fa.nodeState = '终止') ffa on ffa.busSid = d.sid |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT f.busSid, |
|
|
|
f.thisUseMoney |
|
|
|
FROM fin_funds_carried_forward_veh f |
|
|
|
JOIN `fin_funds_carried_forward_apply` fa ON f.mainSid = fa.sid |
|
|
|
WHERE fa.`nodeState` != '终止' |
|
|
|
) f ON f.`busSid` = d.`sid` |
|
|
|
WHERE d.auditState = 3 |
|
|
|
and ff.busVinSid = #{busVinSid} |
|
|
|
GROUP BY d.`sid`) d |
|
|
@ -548,19 +545,18 @@ |
|
|
|
<select id="fetchByReceivablesSid" |
|
|
|
resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailed"> |
|
|
|
select ifnull(sum(dbalance), 0) as subscriptionMoney, d.receivablesSid |
|
|
|
from (SELECT d.sid, |
|
|
|
d.receivablesSid, |
|
|
|
d.`collSid`, |
|
|
|
d.auditState, |
|
|
|
from (SELECT d.receivablesSid, |
|
|
|
cast(( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 0) + |
|
|
|
COALESCE(ffa.`useMoney`, 0)) AS DECIMAL(10, 2)) AS dbalance |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 0)) AS DECIMAL(10, 2)) AS dbalance |
|
|
|
FROM fin_selected_receivables_detailed d |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` f ON f.`busSid` = d.`sid` |
|
|
|
LEFT JOIN (SELECT fa.sid, ff.busSid, ff.thisUseMoney as useMoney |
|
|
|
FROM fin_funds_carried_forward_apply fa |
|
|
|
LEFT JOIN fin_funds_carried_forward_veh ff ON ff.mainSid = fa.sid |
|
|
|
WHERE fa.nodeState = '终止') ffa on ffa.busSid = d.sid |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT f.busSid, |
|
|
|
f.thisUseMoney |
|
|
|
FROM fin_funds_carried_forward_veh f |
|
|
|
JOIN `fin_funds_carried_forward_apply` fa ON f.mainSid = fa.sid |
|
|
|
WHERE fa.`nodeState` != '终止' |
|
|
|
) f ON f.`busSid` = d.`sid` |
|
|
|
WHERE d.auditState = 3 |
|
|
|
GROUP BY d.`sid`) d |
|
|
|
WHERE d.receivablesSid = #{receivablesSid} |
|
|
|