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,