HaniBlindBox/.kiro/specs/goods-system-migration/tasks.md
2026-01-02 20:31:24 +08:00

261 lines
10 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目录下创建Goods相关模型
- 包括GoodsListDto、GoodsDetailResponse、BoxDetailDto、CollectionDto、PrizeLogsResponse等
- _Requirements: 1.1-10.3_
- [x] 1.2 创建服务接口定义
- 在HoneyBox.Core/Interfaces目录下创建IGoodsService、ICollectionService、IPrizeService、IGoodsCacheService接口
- _Requirements: 1.1-10.3_
- [x] 1.3 创建数据库实体模型
- 创建Goods、GoodsList、GoodsType、GoodsExtend、GoodsCollection等实体
- 配置EF Core映射
- _Requirements: 1.1-10.3_
- [x] 1.4 注册服务到DI容器
- 在ServiceModule.cs中注册新服务
- _Requirements: 1.1-10.3_
- [x] 2. 商品列表服务实现
- [x] 2.1 查看PHP代码了解商品列表业务逻辑
- 阅读server/php/app/api/controller/Goods.php中的goods_list方法
- 理解type过滤、unlock_amount过滤、分页、排序逻辑
- 理解join_count统计逻辑
- _Requirements: 1.1-1.6_
- [x] 2.2 实现GoodsService - 商品列表
- 实现GetGoodsListAsync方法
- 实现type过滤逻辑
- 实现unlock_amount过滤逻辑
- 实现排序逻辑sort DESC, id DESC
- 实现join_count从Redis获取
- _Requirements: 1.1-1.6_
- [ ]* 2.3 编写商品列表属性测试
- **Property 1: 商品列表过滤和排序正确性**
- **Validates: Requirements 1.1, 1.4, 1.5, 1.6**
- [x] 3. 商品详情服务实现
- [x] 3.1 查看PHP代码了解商品详情业务逻辑
- 阅读server/php/app/api/controller/Goods.php中的goods_detail方法
- 理解奖品列表查询、概率计算、锁箱信息、参与用户统计
- _Requirements: 2.1-2.7_
- [x] 3.2 实现GoodsService - 商品详情
- 实现GetGoodsDetailAsync方法
- 实现自动选择箱号逻辑goods_num=0时
- 实现奖品列表查询
- 实现概率计算逻辑
- 实现锁箱信息查询
- 实现参与用户头像列表
- 实现收藏状态查询
- 实现限购信息查询
- _Requirements: 2.1-2.7_
- [ ]* 3.3 编写商品详情属性测试
- **Property 2: 商品详情数据完整性**
- **Property 3: 奖品概率计算正确性**
- **Validates: Requirements 2.1, 2.3, 2.4, 2.5, 2.6, 2.7**
- [x] 4. 商品子奖品服务实现
- [x] 4.1 查看PHP代码了解子奖品业务逻辑
- 阅读server/php/app/api/controller/Goods.php中的goods_children方法
- 理解子奖品查询和real_pro计算
- _Requirements: 3.1-3.3_
- [x] 4.2 实现GoodsService - 子奖品查询
- 实现GetGoodsChildrenAsync方法
- 实现real_pro计算逻辑
- 实现shang_info关联查询
- _Requirements: 3.1-3.3_
- [ ]* 4.3 编写子奖品属性测试
- **Property 4: 子奖品数据完整性**
- **Validates: Requirements 3.1, 3.2, 3.3**
- [x] 5. 商品扩展配置服务实现
- [x] 5.1 查看PHP代码了解扩展配置业务逻辑
- 阅读server/php/app/api/controller/Goods.php中的goods_extend方法
- 理解配置优先级(商品配置 > 类型默认配置)
- _Requirements: 4.1-4.3_
- [x] 5.2 实现GoodsService - 扩展配置
- 实现GetGoodsExtendAsync方法
- 实现配置优先级逻辑
- _Requirements: 4.1-4.3_
- [x] 6. Checkpoint - 核心商品服务测试验证
- 确保商品列表、详情、子奖品、扩展配置服务测试通过
- 如有问题请询问用户
- [x] 7. 箱号管理服务实现
- [x] 7.1 查看PHP代码了解箱号管理业务逻辑
- 阅读server/php/app/api/controller/Goods.php中的goods_num_list、goods_num_detail方法
- 理解箱号分组、排序、余量统计逻辑
- _Requirements: 5.1-5.4_
- [x] 7.2 实现GoodsService - 箱号列表
- 实现GetBoxListAsync方法
- 实现箱号分组逻辑每10个一组
- _Requirements: 5.1_
- [x] 7.3 实现GoodsService - 箱号详情
- 实现GetBoxDetailAsync方法
- 实现排序逻辑(箱号升序/降序、余量降序)
- 实现余量统计
- 实现goodslist摘要
- _Requirements: 5.2-5.4_
- [ ]* 7.4 编写箱号管理属性测试
- **Property 5: 箱号管理数据正确性**
- **Validates: Requirements 5.1, 5.2, 5.3, 5.4**
- [x] 8. 收藏服务实现
- [x] 8.1 查看PHP代码了解收藏业务逻辑
- 阅读server/php/app/api/controller/Goods.php中的collection、collection_list方法
- 理解收藏/取消收藏逻辑
- _Requirements: 6.1-6.4_
- [x] 8.2 实现CollectionService
- 实现ToggleCollectionAsync方法收藏/取消收藏)
- 实现GetCollectionListAsync方法收藏列表
- 实现IsCollectedAsync方法检查收藏状态
- 实现重复收藏检查
- _Requirements: 6.1-6.4_
- [ ]* 8.3 编写收藏服务属性测试
- **Property 6: 收藏操作往返一致性**
- **Validates: Requirements 6.1, 6.2, 6.4**
- [x] 9. 奖品统计服务实现
- [x] 9.1 查看PHP代码了解奖品统计业务逻辑
- 阅读server/php/app/api/controller/Goods.php中的goods_prize_count、goods_prize_content方法
- 理解统计计算逻辑
- _Requirements: 7.1-7.2_
- [x] 9.2 实现PrizeService - 奖品统计
- 实现GetPrizeCountAsync方法
- 实现GetPrizeContentAsync方法
- _Requirements: 7.1-7.2_
- [x] 10. 中奖记录服务实现
- [x] 10.1 查看PHP代码了解中奖记录业务逻辑
- 阅读server/php/app/api/controller/Goods.php中的goods_prize_logs方法
- 理解分类筛选、分页逻辑
- _Requirements: 8.1-8.4_
- [x] 10.2 实现PrizeService - 中奖记录
- 实现GetPrizeLogsAsync方法
- 实现shang_id筛选
- 实现分类列表查询
- 实现用户信息、奖品信息关联
- _Requirements: 8.1-8.4_
- [ ]* 10.3 编写中奖记录属性测试
- **Property 7: 中奖记录数据完整性**
- **Validates: Requirements 8.1, 8.2, 8.3, 8.4**
- [x] 11. 缓存服务实现
- [x] 11.1 实现GoodsCacheService
- 实现GetJoinCountAsync方法
- 实现IncrementJoinCountAsync方法
- 实现InvalidateGoodsCacheAsync方法
- 配置缓存过期时间
- _Requirements: 9.1-9.4_
- [x] 12. Checkpoint - 服务层测试验证
- 确保所有服务层单元测试通过
- 确保所有属性测试通过
- 如有问题请询问用户
- [x] 13. 控制器实现 - GoodsController
- [x] 13.1 实现商品列表接口 POST /goods_list
- 调用GoodsService.GetGoodsListAsync
- 更新API接口文档标记迁移状态
- _Requirements: 1.1-1.6_
- [x] 13.2 实现商品详情接口 POST /goods_detail
- 调用GoodsService.GetGoodsDetailAsync
- 更新API接口文档标记迁移状态
- _Requirements: 2.1-2.7_
- [x] 13.3 实现商品子奖品接口 POST /goods_children
- 调用GoodsService.GetGoodsChildrenAsync
- 更新API接口文档标记迁移状态
- _Requirements: 3.1-3.3_
- [x] 13.4 实现商品扩展配置接口 POST /goods_extend
- 调用GoodsService.GetGoodsExtendAsync
- 更新API接口文档标记迁移状态
- _Requirements: 4.1-4.3_
- [x] 13.5 实现箱号列表接口 POST /goods_num_list
- 调用GoodsService.GetBoxListAsync
- 更新API接口文档标记迁移状态
- _Requirements: 5.1_
- [x] 13.6 实现箱号详情接口 POST /goods_num_detail
- 调用GoodsService.GetBoxDetailAsync
- 更新API接口文档标记迁移状态
- _Requirements: 5.2-5.4_
- [x] 13.7 实现奖品数量统计接口 POST /goods_prize_count
- 调用PrizeService.GetPrizeCountAsync
- 更新API接口文档标记迁移状态
- _Requirements: 7.1_
- [x] 13.8 实现奖品内容接口 POST /goods_prize_content
- 调用PrizeService.GetPrizeContentAsync
- 更新API接口文档标记迁移状态
- _Requirements: 7.2_
- [x] 13.9 实现中奖记录接口 POST /goods_prize_logs
- 调用PrizeService.GetPrizeLogsAsync
- 更新API接口文档标记迁移状态
- _Requirements: 8.1-8.4_
- [x] 14. 控制器实现 - CollectionController
- [x] 14.1 实现收藏/取消收藏接口 POST /collection
- 调用CollectionService.ToggleCollectionAsync
- 更新API接口文档标记迁移状态
- _Requirements: 6.1-6.3_
- [x] 14.2 实现收藏列表接口 POST /collection_list
- 调用CollectionService.GetCollectionListAsync
- 更新API接口文档标记迁移状态
- _Requirements: 6.4_
- [x] 15. Checkpoint - 控制器测试验证
- 确保所有控制器接口可正常访问
- 使用Postman或HTTP文件测试各接口
- 如有问题请询问用户
- [x] 16. API响应格式验证
- [x] 16.1 验证所有接口响应格式
- 确保status、msg、data结构一致
- 确保字段命名与PHP API一致snake_case
- _Requirements: 10.1, 10.3_
- [ ]* 16.2 编写API格式属性测试
- **Property 8: API响应格式一致性**
- **Validates: Requirements 10.1, 10.3**
- [x] 17. 集成测试
- [x] 17.1 编写商品列表集成测试
- 测试完整的商品查询流程
- 测试分类筛选
- _Requirements: 1.1-1.6_
- [x] 17.2 编写商品详情集成测试
- 测试商品详情查询
- 测试概率计算
- _Requirements: 2.1-2.7_
- [x] 17.3 编写收藏功能集成测试
- 测试收藏/取消收藏流程
- _Requirements: 6.1-6.4_
- [x] 18. 文档更新和最终验证
- [x] 18.1 更新API接口文档
- 确认所有迁移接口都已标记
- 记录新接口地址
- _Requirements: 10.4_
- [x] 18.2 创建HTTP测试文件
- 在HoneyBox.Api目录下创建goods-system.http测试文件
- 包含所有商品系统相关接口的测试请求
- [x] 19. 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代码了解详细业务逻辑确保功能一致性