fix(pre-planting): 补充社区/省团队/市团队 API 缺失的 treeCount 参数
三个接口调用时未传 treeCount,导致 authorization-service 收到 Number(undefined)=NaN,addMonthlyTrees(NaN) 使字段变为 NaN, Prisma upsert 报 PrismaClientValidationError。 修复:全部传 treeCount=0(预种不计入月度考核), 省团队补充 provinceCode,市团队补充 cityCode, 同时修正社区/团队接口返回格式为 distributions 数组。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e32658fc5e
commit
1157760d4d
|
|
@ -208,9 +208,9 @@ export class PrePlantingRewardService {
|
||||||
this.referralClient.getReferralChain(accountSequence),
|
this.referralClient.getReferralChain(accountSequence),
|
||||||
this.authorizationClient.getCommunityDistribution(accountSequence),
|
this.authorizationClient.getCommunityDistribution(accountSequence),
|
||||||
this.authorizationClient.getProvinceAreaDistribution(stdProvinceCode),
|
this.authorizationClient.getProvinceAreaDistribution(stdProvinceCode),
|
||||||
this.authorizationClient.getProvinceTeamDistribution(accountSequence),
|
this.authorizationClient.getProvinceTeamDistribution(accountSequence, stdProvinceCode),
|
||||||
this.authorizationClient.getCityAreaDistribution(stdCityCode),
|
this.authorizationClient.getCityAreaDistribution(stdCityCode),
|
||||||
this.authorizationClient.getCityTeamDistribution(accountSequence),
|
this.authorizationClient.getCityTeamDistribution(accountSequence, stdCityCode),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 推荐奖励 (SHARE_RIGHT)
|
// 推荐奖励 (SHARE_RIGHT)
|
||||||
|
|
|
||||||
|
|
@ -45,19 +45,33 @@ export class PrePlantingAuthorizationClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社区权益分配对象
|
* 社区权益分配对象
|
||||||
|
*
|
||||||
|
* treeCount=0:预种阶段不计入社区月度考核,避免 addMonthlyTrees(NaN) 导致 Prisma 报错
|
||||||
*/
|
*/
|
||||||
async getCommunityDistribution(
|
async getCommunityDistribution(
|
||||||
accountSequence: string,
|
accountSequence: string,
|
||||||
): Promise<RewardDistributionResult> {
|
): Promise<RewardDistributionResult> {
|
||||||
try {
|
try {
|
||||||
const response = await firstValueFrom(
|
const response = await firstValueFrom(
|
||||||
this.httpService.get<WrappedResponse<{ accountSequence: string }>>(
|
this.httpService.get<WrappedResponse<{ distributions: AreaDistributionItem[] }>>(
|
||||||
`${this.baseUrl}/api/v1/authorization/community-reward-distribution`,
|
`${this.baseUrl}/api/v1/authorization/community-reward-distribution`,
|
||||||
{ params: { accountSequence } },
|
{ params: { accountSequence, treeCount: 0 } },
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const distributions = response.data.data.distributions;
|
||||||
|
if (!distributions || distributions.length === 0) {
|
||||||
|
throw new Error('Empty distributions returned');
|
||||||
|
}
|
||||||
|
|
||||||
|
const target = distributions.find(d => !d.isSystemAccount) || distributions[0];
|
||||||
|
|
||||||
|
this.logger.debug(
|
||||||
|
`Community distribution for ${accountSequence}: ${target.accountSequence} (${target.reason})`,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recipientAccountSequence: response.data.data.accountSequence,
|
recipientAccountSequence: target.accountSequence,
|
||||||
isFallback: false,
|
isFallback: false,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -120,19 +134,34 @@ export class PrePlantingAuthorizationClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 省团队权益分配对象
|
* 省团队权益分配对象
|
||||||
|
*
|
||||||
|
* treeCount=0:预种阶段不计入省团队月度考核
|
||||||
*/
|
*/
|
||||||
async getProvinceTeamDistribution(
|
async getProvinceTeamDistribution(
|
||||||
accountSequence: string,
|
accountSequence: string,
|
||||||
|
provinceCode: string,
|
||||||
): Promise<RewardDistributionResult> {
|
): Promise<RewardDistributionResult> {
|
||||||
try {
|
try {
|
||||||
const response = await firstValueFrom(
|
const response = await firstValueFrom(
|
||||||
this.httpService.get<WrappedResponse<{ accountSequence: string }>>(
|
this.httpService.get<WrappedResponse<{ distributions: AreaDistributionItem[] }>>(
|
||||||
`${this.baseUrl}/api/v1/authorization/province-team-reward-distribution`,
|
`${this.baseUrl}/api/v1/authorization/province-team-reward-distribution`,
|
||||||
{ params: { accountSequence } },
|
{ params: { accountSequence, provinceCode, treeCount: 0 } },
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const distributions = response.data.data.distributions;
|
||||||
|
if (!distributions || distributions.length === 0) {
|
||||||
|
throw new Error('Empty distributions returned');
|
||||||
|
}
|
||||||
|
|
||||||
|
const target = distributions.find(d => !d.isSystemAccount) || distributions[0];
|
||||||
|
|
||||||
|
this.logger.debug(
|
||||||
|
`Province team distribution for ${accountSequence}: ${target.accountSequence} (${target.reason})`,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recipientAccountSequence: response.data.data.accountSequence,
|
recipientAccountSequence: target.accountSequence,
|
||||||
isFallback: false,
|
isFallback: false,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -194,19 +223,34 @@ export class PrePlantingAuthorizationClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 市团队权益分配对象
|
* 市团队权益分配对象
|
||||||
|
*
|
||||||
|
* treeCount=0:预种阶段不计入市团队月度考核
|
||||||
*/
|
*/
|
||||||
async getCityTeamDistribution(
|
async getCityTeamDistribution(
|
||||||
accountSequence: string,
|
accountSequence: string,
|
||||||
|
cityCode: string,
|
||||||
): Promise<RewardDistributionResult> {
|
): Promise<RewardDistributionResult> {
|
||||||
try {
|
try {
|
||||||
const response = await firstValueFrom(
|
const response = await firstValueFrom(
|
||||||
this.httpService.get<WrappedResponse<{ accountSequence: string }>>(
|
this.httpService.get<WrappedResponse<{ distributions: AreaDistributionItem[] }>>(
|
||||||
`${this.baseUrl}/api/v1/authorization/city-team-reward-distribution`,
|
`${this.baseUrl}/api/v1/authorization/city-team-reward-distribution`,
|
||||||
{ params: { accountSequence } },
|
{ params: { accountSequence, cityCode, treeCount: 0 } },
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const distributions = response.data.data.distributions;
|
||||||
|
if (!distributions || distributions.length === 0) {
|
||||||
|
throw new Error('Empty distributions returned');
|
||||||
|
}
|
||||||
|
|
||||||
|
const target = distributions.find(d => !d.isSystemAccount) || distributions[0];
|
||||||
|
|
||||||
|
this.logger.debug(
|
||||||
|
`City team distribution for ${accountSequence}: ${target.accountSequence} (${target.reason})`,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recipientAccountSequence: response.data.data.accountSequence,
|
recipientAccountSequence: target.accountSequence,
|
||||||
isFallback: false,
|
isFallback: false,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue