2025-03-07 16:23:56 +08:00

294 lines
11 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zkj.loan.common.internet.mapper.fac.LoanDetailsMapper">
<resultMap id="BaseResultMap" type="com.zkj.loan.common.internet.model.home.LoanDetailsInterval">
<result column="loan_amt" jdbcType="VARCHAR" property="intervalValue"/>
<result column="intervalTotal" jdbcType="INTEGER" property="intervalTotal"/>
</resultMap>
<resultMap id="BaseBeanResultMap" type="com.zkj.loan.common.internet.model.fac.LoanDetails">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="biz_date" jdbcType="VARCHAR" property="bizDate" />
<result column="duebill_no" jdbcType="VARCHAR" property="duebillNo" />
<result column="loan_amt" jdbcType="VARCHAR" property="loanAmt" />
<result column="payout_date" jdbcType="VARCHAR" property="payoutDate" />
<result column="maturity_date" jdbcType="VARCHAR" property="maturityDate" />
<result column="loan_amt" jdbcType="DECIMAL" property="loanAmt" />
<result column="loan_term" jdbcType="VARCHAR" property="loanTerm" />
<result column="repay_mode" jdbcType="VARCHAR" property="repayMode" />
<result column="ccy" jdbcType="VARCHAR" property="ccy" />
<result column="open_bank" jdbcType="VARCHAR" property="openBank" />
<result column="card_no" jdbcType="VARCHAR" property="cardNo" />
<result column="bank_serial_no" jdbcType="VARCHAR" property="bankSerialNo" />
<result column="bank_loan_time" jdbcType="VARCHAR" property="bankLoanTime" />
<result column="coop_no" jdbcType="VARCHAR" property="coopNo" />
<result column="bank_code" jdbcType="VARCHAR" property="bankCode" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="create_org" jdbcType="VARCHAR" property="createOrg" />
<result column="create_date" jdbcType="DATE" property="createDate" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_user" jdbcType="VARCHAR" property="updateUser" />
<result column="update_org" jdbcType="VARCHAR" property="updateOrg" />
<result column="update_date" jdbcType="DATE" property="updateDate" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="cur_vers" jdbcType="INTEGER" property="curVers" />
</resultMap>
<sql id="Base_Column_List">
id,
biz_date,
cont_no,
duebill_no,
payout_date,
maturity_date,
loan_amt,
loan_term,
repay_mode,
ccy,
coop_no,
open_bank,
card_no,
bank_serial_no,
bank_loan_time,
create_user,
create_org,
create_date,
create_time,
update_user,
update_org,
update_date,
update_time,
cur_vers
</sql>
<select id="loanAmountRangeStatistics" resultMap="BaseResultMap">
select
(case
when loan_amt &gt;=0 and loan_amt &lt; 5000 then '0-5000'
when loan_amt &gt;=5000 and loan_amt &lt; 10000 then '5000-10000'
when loan_amt &gt;=10000 and loan_amt &lt; 15000 then '10000-15000'
when loan_amt &gt;=15000 and loan_amt &lt; 20000 then '15000-20000'
when loan_amt &gt;=20000 and loan_amt &lt; 25000 then '20000-25000'
when loan_amt &gt;=25000 and loan_amt &lt; 30000 then '25000-30000'
when loan_amt &gt;=30000 and loan_amt &lt; 35000 then '30000-35000'
when loan_amt &gt;=35000 and loan_amt &lt; 40000 then '35000-40000'
when loan_amt &gt;=40000 and loan_amt &lt; 45000 then '40000-45000'
when loan_amt &gt;=45000 and loan_amt &lt;= 50000 then '45000-50000'
end
) as loan_amt,
count(id) as intervalTotal
from
fac_loan_details
<where>
<if test="coopNo != null and coopNo!=''">
and coop_no = #{coopNo}
</if>
</where>
group by
(case
when loan_amt &gt;=0 and loan_amt &lt; 5000 then '0-5000'
when loan_amt &gt;=5000 and loan_amt &lt; 10000 then '5000-10000'
when loan_amt &gt;=10000 and loan_amt &lt; 15000 then '10000-15000'
when loan_amt &gt;=15000 and loan_amt &lt; 20000 then '15000-20000'
when loan_amt &gt;=20000 and loan_amt &lt; 25000 then '20000-25000'
when loan_amt &gt;=25000 and loan_amt &lt; 30000 then '25000-30000'
when loan_amt &gt;=30000 and loan_amt &lt; 35000 then '30000-35000'
when loan_amt &gt;=35000 and loan_amt &lt; 40000 then '35000-40000'
when loan_amt &gt;=40000 and loan_amt &lt; 45000 then '40000-45000'
when loan_amt &gt;=45000 and loan_amt &lt;= 50000 then '45000-50000'
end
);
</select>
<insert id="insertBatch" >
INSERT INTO fac_loan_details
(
id,
biz_date,
cont_no,
duebill_no,
payout_date,
maturity_date,
loan_amt,
loan_term,
repay_mode,
ccy,
coop_no,
open_bank,
card_no,
bank_serial_no,
bank_loan_time,
create_user,
create_org,
create_date,
create_time,
update_user,
update_org,
update_date,
update_time,
cur_vers
)
VALUES
<foreach collection ="list" item="item" separator =",">
(
#{item.id},
#{item.bizDate},
#{item.contNo},
#{item.duebillNo},
#{item.payoutDate},
#{item.maturityDate},
#{item.loanAmt},
#{item.loanTerm},
#{item.repayMode},
#{item.ccy},
#{item.coopNo},
#{item.openBank},
#{item.cardNo},
#{item.bankSerialNo},
#{item.bankLoanTime},
#{item.createUser},
#{item.createOrg},
#{item.createDate},
#{item.createTime},
#{item.updateUser},
#{item.updateOrg},
#{item.updateDate},
#{item.updateTime},
#{item.curVers}
)
</foreach >
</insert>
<select id="selectByBizDateAndCoopNo" resultMap="BaseBeanResultMap">
SELECT
<include refid="com.zkj.loan.common.internet.mapper.fac.LoanDetailsMapper.Base_Column_List"/>
FROM fac_loan_details
where biz_date = #{bizDate} and coop_no = #{coopNo}
</select>
<select id="selectByBetweenBizDateAndCoopNo" resultMap="BaseBeanResultMap">
SELECT
<include refid="com.zkj.loan.common.internet.mapper.fac.LoanDetailsMapper.Base_Column_List"/>
FROM fac_loan_details
where biz_date &lt;= #{startDate} and biz_date >= #{endDate}
<if test="coopNo != null and coopNo!=''">
and coop_no = #{coopNo}
</if>
</select>
<resultMap id="LoanDetailsResultMap" type="com.zkj.loan.common.internet.model.shucang.SCLoanDetailsModel">
<result column="loan_amt" jdbcType="VARCHAR" property="loanAmt"/>
<result column="cust_name" jdbcType="VARCHAR" property="custName"/>
<result column="cust_no" jdbcType="VARCHAR" property="custNo"/>
<result column="duebill_no" jdbcType="VARCHAR" property="duebillNo"/>
<result column="loan_term" jdbcType="VARCHAR" property="loanTerm"/>
<result column="scene" jdbcType="VARCHAR" property="scene"/>
<result column="loan_bal" jdbcType="VARCHAR" property="loanBal"/>
<result column="int_over_bal" jdbcType="VARCHAR" property="intOverBal"/>
<result column="int_fine_bal" jdbcType="VARCHAR" property="intFineBal"/>
<result column="duebill_no" jdbcType="VARCHAR" property="serialNo"/>
</resultMap>
<select id="selectLoanDetails" resultMap="LoanDetailsResultMap">
select
'LN_ZCFK' as scene,
flds.loan_amt,
flds.duebill_no,
flds.loan_term,
fld.cust_no,
fld.loan_bal,
fld.int_over_bal,
fld.int_fine_bal,
fld.cust_name
from
fac_loan_details flds
left join fac_loan_duebill fld on
fld.duebill_no = flds.duebill_no
where flds.biz_date = #{bizDate}
</select>
<select id="selectByDuebillNo">
select
<include refid="com.zkj.loan.common.internet.mapper.fac.LoanDetailsMapper.Base_Column_List"/>
from fac_loan_details where duebill_no = #{duebillNo} limit 1
</select>
<select id="countByBizDate" resultType="java.lang.Integer" >
select count(*) from fac_loan_details where biz_date &lt;= #{startDate} and biz_date > #{endDate} and coop_no = #{coopNo}
</select>
<select id="selectByDuebillNoSet" resultMap="BaseBeanResultMap">
SELECT
<include refid="com.zkj.loan.common.internet.mapper.fac.LoanDetailsMapper.Base_Column_List"/>
FROM fac_loan_details
WHERE duebill_no in
<foreach collection="set" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectListByDuebillNo" resultType="com.zkj.loan.common.internet.model.fac.LoanDetails">
SELECT
id, biz_date, cont_no, duebill_no
FROM fac_loan_details
where duebill_no in
<foreach collection="set" index="index" item="item" open="(" separator="," close=")">
#{item,jdbcType=VARCHAR}
</foreach>
</select>
<update id="updateTradeInfoById" parameterType="java.util.List">
<foreach collection="list" item="item" separator=";">
UPDATE fac_loan_details
set
cont_no = #{item.contNo,jdbcType=VARCHAR}
WHERE id = #{item.id,jdbcType=VARCHAR}
</foreach>
</update>
<select id="selectLoanAmtSum" resultMap="BaseBeanResultMap">
SELECT
COALESCE(SUM(loan_Amt),0) as loanAmt
FROM fac_loan_details
where 1=1
<if test="createDate != null">
AND biz_date = #{createDate,jdbcType=VARCHAR}
</if>
</select>
<select id="countLoanData" resultType="com.zkj.loan.common.internet.model.biz.CtrlLoanDetail">
SELECT
fls.biz_date as bizDate, count(fls.id) as detailTotal, sum(fls.loan_amt) as loanAmtTotal
FROM fac_loan_details fls
left join fac_loan_duebill fld on fls.duebill_no = fld.duebill_no
where fls.biz_date = #{yesDate,jdbcType=VARCHAR} and fls.coop_no = #{chanCode,jdbcType=VARCHAR}
and fld.prd_code = #{prdCode,jdbcType=VARCHAR}
</select>
</mapper>