diff --git a/backend/services/wallet-service/src/application/event-handlers/withdrawal-status.handler.ts b/backend/services/wallet-service/src/application/event-handlers/withdrawal-status.handler.ts index ab5f529e..f1964b0c 100644 --- a/backend/services/wallet-service/src/application/event-handlers/withdrawal-status.handler.ts +++ b/backend/services/wallet-service/src/application/event-handlers/withdrawal-status.handler.ts @@ -464,6 +464,25 @@ export class WithdrawalStatusHandler implements OnModuleInit { } this.logger.log(`[FAILED] Refunded ${totalAmount.toString()} USDT (amount + fee) to account ${orderRecord.accountSequence} (version: ${currentVersion} -> ${currentVersion + 1})`); + + // 记录 UNFREEZE 流水(修复:之前缺失导致审计缺口) + await tx.ledgerEntry.create({ + data: { + accountSequence: orderRecord.accountSequence, + userId: orderRecord.userId, + entryType: LedgerEntryType.UNFREEZE, + amount: newAvailable.minus(currentAvailable), + assetType: 'USDT', + balanceAfter: newAvailable, + refOrderId: orderRecord.orderNo, + memo: `提现失败退款: ${payload.error}`, + payloadJson: { + toAddress: orderRecord.toAddress, + chainType: orderRecord.chainType, + error: payload.error, + }, + }, + }); } else { this.logger.error(`[FAILED] Wallet not found for accountSequence: ${orderRecord.accountSequence}, userId: ${orderRecord.userId}`); }