|
|
@ -44,14 +44,7 @@ |
|
|
|
|
|
|
|
<select id="selectListAllVo" |
|
|
|
resultType="com.yxt.anrui.fin.api.finuncollectedreceivablesdetailed.DetailsOfReceivablesAndUncollectedItemsVo"> |
|
|
|
<!-- SELECT * |
|
|
|
FROM fin_uncollected_receivables_detailed |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
|
and length(busVinSid) > 0 |
|
|
|
</where> |
|
|
|
order by id asc--> |
|
|
|
SELECT distinct furd.sid, |
|
|
|
select d.* from (SELECT distinct furd.sid, |
|
|
|
furd.contractNo AS contractNo, |
|
|
|
furd.receivablesName AS receivablesName, |
|
|
|
furd.customerPhone AS customerPhone, |
|
|
@ -92,11 +85,112 @@ |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
|
and length(furd.busVinSid) > 0 |
|
|
|
and furd.kxState != '02' |
|
|
|
and furd.kxState != '02' and furd.receivablesName not like '%融资放款%' |
|
|
|
</where> |
|
|
|
group by furd.sid, currentReceivableMoney>0, furd.contractNo |
|
|
|
having currentReceivableMoney>0 |
|
|
|
order by furd.contractNo desc |
|
|
|
union all |
|
|
|
SELECT distinct furd.sid, |
|
|
|
furd.contractNo AS contractNo, |
|
|
|
furd.receivablesName AS receivablesName, |
|
|
|
furd.customerPhone AS customerPhone, |
|
|
|
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, |
|
|
|
furd.reveivableMoney, |
|
|
|
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, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
0 as subscribedOf, |
|
|
|
furd.sid as receivablesSid |
|
|
|
FROM fin_uncollected_receivables_detailed furd |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.sid = furd.busVinSid |
|
|
|
left join anrui_riskcenter.loan_repayment_plan_details lh on furd.busVinSid = lh.busVinSid |
|
|
|
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, |
|
|
|
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} |
|
|
|
and length(furd.busVinSid) > 0 AND bo.payTypeKey = 2 |
|
|
|
AND ( lls.typeKey IS NULL OR lls.typeKey = '' ) |
|
|
|
and furd.kxState != '02' and furd.receivablesName like '%融资放款%' and length(lh.busVinSid)>0 |
|
|
|
</where> |
|
|
|
group by furd.sid, currentReceivableMoney>0, furd.contractNo |
|
|
|
having currentReceivableMoney>0 |
|
|
|
|
|
|
|
union all |
|
|
|
SELECT distinct furd.sid, |
|
|
|
furd.contractNo AS contractNo, |
|
|
|
furd.receivablesName AS receivablesName, |
|
|
|
furd.customerPhone AS customerPhone, |
|
|
|
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, |
|
|
|
furd.reveivableMoney, |
|
|
|
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, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
0 as subscribedOf, |
|
|
|
furd.sid as receivablesSid |
|
|
|
FROM fin_uncollected_receivables_detailed furd |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.sid = furd.busVinSid |
|
|
|
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, |
|
|
|
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} |
|
|
|
and length(furd.busVinSid) > 0 AND bo.payTypeKey = 2 |
|
|
|
AND lls.typeKey = '01' |
|
|
|
and furd.kxState != '02' and furd.receivablesName like '%融资放款%' |
|
|
|
</where> |
|
|
|
group by furd.sid, currentReceivableMoney>0, furd.contractNo |
|
|
|
having currentReceivableMoney>0 |
|
|
|
) d |
|
|
|
order by d.contractNo desc |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="getCustomerBillList" |
|
|
|