|
|
@ -25,58 +25,58 @@ |
|
|
|
<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.customerSid, |
|
|
|
furd.useOrgSid, |
|
|
|
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, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
0 as subscribedOf, |
|
|
|
furd.sid as receivablesSid, |
|
|
|
CURRENT_DATE() as confirmDate, |
|
|
|
furd.purchaseSystemSid |
|
|
|
furd.contractNo AS contractId, |
|
|
|
furd.receivablesName AS projectName, |
|
|
|
furd.customerPhone AS mobile, |
|
|
|
furd.customerName AS `name`, |
|
|
|
furd.customerSid, |
|
|
|
furd.useOrgSid, |
|
|
|
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, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
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 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` |
|
|
|
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` |
|
|
|
) df ON df.receivablesSid = furd.`sid` |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
|
<if test="name != null and name != ''"> |
|
|
|
and concat(IFNULL(furd.customerName |
|
|
|
, '') |
|
|
|
, ifnull(furd.contractNo |
|
|
|
, '') |
|
|
|
, ifnull(bv.linkNo |
|
|
|
, '')) LIKE concat('%' |
|
|
|
, #{name} |
|
|
|
, '%') |
|
|
|
, '') |
|
|
|
, ifnull(furd.contractNo |
|
|
|
, '') |
|
|
|
, ifnull(bv.linkNo |
|
|
|
, '')) LIKE concat('%' |
|
|
|
, #{name} |
|
|
|
, '%') |
|
|
|
</if> |
|
|
|
and length(furd.busVinSid) |
|
|
|
>0 |
|
|
|
>0 |
|
|
|
</where> |
|
|
|
group by furd.sid,furd.contractNo |
|
|
|
having receivable>0 |
|
|
@ -86,32 +86,32 @@ |
|
|
|
<select id="getPaymentList" |
|
|
|
resultType="com.yxt.anrui.fin.api.finuncollectedreceivablesdetailed.AppFinUncollectedReceivablesDetailedVo"> |
|
|
|
SELECT sid, |
|
|
|
contractNo AS contractId, |
|
|
|
receivablesName AS projectName, |
|
|
|
customerPhone AS mobile, |
|
|
|
customerName AS `name`, |
|
|
|
currentReceivableMoney AS receivable, |
|
|
|
contractSid, |
|
|
|
VIN AS vin, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
furd.customerSid, |
|
|
|
furd.useOrgSid, |
|
|
|
furd.reveivableMoney |
|
|
|
contractNo AS contractId, |
|
|
|
receivablesName AS projectName, |
|
|
|
customerPhone AS mobile, |
|
|
|
customerName AS `name`, |
|
|
|
currentReceivableMoney AS receivable, |
|
|
|
contractSid, |
|
|
|
VIN AS vin, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
furd.customerSid, |
|
|
|
furd.useOrgSid, |
|
|
|
furd.reveivableMoney |
|
|
|
FROM fin_uncollected_receivables_detailed furd |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
|
<if test="name != null and name != ''"> |
|
|
|
and concat(IFNULL(furd.customerName |
|
|
|
, '') |
|
|
|
, ifnull(furd.contractNo |
|
|
|
, '')) LIKE concat('%' |
|
|
|
, #{name} |
|
|
|
, '%') |
|
|
|
, '') |
|
|
|
, ifnull(furd.contractNo |
|
|
|
, '')) LIKE concat('%' |
|
|
|
, #{name} |
|
|
|
, '%') |
|
|
|
</if> |
|
|
|
and length(furd.busVinSid) |
|
|
|
>0 |
|
|
|
>0 |
|
|
|
</where> |
|
|
|
order by furd.contractNo desc |
|
|
|
</select> |
|
|
@ -163,7 +163,7 @@ |
|
|
|
resultType="com.yxt.anrui.fin.api.fincollectionconfirmation.app.AppBusArrearsCarryMoneyVo"> |
|
|
|
SELECT fsrd.subscriptionMoney |
|
|
|
FROM fin_selected_receivables_detailed fsrd |
|
|
|
LEFT JOIN fin_collection_confirmation fcc ON fcc.sid = fsrd.collSid |
|
|
|
LEFT JOIN fin_collection_confirmation fcc ON fcc.sid = fsrd.collSid |
|
|
|
WHERE fcc.paymentState = 1 |
|
|
|
</select> |
|
|
|
|
|
|
@ -179,16 +179,16 @@ |
|
|
|
resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailedVo"> |
|
|
|
select ifnull(sum(dbalance), 0) as subscriptionMoney |
|
|
|
from (SELECT cast(( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 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_uncollected_receivables_detailed ff on ff.sid = d.receivablesSid |
|
|
|
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` |
|
|
|
left join fin_uncollected_receivables_detailed ff on ff.sid = d.receivablesSid |
|
|
|
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,16 +303,16 @@ |
|
|
|
<select id="selectByVinSid" resultType="java.lang.String"> |
|
|
|
select ifnull(sum(dbalance), 0) as subscriptionMoney |
|
|
|
from (SELECT cast(( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 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_uncollected_receivables_detailed ff on ff.sid = d.receivablesSid |
|
|
|
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` |
|
|
|
left join fin_uncollected_receivables_detailed ff on ff.sid = d.receivablesSid |
|
|
|
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 |
|
|
@ -330,8 +330,7 @@ |
|
|
|
FROM fin_selected_receivables_detailed |
|
|
|
WHERE receivablesSid = #{ysSid} |
|
|
|
AND auditState = 3 |
|
|
|
ORDER BY createTime DESC |
|
|
|
LIMIT 1 |
|
|
|
ORDER BY createTime DESC LIMIT 1 |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectUnSelectList" resultType="java.lang.String"> |
|
|
@ -346,102 +345,130 @@ |
|
|
|
<select id="selectPageList" |
|
|
|
resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectReceivablesDetailedVo"> |
|
|
|
select fd.sid, |
|
|
|
fd.receivablesSid, |
|
|
|
fd.contractNo, |
|
|
|
fd.customerSid, |
|
|
|
fd.customerName, |
|
|
|
fd.customerPhone, |
|
|
|
fd.receivablesName, |
|
|
|
fd.currentReceivableMoney, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
fd.subscriptionMoney, |
|
|
|
fd.useOrgSid, |
|
|
|
fd.subscriptionDate |
|
|
|
fd.receivablesSid, |
|
|
|
fd.contractNo, |
|
|
|
fd.customerSid, |
|
|
|
fd.customerName, |
|
|
|
fd.customerPhone, |
|
|
|
fd.receivablesName, |
|
|
|
fd.currentReceivableMoney, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
fd.subscriptionMoney, |
|
|
|
fd.useOrgSid, |
|
|
|
fd.subscriptionDate |
|
|
|
from fin_selected_receivables_detailed fd |
|
|
|
left join fin_uncollected_receivables_detailed furd on furd.sid = fd.receivablesSid |
|
|
|
left join fin_uncollected_receivables_detailed furd on furd.sid = fd.receivablesSid |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
|
and fd.receivablesName not like '%订金%' |
|
|
|
and fd.auditState = 3 |
|
|
|
and fd.receivablesName not like '%订金%' |
|
|
|
and fd.auditState = 3 |
|
|
|
<if test="name != null and name != ''"> |
|
|
|
and concat(IFNULL(fd.customerName |
|
|
|
, '') |
|
|
|
, ifnull(fd.contractNo |
|
|
|
, '')) LIKE concat('%' |
|
|
|
, #{name} |
|
|
|
, '%') |
|
|
|
, '') |
|
|
|
, ifnull(fd.contractNo |
|
|
|
, '')) LIKE concat('%' |
|
|
|
, #{name} |
|
|
|
, '%') |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="noOutVehRecPageList" |
|
|
|
resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectReceivablesDetailedWCKCLRKVo"> |
|
|
|
SELECT ferd.sid, |
|
|
|
fcc.createBySid AS createBySid, |
|
|
|
fcc.`useOrgSid`, |
|
|
|
fcc.`staffDeptName` AS staffDeptName, |
|
|
|
su.staffSid AS staffSid, |
|
|
|
fcc.`staffName` AS staffName, |
|
|
|
ferd.`contractNo`, |
|
|
|
ferd.`payType`, |
|
|
|
ferd.`customerName`, |
|
|
|
ferd.`customerPhone`, |
|
|
|
ferd.`VIN` AS vinNo, |
|
|
|
ferd.`receivablesName`, |
|
|
|
ferd.`auditDate`, |
|
|
|
ferd.`subscriptionMoney`, |
|
|
|
ferd.purchaseSystemSid, |
|
|
|
ferd.purchaseSystemName, |
|
|
|
( |
|
|
|
ferd.`subscriptionMoney` - COALESCE(SUM(ffc.`thisUseMoney`), 0) |
|
|
|
) AS reveivableMoney, |
|
|
|
ferd.kxState AS state |
|
|
|
FROM fin_selected_receivables_detailed ferd |
|
|
|
LEFT JOIN fin_collection_confirmation fcc |
|
|
|
ON ferd.`collSid` = fcc.`sid` |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` ffc |
|
|
|
ON ffc.`busSid` = ferd.`sid` |
|
|
|
LEFT JOIN anrui_portal.`sys_user` su |
|
|
|
ON fcc.`staffUserSid` = su.sid |
|
|
|
LEFT JOIN fin_uncollected_receivables_detailed furd |
|
|
|
ON ferd.`receivablesSid` = furd.`sid` |
|
|
|
JOIN anrui_base.`base_vehicle_state` bvs |
|
|
|
ON furd.busVinSid = bvs.busSid AND (bvs.`busNo` = "200" OR bvs.`busState` = "401") |
|
|
|
SELECT |
|
|
|
ferd.sid, |
|
|
|
fcc.createBySid AS createBySid, |
|
|
|
fcc.`useOrgSid`, |
|
|
|
fcc.`staffDeptName` AS staffDeptName, |
|
|
|
su.staffSid AS staffSid, |
|
|
|
fcc.`staffName` AS staffName, |
|
|
|
ferd.`contractNo`, |
|
|
|
ferd.`payType`, |
|
|
|
ferd.`customerName`, |
|
|
|
ferd.`customerPhone`, |
|
|
|
ferd.`VIN` AS vinNo, |
|
|
|
ferd.`receivablesName`, |
|
|
|
ferd.`auditDate`, |
|
|
|
ferd.`subscriptionMoney`, |
|
|
|
ferd.purchaseSystemSid, |
|
|
|
ferd.purchaseSystemName, |
|
|
|
( |
|
|
|
ferd.`subscriptionMoney` - COALESCE(SUM(ffc.`thisUseMoney`), 0) |
|
|
|
) AS reveivableMoney, |
|
|
|
ferd.kxState AS state |
|
|
|
FROM |
|
|
|
fin_selected_receivables_detailed ferd |
|
|
|
LEFT JOIN fin_collection_confirmation fcc |
|
|
|
ON ferd.`collSid` = fcc.`sid` |
|
|
|
JOIN |
|
|
|
(SELECT |
|
|
|
ffc.busSid, |
|
|
|
ffc.thisUseMoney |
|
|
|
FROM |
|
|
|
fin_funds_carried_forward_veh ffc |
|
|
|
JOIN `fin_funds_carried_forward_apply` fa |
|
|
|
ON ffc.mainSid = fa.sid |
|
|
|
WHERE fa.`nodeState` != '终止') ffc |
|
|
|
ON ffc.`busSid` = ferd.`sid` |
|
|
|
JOIN anrui_portal.`sys_user` su |
|
|
|
ON fcc.`staffUserSid` = su.sid |
|
|
|
JOIN fin_uncollected_receivables_detailed furd |
|
|
|
ON ferd.`receivablesSid` = furd.`sid` |
|
|
|
JOIN anrui_base.`base_vehicle_state` bvs |
|
|
|
ON furd.busVinSid = bvs.busSid |
|
|
|
AND ( |
|
|
|
bvs.`busNo` = "200" |
|
|
|
OR bvs.`busState` = "401" |
|
|
|
) |
|
|
|
<where> |
|
|
|
${ew.SqlSegment} |
|
|
|
${ew.sqlSegment} |
|
|
|
</where> |
|
|
|
UNION |
|
|
|
SELECT ferd.sid, |
|
|
|
ffcfa.createBySid AS createBySid, |
|
|
|
ffcfa.useOrgSid, |
|
|
|
ffcfa.saleDeptName AS staffDeptName, |
|
|
|
ffcfa.staffSid, |
|
|
|
ffcfa.`staffName` AS staffName, |
|
|
|
ferd.`contractNo`, |
|
|
|
ferd.`payType`, |
|
|
|
ferd.`customerName`, |
|
|
|
ferd.`customerPhone`, |
|
|
|
ferd.`VIN` AS vinNo, |
|
|
|
ferd.`receivablesName`, |
|
|
|
ferd.`auditDate`, |
|
|
|
ferd.`subscriptionMoney`, |
|
|
|
ferd.purchaseSystemSid, |
|
|
|
ferd.purchaseSystemName, |
|
|
|
( |
|
|
|
ferd.`subscriptionMoney` - COALESCE(SUM(ffc.`thisUseMoney`), 0) |
|
|
|
) AS reveivableMoney, |
|
|
|
ferd.kxState AS state |
|
|
|
FROM fin_selected_receivables_detailed ferd |
|
|
|
LEFT JOIN fin_funds_carried_forward_apply ffcfa |
|
|
|
ON ferd.`collSid` = ffcfa.`sid` |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` ffc |
|
|
|
ON ffc.`busSid` = ferd.`sid` |
|
|
|
LEFT JOIN fin_uncollected_receivables_detailed furd |
|
|
|
ON ferd.`receivablesSid` = furd.`sid` |
|
|
|
JOIN anrui_base.`base_vehicle_state` bvs |
|
|
|
ON furd.busVinSid = bvs.busSid AND (bvs.`busNo` = "200" OR bvs.`busState` = "401") |
|
|
|
SELECT |
|
|
|
ferd.sid, |
|
|
|
ffcfa.createBySid AS createBySid, |
|
|
|
ffcfa.useOrgSid, |
|
|
|
ffcfa.saleDeptName AS staffDeptName, |
|
|
|
ffcfa.staffSid, |
|
|
|
ffcfa.`staffName` AS staffName, |
|
|
|
ferd.`contractNo`, |
|
|
|
ferd.`payType`, |
|
|
|
ferd.`customerName`, |
|
|
|
ferd.`customerPhone`, |
|
|
|
ferd.`VIN` AS vinNo, |
|
|
|
ferd.`receivablesName`, |
|
|
|
ferd.`auditDate`, |
|
|
|
ferd.`subscriptionMoney`, |
|
|
|
ferd.purchaseSystemSid, |
|
|
|
ferd.purchaseSystemName, |
|
|
|
( |
|
|
|
ferd.`subscriptionMoney` - COALESCE(SUM(ffc.`thisUseMoney`), 0) |
|
|
|
) AS reveivableMoney, |
|
|
|
ferd.kxState AS state |
|
|
|
FROM |
|
|
|
fin_selected_receivables_detailed ferd |
|
|
|
LEFT JOIN fin_funds_carried_forward_apply ffcfa |
|
|
|
ON ferd.`collSid` = ffcfa.`sid` |
|
|
|
JOIN |
|
|
|
(SELECT |
|
|
|
ffc.busSid, |
|
|
|
ffc.thisUseMoney |
|
|
|
FROM |
|
|
|
fin_funds_carried_forward_veh ffc |
|
|
|
JOIN `fin_funds_carried_forward_apply` ffcfa |
|
|
|
ON ffc.mainSid = ffcfa.sid |
|
|
|
WHERE ffcfa.`nodeState` != '终止') ffc |
|
|
|
ON ffc.`busSid` = ferd.`sid` |
|
|
|
JOIN fin_uncollected_receivables_detailed furd |
|
|
|
ON ferd.`receivablesSid` = furd.`sid` |
|
|
|
JOIN anrui_base.`base_vehicle_state` bvs |
|
|
|
ON furd.busVinSid = bvs.busSid |
|
|
|
AND ( |
|
|
|
bvs.`busNo` = "200" |
|
|
|
OR bvs.`busState` = "401" |
|
|
|
) |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
|
</where> |
|
|
@ -458,61 +485,61 @@ |
|
|
|
<select id="selectPageLists" |
|
|
|
resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectReceivablesDetailedVo"> |
|
|
|
select distinct fd.sid, |
|
|
|
fd.receivablesSid, |
|
|
|
fd.contractNo, |
|
|
|
fd.customerSid, |
|
|
|
fd.customerName, |
|
|
|
fd.customerPhone, |
|
|
|
fd.receivablesName, |
|
|
|
fd.currentReceivableMoney, |
|
|
|
cast((furd.`reveivableMoney` - COALESCE(df.dbalance, 0)) AS DECIMAL(10, 2)) AS dbalance, |
|
|
|
if(fd.currentReceivableMoney <= 0, 0, |
|
|
|
if(cast((fd.currentReceivableMoney - fd.subscriptionMoney) AS DECIMAL(10, 2)) <= 0, 0, |
|
|
|
cast((fd.currentReceivableMoney - fd.subscriptionMoney) AS DECIMAL(10, 2)))) as reveivableMoney, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
fd.subscriptionMoney, |
|
|
|
fd.useOrgSid, |
|
|
|
fd.subscriptionDate, |
|
|
|
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, |
|
|
|
CURRENT_DATE() as confirmDate, |
|
|
|
1 as subscribedOf |
|
|
|
fd.receivablesSid, |
|
|
|
fd.contractNo, |
|
|
|
fd.customerSid, |
|
|
|
fd.customerName, |
|
|
|
fd.customerPhone, |
|
|
|
fd.receivablesName, |
|
|
|
fd.currentReceivableMoney, |
|
|
|
cast((furd.`reveivableMoney` - COALESCE(df.dbalance, 0)) AS DECIMAL(10, 2)) AS dbalance, |
|
|
|
if(fd.currentReceivableMoney <= 0, 0, |
|
|
|
if(cast((fd.currentReceivableMoney - fd.subscriptionMoney) AS DECIMAL(10, 2)) <= 0, 0, |
|
|
|
cast((fd.currentReceivableMoney - fd.subscriptionMoney) AS DECIMAL(10, 2)))) as reveivableMoney, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey, |
|
|
|
fd.subscriptionMoney, |
|
|
|
fd.useOrgSid, |
|
|
|
fd.subscriptionDate, |
|
|
|
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, |
|
|
|
CURRENT_DATE() as confirmDate, |
|
|
|
1 as subscribedOf |
|
|
|
from fin_selected_receivables_detailed fd |
|
|
|
left join fin_uncollected_receivables_detailed furd on furd.sid = fd.receivablesSid |
|
|
|
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 fin_uncollected_receivables_detailed furd on furd.sid = fd.receivablesSid |
|
|
|
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 |
|
|
|
) df ON df.receivablesSid = furd.`sid` |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
|
and fd.receivablesName not like '%订金%' |
|
|
|
and fd.auditState = 3 |
|
|
|
and fd.receivablesName not like '%订金%' |
|
|
|
and fd.auditState = 3 |
|
|
|
<if test="name != null and name != ''"> |
|
|
|
and concat(IFNULL(fd.customerName |
|
|
|
, '') |
|
|
|
, ifnull(fd.contractNo |
|
|
|
, '') |
|
|
|
, ifnull(bv.linkNo |
|
|
|
, '')) LIKE concat('%' |
|
|
|
, #{name} |
|
|
|
, '%') |
|
|
|
, '') |
|
|
|
, ifnull(fd.contractNo |
|
|
|
, '') |
|
|
|
, ifnull(bv.linkNo |
|
|
|
, '')) LIKE concat('%' |
|
|
|
, #{name} |
|
|
|
, '%') |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
having dbalance <= 0 |
|
|
@ -536,11 +563,11 @@ |
|
|
|
fsrd.purchaseSystemSid, |
|
|
|
fsrd.purchaseSystemName, |
|
|
|
( |
|
|
|
fsrd.`subscriptionMoney` - COALESCE(SUM(ffc.`thisUseMoney`), 0) |
|
|
|
) AS balance |
|
|
|
fsrd.`subscriptionMoney` - COALESCE(SUM(ffc.`thisUseMoney`), 0) |
|
|
|
) AS balance |
|
|
|
FROM fin_selected_receivables_detailed fsrd |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` ffc |
|
|
|
ON ffc.`busSid` = fsrd.`sid` |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` ffc |
|
|
|
ON ffc.`busSid` = fsrd.`sid` |
|
|
|
WHERE fsrd.`sid` = #{busSid} |
|
|
|
GROUP BY fsrd.sid |
|
|
|
</select> |
|
|
@ -550,15 +577,15 @@ |
|
|
|
select ifnull(sum(dbalance), 0) as subscriptionMoney, d.receivablesSid |
|
|
|
from (SELECT d.receivablesSid, |
|
|
|
cast(( |
|
|
|
d.`subscriptionMoney` - COALESCE(SUM(f.`thisUseMoney`), 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 ( |
|
|
|
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` |
|
|
|
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} |
|
|
@ -570,4 +597,14 @@ |
|
|
|
from fin_selected_receivables_detailed |
|
|
|
where collSid = #{sid} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="getBalance" resultType="java.lang.String"> |
|
|
|
SELECT ( |
|
|
|
ferd.`subscriptionMoney` - COALESCE(SUM(ffc.`thisUseMoney`), 0) |
|
|
|
) AS reveivableMoney |
|
|
|
FROM fin_selected_receivables_detailed ferd |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` ffc |
|
|
|
ON ffc.`busSid` = ferd.`sid` |
|
|
|
WHERE ferd.sid = #{busSid} |
|
|
|
</select> |
|
|
|
</mapper> |