From b705c6aa9164bb7dd09910acd5a2f49f4702f14f Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 13 Dec 2025 18:53:21 -0800 Subject: [PATCH] =?UTF-8?q?feat(wallet-service):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=88=86=E4=BA=AB=E6=9D=83=E7=9B=8A=E6=B1=A0=E8=B4=A6=E6=88=B7?= =?UTF-8?q?S0000000005?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 S0000000005 分享权益池系统账户 (user_id = -5) - 修改 reward-service: 无推荐人的分享权益(500 USDT/棵)进入分享权益池 - 与总部社区账户(S0000000001)分离,便于单独追踪无推荐人的分享权益 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../domain/services/reward-calculation.service.ts | 13 ++++++++----- .../migration.sql | 11 +++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 backend/services/wallet-service/prisma/migrations/20241214100000_add_share_right_pool_account/migration.sql diff --git a/backend/services/reward-service/src/domain/services/reward-calculation.service.ts b/backend/services/reward-service/src/domain/services/reward-calculation.service.ts index c8edade1..ee38b19c 100644 --- a/backend/services/reward-service/src/domain/services/reward-calculation.service.ts +++ b/backend/services/reward-service/src/domain/services/reward-calculation.service.ts @@ -59,6 +59,9 @@ const OPERATION_FEE_ACCOUNT_ID = BigInt(3); // RWAD 1号底池账户ID (需要在系统初始化时创建) const RWAD_POOL_ACCOUNT_ID = BigInt(4); +// 分享权益池账户ID (无推荐人时分享权益进入此账户) +const SHARE_RIGHT_POOL_USER_ID = BigInt(-5); + @Injectable() export class RewardCalculationService { private readonly logger = new Logger(RewardCalculationService.name); @@ -370,15 +373,15 @@ export class RewardCalculationService { })]; } } else { - // 无推荐人,进总部社区 - this.logger.debug(`[calculateShareRights] no referrer -> HEADQUARTERS`); + // 无推荐人,进分享权益池 (S0000000005) + this.logger.debug(`[calculateShareRights] no referrer -> SHARE_RIGHT_POOL (S0000000005)`); return [RewardLedgerEntry.createSettleable({ - userId: HEADQUARTERS_COMMUNITY_USER_ID, - accountSequence: 'S0000000001', + userId: SHARE_RIGHT_POOL_USER_ID, + accountSequence: 'S0000000005', rewardSource, usdtAmount, hashpowerAmount: hashpower, - memo: '分享权益:无推荐人,进总部社区', + memo: '分享权益:无推荐人,进分享权益池', })]; } } diff --git a/backend/services/wallet-service/prisma/migrations/20241214100000_add_share_right_pool_account/migration.sql b/backend/services/wallet-service/prisma/migrations/20241214100000_add_share_right_pool_account/migration.sql new file mode 100644 index 00000000..ef98a0c3 --- /dev/null +++ b/backend/services/wallet-service/prisma/migrations/20241214100000_add_share_right_pool_account/migration.sql @@ -0,0 +1,11 @@ +-- Add share right pool account for users without referrers +-- When a user plants a tree but has no inviter, the 500 USDT share right +-- goes to this dedicated pool instead of the headquarters community account + +-- S0000000005: 分享权益池 (Share Right Pool) +-- Receives: 无推荐人用户的分享权益 500 USDT per tree +INSERT INTO "wallet_accounts" ( + "account_sequence", "user_id", "status", "created_at", "updated_at" +) VALUES ( + 'S0000000005', -5, 'ACTIVE', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP +) ON CONFLICT ("account_sequence") DO NOTHING;