Browse Source

修改查询应收未收款

zhanglei
fanzongzhe 6 months ago
parent
commit
03e2e1ab34
  1. 104
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finuncollectedreceivablesdetailed/FinUncollectedReceivablesDetailedMapper.xml

104
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finuncollectedreceivablesdetailed/FinUncollectedReceivablesDetailedMapper.xml

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

Loading…
Cancel
Save