HaniBlindBox/.kiro/specs/order-system-migration/tasks.md
2026-01-02 22:30:21 +08:00

338 lines
15 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Implementation Plan: 订单系统迁移
## Overview
本任务列表将PHP订单系统迁移到.NET 8按照接口优先级逐个迁移。每迁移一个接口前需要先查看PHP代码了解详细业务逻辑迁移完成后需要在API接口文档.md中标记迁移状态。
## Tasks
- [x] 1. 基础设施准备
- [x] 1.1 创建订单相关的DTO和Request/Response模型
- 在HoneyBox.Model/Models/Order目录下创建相关模型
- 包括OrderMoneyRequest、OrderBuyRequest、OrderListDto、OrderDetailDto等
- 包括WarehouseIndexRequest、WarehouseItemDto、SendRequest、RecoveryResultDto等
- _Requirements: 1.1-18.4_
- [x] 1.2 创建服务接口定义
- 在HoneyBox.Core/Interfaces目录下创建IOrderService、IWarehouseService接口
- _Requirements: 1.1-18.4_
- [x] 1.3 创建数据库实体模型(如果尚未存在)
- 确认Order、OrderList、Delivery、Recovery等实体存在
- 配置EF Core映射
- _Requirements: 1.1-18.4_
- [x] 1.4 注册服务到DI容器
- 在ServiceModule.cs中注册OrderService、WarehouseService
- _Requirements: 1.1-18.4_
- [x] 2. 一番赏订单金额计算服务实现
- [x] 2.1 查看PHP代码了解一番赏订单金额计算业务逻辑
- 阅读server/php/app/api/controller/Order.php中的ordermoney方法
- 理解优惠券抵扣、余额抵扣、积分抵扣、哈尼券抵扣逻辑
- 理解商品扩展配置对支付方式的影响
- _Requirements: 1.1-1.6_
- [x] 2.2 实现OrderService - 一番赏订单金额计算
- 实现CalculateOrderMoneyAsync方法
- 实现优惠券验证和抵扣逻辑
- 实现余额、积分、哈尼券抵扣逻辑
- 实现购买限制验证
- _Requirements: 1.1-1.6_
- [ ]* 2.3 编写订单金额计算属性测试
- **Property 1: 订单金额计算正确性**
- **Validates: Requirements 1.1, 1.2, 1.3, 1.4, 1.5**
- [x] 3. 一番赏订单创建服务实现
- [x] 3.1 查看PHP代码了解一番赏订单创建业务逻辑
- 阅读server/php/app/api/controller/Order.php中的orderbuy方法
- 理解订单创建、库存扣减、资产扣减、微信支付调用逻辑
- _Requirements: 2.1-2.6_
- [x] 3.2 实现OrderService - 一番赏订单创建
- 实现CreateOrderAsync方法
- 实现库存验证和扣减逻辑
- 实现用户资产扣减逻辑
- 实现订单记录创建
- 实现微信支付参数生成调用现有WechatService
- _Requirements: 2.1-2.6_
- [ ]* 3.3 编写订单创建属性测试
- **Property 2: 订单创建数据完整性**
- **Validates: Requirements 2.1, 2.2**
- [x] 4. 无限赏订单服务实现
- [x] 4.1 查看PHP代码了解无限赏订单业务逻辑
- 阅读server/php/app/api/controller/Order.php中的infinite_ordermoney、infinite_orderbuy方法
- 理解无限赏特有的业务逻辑
- _Requirements: 3.1-3.3, 4.1-4.3_
- [x] 4.2 实现OrderService - 无限赏订单金额计算
- 实现CalculateInfiniteOrderMoneyAsync方法
- _Requirements: 3.1-3.3_
- [x] 4.3 实现OrderService - 无限赏订单创建
- 实现CreateInfiniteOrderAsync方法
- _Requirements: 4.1-4.3_
- [x] 5. 商城订单金额计算服务实现
- [x] 5.1 查看PHP代码了解商城订单业务逻辑
- 阅读server/php/app/api/controller/Order.php中的mall_ordermoney方法
- 理解商城订单特有的业务逻辑
- _Requirements: 5.1-5.3_
- [x] 5.2 实现OrderService - 商城订单金额计算
- 实现CalculateMallOrderMoneyAsync方法
- _Requirements: 5.1-5.3_
- [x] 6. Checkpoint - 订单计算和创建服务测试验证
- 确保订单金额计算、订单创建服务测试通过
- 如有问题请询问用户
- [x] 7. 订单查询服务实现
- [x] 7.1 查看PHP代码了解订单查询业务逻辑
- 阅读server/php/app/api/controller/Order.php中的order_list、order_detail方法
- 理解订单列表查询、订单详情查询逻辑
- _Requirements: 6.1-6.4, 7.1-7.3_
- [x] 7.2 实现OrderService - 订单列表查询
- 实现GetOrderListAsync方法
- 实现分页逻辑
- _Requirements: 6.1-6.4_
- [x] 7.3 实现OrderService - 订单详情查询
- 实现GetOrderDetailAsync方法
- 实现订单权限验证
- _Requirements: 7.1-7.3_
- [ ]* 7.4 编写订单列表属性测试
- **Property 5: 订单列表分页正确性**
- **Validates: Requirements 6.1, 6.3, 6.4**
- [x] 8. 抽奖结果查询服务实现
- [x] 8.1 查看PHP代码了解抽奖结果查询业务逻辑
- 阅读server/php/app/api/controller/Order.php中的prizeorderlog、infinite_prizeorderlog方法
- 理解抽奖结果查询逻辑
- _Requirements: 8.1-8.3, 9.1-9.2_
- [x] 8.2 实现OrderService - 一番赏抽奖结果查询
- 实现GetPrizeOrderLogAsync方法
- _Requirements: 8.1-8.3_
- [x] 8.3 实现OrderService - 无限赏抽奖结果查询
- 实现GetInfinitePrizeOrderLogAsync方法
- _Requirements: 9.1-9.2_
- [x] 9. Checkpoint - 订单查询服务测试验证
- 确保订单列表、订单详情、抽奖结果查询服务测试通过
- 如有问题请询问用户
- [x] 10. 仓库首页服务实现
- [x] 10.1 查看PHP代码了解仓库首页业务逻辑
- 阅读server/php/app/api/controller/Warehouse.php中的warehouse_index方法
- 理解仓库物品查询、状态筛选逻辑
- _Requirements: 10.1-10.3_
- [x] 10.2 实现WarehouseService - 仓库首页查询
- 实现GetWarehouseIndexAsync方法
- 实现状态筛选逻辑
- 实现分页逻辑
- _Requirements: 10.1-10.3_
- [x] 11. 奖品回收服务实现
- [x] 11.1 查看PHP代码了解奖品回收业务逻辑
- 阅读server/php/app/api/controller/Warehouse.php中的warehouse_recovery方法
- 理解回收金额计算、余额增加、状态更新逻辑
- _Requirements: 11.1-11.5_
- [x] 11.2 实现WarehouseService - 奖品回收
- 实现RecoveryPrizesAsync方法
- 实现回收金额计算
- 实现用户余额增加
- 实现奖品状态更新
- _Requirements: 11.1-11.5_
- [ ]* 11.3 编写奖品回收属性测试
- **Property 3: 仓库物品状态一致性**
- **Validates: Requirements 11.2, 11.3**
- [x] 12. 奖品发货服务实现
- [x] 12.1 查看PHP代码了解奖品发货业务逻辑
- 阅读server/php/app/api/controller/Warehouse.php中的warehouse_send、warehouse_send_confirm方法
- 理解发货申请、确认发货逻辑
- _Requirements: 12.1-12.5, 13.1-13.2_
- [x] 12.2 实现WarehouseService - 奖品发货申请
- 实现SendPrizesAsync方法
- 实现地址信息验证
- 实现发货记录创建
- 实现奖品状态更新
- _Requirements: 12.1-12.5_
- [x] 12.3 实现WarehouseService - 确认发货
- 实现ConfirmSendAsync方法
- _Requirements: 13.1-13.2_
- [ ]* 12.4 编写发货服务属性测试
- **Property 4: 发货记录完整性**
- **Validates: Requirements 12.1, 12.2, 12.3, 12.4**
- [x] 13. 发货和回收记录查询服务实现
- [x] 13.1 查看PHP代码了解记录查询业务逻辑
- 阅读server/php/app/api/controller/Warehouse.php中的warehouse_send_record、warehouse_send_record_detail、warehouse_recovery_record方法
- 理解记录查询逻辑
- _Requirements: 14.1-14.3, 15.1-15.3, 16.1-16.2_
- [x] 13.2 实现WarehouseService - 发货记录查询
- 实现GetSendRecordsAsync方法
- _Requirements: 14.1-14.3_
- [x] 13.3 实现WarehouseService - 发货记录详情
- 实现GetSendRecordDetailAsync方法
- _Requirements: 15.1-15.3_
- [x] 13.4 实现WarehouseService - 回收记录查询
- 实现GetRecoveryRecordsAsync方法
- _Requirements: 16.1-16.2_
- [x] 14. 物流信息查询服务实现
- [x] 14.1 查看PHP代码了解物流查询业务逻辑
- 阅读server/php/app/api/controller/Warehouse.php中的warehouse_order_logistics方法
- 理解物流信息查询逻辑
- _Requirements: 17.1-17.3_
- [x] 14.2 实现WarehouseService - 物流信息查询
- 实现GetLogisticsAsync方法
- _Requirements: 17.1-17.3_
- [x] 15. Checkpoint - 仓库服务测试验证
- 确保所有仓库服务测试通过
- 如有问题请询问用户
- [x] 16. 控制器实现 - OrderController
- [x] 16.1 实现一番赏订单金额计算接口 POST /ordermoney
- 调用OrderService.CalculateOrderMoneyAsync
- 更新API接口文档标记迁移状态
- _Requirements: 1.1-1.6_
- [x] 16.2 实现一番赏订单创建接口 POST /orderbuy
- 调用OrderService.CreateOrderAsync
- 更新API接口文档标记迁移状态
- _Requirements: 2.1-2.6_
- [x] 16.3 实现无限赏订单金额计算接口 POST /infinite_ordermoney
- 调用OrderService.CalculateInfiniteOrderMoneyAsync
- 更新API接口文档标记迁移状态
- _Requirements: 3.1-3.3_
- [x] 16.4 实现无限赏订单创建接口 POST /infinite_orderbuy
- 调用OrderService.CreateInfiniteOrderAsync
- 更新API接口文档标记迁移状态
- _Requirements: 4.1-4.3_
- [x] 16.5 实现商城订单金额计算接口 POST /mall_ordermoney
- 调用OrderService.CalculateMallOrderMoneyAsync
- 更新API接口文档标记迁移状态
- _Requirements: 5.1-5.3_
- [x] 16.6 实现订单列表接口 POST /order_list
- 调用OrderService.GetOrderListAsync
- 更新API接口文档标记迁移状态
- _Requirements: 6.1-6.4_
- [x] 16.7 实现订单详情接口 POST /order_detail
- 调用OrderService.GetOrderDetailAsync
- 更新API接口文档标记迁移状态
- _Requirements: 7.1-7.3_
- [x] 16.8 实现一番赏抽奖结果接口 POST /prizeorderlog
- 调用OrderService.GetPrizeOrderLogAsync
- 更新API接口文档标记迁移状态
- _Requirements: 8.1-8.3_
- [x] 16.9 实现无限赏抽奖结果接口 POST /infinite_prizeorderlog
- 调用OrderService.GetInfinitePrizeOrderLogAsync
- 更新API接口文档标记迁移状态
- _Requirements: 9.1-9.2_
- [x] 17. 控制器实现 - WarehouseController
- [x] 17.1 实现仓库首页接口 POST /warehouse_index
- 调用WarehouseService.GetWarehouseIndexAsync
- 更新API接口文档标记迁移状态
- _Requirements: 10.1-10.3_
- [x] 17.2 实现奖品回收接口 POST /warehouse_recovery
- 调用WarehouseService.RecoveryPrizesAsync
- 更新API接口文档标记迁移状态
- _Requirements: 11.1-11.5_
- [x] 17.3 实现奖品发货接口 POST /warehouse_send
- 调用WarehouseService.SendPrizesAsync
- 更新API接口文档标记迁移状态
- _Requirements: 12.1-12.5_
- [x] 17.4 实现确认发货接口 POST /warehouse_send_confirm
- 调用WarehouseService.ConfirmSendAsync
- 更新API接口文档标记迁移状态
- _Requirements: 13.1-13.2_
- [x] 17.5 实现发货记录接口 POST /warehouse_send_record
- 调用WarehouseService.GetSendRecordsAsync
- 更新API接口文档标记迁移状态
- _Requirements: 14.1-14.3_
- [x] 17.6 实现发货记录详情接口 POST /warehouse_send_record_detail
- 调用WarehouseService.GetSendRecordDetailAsync
- 更新API接口文档标记迁移状态
- _Requirements: 15.1-15.3_
- [x] 17.7 实现回收记录接口 POST /warehouse_recovery_record
- 调用WarehouseService.GetRecoveryRecordsAsync
- 更新API接口文档标记迁移状态
- _Requirements: 16.1-16.2_
- [x] 17.8 实现物流信息接口 POST /warehouse_order_logistics
- 调用WarehouseService.GetLogisticsAsync
- 更新API接口文档标记迁移状态
- _Requirements: 17.1-17.3_
- [x] 18. Checkpoint - 控制器测试验证
- 确保所有控制器接口可正常访问
- 使用Postman或HTTP文件测试各接口
- 如有问题请询问用户
- [x] 19. API响应格式验证
- [x] 19.1 验证所有接口响应格式
- 确保status、msg、data结构一致
- 确保字段命名与PHP API一致snake_case
- _Requirements: 18.1-18.4_
- [ ]* 19.2 编写API格式属性测试
- **Property 6: API响应格式一致性**
- **Validates: Requirements 18.1-18.4**
- [x] 20. 集成测试
- [x] 20.1 编写订单金额计算集成测试
- 测试完整的订单金额计算流程
- 测试各种抵扣组合
- _Requirements: 1.1-1.6_
- [x] 20.2 编写订单创建集成测试
- 测试订单创建流程
- 测试库存扣减
- Note: 部分测试因InMemory数据库不支持事务而被跳过
- _Requirements: 2.1-2.6_
- [x] 20.3 编写仓库功能集成测试
- 测试奖品回收流程
- 测试奖品发货流程
- Note: 部分测试因InMemory数据库不支持事务和ExecuteUpdate而被跳过
- _Requirements: 10.1-17.3_
- [x] 21. 文档更新和最终验证
- [x] 21.1 更新API接口文档
- 确认所有迁移接口都已标记
- 记录新接口地址
- _Requirements: 18.1-18.4_
- [x] 21.2 创建HTTP测试文件
- 在HoneyBox.Api目录下创建order-system.http测试文件
- 包含所有订单系统相关接口的测试请求
- [ ] 22. Final Checkpoint - 完整功能验证
- 确保所有测试通过
- 确保API文档已更新
- 确保与前端兼容性
- 如有问题请询问用户
## Notes
- Tasks marked with `*` are optional and can be skipped for faster MVP
- Each task references specific requirements for traceability
- Checkpoints ensure incremental validation
- Property tests validate universal correctness properties
- Unit tests validate specific examples and edge cases
- 每迁移完成一个接口都需要在docs/API接口文档.md中标记迁移状态和新接口地址
- 迁移前必须先查看PHP代码了解详细业务逻辑确保功能一致性
- 订单系统涉及支付,需要特别注意数据一致性和事务处理
- 仓库系统涉及用户资产变更,需要确保金额计算准确
## 接口迁移清单
| 序号 | PHP接口 | 新接口地址 | 状态 |
|------|---------|-----------|------|
| 1 | POST /ordermoney | POST /api/ordermoney | ✅ |
| 2 | POST /orderbuy | POST /api/orderbuy | ✅ |
| 3 | POST /infinite_ordermoney | POST /api/infinite_ordermoney | ✅ |
| 4 | POST /infinite_orderbuy | POST /api/infinite_orderbuy | ✅ |
| 5 | POST /mall_ordermoney | POST /api/mall_ordermoney | ✅ |
| 6 | POST /order_list | POST /api/order_list | ✅ |
| 7 | POST /order_detail | POST /api/order_detail | ✅ |
| 8 | POST /prizeorderlog | POST /api/prizeorderlog | ✅ |
| 9 | POST /infinite_prizeorderlog | POST /api/infinite_prizeorderlog | ✅ |
| 10 | POST /warehouse_index | POST /api/warehouse_index | ✅ |
| 11 | POST /warehouse_recovery | POST /api/warehouse_recovery | ✅ |
| 12 | POST /warehouse_send | POST /api/warehouse_send | ✅ |
| 13 | POST /warehouse_send_confirm | POST /api/warehouse_send_confirm | ✅ |
| 14 | POST /warehouse_send_record | POST /api/warehouse_send_record | ✅ |
| 15 | POST /warehouse_send_record_detail | POST /api/warehouse_send_record_detail | ✅ |
| 16 | POST /warehouse_recovery_record | POST /api/warehouse_recovery_record | ✅ |
| 17 | POST /warehouse_order_logistics | POST /api/warehouse_order_logistics | ✅ |