135 lines
6.7 KiB
XML
135 lines
6.7 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.bms.customer.customermoney.mapper.CustomerCreditApplyMapper">
|
|
|
|
<resultMap type="com.bms.customer.customermoney.domain.CustomerCreditApply" id="CustomerCreditApplyResult">
|
|
<id property="applyId" column="apply_id" />
|
|
<result property="applyNo" column="apply_no" />
|
|
<result property="customerId" column="customer_id" />
|
|
<result property="accountId" column="account_id" />
|
|
<result property="creditType" column="credit_type" />
|
|
<result property="adjustMode" column="adjust_mode" />
|
|
<result property="changeAmount" column="change_amount" />
|
|
<result property="effectiveDate" column="effective_date" />
|
|
<result property="expireDate" column="expire_date" />
|
|
<result property="reason" column="reason" />
|
|
<result property="status" column="status" />
|
|
<result property="applyBy" column="apply_by" />
|
|
<result property="applyUserId" column="apply_user_id" />
|
|
<result property="applyTime" column="apply_time" />
|
|
<result property="approveBy" column="approve_by" />
|
|
<result property="approveUserId" column="approve_user_id"/>
|
|
<result property="approveRoleId" column="approve_role_id"/>
|
|
<result property="approveRoleName" column="approve_role_name"/>
|
|
<result property="approveTime" column="approve_time" />
|
|
<result property="approveRemark" column="approve_remark" />
|
|
<result property="flowId" column="flow_id" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="remark" column="remark" />
|
|
<result property="delFlag" column="del_flag" />
|
|
<result property="customerCode" column="customer_code" />
|
|
<result property="customerName" column="customer_name" />
|
|
</resultMap>
|
|
|
|
<sql id="applyVo">
|
|
select a.apply_id, a.apply_no, a.customer_id, a.account_id, a.credit_type, a.adjust_mode,
|
|
a.change_amount, a.effective_date, a.expire_date, a.reason, a.status,
|
|
a.apply_by, a.apply_user_id, a.apply_time,
|
|
a.approve_by, a.approve_user_id, a.approve_role_id, a.approve_time, a.approve_remark, a.flow_id,
|
|
a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.del_flag,
|
|
c.customer_code, c.customer_name,
|
|
r.role_name as approve_role_name
|
|
from ctr_customer_credit_apply a
|
|
left join ctr_customer c on a.customer_id = c.customer_id
|
|
left join sys_role r on r.role_id = a.approve_role_id
|
|
</sql>
|
|
|
|
<select id="selectApplyList"
|
|
parameterType="com.bms.customer.customermoney.domain.CustomerCreditApply"
|
|
resultMap="CustomerCreditApplyResult">
|
|
<include refid="applyVo"/>
|
|
<where>
|
|
a.del_flag = '0'
|
|
<if test="customerId != null"> and a.customer_id = #{customerId}</if>
|
|
<if test="status != null and status != ''"> and a.status = #{status}</if>
|
|
<if test="creditType != null and creditType != ''"> and a.credit_type = #{creditType}</if>
|
|
<if test="applyNo != null and applyNo != ''"> and a.apply_no like concat('%', #{applyNo}, '%')</if>
|
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 申请时间范围 -->
|
|
and date_format(a.apply_time, '%y%m%d') >= date_format(#{params.beginTime}, '%y%m%d')
|
|
</if>
|
|
<if test="params.endTime != null and params.endTime != ''">
|
|
and date_format(a.apply_time, '%y%m%d') <= date_format(#{params.endTime}, '%y%m%d')
|
|
</if>
|
|
</where>
|
|
order by a.apply_id desc
|
|
</select>
|
|
|
|
<select id="selectApplyById" resultMap="CustomerCreditApplyResult">
|
|
<include refid="applyVo"/>
|
|
where a.apply_id = #{applyId} and a.del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectApplyByIdForUpdate" resultMap="CustomerCreditApplyResult">
|
|
select * from ctr_customer_credit_apply where apply_id = #{applyId} and del_flag = '0' for update
|
|
</select>
|
|
|
|
<insert id="insertApply"
|
|
parameterType="com.bms.customer.customermoney.domain.CustomerCreditApply"
|
|
useGeneratedKeys="true" keyProperty="applyId">
|
|
insert into ctr_customer_credit_apply (
|
|
apply_no, customer_id, credit_type, adjust_mode, change_amount,
|
|
effective_date, expire_date, reason, status,
|
|
apply_by, apply_user_id, apply_time,
|
|
create_by, create_time, remark
|
|
) values (
|
|
#{applyNo}, #{customerId}, #{creditType}, #{adjustMode}, #{changeAmount},
|
|
#{effectiveDate}, #{expireDate}, #{reason}, #{status},
|
|
#{applyBy}, #{applyUserId}, #{applyTime},
|
|
#{createBy}, sysdate(), #{remark}
|
|
)
|
|
</insert>
|
|
|
|
<update id="updateApproved"
|
|
parameterType="com.bms.customer.customermoney.domain.CustomerCreditApply">
|
|
update ctr_customer_credit_apply
|
|
set status = 'APPROVED',
|
|
account_id = #{accountId},
|
|
flow_id = #{flowId},
|
|
approve_by = #{approveBy},
|
|
approve_user_id = #{approveUserId},
|
|
approve_role_id = #{approveRoleId},
|
|
approve_time = sysdate(),
|
|
approve_remark = #{approveRemark},
|
|
update_by = #{approveBy},
|
|
update_time = sysdate()
|
|
where apply_id = #{applyId} and status = 'PENDING' and del_flag = '0'
|
|
</update>
|
|
|
|
<update id="updateRejected"
|
|
parameterType="com.bms.customer.customermoney.domain.CustomerCreditApply">
|
|
update ctr_customer_credit_apply
|
|
set status = 'REJECTED',
|
|
approve_by = #{approveBy},
|
|
approve_user_id = #{approveUserId},
|
|
approve_time = sysdate(),
|
|
approve_remark = #{approveRemark},
|
|
update_by = #{approveBy},
|
|
update_time = sysdate()
|
|
where apply_id = #{applyId} and status = 'PENDING' and del_flag = '0'
|
|
</update>
|
|
|
|
<update id="updateCancelled">
|
|
update ctr_customer_credit_apply
|
|
set status = 'CANCELLED',
|
|
update_by = #{updateBy},
|
|
update_time = sysdate()
|
|
where apply_id = #{applyId} and status = 'PENDING' and del_flag = '0'
|
|
</update>
|
|
|
|
</mapper>
|