From 299c82fc4f82aae9b59809106b580f59e5b7e143 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 28 Feb 2026 20:08:52 -0800 Subject: [PATCH] =?UTF-8?q?fix(wallet):=20=E6=B5=81=E6=B0=B4=E5=A4=87?= =?UTF-8?q?=E6=B3=A8=E5=A2=9E=E5=8A=A0=E6=9D=A5=E6=BA=90=E7=94=A8=E6=88=B7?= =?UTF-8?q?AccountSequence=E5=92=8C=E8=AE=A2=E5=8D=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 所有分配类型(系统账户/区域账户/用户钱包/社区权益)的流水 memo 从原来的纯英文标识改为:中文描述 | 来源: 账户序列号 (订单号) 例: [预种] 预种成本费 | 来源: D26022600000 (PPLMM6670DO9VETGK) 修改方法: - 新增 buildAllocationMemo() 统一从 metadata 中提取 memo/sourceAccountSequence - 替换 allocateToSystemAccount/allocateToUserWallet/allocateCommunityRight/allocateToRegionAccount 中的 memo 生成 - 兼容无 metadata 的历史调用(回退到 allocationType 英文标识) Co-Authored-By: Claude Opus 4.6 --- .../services/wallet-application.service.ts | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 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 4149ae28..39db5706 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 @@ -1047,6 +1047,25 @@ export class WalletApplicationService { return allocation.metadata?.source === 'PRE_PLANTING' ? '[预种] ' : ''; } + /** + * 构建包含来源信息的分配备注 + * 格式: [预种] {中文memo} | 来源: {sourceAccountSequence} ({orderId}) + * 如果 metadata 中有中文 memo 则优先使用,否则使用 allocationType 英文标识 + */ + private buildAllocationMemo(allocation: FundAllocationItem, orderId: string, suffix?: string): string { + const prefix = this.prePlantingPrefix(allocation); + const memo = allocation.metadata?.memo || allocation.allocationType; + const sourceAccount = allocation.metadata?.sourceAccountSequence; + const parts = [prefix + memo]; + if (sourceAccount) { + parts.push(`来源: ${sourceAccount} (${orderId})`); + } + if (suffix) { + parts.push(suffix); + } + return parts.join(' | '); + } + /** * 检查分配是否已存在(幂等性检查) * 通过查询流水表判断该订单+账户+分配类型是否已处理 @@ -1126,7 +1145,7 @@ export class WalletApplicationService { entryType: LedgerEntryType.REWARD_TO_SETTLEABLE, amount, refOrderId: orderId, - memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} allocation (direct settleable)`, + memo: this.buildAllocationMemo(allocation, orderId, '可结算'), payloadJson: { allocationType: allocation.allocationType, metadata: allocation.metadata, @@ -1165,7 +1184,7 @@ export class WalletApplicationService { entryType: LedgerEntryType.REWARD_PENDING, amount, refOrderId: orderId, - memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} allocation`, + memo: this.buildAllocationMemo(allocation, orderId, '待领取'), payloadJson: { allocationType: allocation.allocationType, expireAt: expireAt.toISOString(), @@ -1228,9 +1247,7 @@ export class WalletApplicationService { entryType: LedgerEntryType.REWARD_TO_SETTLEABLE, amount, refOrderId: orderId, - memo: isUserAccount - ? `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - community authorization allocation (settleable)` - : `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - headquarters community allocation (settleable)`, + memo: this.buildAllocationMemo(allocation, orderId, isUserAccount ? '社区授权' : '归总部'), payloadJson: { allocationType: allocation.allocationType, metadata: allocation.metadata, @@ -1292,7 +1309,7 @@ export class WalletApplicationService { entryType: LedgerEntryType.REWARD_TO_SETTLEABLE, amount, refOrderId: orderId, - memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - region account allocation (settleable)`, + memo: this.buildAllocationMemo(allocation, orderId, '可结算'), payloadJson: { allocationType: allocation.allocationType, metadata: allocation.metadata, @@ -1352,7 +1369,7 @@ export class WalletApplicationService { entryType: LedgerEntryType.SYSTEM_ALLOCATION, amount, refOrderId: orderId, - memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - system account allocation`, + memo: this.buildAllocationMemo(allocation, orderId), payloadJson: { allocationType: allocation.allocationType, metadata: allocation.metadata,