fix(authorization): correctly distribute rewards when assessment target is exactly reached
修复当认种恰好达标时的收益分配错误: - 之前:恰好达标时全部收益给上级/总部,被授权用户无法获得任何收益 - 现在:达标时的那一棵收益归被授权用户所有 影响的分配方法: - getCommunityRewardDistribution (社区) - getProvinceTeamRewardDistribution (省团队) - getCityTeamRewardDistribution (市团队) - getProvinceAreaRewardDistribution (省区域) - getCityAreaRewardDistribution (市区域) 🤖 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
f60d4eac87
commit
a54e9743ef
|
|
@ -1050,30 +1050,25 @@ export class AuthorizationApplicationService {
|
|||
treeCount,
|
||||
reason: `初始考核中(${currentTeamCount}+${treeCount}=${afterPlantingCount}/${initialTarget}),${parentCommunityReason}`,
|
||||
})
|
||||
} else if (afterPlantingCount === initialTarget) {
|
||||
// 本次认种恰好达标,全部给上级/总部,但需要激活权益
|
||||
distributions.push({
|
||||
accountSequence: parentCommunityAccountSequence,
|
||||
treeCount,
|
||||
reason: `初始考核达标(${currentTeamCount}+${treeCount}=${initialTarget}),${parentCommunityReason}`,
|
||||
})
|
||||
|
||||
// 自动激活权益(本次认种使其恰好达标)
|
||||
await this.tryActivateBenefit(nearestCommunity)
|
||||
} else {
|
||||
// 本次认种跨越考核达标点 (afterPlantingCount > initialTarget)
|
||||
// 考核前的部分给上级/总部
|
||||
distributions.push({
|
||||
accountSequence: parentCommunityAccountSequence,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),${parentCommunityReason}`,
|
||||
})
|
||||
// 考核后的部分给该社区
|
||||
distributions.push({
|
||||
accountSequence: Number(nearestCommunity.userId.accountSequence),
|
||||
treeCount: treeCount - remaining,
|
||||
reason: `考核达标后权益生效`,
|
||||
})
|
||||
// 本次认种达到或跨越考核达标点 (afterPlantingCount >= initialTarget)
|
||||
// 考核前的部分给上级/总部(remaining 可能为0,此时不添加分配记录)
|
||||
if (remaining > 0) {
|
||||
distributions.push({
|
||||
accountSequence: parentCommunityAccountSequence,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),${parentCommunityReason}`,
|
||||
})
|
||||
}
|
||||
// 考核后的部分(达标后多出来的)给该社区
|
||||
const afterTargetCount = treeCount - remaining
|
||||
if (afterTargetCount > 0) {
|
||||
distributions.push({
|
||||
accountSequence: Number(nearestCommunity.userId.accountSequence),
|
||||
treeCount: afterTargetCount,
|
||||
reason: `考核达标后权益生效`,
|
||||
})
|
||||
}
|
||||
|
||||
// 自动激活权益(本次认种使其达标)
|
||||
await this.tryActivateBenefit(nearestCommunity)
|
||||
|
|
@ -1223,27 +1218,25 @@ export class AuthorizationApplicationService {
|
|||
treeCount,
|
||||
reason: `初始考核中(${currentTeamCount}+${treeCount}=${afterPlantingCount}/${initialTarget}),${parentReason}`,
|
||||
})
|
||||
} else if (afterPlantingCount === initialTarget) {
|
||||
// 本次认种恰好达标
|
||||
distributions.push({
|
||||
accountSequence: parentAccountSequence,
|
||||
treeCount,
|
||||
reason: `初始考核达标(${currentTeamCount}+${treeCount}=${initialTarget}),${parentReason}`,
|
||||
})
|
||||
// 自动激活权益
|
||||
await this.tryActivateBenefit(nearestAuthProvince)
|
||||
} else {
|
||||
// 本次认种跨越达标点
|
||||
distributions.push({
|
||||
accountSequence: parentAccountSequence,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),${parentReason}`,
|
||||
})
|
||||
distributions.push({
|
||||
accountSequence: Number(nearestAuthProvince.userId.accountSequence),
|
||||
treeCount: treeCount - remaining,
|
||||
reason: '考核达标后权益生效',
|
||||
})
|
||||
// 本次认种达到或跨越达标点 (afterPlantingCount >= initialTarget)
|
||||
// 考核前的部分给上级/总部(remaining 可能为0,此时不添加分配记录)
|
||||
if (remaining > 0) {
|
||||
distributions.push({
|
||||
accountSequence: parentAccountSequence,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),${parentReason}`,
|
||||
})
|
||||
}
|
||||
// 考核后的部分(达标后多出来的)给该省团队
|
||||
const afterTargetCount = treeCount - remaining
|
||||
if (afterTargetCount > 0) {
|
||||
distributions.push({
|
||||
accountSequence: Number(nearestAuthProvince.userId.accountSequence),
|
||||
treeCount: afterTargetCount,
|
||||
reason: '考核达标后权益生效',
|
||||
})
|
||||
}
|
||||
// 自动激活权益(本次认种使其达标)
|
||||
await this.tryActivateBenefit(nearestAuthProvince)
|
||||
}
|
||||
|
|
@ -1354,32 +1347,27 @@ export class AuthorizationApplicationService {
|
|||
reason: `初始考核中(${currentTeamCount}+${treeCount}=${afterPlantingCount}/${initialTarget}),进系统省账户`,
|
||||
isSystemAccount: true,
|
||||
})
|
||||
} else if (afterPlantingCount === initialTarget) {
|
||||
// 本次认种恰好达标,全部进系统省账户,但需要激活权益
|
||||
distributions.push({
|
||||
accountSequence: systemProvinceAccountId,
|
||||
treeCount,
|
||||
reason: `初始考核达标(${currentTeamCount}+${treeCount}=${initialTarget}),进系统省账户`,
|
||||
isSystemAccount: true,
|
||||
})
|
||||
// 自动激活权益
|
||||
await this.tryActivateBenefit(provinceCompany)
|
||||
} else {
|
||||
// 本次认种跨越考核达标点
|
||||
// 考核前的部分进系统省账户
|
||||
distributions.push({
|
||||
accountSequence: systemProvinceAccountId,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),进系统省账户`,
|
||||
isSystemAccount: true,
|
||||
})
|
||||
// 考核后的部分给该省公司
|
||||
distributions.push({
|
||||
accountSequence: Number(provinceCompany.userId.accountSequence),
|
||||
treeCount: treeCount - remaining,
|
||||
reason: '考核达标后权益生效',
|
||||
isSystemAccount: false,
|
||||
})
|
||||
// 本次认种达到或跨越考核达标点 (afterPlantingCount >= initialTarget)
|
||||
// 考核前的部分进系统省账户(remaining 可能为0,此时不添加分配记录)
|
||||
if (remaining > 0) {
|
||||
distributions.push({
|
||||
accountSequence: systemProvinceAccountId,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),进系统省账户`,
|
||||
isSystemAccount: true,
|
||||
})
|
||||
}
|
||||
// 考核后的部分(达标后多出来的)给该省公司
|
||||
const afterTargetCount = treeCount - remaining
|
||||
if (afterTargetCount > 0) {
|
||||
distributions.push({
|
||||
accountSequence: Number(provinceCompany.userId.accountSequence),
|
||||
treeCount: afterTargetCount,
|
||||
reason: '考核达标后权益生效',
|
||||
isSystemAccount: false,
|
||||
})
|
||||
}
|
||||
// 自动激活权益
|
||||
await this.tryActivateBenefit(provinceCompany)
|
||||
}
|
||||
|
|
@ -1525,27 +1513,25 @@ export class AuthorizationApplicationService {
|
|||
treeCount,
|
||||
reason: `初始考核中(${currentTeamCount}+${treeCount}=${afterPlantingCount}/${initialTarget}),${parentReason}`,
|
||||
})
|
||||
} else if (afterPlantingCount === initialTarget) {
|
||||
// 本次认种恰好达标
|
||||
distributions.push({
|
||||
accountSequence: parentAccountSequence,
|
||||
treeCount,
|
||||
reason: `初始考核达标(${currentTeamCount}+${treeCount}=${initialTarget}),${parentReason}`,
|
||||
})
|
||||
// 自动激活权益
|
||||
await this.tryActivateBenefit(nearestAuthCity)
|
||||
} else {
|
||||
// 本次认种跨越达标点
|
||||
distributions.push({
|
||||
accountSequence: parentAccountSequence,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),${parentReason}`,
|
||||
})
|
||||
distributions.push({
|
||||
accountSequence: Number(nearestAuthCity.userId.accountSequence),
|
||||
treeCount: treeCount - remaining,
|
||||
reason: '考核达标后权益生效',
|
||||
})
|
||||
// 本次认种达到或跨越达标点 (afterPlantingCount >= initialTarget)
|
||||
// 考核前的部分给上级/总部(remaining 可能为0,此时不添加分配记录)
|
||||
if (remaining > 0) {
|
||||
distributions.push({
|
||||
accountSequence: parentAccountSequence,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),${parentReason}`,
|
||||
})
|
||||
}
|
||||
// 考核后的部分(达标后多出来的)给该市团队
|
||||
const afterTargetCount = treeCount - remaining
|
||||
if (afterTargetCount > 0) {
|
||||
distributions.push({
|
||||
accountSequence: Number(nearestAuthCity.userId.accountSequence),
|
||||
treeCount: afterTargetCount,
|
||||
reason: '考核达标后权益生效',
|
||||
})
|
||||
}
|
||||
// 自动激活权益(本次认种使其达标)
|
||||
await this.tryActivateBenefit(nearestAuthCity)
|
||||
}
|
||||
|
|
@ -1656,32 +1642,27 @@ export class AuthorizationApplicationService {
|
|||
reason: `初始考核中(${currentTeamCount}+${treeCount}=${afterPlantingCount}/${initialTarget}),进系统市账户`,
|
||||
isSystemAccount: true,
|
||||
})
|
||||
} else if (afterPlantingCount === initialTarget) {
|
||||
// 本次认种恰好达标,全部进系统市账户,但需要激活权益
|
||||
distributions.push({
|
||||
accountSequence: systemCityAccountId,
|
||||
treeCount,
|
||||
reason: `初始考核达标(${currentTeamCount}+${treeCount}=${initialTarget}),进系统市账户`,
|
||||
isSystemAccount: true,
|
||||
})
|
||||
// 自动激活权益
|
||||
await this.tryActivateBenefit(cityCompany)
|
||||
} else {
|
||||
// 本次认种跨越考核达标点
|
||||
// 考核前的部分进系统市账户
|
||||
distributions.push({
|
||||
accountSequence: systemCityAccountId,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),进系统市账户`,
|
||||
isSystemAccount: true,
|
||||
})
|
||||
// 考核后的部分给该市公司
|
||||
distributions.push({
|
||||
accountSequence: Number(cityCompany.userId.accountSequence),
|
||||
treeCount: treeCount - remaining,
|
||||
reason: '考核达标后权益生效',
|
||||
isSystemAccount: false,
|
||||
})
|
||||
// 本次认种达到或跨越考核达标点 (afterPlantingCount >= initialTarget)
|
||||
// 考核前的部分进系统市账户(remaining 可能为0,此时不添加分配记录)
|
||||
if (remaining > 0) {
|
||||
distributions.push({
|
||||
accountSequence: systemCityAccountId,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),进系统市账户`,
|
||||
isSystemAccount: true,
|
||||
})
|
||||
}
|
||||
// 考核后的部分(达标后多出来的)给该市公司
|
||||
const afterTargetCount = treeCount - remaining
|
||||
if (afterTargetCount > 0) {
|
||||
distributions.push({
|
||||
accountSequence: Number(cityCompany.userId.accountSequence),
|
||||
treeCount: afterTargetCount,
|
||||
reason: '考核达标后权益生效',
|
||||
isSystemAccount: false,
|
||||
})
|
||||
}
|
||||
// 自动激活权益
|
||||
await this.tryActivateBenefit(cityCompany)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue