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:
parent
d24a474d02
commit
8501cc34dc
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue