fix(authorization): 修改市/省团队自动升级逻辑为使用伞下认种数

业务规则调整:
- 市团队本人伞下认种数(不含自己)达到1万棵时自动升级为市区域
- 省团队本人伞下认种数(不含自己)达到5万棵时自动升级为省区域
- 伞下认种数 = 团队总认种数 - 自己认种数

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-23 07:06:46 -08:00
parent d24a474d02
commit 8501cc34dc
1 changed files with 14 additions and 10 deletions

View File

@ -530,6 +530,7 @@ export class EventConsumerController {
/**
*
* 5
*/
private async checkAuthProvinceUpgrade(authProvince: AuthorizationRole): Promise<void> {
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<void> {
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(