From 8501cc34dc8e3cd278f32bed48c8d980e8fa57b9 Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 23 Dec 2025 07:06:46 -0800 Subject: [PATCH] =?UTF-8?q?fix(authorization):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=B8=82/=E7=9C=81=E5=9B=A2=E9=98=9F=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E9=80=BB=E8=BE=91=E4=B8=BA=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BC=9E=E4=B8=8B=E8=AE=A4=E7=A7=8D=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 业务规则调整: - 市团队本人伞下认种数(不含自己)达到1万棵时自动升级为市区域 - 省团队本人伞下认种数(不含自己)达到5万棵时自动升级为省区域 - 伞下认种数 = 团队总认种数 - 自己认种数 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../kafka/event-consumer.controller.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/backend/services/authorization-service/src/infrastructure/kafka/event-consumer.controller.ts b/backend/services/authorization-service/src/infrastructure/kafka/event-consumer.controller.ts index e0c9517a..15edbed7 100644 --- a/backend/services/authorization-service/src/infrastructure/kafka/event-consumer.controller.ts +++ b/backend/services/authorization-service/src/infrastructure/kafka/event-consumer.controller.ts @@ -530,6 +530,7 @@ export class EventConsumerController { /** * 检查单个省团队是否可以升级为省区域 + * 业务规则:省团队本人伞下认种数(不含自己)达到5万棵时自动升级 */ private async checkAuthProvinceUpgrade(authProvince: AuthorizationRole): Promise { const accountSequence = authProvince.userId.accountSequence @@ -543,15 +544,16 @@ export class EventConsumerController { return } - const totalTeamCount = teamStats.totalTeamPlantingCount + // 伞下认种数 = 团队总认种数 - 自己认种数 + const subordinateCount = teamStats.totalTeamPlantingCount - teamStats.selfPlantingCount - // 2. 检查是否达到省区域升级阈值(5万棵) - if (totalTeamCount < EventConsumerController.PROVINCE_UPGRADE_THRESHOLD) { - this.logger.debug(`[TEAM-AUTO-UPGRADE] Auth province ${accountSequence} has ${totalTeamCount} trees, not reaching ${EventConsumerController.PROVINCE_UPGRADE_THRESHOLD} threshold`) + // 2. 检查伞下认种数是否达到省区域升级阈值(5万棵) + if (subordinateCount < EventConsumerController.PROVINCE_UPGRADE_THRESHOLD) { + this.logger.debug(`[TEAM-AUTO-UPGRADE] Auth province ${accountSequence} has subordinate count ${subordinateCount} (total=${teamStats.totalTeamPlantingCount}, self=${teamStats.selfPlantingCount}), not reaching ${EventConsumerController.PROVINCE_UPGRADE_THRESHOLD} threshold`) return } - this.logger.log(`[TEAM-AUTO-UPGRADE] Auth province ${accountSequence} reached ${totalTeamCount} trees, checking upgrade eligibility`) + this.logger.log(`[TEAM-AUTO-UPGRADE] Auth province ${accountSequence} subordinate count ${subordinateCount} reached threshold, checking upgrade eligibility`) // 3. 检查该用户是否已有省区域授权 const existingProvinceCompany = await this.authorizationRepository.findByAccountSequenceAndRoleType( @@ -618,6 +620,7 @@ export class EventConsumerController { /** * 检查单个市团队是否可以升级为市区域 + * 业务规则:市团队本人伞下认种数(不含自己)达到1万棵时自动升级 */ private async checkAuthCityUpgrade(authCity: AuthorizationRole): Promise { const accountSequence = authCity.userId.accountSequence @@ -631,15 +634,16 @@ export class EventConsumerController { return } - const totalTeamCount = teamStats.totalTeamPlantingCount + // 伞下认种数 = 团队总认种数 - 自己认种数 + const subordinateCount = teamStats.totalTeamPlantingCount - teamStats.selfPlantingCount - // 2. 检查是否达到市区域升级阈值(1万棵) - if (totalTeamCount < EventConsumerController.CITY_UPGRADE_THRESHOLD) { - this.logger.debug(`[TEAM-AUTO-UPGRADE] Auth city ${accountSequence} has ${totalTeamCount} trees, not reaching ${EventConsumerController.CITY_UPGRADE_THRESHOLD} threshold`) + // 2. 检查伞下认种数是否达到市区域升级阈值(1万棵) + if (subordinateCount < EventConsumerController.CITY_UPGRADE_THRESHOLD) { + this.logger.debug(`[TEAM-AUTO-UPGRADE] Auth city ${accountSequence} has subordinate count ${subordinateCount} (total=${teamStats.totalTeamPlantingCount}, self=${teamStats.selfPlantingCount}), not reaching ${EventConsumerController.CITY_UPGRADE_THRESHOLD} threshold`) return } - this.logger.log(`[TEAM-AUTO-UPGRADE] Auth city ${accountSequence} reached ${totalTeamCount} trees, checking upgrade eligibility`) + this.logger.log(`[TEAM-AUTO-UPGRADE] Auth city ${accountSequence} subordinate count ${subordinateCount} reached threshold, checking upgrade eligibility`) // 3. 检查该用户是否已有市区域授权 const existingCityCompany = await this.authorizationRepository.findByAccountSequenceAndRoleType(