rwadurian/backend
hailin 390e5ccb19 fix(pre-planting): 用 orderNo 替代 BigInt 自增 ID 作为 CDC 关联键
问题:Debezium CDC 事件中 Prisma @map("order_id") 字段以 DB 列名
order_id 发送,而代码访问 data.id 导致 undefined → BigInt 转换失败。

修复方案(遵循"用 orderNo 业务键关联"原则):
- pre-planting-order-synced.handler.ts:
  * PrePlantingOrderSyncResult 改为 { orderNo: string }
  * handleCreateOrSnapshot/handleUpdate 均用 order_no 字段
  * syncToTrackingTable upsert where 改为 { orderNo }
  * ensureAdoptionMarker 入参从 orderId bigint 改为 orderNo string
    - markerAdoptionId = PRE_PLANTING_SOURCE_ID_OFFSET + hash(orderNo)
  * isAlreadyDistributed 改为 findUnique({ where: { orderNo } })
  * calculateAfterCommit 传 result.orderNo
- pre-planting-contribution.service.ts:
  * calculateForPrePlantingOrder 入参从 bigint 改为 string(orderNo)
  * findUnique({ where: { orderNo } }) 查询,用存储的 originalOrderId 计算偏移
  * 所有日志/update 中 originalOrderId 替换为 orderNo
  * processUndistributedOrders 改为传 order.orderNo,orderBy 改为 createdAt
- schema.prisma:orderNo 字段新增 @unique 约束
- migration SQL:CREATE UNIQUE INDEX on order_no 列

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 02:31:04 -08:00
..
.claude refactor: simplify mpc-service to gateway mode 2025-12-06 17:16:14 -08:00
api-gateway fix(kong): 添加3171预种计划API网关路由 2026-02-26 18:24:49 -08:00
infrastructure chore(docker): 为 mpc-system、api-gateway、infrastructure 添加时区配置 2025-12-23 18:35:09 -08:00
mpc-system fix(service-party-android): 修复导入钱包签名时 'party not registered' 错误 2026-02-02 03:24:14 -08:00
scripts fix(scripts): 修正容器名为 rwa-blockchain-service 2025-12-15 10:34:25 -08:00
services fix(pre-planting): 用 orderNo 替代 BigInt 自增 ID 作为 CDC 关联键 2026-02-28 02:31:04 -08:00
.env.windows fix(referral): 修复 getMyReferralInfo 使用 userId 而不是 accountSequence 的问题 2025-12-14 05:05:03 -08:00
docker-compose.windows.yml fix(mining-service): Redis DB 11 冲突修复,迁移至 DB 16 2026-01-30 02:22:20 -08:00