fix(wallet): 流水备注增加来源用户AccountSequence和订单号

所有分配类型(系统账户/区域账户/用户钱包/社区权益)的流水 memo
从原来的纯英文标识改为:中文描述 | 来源: 账户序列号 (订单号)
例: [预种] 预种成本费 | 来源: D26022600000 (PPLMM6670DO9VETGK)

修改方法:
- 新增 buildAllocationMemo() 统一从 metadata 中提取 memo/sourceAccountSequence
- 替换 allocateToSystemAccount/allocateToUserWallet/allocateCommunityRight/allocateToRegionAccount 中的 memo 生成
- 兼容无 metadata 的历史调用(回退到 allocationType 英文标识)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-28 20:08:52 -08:00
parent 05aacc0d5b
commit 299c82fc4f
1 changed files with 24 additions and 7 deletions

View File

@ -1047,6 +1047,25 @@ export class WalletApplicationService {
return allocation.metadata?.source === 'PRE_PLANTING' ? '[预种] ' : ''; 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, entryType: LedgerEntryType.REWARD_TO_SETTLEABLE,
amount, amount,
refOrderId: orderId, refOrderId: orderId,
memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} allocation (direct settleable)`, memo: this.buildAllocationMemo(allocation, orderId, '可结算'),
payloadJson: { payloadJson: {
allocationType: allocation.allocationType, allocationType: allocation.allocationType,
metadata: allocation.metadata, metadata: allocation.metadata,
@ -1165,7 +1184,7 @@ export class WalletApplicationService {
entryType: LedgerEntryType.REWARD_PENDING, entryType: LedgerEntryType.REWARD_PENDING,
amount, amount,
refOrderId: orderId, refOrderId: orderId,
memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} allocation`, memo: this.buildAllocationMemo(allocation, orderId, '待领取'),
payloadJson: { payloadJson: {
allocationType: allocation.allocationType, allocationType: allocation.allocationType,
expireAt: expireAt.toISOString(), expireAt: expireAt.toISOString(),
@ -1228,9 +1247,7 @@ export class WalletApplicationService {
entryType: LedgerEntryType.REWARD_TO_SETTLEABLE, entryType: LedgerEntryType.REWARD_TO_SETTLEABLE,
amount, amount,
refOrderId: orderId, refOrderId: orderId,
memo: isUserAccount memo: this.buildAllocationMemo(allocation, orderId, isUserAccount ? '社区授权' : '归总部'),
? `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - community authorization allocation (settleable)`
: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - headquarters community allocation (settleable)`,
payloadJson: { payloadJson: {
allocationType: allocation.allocationType, allocationType: allocation.allocationType,
metadata: allocation.metadata, metadata: allocation.metadata,
@ -1292,7 +1309,7 @@ export class WalletApplicationService {
entryType: LedgerEntryType.REWARD_TO_SETTLEABLE, entryType: LedgerEntryType.REWARD_TO_SETTLEABLE,
amount, amount,
refOrderId: orderId, refOrderId: orderId,
memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - region account allocation (settleable)`, memo: this.buildAllocationMemo(allocation, orderId, '可结算'),
payloadJson: { payloadJson: {
allocationType: allocation.allocationType, allocationType: allocation.allocationType,
metadata: allocation.metadata, metadata: allocation.metadata,
@ -1352,7 +1369,7 @@ export class WalletApplicationService {
entryType: LedgerEntryType.SYSTEM_ALLOCATION, entryType: LedgerEntryType.SYSTEM_ALLOCATION,
amount, amount,
refOrderId: orderId, refOrderId: orderId,
memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - system account allocation`, memo: this.buildAllocationMemo(allocation, orderId),
payloadJson: { payloadJson: {
allocationType: allocation.allocationType, allocationType: allocation.allocationType,
metadata: allocation.metadata, metadata: allocation.metadata,