Commit Graph

2 Commits

Author SHA1 Message Date
hailin a11e4d0261 fix(pre-planting): 修复 5 个预种模块 Bug + 补全 3 服务 migration
Bug #1 (HIGH): allocateFunds 从 Prisma 事务内移到事务外
  - pre-planting-reward.service.ts: distributeRewards 拆为
    prepareAndPersistRewards(事务内持久化)+ executeAllocations(事务后转账)
  - pre-planting-application.service.ts: 事务后调用 executeAllocations

Bug #2 (HIGH): signContract 后触发 hasPlanted
  - 签约事务成功后发布 PlantingOrderPaid 到 planting-events topic
  - wallet-service 消费后执行 markUserAsPlanted + settleUserPendingRewards
  - event-publisher.service.ts: 新增 publishRawToPlantingEvents 方法

Bug #3 (MEDIUM): PENDING 推荐奖励改为全部 SETTLED
  - 与现有认种行为对齐,推荐奖励立即发放

Bug #4 (HIGH): 补全 3 个服务的数据库迁移文件
  - planting-service: 4 张预种表(orders/positions/merges/reward_entries)
  - admin-service: 1 张配置表(pre_planting_configs)+ 默认数据
  - contribution-service: 4 张 CDC 追踪表(synced_orders/positions/freeze_states/processed_cdc_events)

Bug #5 (LOW): 合并循环 if→while,支持一次购买多份触发多次合并

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:09:14 -08:00
hailin e1cd8ed7f2 feat(pre-planting): 3171 预种计划 2.0 算力集成(contribution-service CDC 模块)
Phase 5:将预种数据集成到 contribution-service 2.0 算力体系。

=== 新增文件(11 个) ===
- prisma/pre-planting/schema.prisma:独立 Prisma schema(4 张追踪表)
- PrePlantingPrismaService + Module:独立 PrismaClient
- PrePlantingCdcConsumerService:独立 CDC 消费者(consumer group: contribution-pre-planting-cdc)
- PrePlantingOrderSyncedHandler:订单 CDC handler + synced_adoptions marker 插入
- PrePlantingPositionSyncedHandler:持仓 CDC handler
- PrePlantingCdcDispatcher:CDC 事件分发器
- PrePlantingContributionService:1/5 算力计算(复用领域计算器)
- PrePlantingFreezeScheduler:每日冻结/解冻调度(凌晨 5 点)
- PrePlantingCdcModule:模块注册
- constants.ts:10B 偏移量、冻结期限等常量

=== 隔离保证 ===
- 独立 Kafka consumer group(contribution-pre-planting-cdc)
- 独立 CDC topics(cdc.pre-planting.public.*)
- 独立 Prisma schema + generated client
- sourceAdoptionId 使用 10,000,000,000 偏移避免 ID 冲突
- synced_adoptions marker: contributionDistributed=true + treeCount=0
- 不更新 NetworkAdoptionProgress(预种不推高全网算力系数)
- 现有代码文件零修改(仅 app.module.ts 加 1 行 import)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 05:25:14 -08:00