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:
parent
05aacc0d5b
commit
299c82fc4f
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue