客户余额额度初始化始终为0

This commit is contained in:
luojiaquan
2026-09-30 17:40:26 +08:00
parent d26b90f7e5
commit d20dccf485
4 changed files with 35 additions and 59 deletions
@@ -26,18 +26,9 @@ public interface BmsCustomerMapper
/** 轻量查询客户当前状态;不存在或已逻辑删除时返回 null。 */ /** 轻量查询客户当前状态;不存在或已逻辑删除时返回 null。 */
public BmsCustomer selectCustomerStatusByCustomerId(Long customerId); public BmsCustomer selectCustomerStatusByCustomerId(Long customerId);
/**
* 只取客户档案物理额度列(credit_ed 在通用查询里是账户可用额度的子查询别名,
* 账户首次初始化时必须读取档案原始值)
*
* @param customerId 客户ID
* @return 仅含 creditEd/tempEd 的客户对象
*/
public BmsCustomer selectRawCreditByCustomerId(Long customerId);
/** /**
* 查询客户主列表 * 查询客户主列表
* *
* @param bmsCustomer 客户主 * @param bmsCustomer 客户主
* @return 客户主集合 * @return 客户主集合
*/ */
@@ -49,7 +49,7 @@ public class CustomerAccountApiImpl implements ICustomerAccountApi
/** 本位币币种 */ /** 本位币币种 */
private static final String BASE_CURRENCY = BmsExchangeRate.BASE_CURRENCY; private static final String BASE_CURRENCY = BmsExchangeRate.BASE_CURRENCY;
/** 新客户默认总额度(CNY):默认0,信用额度一律通过「申请-审批」分配 */ /** 账户初始化额度(CNY):信用额度/临时额度一律初始化为0,不取客户档案录入值;额度仅在「客户余额-额度管理」调整时变化 */
private static final BigDecimal DEFAULT_CREDIT = BigDecimal.ZERO; private static final BigDecimal DEFAULT_CREDIT = BigDecimal.ZERO;
/** 金额保留位数 */ /** 金额保留位数 */
private static final int MONEY_SCALE = 2; private static final int MONEY_SCALE = 2;
@@ -111,27 +111,20 @@ public class CustomerAccountApiImpl implements ICustomerAccountApi
{ {
return 1; return 1;
} }
BmsCustomer customer = bmsCustomerMapper.selectRawCreditByCustomerId(customerId); BmsCustomer customer = bmsCustomerMapper.selectBmsCustomerByCustomerId(customerId);
if (customer == null) if (customer == null)
{ {
throw new ServiceException("客户不存在"); throw new ServiceException("客户不存在");
} }
BigDecimal initCredit = nz(customer.getCreditEd()); // 初始化口径(2026-09-30):信用额度/临时额度一律初始化为0,不从客户档案取值;
if (initCredit.compareTo(BigDecimal.ZERO) < 0) // 额度仅在「客户余额-额度管理」调整时变化
{ account = createCnyAccount(customerId, DEFAULT_CREDIT, DEFAULT_CREDIT, username);
initCredit = BigDecimal.ZERO; // 档案物理额度列同步为0,与账户初始额度保持一致
} bmsCustomerMapper.updateCustomerCredit(customerId, DEFAULT_CREDIT, DEFAULT_CREDIT, username);
BigDecimal initTemp = nz(customer.getTempEd());
account = createCnyAccount(customerId, initCredit, initTemp, username);
// 档案额度与实际初始额度保持一致
bmsCustomerMapper.updateCustomerCredit(customerId, initCredit, initTemp, username);
writeInitFlow(account, CustomerCreditFlow.CREDIT_TYPE_CREDIT, writeInitFlow(account, CustomerCreditFlow.CREDIT_TYPE_CREDIT,
initCredit, null, null, username, "新客户初始化账户,默认信用额度0(需通过额度申请审批分配)"); DEFAULT_CREDIT, null, null, username, "新客户初始化账户,信用额度默认0,需在客户余额-额度管理中调整");
if (initTemp.compareTo(BigDecimal.ZERO) > 0) writeInitFlow(account, CustomerCreditFlow.CREDIT_TYPE_TEMP,
{ DEFAULT_CREDIT, null, null, username, "新客户初始化账户,临时额度默认0,需在客户余额-额度管理中调整");
writeInitFlow(account, CustomerCreditFlow.CREDIT_TYPE_TEMP,
initTemp, null, null, username, "新客户初始化临时额度");
}
return 1; return 1;
} }
@@ -506,7 +499,7 @@ public class CustomerAccountApiImpl implements ICustomerAccountApi
return account; return account;
} }
/** 行锁获取客户CNY账户,不存在则按客户档案当前额度初始化创建 */ /** 行锁获取客户CNY账户,不存在则初始化创建(信用/临时额度一律初始化为0,不取客户档案值) */
private CustomerAccount getOrInitCnyAccount(Long customerId, String username) private CustomerAccount getOrInitCnyAccount(Long customerId, String username)
{ {
CustomerAccount account = customerMoneyMapper.selectAccountForUpdate(customerId, BASE_CURRENCY); CustomerAccount account = customerMoneyMapper.selectAccountForUpdate(customerId, BASE_CURRENCY);
@@ -514,23 +507,20 @@ public class CustomerAccountApiImpl implements ICustomerAccountApi
{ {
return account; return account;
} }
BmsCustomer customer = bmsCustomerMapper.selectRawCreditByCustomerId(customerId); BmsCustomer customer = bmsCustomerMapper.selectBmsCustomerByCustomerId(customerId);
if (customer == null) if (customer == null)
{ {
throw new ServiceException("客户不存在"); throw new ServiceException("客户不存在");
} }
BigDecimal initCredit = nz(customer.getCreditEd());
BigDecimal initTemp = nz(customer.getTempEd());
try try
{ {
account = createCnyAccount(customerId, initCredit, initTemp, username); account = createCnyAccount(customerId, DEFAULT_CREDIT, DEFAULT_CREDIT, username);
// 档案物理额度列同步为0,与账户初始额度保持一致
bmsCustomerMapper.updateCustomerCredit(customerId, DEFAULT_CREDIT, DEFAULT_CREDIT, username);
writeInitFlow(account, CustomerCreditFlow.CREDIT_TYPE_CREDIT, writeInitFlow(account, CustomerCreditFlow.CREDIT_TYPE_CREDIT,
initCredit, null, null, username, "首次创建CNY账户,从客户档案同步初始额度"); DEFAULT_CREDIT, null, null, username, "首次创建CNY账户,信用额度默认0,需在客户余额-额度管理中调整");
if (initTemp.compareTo(BigDecimal.ZERO) > 0) writeInitFlow(account, CustomerCreditFlow.CREDIT_TYPE_TEMP,
{ DEFAULT_CREDIT, null, null, username, "首次创建CNY账户,临时额度默认0,需在客户余额-额度管理中调整");
writeInitFlow(account, CustomerCreditFlow.CREDIT_TYPE_TEMP,
initTemp, null, null, username, "首次创建CNY账户,从客户档案同步临时额度");
}
return account; return account;
} }
catch (RuntimeException e) catch (RuntimeException e)
@@ -598,7 +588,7 @@ public class CustomerAccountApiImpl implements ICustomerAccountApi
return account; return account;
} }
/** 账户首次初始化时写额度 INIT 流水(从客户档案额度同步) */ /** 账户首次初始化时写额度 INIT 流水(初始化额度固定为0) */
private void writeInitFlow(CustomerAccount account, String creditType, private void writeInitFlow(CustomerAccount account, String creditType,
BigDecimal initAmount, Date effectiveDate, Date expireDate, BigDecimal initAmount, Date effectiveDate, Date expireDate,
String username, String remark) String username, String remark)
@@ -236,15 +236,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where customer_id = #{customerId} where customer_id = #{customerId}
</update> </update>
<!-- 只取档案物理额度列(列表查询里的 credit_ed 是账户可用额度子查询) -->
<select id="selectRawCreditByCustomerId" resultType="BmsCustomer">
select customer_id as customerId,
credit_ed as creditEd,
temp_ed as tempEd
from ctr_customer
where customer_id = #{customerId}
</select>
<delete id="deleteBmsCustomerAttachmentByAttachmentIds" parameterType="String"> <delete id="deleteBmsCustomerAttachmentByAttachmentIds" parameterType="String">
update ctr_customer_attachment set del_flag = '2' where attachment_id in update ctr_customer_attachment set del_flag = '2' where attachment_id in
<foreach item="attachmentId" collection="attachmentIds" open="(" separator="," close=")"> <foreach item="attachmentId" collection="attachmentIds" open="(" separator="," close=")">
@@ -130,21 +130,19 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="信用额度" prop="creditEd"> <el-form-item label="信用额度">
<el-input v-model="form.creditEd" :disabled="!isAdd" placeholder="默认为0,授信需在客户余额中申请审批"> <el-input :model-value="formatBalance(form.creditEd)" disabled placeholder="0.00">
<template #append v-if="!isAdd"> <template #append>CNY</template>
<span style="color: #e6a23c">请在客户余额-额度管理中调整</span>
</template>
</el-input> </el-input>
<div class="form-tip-text">新建客户初始化为0,需在「客户余额-额度管理」中调整</div>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="临时额度" prop="tempEd"> <el-form-item label="临时额度">
<el-input v-model="form.tempEd" :disabled="!isAdd" placeholder="请输入临时额度"> <el-input :model-value="formatBalance(form.tempEd)" disabled placeholder="0.00">
<template #append v-if="!isAdd"> <template #append>CNY</template>
<span style="color: #e6a23c">请在客户余额-额度管理中调整</span>
</template>
</el-input> </el-input>
<div class="form-tip-text">新建客户初始化为0,需在「客户余额-额度管理」中调整</div>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@@ -779,7 +777,7 @@ function buildEmptyForm() {
serviceUserId: null, serviceUserId: null,
serviceUser: null, serviceUser: null,
settlementType: null, settlementType: null,
tempEd: null, tempEd: 0,
accountBalance: null, accountBalance: null,
foreignCurrencyBalance: null, foreignCurrencyBalance: null,
weightThreshold: null, weightThreshold: null,
@@ -1321,6 +1319,12 @@ onMounted(() => {
color: #909399; color: #909399;
font-size: 12px; font-size: 12px;
} }
.form-tip-text {
color: #e6a23c;
font-size: 12px;
line-height: 1.4;
margin-top: 2px;
}
.bound-table { .bound-table {
margin-top: 4px; margin-top: 4px;
} }