|
|
@ -51,8 +51,8 @@ |
|
|
|
furd.customerName AS `customerName`, |
|
|
|
furd.customerSid, |
|
|
|
furd.useOrgSid, |
|
|
|
COALESCE(SUM(df.dbalance), 0) AS realMoney, |
|
|
|
cast((furd.`reveivableMoney` - COALESCE(SUM(df.dbalance), 0)) AS DECIMAL(10, 2)) AS currentReceivableMoney, |
|
|
|
COALESCE (df.dbalance, 0 ) AS realMoney, |
|
|
|
CAST((furd.`reveivableMoney` - COALESCE ( df.dbalance, 0 )) AS DECIMAL ( 10, 2 )) AS currentReceivableMoney, |
|
|
|
furd.reveivableMoney, |
|
|
|
furd.contractSid, |
|
|
|
if(bv.linkNo is null or LENGTH(trim(bv.linkNo)) < 1, |
|
|
@ -66,21 +66,27 @@ |
|
|
|
FROM fin_uncollected_receivables_detailed furd |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.sid = furd.busVinSid |
|
|
|
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` |
|
|
|
SELECT |
|
|
|
d.`receivablesSid`, |
|
|
|
SUM(d.`subscriptionMoney` - COALESCE (f.`thisUseMoney`, 0 )) AS dbalance |
|
|
|
FROM |
|
|
|
fin_selected_receivables_detailed d |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT |
|
|
|
f.busSid, |
|
|
|
SUM(f.thisUseMoney) AS thisUseMoney |
|
|
|
FROM |
|
|
|
fin_funds_carried_forward_veh f |
|
|
|
JOIN `fin_funds_carried_forward_apply` fa ON f.mainSid = fa.sid |
|
|
|
WHERE |
|
|
|
fa.`nodeState` != '终止' |
|
|
|
GROUP BY f.`busSid` |
|
|
|
) f ON f.`busSid` = d.`sid` |
|
|
|
WHERE |
|
|
|
(d.`auditState` = 3 |
|
|
|
OR d.auditState = 1) |
|
|
|
GROUP BY |
|
|
|
d.`receivablesSid` |
|
|
|
) df ON df.receivablesSid = furd.`sid` |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
@ -97,8 +103,8 @@ |
|
|
|
furd.customerName AS `customerName`, |
|
|
|
furd.customerSid, |
|
|
|
furd.useOrgSid, |
|
|
|
COALESCE(SUM(df.dbalance), 0) AS realMoney, |
|
|
|
cast((furd.`reveivableMoney` - COALESCE(SUM(df.dbalance), 0)) AS DECIMAL(10, 2)) AS currentReceivableMoney, |
|
|
|
COALESCE (df.dbalance, 0 ) AS realMoney, |
|
|
|
CAST((furd.`reveivableMoney` - COALESCE ( df.dbalance, 0 )) AS DECIMAL ( 10, 2 )) AS currentReceivableMoney, |
|
|
|
furd.reveivableMoney, |
|
|
|
furd.contractSid, |
|
|
|
if(bv.linkNo is null or LENGTH(trim(bv.linkNo)) < 1, |
|
|
@ -115,21 +121,27 @@ |
|
|
|
LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid |
|
|
|
LEFT JOIN anrui_riskcenter.loan_solutions lls ON lls.salesOrderSid = bo.sid |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT d.sid, |
|
|
|
SELECT |
|
|
|
d.`receivablesSid`, |
|
|
|
( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 0)) AS dbalance |
|
|
|
FROM fin_selected_receivables_detailed d |
|
|
|
SUM(d.`subscriptionMoney` - COALESCE (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 |
|
|
|
SELECT |
|
|
|
f.busSid, |
|
|
|
SUM(f.thisUseMoney) AS thisUseMoney |
|
|
|
FROM |
|
|
|
fin_funds_carried_forward_veh f |
|
|
|
JOIN `fin_funds_carried_forward_apply` fa ON f.mainSid = fa.sid |
|
|
|
WHERE fa.`nodeState` != '终止' |
|
|
|
WHERE |
|
|
|
fa.`nodeState` != '终止' |
|
|
|
GROUP BY f.`busSid` |
|
|
|
) f ON f.`busSid` = d.`sid` |
|
|
|
WHERE d.`auditState` = 3 |
|
|
|
or d.auditState = 1 |
|
|
|
GROUP BY d.`sid` |
|
|
|
WHERE |
|
|
|
(d.`auditState` = 3 |
|
|
|
OR d.auditState = 1) |
|
|
|
GROUP BY |
|
|
|
d.`receivablesSid` |
|
|
|
) df ON df.receivablesSid = furd.`sid` |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
@ -148,8 +160,8 @@ |
|
|
|
furd.customerName AS `customerName`, |
|
|
|
furd.customerSid, |
|
|
|
furd.useOrgSid, |
|
|
|
COALESCE(SUM(df.dbalance), 0) AS realMoney, |
|
|
|
cast((furd.`reveivableMoney` - COALESCE(SUM(df.dbalance), 0)) AS DECIMAL(10, 2)) AS currentReceivableMoney, |
|
|
|
COALESCE (df.dbalance, 0 ) AS realMoney, |
|
|
|
CAST((furd.`reveivableMoney` - COALESCE ( df.dbalance, 0 )) AS DECIMAL ( 10, 2 )) AS currentReceivableMoney, |
|
|
|
furd.reveivableMoney, |
|
|
|
furd.contractSid, |
|
|
|
if(bv.linkNo is null or LENGTH(trim(bv.linkNo)) < 1, |
|
|
@ -165,21 +177,27 @@ |
|
|
|
LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid |
|
|
|
LEFT JOIN anrui_riskcenter.loan_solutions lls ON lls.salesOrderSid = bo.sid |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT d.sid, |
|
|
|
SELECT |
|
|
|
d.`receivablesSid`, |
|
|
|
( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 0)) AS dbalance |
|
|
|
FROM fin_selected_receivables_detailed d |
|
|
|
SUM(d.`subscriptionMoney` - COALESCE (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 |
|
|
|
SELECT |
|
|
|
f.busSid, |
|
|
|
SUM(f.thisUseMoney) AS thisUseMoney |
|
|
|
FROM |
|
|
|
fin_funds_carried_forward_veh f |
|
|
|
JOIN `fin_funds_carried_forward_apply` fa ON f.mainSid = fa.sid |
|
|
|
WHERE fa.`nodeState` != '终止' |
|
|
|
WHERE |
|
|
|
fa.`nodeState` != '终止' |
|
|
|
GROUP BY f.`busSid` |
|
|
|
) f ON f.`busSid` = d.`sid` |
|
|
|
WHERE d.`auditState` = 3 |
|
|
|
or d.auditState = 1 |
|
|
|
GROUP BY d.`sid` |
|
|
|
WHERE |
|
|
|
(d.`auditState` = 3 |
|
|
|
OR d.auditState = 1) |
|
|
|
GROUP BY |
|
|
|
d.`receivablesSid` |
|
|
|
) df ON df.receivablesSid = furd.`sid` |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
|