新加额度池配置功能
This commit is contained in:
@@ -0,0 +1,169 @@
|
||||
<?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.ruoyi.customer.customermoney.mapper.CreditQuotaMapper">
|
||||
|
||||
<!-- ================= 角色额度池 ================= -->
|
||||
|
||||
<select id="selectRoleQuotaList" resultType="com.ruoyi.customer.customermoney.vo.RoleCreditQuotaVo">
|
||||
select r.role_id as roleId,
|
||||
r.role_name as roleName,
|
||||
r.role_key as roleKey,
|
||||
r.status as status,
|
||||
coalesce(q.total_quota, 0) as totalQuota,
|
||||
(select coalesce(sum(g.remaining), 0)
|
||||
from customer_credit_grant g
|
||||
where g.role_id = r.role_id and g.status = '0' and g.del_flag = '0') as usedQuota,
|
||||
q.remark as remark
|
||||
from sys_role r
|
||||
left join sys_role_credit_quota q on q.role_id = r.role_id
|
||||
where r.del_flag = '0'
|
||||
order by r.role_sort, r.role_id
|
||||
</select>
|
||||
|
||||
<select id="selectRoleQuotaListByUserId"
|
||||
resultType="com.ruoyi.customer.customermoney.vo.RoleCreditQuotaVo">
|
||||
select r.role_id as roleId,
|
||||
r.role_name as roleName,
|
||||
r.role_key as roleKey,
|
||||
r.status as status,
|
||||
coalesce(q.total_quota, 0) as totalQuota,
|
||||
(select coalesce(sum(g.remaining), 0)
|
||||
from customer_credit_grant g
|
||||
where g.role_id = r.role_id and g.status = '0' and g.del_flag = '0') as usedQuota,
|
||||
q.remark as remark
|
||||
from sys_user_role ur
|
||||
inner join sys_role r on r.role_id = ur.role_id and r.del_flag = '0' and r.status = '0'
|
||||
left join sys_role_credit_quota q on q.role_id = r.role_id
|
||||
where ur.user_id = #{userId}
|
||||
order by r.role_sort, r.role_id
|
||||
</select>
|
||||
|
||||
<select id="selectQuotaForUpdate"
|
||||
resultType="com.ruoyi.customer.customermoney.domain.SysRoleCreditQuota">
|
||||
select role_id as roleId, total_quota as totalQuota, version, remark
|
||||
from sys_role_credit_quota
|
||||
where role_id = #{roleId}
|
||||
for update
|
||||
</select>
|
||||
|
||||
<select id="sumActiveRemaining" resultType="java.math.BigDecimal">
|
||||
select coalesce(sum(remaining), 0)
|
||||
from customer_credit_grant
|
||||
where role_id = #{roleId} and status = '0' and del_flag = '0'
|
||||
</select>
|
||||
|
||||
<insert id="insertQuota" parameterType="com.ruoyi.customer.customermoney.domain.SysRoleCreditQuota">
|
||||
insert into sys_role_credit_quota (role_id, total_quota, version, create_by, create_time, remark)
|
||||
values (#{roleId}, #{totalQuota}, 0, #{createBy}, sysdate(), #{remark})
|
||||
on duplicate key update total_quota = values(total_quota),
|
||||
remark = values(remark),
|
||||
update_by = values(create_by),
|
||||
update_time = now()
|
||||
</insert>
|
||||
|
||||
<update id="updateQuota" parameterType="com.ruoyi.customer.customermoney.domain.SysRoleCreditQuota">
|
||||
update sys_role_credit_quota
|
||||
set total_quota = #{totalQuota},
|
||||
version = version + 1,
|
||||
update_by = #{updateBy},
|
||||
update_time = now(),
|
||||
remark = #{remark}
|
||||
where role_id = #{roleId} and version = #{version}
|
||||
</update>
|
||||
|
||||
<!-- ================= 授信分配台账 ================= -->
|
||||
|
||||
<resultMap type="com.ruoyi.customer.customermoney.domain.CustomerCreditGrant" id="CustomerCreditGrantResult">
|
||||
<id property="grantId" column="grant_id" />
|
||||
<result property="customerId" column="customer_id" />
|
||||
<result property="accountId" column="account_id" />
|
||||
<result property="roleId" column="role_id" />
|
||||
<result property="approveUserId" column="approve_user_id" />
|
||||
<result property="applyId" column="apply_id" />
|
||||
<result property="flowId" column="flow_id" />
|
||||
<result property="creditType" column="credit_type" />
|
||||
<result property="amount" column="amount" />
|
||||
<result property="remaining" column="remaining" />
|
||||
<result property="effectiveDate" column="effective_date" />
|
||||
<result property="expireDate" column="expire_date" />
|
||||
<result property="status" column="status" />
|
||||
<result property="releaseTime" column="release_time" />
|
||||
<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" />
|
||||
<result property="roleName" column="role_name" />
|
||||
<result property="approveBy" column="approve_by" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="grantVo">
|
||||
select g.grant_id, g.customer_id, g.account_id, g.role_id, g.approve_user_id, g.apply_id, g.flow_id,
|
||||
g.credit_type, g.amount, g.remaining, g.effective_date, g.expire_date, g.status, g.release_time,
|
||||
g.create_by, g.create_time, g.update_by, g.update_time, g.remark, g.del_flag,
|
||||
c.customer_code, c.customer_name,
|
||||
r.role_name,
|
||||
u.user_name as approve_by
|
||||
from customer_credit_grant g
|
||||
left join bms_customer c on c.customer_id = g.customer_id
|
||||
left join sys_role r on r.role_id = g.role_id
|
||||
left join sys_user u on u.user_id = g.approve_user_id
|
||||
</sql>
|
||||
|
||||
<select id="selectGrantList"
|
||||
parameterType="com.ruoyi.customer.customermoney.domain.CustomerCreditGrant"
|
||||
resultMap="CustomerCreditGrantResult">
|
||||
<include refid="grantVo"/>
|
||||
<where>
|
||||
g.del_flag = '0'
|
||||
<if test="customerId != null"> and g.customer_id = #{customerId}</if>
|
||||
<if test="roleId != null"> and g.role_id = #{roleId}</if>
|
||||
<if test="creditType != null and creditType != ''"> and g.credit_type = #{creditType}</if>
|
||||
<if test="status != null and status != ''"> and g.status = #{status}</if>
|
||||
</where>
|
||||
order by g.grant_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectActiveGrantsForUpdate"
|
||||
resultMap="CustomerCreditGrantResult">
|
||||
select grant_id, customer_id, account_id, role_id, approve_user_id, apply_id, flow_id,
|
||||
credit_type, amount, remaining, effective_date, expire_date, status,
|
||||
create_by, create_time, update_by, update_time, del_flag
|
||||
from customer_credit_grant
|
||||
where customer_id = #{customerId}
|
||||
and credit_type = #{creditType}
|
||||
and status = '0'
|
||||
and del_flag = '0'
|
||||
order by grant_id
|
||||
for update
|
||||
</select>
|
||||
|
||||
<insert id="insertGrant" parameterType="com.ruoyi.customer.customermoney.domain.CustomerCreditGrant"
|
||||
useGeneratedKeys="true" keyProperty="grantId">
|
||||
insert into customer_credit_grant (
|
||||
customer_id, account_id, role_id, approve_user_id, apply_id, flow_id,
|
||||
credit_type, amount, remaining, effective_date, expire_date, status,
|
||||
create_by, create_time, remark, del_flag
|
||||
) values (
|
||||
#{customerId}, #{accountId}, #{roleId}, #{approveUserId}, #{applyId}, #{flowId},
|
||||
#{creditType}, #{amount}, #{remaining}, #{effectiveDate}, #{expireDate}, #{status},
|
||||
#{createBy}, sysdate(), #{remark}, '0'
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateGrantRemaining"
|
||||
parameterType="com.ruoyi.customer.customermoney.domain.CustomerCreditGrant">
|
||||
update customer_credit_grant
|
||||
set remaining = #{remaining},
|
||||
status = #{status},
|
||||
release_time = #{releaseTime},
|
||||
update_by = #{updateBy},
|
||||
update_time = now()
|
||||
where grant_id = #{grantId}
|
||||
</update>
|
||||
</mapper>
|
||||
+7
-2
@@ -21,6 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<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" />
|
||||
@@ -38,11 +40,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
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_time, a.approve_remark, a.flow_id,
|
||||
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
|
||||
c.customer_code, c.customer_name,
|
||||
r.role_name as approve_role_name
|
||||
from customer_credit_apply a
|
||||
left join bms_customer c on c.customer_id = a.customer_id
|
||||
left join sys_role r on r.role_id = a.approve_role_id
|
||||
</sql>
|
||||
|
||||
<select id="selectApplyList"
|
||||
@@ -98,6 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
flow_id = #{flowId},
|
||||
approve_by = #{approveBy},
|
||||
approve_user_id = #{approveUserId},
|
||||
approve_role_id = #{approveRoleId},
|
||||
approve_time = sysdate(),
|
||||
approve_remark = #{approveRemark},
|
||||
update_by = #{approveBy},
|
||||
|
||||
@@ -12,6 +12,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="balance" column="balance" />
|
||||
<result property="frozenBalance" column="frozen_balance" />
|
||||
<result property="totalCredit" column="total_credit" />
|
||||
<result property="creditEffectiveDate" column="credit_effective_date" />
|
||||
<result property="creditExpireDate" column="credit_expire_date" />
|
||||
<result property="extraCredit" column="extra_credit" />
|
||||
<result property="extraEffectiveDate" column="extra_effective_date" />
|
||||
<result property="extraExpireDate" column="extra_expire_date" />
|
||||
@@ -27,7 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCustomerAccountVo">
|
||||
select id, customer_id, currency, balance, frozen_balance, total_credit, extra_credit,
|
||||
select id, customer_id, currency, balance, frozen_balance, total_credit,
|
||||
credit_effective_date, credit_expire_date, extra_credit,
|
||||
extra_effective_date, extra_expire_date, used_credit,
|
||||
tax, version, create_by, create_time, update_by, update_time, remark, del_flag
|
||||
from customer_account
|
||||
@@ -49,15 +52,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where customer_id = #{customerId} and del_flag = '0'
|
||||
</select>
|
||||
|
||||
<!-- 扫描已到期临时额度的CNY账户(失效日当天仍有效,故严格小于今天) -->
|
||||
<select id="selectExpiredTempCreditCustomerIds" resultType="java.lang.Long">
|
||||
select customer_id
|
||||
<!-- 扫描已到期授信的CNY账户(信用或临时额度失效日早于今天;失效日当天仍有效,故严格小于今天) -->
|
||||
<select id="selectExpiredCreditCustomerIds" resultType="java.lang.Long">
|
||||
select distinct customer_id
|
||||
from customer_account
|
||||
where del_flag = '0'
|
||||
and currency = 'CNY'
|
||||
and extra_credit > 0
|
||||
and extra_expire_date is not null
|
||||
and extra_expire_date < CURDATE()
|
||||
and (
|
||||
(total_credit > 0 and credit_expire_date is not null and credit_expire_date < CURDATE())
|
||||
or
|
||||
(extra_credit > 0 and extra_expire_date is not null and extra_expire_date < CURDATE())
|
||||
)
|
||||
</select>
|
||||
|
||||
<insert id="insertAccount" parameterType="com.ruoyi.customer.customermoney.domain.CustomerAccount"
|
||||
@@ -104,10 +109,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where id = #{id} and version = #{version} and del_flag = '0'
|
||||
</update>
|
||||
|
||||
<!-- 乐观锁更新额度(信用/临时额度及临时额度有效期) -->
|
||||
<!-- 乐观锁更新额度(信用/临时额度及各自有效期) -->
|
||||
<update id="updateAccountCredit">
|
||||
update customer_account
|
||||
set total_credit = #{totalCredit},
|
||||
credit_effective_date = #{creditEffectiveDate},
|
||||
credit_expire_date = #{creditExpireDate},
|
||||
extra_credit = #{extraCredit},
|
||||
extra_effective_date = #{extraEffectiveDate},
|
||||
extra_expire_date = #{extraExpireDate},
|
||||
@@ -138,6 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="reason" column="reason" />
|
||||
<result property="adjustMode" column="adjust_mode" />
|
||||
<result property="operatorId" column="operator_id" />
|
||||
<result property="roleId" column="role_id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
@@ -149,7 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<sql id="selectCustomerCreditFlowVo">
|
||||
select id, flow_no, customer_id, account_id, credit_type, change_type, biz_type, biz_id, biz_no, direction,
|
||||
before_amount, change_amount, after_amount, used_credit,
|
||||
effective_date, expire_date, reason, adjust_mode, operator_id,
|
||||
effective_date, expire_date, reason, adjust_mode, operator_id, role_id,
|
||||
create_by, create_time, update_by, update_time, remark, del_flag
|
||||
from customer_credit_flow
|
||||
</sql>
|
||||
@@ -192,6 +200,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="reason != null">reason,</if>
|
||||
<if test="adjustMode != null">adjust_mode,</if>
|
||||
<if test="operatorId != null">operator_id,</if>
|
||||
<if test="roleId != null">role_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
@@ -215,6 +224,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="reason != null">#{reason},</if>
|
||||
<if test="adjustMode != null">#{adjustMode},</if>
|
||||
<if test="operatorId != null">#{operatorId},</if>
|
||||
<if test="roleId != null">#{roleId},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
|
||||
Reference in New Issue
Block a user