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
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}
)
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 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 ctr_customer_credit_apply
set status = 'CANCELLED',
update_by = #{updateBy},
update_time = sysdate()
where apply_id = #{applyId} and status = 'PENDING' and del_flag = '0'