|
|
@ -24,26 +24,32 @@ |
|
|
|
<!--手机端—查询可使用款项明细列表--> |
|
|
|
<select id="getPaymentDetailsList" |
|
|
|
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, |
|
|
|
<!--currentReceivableMoney AS confirmMoney,--> |
|
|
|
VIN AS vin, |
|
|
|
furd.busVinSid, |
|
|
|
furd.payType, |
|
|
|
furd.payTypeKey |
|
|
|
SELECT distinct furd.sid, |
|
|
|
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, |
|
|
|
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.`collSid`, |
|
|
|
( |
|
|
|
sum(d.`subscriptionMoney`) - COALESCE(SUM(f.`thisUseMoney`), 0)) AS dbalance |
|
|
|
cast((sum(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` |
|
|
|
where d.auditState = 1 |
|
|
@ -199,7 +205,6 @@ |
|
|
|
and auditState = #{state} |
|
|
|
and receivablesName = #{type} |
|
|
|
and payTypeKey = #{payTypeKey} |
|
|
|
and subscribedOf = 0 |
|
|
|
group by contractNo |
|
|
|
</select> |
|
|
|
|
|
|
@ -211,7 +216,6 @@ |
|
|
|
and auditState = #{state} |
|
|
|
and receivablesName = #{type} |
|
|
|
and payTypeKey = #{payTypeKey} |
|
|
|
and subscribedOf = 0 |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectCustomerList" resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.SelectCustomerVo"> |
|
|
@ -220,7 +224,6 @@ |
|
|
|
where collSid = #{sid} |
|
|
|
and auditState = #{state} |
|
|
|
and receivablesName = #{type} |
|
|
|
and subscribedOf = 0 |
|
|
|
group by concat(customerName, customerPhone) |
|
|
|
</select> |
|
|
|
|
|
|
@ -230,7 +233,6 @@ |
|
|
|
from fin_selected_receivables_detailed |
|
|
|
where collSid = #{sid} |
|
|
|
and auditState = #{state} |
|
|
|
and subscribedOf = 0 |
|
|
|
and receivablesName = #{type} |
|
|
|
</select> |
|
|
|
|
|
|
@ -243,7 +245,6 @@ |
|
|
|
and receivablesName = #{type} |
|
|
|
and customerName = #{customerName} |
|
|
|
and customerPhone = #{customerPhone} |
|
|
|
and subscribedOf = 0 |
|
|
|
and length(VIN) > 0 |
|
|
|
</select> |
|
|
|
|
|
|
@ -255,7 +256,6 @@ |
|
|
|
and auditState = #{state} |
|
|
|
and receivablesName = #{type} |
|
|
|
and contractNo = #{contractNo} |
|
|
|
and subscribedOf = 0 |
|
|
|
and length(VIN) > 0 |
|
|
|
</select> |
|
|
|
|
|
|
@ -267,7 +267,6 @@ |
|
|
|
and auditState = #{state} |
|
|
|
and receivablesName = #{type} |
|
|
|
and contractNo = #{contractNo} |
|
|
|
and subscribedOf = 0 |
|
|
|
and length(VIN) = 0 |
|
|
|
</select> |
|
|
|
|
|
|
@ -280,18 +279,16 @@ |
|
|
|
and receivablesName = #{type} |
|
|
|
and customerName = #{customerName} |
|
|
|
and customerPhone = #{customerPhone} |
|
|
|
and subscribedOf = 0 |
|
|
|
and length(VIN) = 0 |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectByVinSid" resultType="java.lang.String"> |
|
|
|
select cast((sum(fd.`subscriptionMoney`) - COALESCE(SUM(f.`thisUseMoney`), 0)) AS DECIMAL (10, 2) ) AS dbalance |
|
|
|
select cast((sum(fd.`subscriptionMoney`) - COALESCE(SUM(f.`thisUseMoney`), 0)) AS DECIMAL(10, 2)) AS dbalance |
|
|
|
from fin_selected_receivables_detailed fd |
|
|
|
left join fin_uncollected_receivables_detailed ff on ff.sid = fd.receivablesSid |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` f ON f.`busSid` = fd.`sid` |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` f ON f.`busSid` = fd.`sid` |
|
|
|
where ff.busVinSid = #{busVinSid} |
|
|
|
and fd.auditState = 3 |
|
|
|
and subscribedOf = 0 |
|
|
|
</select> |
|
|
|
|
|
|
|
<update id="updateAuditStateBySid"> |
|
|
@ -354,53 +351,49 @@ |
|
|
|
|
|
|
|
<select id="noOutVehRecPageList" |
|
|
|
resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectReceivablesDetailedWCKCLRKVo"> |
|
|
|
SELECT |
|
|
|
ferd.sid, |
|
|
|
fcc.`useOrgSid`, |
|
|
|
fcc.`staffDeptName`, |
|
|
|
fcc.staffUserSid AS staffSid, |
|
|
|
fcc.`staffName`, |
|
|
|
ferd.`contractNo`, |
|
|
|
ferd.`payType`, |
|
|
|
ferd.`customerName`, |
|
|
|
ferd.`customerPhone`, |
|
|
|
ferd.`VIN` AS vinNo, |
|
|
|
ferd.`receivablesName`, |
|
|
|
ferd.`auditDate`, |
|
|
|
ferd.`subscriptionMoney`, |
|
|
|
ferd.balance 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 anrui_base.`base_vehicle` bv |
|
|
|
ON RIGHT(ferd.`VIN`, 8) = RIGHT(bv.`vinNo`, 8) |
|
|
|
AND fcc.`useOrgSid` = bv.`createOrgSid` |
|
|
|
SELECT ferd.sid, |
|
|
|
fcc.`useOrgSid`, |
|
|
|
fcc.`staffDeptName`, |
|
|
|
fcc.staffUserSid AS staffSid, |
|
|
|
fcc.`staffName`, |
|
|
|
ferd.`contractNo`, |
|
|
|
ferd.`payType`, |
|
|
|
ferd.`customerName`, |
|
|
|
ferd.`customerPhone`, |
|
|
|
ferd.`VIN` AS vinNo, |
|
|
|
ferd.`receivablesName`, |
|
|
|
ferd.`auditDate`, |
|
|
|
ferd.`subscriptionMoney`, |
|
|
|
ferd.balance 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 anrui_base.`base_vehicle` bv |
|
|
|
ON RIGHT(ferd.`VIN`, 8) = RIGHT(bv.`vinNo`, 8) |
|
|
|
AND fcc.`useOrgSid` = bv.`createOrgSid` |
|
|
|
UNION |
|
|
|
SELECT |
|
|
|
ferd.sid, |
|
|
|
ffcfa.useOrgSid, |
|
|
|
ffcfa.saleDeptName AS staffDeptName, |
|
|
|
ffcfa.staffSid, |
|
|
|
ffcfa.`staffName`, |
|
|
|
ferd.`contractNo`, |
|
|
|
ferd.`payType`, |
|
|
|
ferd.`customerName`, |
|
|
|
ferd.`customerPhone`, |
|
|
|
ferd.`VIN` AS vinNo, |
|
|
|
ferd.`receivablesName`, |
|
|
|
ferd.`auditDate`, |
|
|
|
ferd.`subscriptionMoney`, |
|
|
|
ferd.balance 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 anrui_base.`base_vehicle` bv |
|
|
|
ON RIGHT(ferd.`VIN`, 8) = RIGHT(bv.`vinNo`, 8) |
|
|
|
AND ffcfa.`useOrgSid` = bv.`createOrgSid` |
|
|
|
SELECT ferd.sid, |
|
|
|
ffcfa.useOrgSid, |
|
|
|
ffcfa.saleDeptName AS staffDeptName, |
|
|
|
ffcfa.staffSid, |
|
|
|
ffcfa.`staffName`, |
|
|
|
ferd.`contractNo`, |
|
|
|
ferd.`payType`, |
|
|
|
ferd.`customerName`, |
|
|
|
ferd.`customerPhone`, |
|
|
|
ferd.`VIN` AS vinNo, |
|
|
|
ferd.`receivablesName`, |
|
|
|
ferd.`auditDate`, |
|
|
|
ferd.`subscriptionMoney`, |
|
|
|
ferd.balance 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 anrui_base.`base_vehicle` bv |
|
|
|
ON RIGHT(ferd.`VIN`, 8) = RIGHT(bv.`vinNo`, 8) |
|
|
|
AND ffcfa.`useOrgSid` = bv.`createOrgSid` |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
|
</where> |
|
|
@ -421,65 +414,58 @@ |
|
|
|
and (auditState = 1 or auditState = 3) |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectListByReceivableSid" |
|
|
|
resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailed"> |
|
|
|
select * |
|
|
|
from fin_selected_receivables_detailed |
|
|
|
where receivablesSid = #{receivablesSid} |
|
|
|
and (auditState = 1 or auditState = 3) |
|
|
|
</select> |
|
|
|
|
|
|
|
<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, |
|
|
|
(furd.`reveivableMoney` - COALESCE(df.dbalance, 0)) AS dbalance, |
|
|
|
if(fd.currentReceivableMoney <= 0,0,if(fd.currentReceivableMoney-fd.subscriptionMoney <=0,0,fd.currentReceivableMoney-fd.subscriptionMoney)) 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 d.sid, |
|
|
|
d.receivablesSid, |
|
|
|
d.`collSid`, |
|
|
|
( |
|
|
|
sum(d.`subscriptionMoney`) - COALESCE(SUM(f.`thisUseMoney`), 0)) AS dbalance |
|
|
|
FROM fin_selected_receivables_detailed d |
|
|
|
LEFT JOIN `fin_funds_carried_forward_veh` f ON f.`busSid` = d.`sid` |
|
|
|
where d.auditState = 1 |
|
|
|
or d.auditState = 3 |
|
|
|
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 d.sid, |
|
|
|
d.receivablesSid, |
|
|
|
d.`collSid`, |
|
|
|
cast((sum(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` |
|
|
|
where d.auditState = 1 |
|
|
|
or d.auditState = 3 |
|
|
|
GROUP BY d.`receivablesSid` |
|
|
|
) df ON df.receivablesSid = furd.`sid` |
|
|
|
<where> |
|
|
|
${ew.sqlSegment} |
|
|
|
and fd.receivablesName != '订金' |
|
|
|
and fd.auditState = 3 |
|
|
|
and fd.receivablesName != '订金' |
|
|
|
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 |
|
|
|