diff --git a/backend/services/planting-service/src/pre-planting/application/services/pre-planting-reward.service.ts b/backend/services/planting-service/src/pre-planting/application/services/pre-planting-reward.service.ts index b2c92ba9..92f41bce 100644 --- a/backend/services/planting-service/src/pre-planting/application/services/pre-planting-reward.service.ts +++ b/backend/services/planting-service/src/pre-planting/application/services/pre-planting-reward.service.ts @@ -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), ]); diff --git a/backend/services/planting-service/src/pre-planting/infrastructure/external/pre-planting-authorization.client.ts b/backend/services/planting-service/src/pre-planting/infrastructure/external/pre-planting-authorization.client.ts index f85c4c2e..51e737d3 100644 --- a/backend/services/planting-service/src/pre-planting/infrastructure/external/pre-planting-authorization.client.ts +++ b/backend/services/planting-service/src/pre-planting/infrastructure/external/pre-planting-authorization.client.ts @@ -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, }; }