Browse Source

修改

master
dimengzhe 2 months ago
parent
commit
4b5b21bcb7
  1. 136
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanoverduefin/LoanOverdueFinMapper.xml

136
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanoverduefin/LoanOverdueFinMapper.xml

@ -3,17 +3,17 @@
<mapper namespace="com.yxt.anrui.riskcenter.biz.loanoverduefin.LoanOverdueFinMapper"> <mapper namespace="com.yxt.anrui.riskcenter.biz.loanoverduefin.LoanOverdueFinMapper">
<select id="selectPageVo" resultType="com.yxt.anrui.riskcenter.api.loanoverduefin.LoanOverdueFinVo"> <select id="selectPageVo" resultType="com.yxt.anrui.riskcenter.api.loanoverduefin.LoanOverdueFinVo">
select lof.sid, select lof.sid,
if(length(lof.nodeState) > 0, lof.nodeState, '待提交') as nodeState, if(length(lof.nodeState) > 0, lof.nodeState, '待提交') as nodeState,
lof.useOrgName, lof.useOrgName,
lof.createDept, lof.createDept,
lof.createByName, lof.createByName,
DATE_FORMAT(lof.createTime, '%Y-%m-%d') as createTime, DATE_FORMAT(lof.createTime, '%Y-%m-%d') as createTime,
lof.closeDate, lof.closeDate,
lof.stopDate, lof.stopDate,
lof.remarks, lof.remarks,
lof.createBySid, lof.createBySid,
lof.procInstId, lof.procInstId,
lof.procDefId lof.procDefId
from loan_overdue_fin lof from loan_overdue_fin lof
<where> <where>
${ew.sqlSegment} ${ew.sqlSegment}
@ -61,59 +61,71 @@
</update> </update>
<select id="detailsList" resultType="com.yxt.anrui.riskcenter.api.loanoverduefindetails.LoanOverdueFinDetailsDto"> <select id="detailsList" resultType="com.yxt.anrui.riskcenter.api.loanoverduefindetails.LoanOverdueFinDetailsDto">
SELECT a1.busVinSid AS busViNSid, SELECT
RIGHT(a1.vinNo, 8) AS vinNo, a1.busVinSid AS busViNSid,
<!--逾期金额--> RIGHT(a1.vinNo, 8) AS vinNo,
( (
SUM(a1.yq_total) + IFNULL( a1.yq_total
(SELECT SUM(lbpv.`bankBeInter`) + IFNULL(lbpv_total.bankBeInter, 0)
FROM loan_be_padsincere_veh lbpv + IFNULL(fin_total.overdueMoney, 0)
WHERE lbpv.saleVehSid = a1.busVinSid), ) AS overdueMoney,
0 a1.customer AS customerName,
) + IFNULL( a1.customerSid AS customerSid,
(select ifnull(SUM(a.reveivableMoney), 0) - IFNULL(sum(a.m), 0) a1.borrowerSid AS loanSid,
FROM ( a1.borrowerName AS loanName
select fjj.reveivableMoney, FROM (
(select IFNULL(SUM(s.subscriptionMoney), 0) -- ✅ 计算逾期金额 yq_total
FROM anrui_fin.fin_selected_receivables_detailed AS s SELECT
WHERE s.auditState = '3' lrpd.sid,
AND s.receivablesSid = fjj.sid) as m lrpd.busVinSid,
from anrui_fin.fin_uncollected_receivables_detailed_jr fjj lrpd.borrowerName,
where fjj.busSid in (SELECT lrpd.sid lrpd.vinNo,
FROM loan_repayment_plan_details lrpd lrpd.dueMoney,
WHERE DATE_FORMAT(lrpd.dueDate, '%Y-%m-%d') &lt; #{stopDate} (lrpd.dueMoney - COALESCE(SUM(lrh.actualMoney), 0)) AS yq_total,
and lrpd.busVinSid = a1.busVinSid) lrpd.borrowerSid,
and fjj.payCostTitleKey = '006') a), lrpd.customerSid,
0 lrpd.customer
) FROM loan_repayment_plan_details lrpd
) AS overdueMoney, LEFT JOIN loan_repayment_history lrh
a1.customer AS customerName, ON lrh.planDetailSid = lrpd.sid
a1.customerSid as customerSid, WHERE
a1.borrowerSid loanSid, lrpd.dueDate
a1.borrowerName loanName &lt;
FROM (SELECT lrpd.sid, #{stopDate} -- ✅ 直接比较日期,避免索引失效
lrpd.busVinSid, AND lrpd.useOrgSid = #{useOrgSid}
lrpd.borrowerName, GROUP BY lrpd.sid, lrpd.busVinSid, lrpd.borrowerName, lrpd.vinNo,
lrpd.`vinNo`, lrpd.dueMoney, lrpd.borrowerSid, lrpd.customerSid, lrpd.customer
lrpd.dueMoney, HAVING yq_total > 0
( ) a1
lrpd.`dueMoney` - SUM(IFNULL(lrh.actualMoney, 0)) LEFT JOIN (
) AS yq_total, -- ✅ 计算 bankBeInter 总金额
lrpd.borrowerSid, SELECT saleVehSid, SUM(bankBeInter) AS bankBeInter
lrpd.customerSid, FROM loan_be_padsincere_veh
lrpd.customer GROUP BY saleVehSid
FROM `loan_repayment_plan_details` lrpd ) lbpv_total ON lbpv_total.saleVehSid = a1.busVinSid
LEFT JOIN `loan_repayment_history` lrh LEFT JOIN (
ON lrh.planDetailSid = lrpd.`sid` -- ✅ 计算 overdueMoney
LEFT JOIN anrui_buscenter.`bus_sales_order_vehicle` bv SELECT
ON lrpd.busVinSid = bv.sid lrpd.busVinSid,
WHERE DATE_FORMAT(lrpd.dueDate, '%Y-%m-%d') &lt; #{stopDate} IFNULL(SUM(fjj.reveivableMoney), 0) - IFNULL(SUM(fin_sub.m), 0) AS overdueMoney
and lrpd.useOrgSid = #{useOrgSid} FROM anrui_fin.fin_uncollected_receivables_detailed_jr fjj
GROUP BY lrpd.`sid` JOIN loan_repayment_plan_details lrpd
HAVING (yq_total > 0)) a1 ON fjj.busSid = lrpd.sid
AND lrpd.dueDate
&lt;
#{stopDate} -- ✅ 避免 DATE_FORMAT
LEFT JOIN (
SELECT receivablesSid, SUM(subscriptionMoney) AS m
FROM anrui_fin.fin_selected_receivables_detailed
WHERE auditState = '3'
GROUP BY receivablesSid
) fin_sub ON fin_sub.receivablesSid = fjj.sid
WHERE fjj.payCostTitleKey = '006'
GROUP BY lrpd.busVinSid
) fin_total ON fin_total.busVinSid = a1.busVinSid
<where> <where>
${ew.sqlSegment} ${ew.sqlSegment} -- ✅ 添加动态查询条件
</where> </where>;
</select> </select>
<select id="getAppDetails" resultType="com.yxt.anrui.riskcenter.api.loanoverduefin.LoanOverdueFinAppVo"> <select id="getAppDetails" resultType="com.yxt.anrui.riskcenter.api.loanoverduefin.LoanOverdueFinAppVo">

Loading…
Cancel
Save