Revert "fix(wallet-service): 社区权益按 targetId 分配到正确账户"

This reverts commit 43a0e5f5e1.
This commit is contained in:
hailin 2025-12-26 04:52:01 -08:00
parent 43a0e5f5e1
commit 09cc696efa
1 changed files with 3 additions and 54 deletions

View File

@ -980,7 +980,7 @@ export class WalletApplicationService {
*
* - SHARE_RIGHT (): pending_rewards 24
* - PROVINCE_TEAM_RIGHT, PROVINCE_AREA_RIGHT, CITY_TEAM_RIGHT, CITY_AREA_RIGHT: 直接到账
* - COMMUNITY_RIGHT (): targetId
* - COMMUNITY_RIGHT (): S0000000001
*/
private async allocateToUserWallet(
allocation: FundAllocationItem,
@ -989,17 +989,9 @@ export class WalletApplicationService {
const amount = Money.USDT(allocation.amount);
const allocationType = allocation.allocationType;
// 社区权益:根据 targetId 判断分配目标
// - targetId 为 '1' 或 'S0000000001' 时进入总部社区账户
// - targetId 为用户账户D开头时进入该用户账户
// 社区权益直接进入总部社区账户 S0000000001
if (allocationType === 'COMMUNITY_RIGHT') {
const targetId = allocation.targetId;
if (targetId === '1' || targetId === 'S0000000001') {
await this.allocateToHeadquartersCommunity(allocation, orderId);
} else {
// 分配到具体用户的社区权益
await this.allocateCommunityRightToUser(allocation, orderId);
}
await this.allocateToHeadquartersCommunity(allocation, orderId);
return;
}
@ -1089,49 +1081,6 @@ export class WalletApplicationService {
}
}
/**
*
*
*/
private async allocateCommunityRightToUser(
allocation: FundAllocationItem,
orderId: string,
): Promise<void> {
const targetId = allocation.targetId;
const wallet = await this.walletRepo.findByAccountSequence(targetId);
if (!wallet) {
this.logger.warn(`Failed to find wallet for community right allocation: ${targetId}`);
return;
}
const amount = Money.USDT(allocation.amount);
// 社区权益直接进入可结算余额(与分享权益的处理类似但不进 pending
wallet.addSettleableReward(amount, Hashpower.create(0));
await this.walletRepo.save(wallet);
// 记录流水
const ledgerEntry = LedgerEntry.create({
accountSequence: wallet.accountSequence,
userId: wallet.userId,
entryType: LedgerEntryType.REWARD_TO_SETTLEABLE,
amount,
refOrderId: orderId,
memo: `${allocation.allocationType} allocation (direct settleable)`,
payloadJson: {
allocationType: allocation.allocationType,
metadata: allocation.metadata,
},
});
await this.ledgerRepo.save(ledgerEntry);
await this.walletCacheService.invalidateWallet(wallet.userId.value);
this.logger.debug(
`Allocated ${allocation.amount} USDT to user ${targetId} for ${allocation.allocationType} (community right)`,
);
}
/**
* S0000000001
*/