fix(authorization): include target-reaching tree in user's reward
修复达标时收益分配错误:达标的那一棵应该归被授权用户所有。 之前逻辑:目标10棵,当前0棵,本次种10棵 - remaining = 10 - 0 = 10 - 上级得到10棵,用户得到0棵 ❌ 修复后: - remaining = max(0, 10 - 0 - 1) = 9(不包括达标那一棵) - 上级得到9棵,用户得到1棵 ✅ 影响:社区、省团队、市团队、省区域、市区域 🤖 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
a54e9743ef
commit
16f891b743
|
|
@ -1040,7 +1040,9 @@ export class AuthorizationApplicationService {
|
|||
await this.tryActivateBenefit(nearestCommunity)
|
||||
} else {
|
||||
// 未达标,需要拆分
|
||||
const remaining = initialTarget - currentTeamCount // 还差多少棵达标
|
||||
// remaining: 还差多少棵达标(不包括达标那一棵本身)
|
||||
// 例如:目标10棵,当前0棵 -> remaining = 9(前9棵给上级,第10棵给自己)
|
||||
const remaining = Math.max(0, initialTarget - currentTeamCount - 1)
|
||||
const afterPlantingCount = currentTeamCount + treeCount // 本次认种后的总数
|
||||
|
||||
if (afterPlantingCount < initialTarget) {
|
||||
|
|
@ -1057,10 +1059,10 @@ export class AuthorizationApplicationService {
|
|||
distributions.push({
|
||||
accountSequence: parentCommunityAccountSequence,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),${parentCommunityReason}`,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${currentTeamCount + remaining}/${initialTarget}),${parentCommunityReason}`,
|
||||
})
|
||||
}
|
||||
// 考核后的部分(达标后多出来的)给该社区
|
||||
// 达标的那一棵 + 之后多出来的,全部给该社区
|
||||
const afterTargetCount = treeCount - remaining
|
||||
if (afterTargetCount > 0) {
|
||||
distributions.push({
|
||||
|
|
@ -1208,7 +1210,8 @@ export class AuthorizationApplicationService {
|
|||
// 自动激活权益
|
||||
await this.tryActivateBenefit(nearestAuthProvince)
|
||||
} else {
|
||||
const remaining = initialTarget - currentTeamCount
|
||||
// remaining: 还差多少棵达标(不包括达标那一棵本身)
|
||||
const remaining = Math.max(0, initialTarget - currentTeamCount - 1)
|
||||
const afterPlantingCount = currentTeamCount + treeCount
|
||||
|
||||
if (afterPlantingCount < initialTarget) {
|
||||
|
|
@ -1225,10 +1228,10 @@ export class AuthorizationApplicationService {
|
|||
distributions.push({
|
||||
accountSequence: parentAccountSequence,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),${parentReason}`,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${currentTeamCount + remaining}/${initialTarget}),${parentReason}`,
|
||||
})
|
||||
}
|
||||
// 考核后的部分(达标后多出来的)给该省团队
|
||||
// 达标的那一棵 + 之后多出来的,全部给该省团队
|
||||
const afterTargetCount = treeCount - remaining
|
||||
if (afterTargetCount > 0) {
|
||||
distributions.push({
|
||||
|
|
@ -1336,7 +1339,8 @@ export class AuthorizationApplicationService {
|
|||
// 自动激活权益
|
||||
await this.tryActivateBenefit(provinceCompany)
|
||||
} else {
|
||||
const remaining = initialTarget - currentTeamCount
|
||||
// remaining: 还差多少棵达标(不包括达标那一棵本身)
|
||||
const remaining = Math.max(0, initialTarget - currentTeamCount - 1)
|
||||
const afterPlantingCount = currentTeamCount + treeCount
|
||||
|
||||
if (afterPlantingCount < initialTarget) {
|
||||
|
|
@ -1354,11 +1358,11 @@ export class AuthorizationApplicationService {
|
|||
distributions.push({
|
||||
accountSequence: systemProvinceAccountId,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),进系统省账户`,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${currentTeamCount + remaining}/${initialTarget}),进系统省账户`,
|
||||
isSystemAccount: true,
|
||||
})
|
||||
}
|
||||
// 考核后的部分(达标后多出来的)给该省公司
|
||||
// 达标的那一棵 + 之后多出来的,全部给该省公司
|
||||
const afterTargetCount = treeCount - remaining
|
||||
if (afterTargetCount > 0) {
|
||||
distributions.push({
|
||||
|
|
@ -1503,7 +1507,8 @@ export class AuthorizationApplicationService {
|
|||
// 自动激活权益
|
||||
await this.tryActivateBenefit(nearestAuthCity)
|
||||
} else {
|
||||
const remaining = initialTarget - currentTeamCount
|
||||
// remaining: 还差多少棵达标(不包括达标那一棵本身)
|
||||
const remaining = Math.max(0, initialTarget - currentTeamCount - 1)
|
||||
const afterPlantingCount = currentTeamCount + treeCount
|
||||
|
||||
if (afterPlantingCount < initialTarget) {
|
||||
|
|
@ -1520,10 +1525,10 @@ export class AuthorizationApplicationService {
|
|||
distributions.push({
|
||||
accountSequence: parentAccountSequence,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),${parentReason}`,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${currentTeamCount + remaining}/${initialTarget}),${parentReason}`,
|
||||
})
|
||||
}
|
||||
// 考核后的部分(达标后多出来的)给该市团队
|
||||
// 达标的那一棵 + 之后多出来的,全部给该市团队
|
||||
const afterTargetCount = treeCount - remaining
|
||||
if (afterTargetCount > 0) {
|
||||
distributions.push({
|
||||
|
|
@ -1631,7 +1636,8 @@ export class AuthorizationApplicationService {
|
|||
// 自动激活权益
|
||||
await this.tryActivateBenefit(cityCompany)
|
||||
} else {
|
||||
const remaining = initialTarget - currentTeamCount
|
||||
// remaining: 还差多少棵达标(不包括达标那一棵本身)
|
||||
const remaining = Math.max(0, initialTarget - currentTeamCount - 1)
|
||||
const afterPlantingCount = currentTeamCount + treeCount
|
||||
|
||||
if (afterPlantingCount < initialTarget) {
|
||||
|
|
@ -1649,11 +1655,11 @@ export class AuthorizationApplicationService {
|
|||
distributions.push({
|
||||
accountSequence: systemCityAccountId,
|
||||
treeCount: remaining,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${initialTarget}),进系统市账户`,
|
||||
reason: `初始考核(${currentTeamCount}+${remaining}=${currentTeamCount + remaining}/${initialTarget}),进系统市账户`,
|
||||
isSystemAccount: true,
|
||||
})
|
||||
}
|
||||
// 考核后的部分(达标后多出来的)给该市公司
|
||||
// 达标的那一棵 + 之后多出来的,全部给该市公司
|
||||
const afterTargetCount = treeCount - remaining
|
||||
if (afterTargetCount > 0) {
|
||||
distributions.push({
|
||||
|
|
|
|||
Loading…
Reference in New Issue