rwadurian/backend/services/planting-service/prisma/migrations
hailin 26dcd1d2de fix(pre-planting): 修复购买省市名称存储及多项购买失败问题
== 问题修复 ==

1. 购买失败:NestJS 返回数组 message 导致 Flutter 类型转换错误
   - 症状:List<dynamic> is not a subtype of String
   - 原因:ValidationPipe 校验失败时 message 字段为 List<String>(每条字段错误一条),
     Flutter _handleDioError 直接用 data['message'] 作为 String 参数导致运行时崩溃
   - 修复:api_client.dart 中对 rawMsg 判断是否 List,若是则 join(', ')

2. 续购省市为空导致 400 校验失败
   - 症状:续购时后端返回 "provinceCode should not be empty"
   - 原因:购买页面续购分支未传入省市,导致 provinceCode/cityCode 为 null
   - 修复:pre_planting_purchase_page.dart 中续购时使用 _position?.provinceCode

3. 购买请求携带 provinceName/cityName 被后端 forbidNonWhitelisted 拒绝
   - 症状:400 "property provinceName should not exist"
   - 原因:前端发送名称字段,但 PurchasePrePlantingDto 未声明这些字段
   - 修复:在 DTO 中添加 @IsOptional() 的 provinceName / cityName 字段

== 功能新增 ==

4. 预种持仓表新增省市名称存储(参照正式认种的处理方式)
   - 迁移:20260228000000_add_province_city_name_to_position
   - Prisma schema:PrePlantingPosition 新增 provinceName / cityName 可空字段
   - 聚合根:addPortions() 接受可选 provinceName/cityName,首购时写入,续购忽略
   - Repository:save/toDomain 同步处理名称字段
   - Application Service:purchasePortion 透传名称,getPosition 返回名称
   - Controller:purchase 端点透传 dto.provinceName / dto.cityName

5. 预种合并时算力精确回滚(contribution-service)
   - 新增 9a-team 步骤:事务内查询即将作废的 TEAM_LEVEL/TEAM_BONUS 算力记录
   - 新增 9c-team 步骤:按账户聚合后精确 decrement 上游推荐人的各档位 pending 和 effective
   - 目的:确保旧份额算力精确回滚,避免新树算力 9d 叠加后造成双倍计入

== UI 优化 ==
   - 购买页面将 "USDT" 改为 "绿积分"(单价、总价、成功提示)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 08:02:14 -08:00
..
20241204000000_init feat(db): add Prisma migrations for wallet-service and planting-service 2025-12-09 20:30:23 -08:00
20241210000000_add_outbox feat(planting): implement Outbox Pattern with consumer acknowledgment (B方案) 2025-12-09 21:32:16 -08:00
20241210100000_add_payment_compensation feat(planting): add payment reliability improvements 2025-12-10 06:31:54 -08:00
20241224000000_add_contract_signing feat(contract-signing): 添加电子合同签署功能及单点配置优化 2025-12-24 20:12:12 -08:00
20241225000000_add_signed_pdf_url feat(planting-service): 实现合同签名和PDF云存储功能 2025-12-25 03:35:15 -08:00
20241225100000_add_contract_no fix(migration): 移除 DO $$ 块,Prisma 不支持 PL/pgSQL 2025-12-25 05:55:42 -08:00
20241225110000_add_account_sequence_to_order feat(planting-service): 订单表添加 accountSequence,实现合同恢复任务 2025-12-25 08:19:36 -08:00
20260120000000_add_debezium_heartbeat fix: migration 使用 IF NOT EXISTS 防止重复创建 + clean 去掉 --remove-orphans 2026-01-30 00:37:29 -08:00
20260223000000_add_pre_planting_tables fix(pre-planting): 修复 5 个预种模块 Bug + 补全 3 服务 migration 2026-02-23 18:09:14 -08:00
20260226100000_add_price_supplement feat(pricing): 认种树动态定价涨价系统(总部运营成本压力涨价) 2026-02-26 03:02:56 -08:00
20260227000000_add_transfer_locked_count feat(planting-service): 添加 transfer_locked_count 列的数据库迁移 2026-02-26 22:57:15 -08:00
20260228000000_add_province_city_name_to_position fix(pre-planting): 修复购买省市名称存储及多项购买失败问题 2026-02-28 08:02:14 -08:00
migration_lock.toml chore(prisma): add missing migration_lock.toml files 2025-12-09 21:39:20 -08:00