feat(authorization): remove region matching requirement for team rewards

省团队(AUTH_PROVINCE_COMPANY)和市团队(AUTH_CITY_COMPANY)收益分配不再要求
认种者选择的省市与被授权用户的省市一致,只要在推荐链上有授权即可获得收益。

省区域(PROVINCE_COMPANY)和市区域(CITY_COMPANY)收益仍保持省市匹配要求。

🤖 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-12 03:04:55 -08:00
parent 26427443fe
commit f60d4eac87
3 changed files with 56 additions and 4 deletions

View File

@ -1128,9 +1128,9 @@ export class AuthorizationApplicationService {
}
// 2. 查找祖先链中所有授权省公司(包括 benefitActive=false
const ancestorAuthProvinces = await this.authorizationRepository.findAuthProvinceByAccountSequencesAndRegion(
// 注意:省团队收益不再要求省份匹配,只要推荐链上有省团队授权即可获得收益
const ancestorAuthProvinces = await this.authorizationRepository.findAuthProvinceByAccountSequences(
ancestorAccountSequences.map((seq) => BigInt(seq)),
provinceCode,
)
if (ancestorAuthProvinces.length === 0) {
@ -1430,9 +1430,9 @@ export class AuthorizationApplicationService {
}
// 2. 查找祖先链中所有授权市公司(包括 benefitActive=false
const ancestorAuthCities = await this.authorizationRepository.findAuthCityByAccountSequencesAndRegion(
// 注意:市团队收益不再要求城市匹配,只要推荐链上有市团队授权即可获得收益
const ancestorAuthCities = await this.authorizationRepository.findAuthCityByAccountSequences(
ancestorAccountSequences.map((seq) => BigInt(seq)),
cityCode,
)
if (ancestorAuthCities.length === 0) {

View File

@ -50,6 +50,7 @@ export interface IAuthorizationRoleRepository {
/**
* accountSequence benefitActive=false
*
* @deprecated 使 findAuthProvinceByAccountSequences
*/
findAuthProvinceByAccountSequencesAndRegion(
accountSequences: bigint[],
@ -58,11 +59,22 @@ export interface IAuthorizationRoleRepository {
/**
* accountSequence benefitActive=false
*
* @deprecated 使 findAuthCityByAccountSequences
*/
findAuthCityByAccountSequencesAndRegion(
accountSequences: bigint[],
cityCode: string,
): Promise<AuthorizationRole[]>
/**
* accountSequence () benefitActive=false
*
*/
findAuthProvinceByAccountSequences(accountSequences: bigint[]): Promise<AuthorizationRole[]>
/**
* accountSequence () benefitActive=false
*
*/
findAuthCityByAccountSequences(accountSequences: bigint[]): Promise<AuthorizationRole[]>
/**
*
*/

View File

@ -299,6 +299,46 @@ export class AuthorizationRoleRepositoryImpl implements IAuthorizationRoleReposi
return records.map((record) => this.toDomain(record))
}
async findAuthProvinceByAccountSequences(
accountSequences: bigint[],
): Promise<AuthorizationRole[]> {
if (accountSequences.length === 0) {
return []
}
const records = await this.prisma.authorizationRole.findMany({
where: {
accountSequence: { in: accountSequences },
roleType: RoleType.AUTH_PROVINCE_COMPANY,
status: AuthorizationStatus.AUTHORIZED,
// 注意:不过滤 benefitActive用于计算省团队权益分配
// 注意:不过滤 regionCode省团队收益不要求省份匹配
},
orderBy: { accountSequence: 'asc' },
})
return records.map((record) => this.toDomain(record))
}
async findAuthCityByAccountSequences(
accountSequences: bigint[],
): Promise<AuthorizationRole[]> {
if (accountSequences.length === 0) {
return []
}
const records = await this.prisma.authorizationRole.findMany({
where: {
accountSequence: { in: accountSequences },
roleType: RoleType.AUTH_CITY_COMPANY,
status: AuthorizationStatus.AUTHORIZED,
// 注意:不过滤 benefitActive用于计算市团队权益分配
// 注意:不过滤 regionCode市团队收益不要求城市匹配
},
orderBy: { accountSequence: 'asc' },
})
return records.map((record) => this.toDomain(record))
}
async findProvinceCompanyByRegion(provinceCode: string): Promise<AuthorizationRole | null> {
const record = await this.prisma.authorizationRole.findFirst({
where: {