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

10 KiB
Raw Blame History

Implementation Plan: 商品系统迁移

Overview

本任务列表将PHP商品系统迁移到.NET 8按照接口优先级逐个迁移。每迁移一个接口前需要先查看PHP代码了解详细业务逻辑迁移完成后需要在API接口文档.md中标记迁移状态。

Tasks

  • 1. 基础设施准备

    • 1.1 创建商品相关的DTO和Request/Response模型
      • 在HoneyBox.Model/Models目录下创建Goods相关模型
      • 包括GoodsListDto、GoodsDetailResponse、BoxDetailDto、CollectionDto、PrizeLogsResponse等
      • Requirements: 1.1-10.3
    • 1.2 创建服务接口定义
      • 在HoneyBox.Core/Interfaces目录下创建IGoodsService、ICollectionService、IPrizeService、IGoodsCacheService接口
      • Requirements: 1.1-10.3
    • 1.3 创建数据库实体模型
      • 创建Goods、GoodsList、GoodsType、GoodsExtend、GoodsCollection等实体
      • 配置EF Core映射
      • Requirements: 1.1-10.3
    • 1.4 注册服务到DI容器
      • 在ServiceModule.cs中注册新服务
      • Requirements: 1.1-10.3
  • 2. 商品列表服务实现

    • 2.1 查看PHP代码了解商品列表业务逻辑
      • 阅读server/php/app/api/controller/Goods.php中的goods_list方法
      • 理解type过滤、unlock_amount过滤、分页、排序逻辑
      • 理解join_count统计逻辑
      • Requirements: 1.1-1.6
    • 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
  • 3. 商品详情服务实现

    • 3.1 查看PHP代码了解商品详情业务逻辑
      • 阅读server/php/app/api/controller/Goods.php中的goods_detail方法
      • 理解奖品列表查询、概率计算、锁箱信息、参与用户统计
      • Requirements: 2.1-2.7
    • 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
  • 4. 商品子奖品服务实现

    • 4.1 查看PHP代码了解子奖品业务逻辑
      • 阅读server/php/app/api/controller/Goods.php中的goods_children方法
      • 理解子奖品查询和real_pro计算
      • Requirements: 3.1-3.3
    • 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
  • 5. 商品扩展配置服务实现

    • 5.1 查看PHP代码了解扩展配置业务逻辑
      • 阅读server/php/app/api/controller/Goods.php中的goods_extend方法
      • 理解配置优先级(商品配置 > 类型默认配置)
      • Requirements: 4.1-4.3
    • 5.2 实现GoodsService - 扩展配置
      • 实现GetGoodsExtendAsync方法
      • 实现配置优先级逻辑
      • Requirements: 4.1-4.3
  • 6. Checkpoint - 核心商品服务测试验证

    • 确保商品列表、详情、子奖品、扩展配置服务测试通过
    • 如有问题请询问用户
  • 7. 箱号管理服务实现

    • 7.1 查看PHP代码了解箱号管理业务逻辑
      • 阅读server/php/app/api/controller/Goods.php中的goods_num_list、goods_num_detail方法
      • 理解箱号分组、排序、余量统计逻辑
      • Requirements: 5.1-5.4
    • 7.2 实现GoodsService - 箱号列表
      • 实现GetBoxListAsync方法
      • 实现箱号分组逻辑每10个一组
      • Requirements: 5.1
    • 7.3 实现GoodsService - 箱号详情
      • 实现GetBoxDetailAsync方法
      • 实现排序逻辑(箱号升序/降序、余量降序)
      • 实现余量统计
      • 实现goodslist摘要
      • Requirements: 5.2-5.4
    • * 7.4 编写箱号管理属性测试
      • Property 5: 箱号管理数据正确性
      • Validates: Requirements 5.1, 5.2, 5.3, 5.4
  • 8. 收藏服务实现

    • 8.1 查看PHP代码了解收藏业务逻辑
      • 阅读server/php/app/api/controller/Goods.php中的collection、collection_list方法
      • 理解收藏/取消收藏逻辑
      • Requirements: 6.1-6.4
    • 8.2 实现CollectionService
      • 实现ToggleCollectionAsync方法收藏/取消收藏)
      • 实现GetCollectionListAsync方法收藏列表
      • 实现IsCollectedAsync方法检查收藏状态
      • 实现重复收藏检查
      • Requirements: 6.1-6.4
    • * 8.3 编写收藏服务属性测试
      • Property 6: 收藏操作往返一致性
      • Validates: Requirements 6.1, 6.2, 6.4
  • 9. 奖品统计服务实现

    • 9.1 查看PHP代码了解奖品统计业务逻辑
      • 阅读server/php/app/api/controller/Goods.php中的goods_prize_count、goods_prize_content方法
      • 理解统计计算逻辑
      • Requirements: 7.1-7.2
    • 9.2 实现PrizeService - 奖品统计
      • 实现GetPrizeCountAsync方法
      • 实现GetPrizeContentAsync方法
      • Requirements: 7.1-7.2
  • 10. 中奖记录服务实现

    • 10.1 查看PHP代码了解中奖记录业务逻辑
      • 阅读server/php/app/api/controller/Goods.php中的goods_prize_logs方法
      • 理解分类筛选、分页逻辑
      • Requirements: 8.1-8.4
    • 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
  • 11. 缓存服务实现

    • 11.1 实现GoodsCacheService
      • 实现GetJoinCountAsync方法
      • 实现IncrementJoinCountAsync方法
      • 实现InvalidateGoodsCacheAsync方法
      • 配置缓存过期时间
      • Requirements: 9.1-9.4
  • 12. Checkpoint - 服务层测试验证

    • 确保所有服务层单元测试通过
    • 确保所有属性测试通过
    • 如有问题请询问用户
  • 13. 控制器实现 - GoodsController

    • 13.1 实现商品列表接口 POST /goods_list
      • 调用GoodsService.GetGoodsListAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 1.1-1.6
    • 13.2 实现商品详情接口 POST /goods_detail
      • 调用GoodsService.GetGoodsDetailAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 2.1-2.7
    • 13.3 实现商品子奖品接口 POST /goods_children
      • 调用GoodsService.GetGoodsChildrenAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 3.1-3.3
    • 13.4 实现商品扩展配置接口 POST /goods_extend
      • 调用GoodsService.GetGoodsExtendAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 4.1-4.3
    • 13.5 实现箱号列表接口 POST /goods_num_list
      • 调用GoodsService.GetBoxListAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 5.1
    • 13.6 实现箱号详情接口 POST /goods_num_detail
      • 调用GoodsService.GetBoxDetailAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 5.2-5.4
    • 13.7 实现奖品数量统计接口 POST /goods_prize_count
      • 调用PrizeService.GetPrizeCountAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 7.1
    • 13.8 实现奖品内容接口 POST /goods_prize_content
      • 调用PrizeService.GetPrizeContentAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 7.2
    • 13.9 实现中奖记录接口 POST /goods_prize_logs
      • 调用PrizeService.GetPrizeLogsAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 8.1-8.4
  • 14. 控制器实现 - CollectionController

    • 14.1 实现收藏/取消收藏接口 POST /collection
      • 调用CollectionService.ToggleCollectionAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 6.1-6.3
    • 14.2 实现收藏列表接口 POST /collection_list
      • 调用CollectionService.GetCollectionListAsync
      • 更新API接口文档标记迁移状态
      • Requirements: 6.4
  • 15. Checkpoint - 控制器测试验证

    • 确保所有控制器接口可正常访问
    • 使用Postman或HTTP文件测试各接口
    • 如有问题请询问用户
  • 16. API响应格式验证

    • 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
  • 17. 集成测试

    • 17.1 编写商品列表集成测试
      • 测试完整的商品查询流程
      • 测试分类筛选
      • Requirements: 1.1-1.6
    • 17.2 编写商品详情集成测试
      • 测试商品详情查询
      • 测试概率计算
      • Requirements: 2.1-2.7
    • 17.3 编写收藏功能集成测试
      • 测试收藏/取消收藏流程
      • Requirements: 6.1-6.4
  • 18. 文档更新和最终验证

    • 18.1 更新API接口文档
      • 确认所有迁移接口都已标记
      • 记录新接口地址
      • Requirements: 10.4
    • 18.2 创建HTTP测试文件
      • 在HoneyBox.Api目录下创建goods-system.http测试文件
      • 包含所有商品系统相关接口的测试请求
  • 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代码了解详细业务逻辑确保功能一致性