Commit 97e512b4 authored by haoyanhui's avatar haoyanhui

还款和逾期sql优化

parent 806c1250
...@@ -360,7 +360,9 @@ ...@@ -360,7 +360,9 @@
end as loanStatus end as loanStatus
,if(f.yqze>0,'overdue','normal') termStatus ,if(f.yqze>0,'overdue','normal') termStatus
from ( from (
select a.*,if(c.term_no is null,a.term_no,c.term_no) next_term select -- a.*,
a.id,a.user_id,a.loan_application_history_id,a.term_no,a.deadline,a.required_repayment,a.repayment_status,a.repaid_at,a.created_at,
if(c.term_no is null,a.term_no,c.term_no) next_term
,if(c.deadline is null,a.deadline,c.deadline) next_deadline ,if(c.deadline is null,a.deadline,c.deadline) next_deadline
,b.loan_paid_at ,b.loan_paid_at
from xyqb_i_repayment_plan a from xyqb_i_repayment_plan a
...@@ -467,7 +469,9 @@ ...@@ -467,7 +469,9 @@
when f.yqze=0 and f.dkye>0 then '1' when f.yqze=0 and f.dkye>0 then '1'
end as loanStatus end as loanStatus
,'overdue' termStatus ,'overdue' termStatus
from (select a.* from (
select -- a.*
a.id,a.user_id,a.loan_application_history_id,a.term_no,a.deadline,a.required_repayment,a.repayment_status,a.repaid_at,a.repayment_received_at
from xyqb_i_repayment_plan a from xyqb_i_repayment_plan a
left join xyqb_i_loan_application_manifest_history b left join xyqb_i_loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at < #{endTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at < #{endTime,jdbcType=VARCHAR}
...@@ -476,7 +480,8 @@ ...@@ -476,7 +480,8 @@
and floor(DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)/30)=DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)/30 and floor(DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)/30)=DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)/30
and b.funding_corp_id in (420,520,580,650,670,810,240,640,700) and b.funding_corp_id in (420,520,580,650,670,810,240,640,700)
and b.transaction_status in (2,5) and b.transaction_status in (2,5)
and b.contract_term not in (2,3)) a and b.contract_term not in (2,3)
) a
left join xyqb_user_i_user_detail b on a.user_id=b.user_id left join xyqb_user_i_user_detail b on a.user_id=b.user_id
left join xyqb_i_loan_account_ext c on a.loan_application_history_id=c.loan_id left join xyqb_i_loan_account_ext c on a.loan_application_history_id=c.loan_id
left join xyqb_i_apply_quota_record d on c.order_no=d.order_no left join xyqb_i_apply_quota_record d on c.order_no=d.order_no
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment