From d9c238702edfa67cda1513ecbce5d967e1bb8f8d Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 28 Feb 2026 12:34:01 -0800 Subject: [PATCH] =?UTF-8?q?feat(pre-planting):=20=E9=A2=84=E7=A7=8D?= =?UTF-8?q?=E6=9D=83=E7=9B=8A=E6=B5=81=E6=B0=B4=E5=A4=87=E6=B3=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0[=E9=A2=84=E7=A7=8D]=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wallet-service 新增 prePlantingPrefix 私有方法, 当 FundAllocationItem.metadata.source === 'PRE_PLANTING' 时, 在流水 memo 中添加 "[预种] " 前缀,使用户可区分预种与普通认种权益。 仅影响 pre-planting 新增的分配流水,不修改任何普通认种 memo。 Co-Authored-By: Claude Sonnet 4.6 --- .../internal-pre-planting.controller.ts | 1 + .../services/pre-planting-reward.service.ts | 2 ++ .../services/wallet-application.service.ts | 21 +++++++++++++------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/backend/services/planting-service/src/pre-planting/api/controllers/internal-pre-planting.controller.ts b/backend/services/planting-service/src/pre-planting/api/controllers/internal-pre-planting.controller.ts index 9549b943..c651ce3e 100644 --- a/backend/services/planting-service/src/pre-planting/api/controllers/internal-pre-planting.controller.ts +++ b/backend/services/planting-service/src/pre-planting/api/controllers/internal-pre-planting.controller.ts @@ -283,6 +283,7 @@ export class InternalPrePlantingController { targetId: e.recipientAccountSequence, allocationType: e.rightType, amount: Number(e.usdtAmount), + metadata: { source: 'PRE_PLANTING' }, })), }); diff --git a/backend/services/planting-service/src/pre-planting/application/services/pre-planting-reward.service.ts b/backend/services/planting-service/src/pre-planting/application/services/pre-planting-reward.service.ts index d8aaefed..f262fa2a 100644 --- a/backend/services/planting-service/src/pre-planting/application/services/pre-planting-reward.service.ts +++ b/backend/services/planting-service/src/pre-planting/application/services/pre-planting-reward.service.ts @@ -109,6 +109,8 @@ export class PrePlantingRewardService { targetId: a.recipientAccountSequence, allocationType: a.rightType, amount: a.amount, + // source 标识供 wallet-service 在流水备注中加"[预种]"前缀,与普通认种权益区分 + metadata: { source: 'PRE_PLANTING' }, })), }); 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 73e89c4a..4149ae28 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 @@ -1038,6 +1038,15 @@ export class WalletApplicationService { }; } + /** + * [新增] 预种来源备注前缀 + * 当 metadata.source === 'PRE_PLANTING' 时返回 "[预种] ",否则返回空字符串。 + * 只影响预种权益流水,不修改普通认种的任何备注。 + */ + private prePlantingPrefix(allocation: FundAllocationItem): string { + return allocation.metadata?.source === 'PRE_PLANTING' ? '[预种] ' : ''; + } + /** * 检查分配是否已存在(幂等性检查) * 通过查询流水表判断该订单+账户+分配类型是否已处理 @@ -1117,7 +1126,7 @@ export class WalletApplicationService { entryType: LedgerEntryType.REWARD_TO_SETTLEABLE, amount, refOrderId: orderId, - memo: `${allocation.allocationType} allocation (direct settleable)`, + memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} allocation (direct settleable)`, payloadJson: { allocationType: allocation.allocationType, metadata: allocation.metadata, @@ -1156,7 +1165,7 @@ export class WalletApplicationService { entryType: LedgerEntryType.REWARD_PENDING, amount, refOrderId: orderId, - memo: `${allocation.allocationType} allocation`, + memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} allocation`, payloadJson: { allocationType: allocation.allocationType, expireAt: expireAt.toISOString(), @@ -1220,8 +1229,8 @@ export class WalletApplicationService { amount, refOrderId: orderId, memo: isUserAccount - ? `${allocation.allocationType} - community authorization allocation (settleable)` - : `${allocation.allocationType} - headquarters community allocation (settleable)`, + ? `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - community authorization allocation (settleable)` + : `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - headquarters community allocation (settleable)`, payloadJson: { allocationType: allocation.allocationType, metadata: allocation.metadata, @@ -1283,7 +1292,7 @@ export class WalletApplicationService { entryType: LedgerEntryType.REWARD_TO_SETTLEABLE, amount, refOrderId: orderId, - memo: `${allocation.allocationType} - region account allocation (settleable)`, + memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - region account allocation (settleable)`, payloadJson: { allocationType: allocation.allocationType, metadata: allocation.metadata, @@ -1343,7 +1352,7 @@ export class WalletApplicationService { entryType: LedgerEntryType.SYSTEM_ALLOCATION, amount, refOrderId: orderId, - memo: `${allocation.allocationType} - system account allocation`, + memo: `${this.prePlantingPrefix(allocation)}${allocation.allocationType} - system account allocation`, payloadJson: { allocationType: allocation.allocationType, metadata: allocation.metadata,