fix(pre-planting): 修复省市代码格式不一致导致授权分配失败
预种DTO接收2位省代码(如"44")和4位市代码(如"4401"), 但authorization-service需要6位标准格式(如"440000"/"440100")。 - resolveAllocations中新增padEnd(6,'0')标准化转换 - fallback系统账户生成从padStart改为padEnd(右补零) - 正常认种不受影响(SelectProvinceCityDto直接接收6位格式) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3be7b47678
commit
b9ddda2532
|
|
@ -151,6 +151,17 @@ export class PrePlantingRewardService {
|
|||
const allocations: RewardAllocation[] = [];
|
||||
const multiplier = portionCount;
|
||||
|
||||
// [2026-03-01] 标准化省市代码为 6 位格式
|
||||
// 预种 DTO 接收前端传入的短格式(省 2 位如 "44",市 4 位如 "4401"),
|
||||
// 但 authorization-service 查询和系统账户编号都需要 6 位格式("440000"/"440100")。
|
||||
// 正常认种 SelectProvinceCityDto 直接接收 6 位格式,故不存在此问题。
|
||||
const stdProvinceCode = provinceCode.length < 6
|
||||
? provinceCode.padEnd(6, '0')
|
||||
: provinceCode;
|
||||
const stdCityCode = cityCode.length < 6
|
||||
? cityCode.padEnd(6, '0')
|
||||
: cityCode;
|
||||
|
||||
// ===== 4 类系统费用(硬编码,无需查询) =====
|
||||
allocations.push({
|
||||
recipientAccountSequence: SYSTEM_ACCOUNTS.COST,
|
||||
|
|
@ -196,9 +207,9 @@ export class PrePlantingRewardService {
|
|||
] = await Promise.all([
|
||||
this.referralClient.getReferralChain(accountSequence),
|
||||
this.authorizationClient.getCommunityDistribution(accountSequence),
|
||||
this.authorizationClient.getProvinceAreaDistribution(provinceCode),
|
||||
this.authorizationClient.getProvinceAreaDistribution(stdProvinceCode),
|
||||
this.authorizationClient.getProvinceTeamDistribution(accountSequence),
|
||||
this.authorizationClient.getCityAreaDistribution(cityCode),
|
||||
this.authorizationClient.getCityAreaDistribution(stdCityCode),
|
||||
this.authorizationClient.getCityTeamDistribution(accountSequence),
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ export class PrePlantingAuthorizationClient {
|
|||
* [2026-02-28] 修复:
|
||||
* 1. 传 treeCount=0(预种阶段不计入省公司月度考核,等合成1棵树后再累计)
|
||||
* 2. 正确解析 { distributions: [{accountSequence, ...}] } 返回格式(之前错误地期望 { accountSequence })
|
||||
* 3. fallback 路径添加 padStart(6,'0'),确保生成 7 位标准格式(如 9440000 而非 944)
|
||||
* 3. fallback 路径使用 padEnd(6,'0') 右补零,确保生成 7 位标准格式(如 9440000)
|
||||
*/
|
||||
async getProvinceAreaDistribution(
|
||||
provinceCode: string,
|
||||
|
|
@ -102,7 +102,7 @@ export class PrePlantingAuthorizationClient {
|
|||
`Failed to get province area distribution for ${provinceCode}, fallback to system province account`,
|
||||
);
|
||||
return {
|
||||
recipientAccountSequence: `9${provinceCode.padStart(6, '0')}`,
|
||||
recipientAccountSequence: `9${provinceCode.padEnd(6, '0')}`,
|
||||
isFallback: true,
|
||||
};
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ export class PrePlantingAuthorizationClient {
|
|||
* [2026-02-28] 修复:与省区域同样的三个问题
|
||||
* 1. 传 treeCount=0(预种阶段不计入市公司月度考核,等合成1棵树后再累计)
|
||||
* 2. 正确解析 { distributions: [...] } 返回格式
|
||||
* 3. fallback 路径添加 padStart(6,'0'),确保生成 7 位标准格式(如 8440100 而非 84401)
|
||||
* 3. fallback 路径使用 padEnd(6,'0') 右补零,确保生成 7 位标准格式(如 8440100)
|
||||
*/
|
||||
async getCityAreaDistribution(
|
||||
cityCode: string,
|
||||
|
|
@ -176,7 +176,7 @@ export class PrePlantingAuthorizationClient {
|
|||
`Failed to get city area distribution for ${cityCode}, fallback to system city account`,
|
||||
);
|
||||
return {
|
||||
recipientAccountSequence: `8${cityCode.padStart(6, '0')}`,
|
||||
recipientAccountSequence: `8${cityCode.padEnd(6, '0')}`,
|
||||
isFallback: true,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue