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()
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}
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 ctr_customer_credit_grant g
left join ctr_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
insert into ctr_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'
)
update ctr_customer_credit_grant
set remaining = #{remaining},
status = #{status},
release_time = #{releaseTime},
update_by = #{updateBy},
update_time = now()
where grant_id = #{grantId}