From 96f031da3564de3199841fc254696423cf2f877d Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 12 Dec 2025 19:15:47 -0800 Subject: [PATCH] =?UTF-8?q?fix(wallet-service):=20=E4=BF=AE=E5=A4=8D=20all?= =?UTF-8?q?ocateToUserWallet=20=E4=BD=BF=E7=94=A8=20accountSequence=20?= =?UTF-8?q?=E6=9F=A5=E6=89=BE=E9=92=B1=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - targetId 现在是 accountSequence (如 D2512120001),不再是 userId - 移除无效的 BigInt(targetId) 转换 - 从 wallet 对象获取 userId 用于流水记录和缓存失效 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../services/wallet-application.service.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/backend/services/wallet-service/src/application/services/wallet-application.service.ts b/backend/services/wallet-service/src/application/services/wallet-application.service.ts index 5b22c4af..53d470f8 100644 --- a/backend/services/wallet-service/src/application/services/wallet-application.service.ts +++ b/backend/services/wallet-service/src/application/services/wallet-application.service.ts @@ -612,15 +612,10 @@ export class WalletApplicationService { allocation: FundAllocationItem, orderId: string, ): Promise { - const userId = BigInt(allocation.targetId); - - // 优先按 accountSequence 查找,如果未找到则按 userId 查找 - let wallet = await this.walletRepo.findByAccountSequence(allocation.targetId); + // targetId 是 accountSequence (如 D2512120001),优先用它查找钱包 + const wallet = await this.walletRepo.findByAccountSequence(allocation.targetId); if (!wallet) { - wallet = await this.walletRepo.findByUserId(userId); - } - if (!wallet) { - this.logger.warn(`Wallet not found for user/accountSequence ${allocation.targetId}, skipping allocation`); + this.logger.warn(`Wallet not found for accountSequence ${allocation.targetId}, skipping allocation`); return; } @@ -640,7 +635,7 @@ export class WalletApplicationService { // 记录流水 const ledgerEntry = LedgerEntry.create({ accountSequence: wallet.accountSequence, - userId: UserId.create(userId), + userId: wallet.userId, // 从钱包获取 userId entryType: LedgerEntryType.REWARD_PENDING, amount, refOrderId: orderId, @@ -653,7 +648,7 @@ export class WalletApplicationService { }); await this.ledgerRepo.save(ledgerEntry); - await this.walletCacheService.invalidateWallet(userId); + await this.walletCacheService.invalidateWallet(wallet.userId.value); this.logger.debug( `Allocated ${allocation.amount} USDT to user ${allocation.targetId} for ${allocation.allocationType}`,