Files
junhong_cmp_fiber/openspec/changes/archive/2026-01-24-add-standalone-card-allocation/tasks.md
huang 194078674a
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m45s
feat: 实现单卡资产分配与回收功能
- 新增单卡分配/回收 API(支持 ICCID 列表、号段范围、筛选条件三种选卡方式)
- 新增资产分配记录查询 API(支持多条件筛选和分页)
- 新增 AssetAllocationRecord 模型、Store、Service、Handler 完整实现
- 扩展 IotCardStore 新增批量更新、号段查询、筛选查询等方法
- 修复 GORM Callback 处理 slice 类型(BatchCreate)的问题
- 新增完整的单元测试和集成测试
- 同步 OpenSpec 规范并归档 change
2026-01-24 15:46:15 +08:00

77 lines
3.1 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.
# Tasks: 单卡资产分配功能
## 1. DTO 定义
- [x] 1.1 创建 AllocateStandaloneCardsRequest DTO支持三种选卡方式
- [x] 1.2 创建 AllocateStandaloneCardsResponse DTO返回成功/失败统计)
- [x] 1.3 创建 RecallStandaloneCardsRequest DTO
- [x] 1.4 创建 RecallStandaloneCardsResponse DTO
- [x] 1.5 创建 ListAssetAllocationRecordRequest DTO
- [x] 1.6 创建 AssetAllocationRecordResponse DTO
- [x] 1.7 创建 ListAssetAllocationRecordResponse DTO
## 2. Store 层
- [x] 2.1 创建 AssetAllocationRecordStore
- [x] 2.1.1 实现 Create 方法
- [x] 2.1.2 实现 BatchCreate 方法
- [x] 2.1.3 实现 GetByID 方法
- [x] 2.1.4 实现 List 方法(支持筛选和分页)
- [x] 2.2 实现 IotCardStore.BatchUpdateShopIDAndStatus 方法
- [x] 2.3 实现 IotCardStore.GetStandaloneByICCIDRange 方法(号段查询)
- [x] 2.4 实现 IotCardStore.GetStandaloneByFilters 方法(筛选条件查询,排除已绑定设备的卡)
- [x] 2.5 实现 IotCardStore.GetByICCIDs 方法
- [x] 2.6 实现 IotCardStore.GetBoundCardIDs 方法
## 3. Service 层
- [x] 3.1 创建 AssetAllocationRecordService
- [x] 3.1.1 实现 List 方法
- [x] 3.1.2 实现 GetByID 方法
- [x] 3.2 实现 IotCardService.AllocateCards 方法
- [x] 3.2.1 校验目标店铺是当前用户的直属下级
- [x] 3.2.2 根据选卡方式获取待分配的卡列表
- [x] 3.2.3 校验卡是单卡(未绑定设备)
- [x] 3.2.4 校验卡状态和所有权
- [x] 3.2.5 批量更新 shop_id 和 status
- [x] 3.2.6 创建分配记录
- [x] 3.3 实现 IotCardService.RecallCards 方法
- [x] 3.3.1 校验来源店铺是当前用户的直属下级
- [x] 3.3.2 根据选卡方式获取待回收的卡列表
- [x] 3.3.3 校验卡是单卡(未绑定设备)
- [x] 3.3.4 批量更新 shop_id平台→NULL店铺→回收方ID和 status
- [x] 3.3.5 创建回收记录
## 4. Handler 层
- [x] 4.1 创建 AssetAllocationRecordHandler
- [x] 4.1.1 实现 List 方法
- [x] 4.1.2 实现 GetByID 方法
- [x] 4.2 实现 IotCardHandler.AllocateCards 方法
- [x] 4.3 实现 IotCardHandler.RecallCards 方法
## 5. 路由注册
- [x] 5.1 注册 POST /api/admin/iot-cards/standalone/allocate
- [x] 5.2 注册 POST /api/admin/iot-cards/standalone/recall
- [x] 5.3 注册 GET /api/admin/asset-allocation-records
- [x] 5.4 注册 GET /api/admin/asset-allocation-records/:id
- [x] 5.5 更新 Bootstraphandlers.go、services.go、stores.go、types.go
- [x] 5.6 更新文档生成器cmd/api/docs.go 和 cmd/gendocs/main.go
## 6. 测试
- [x] 6.1 AssetAllocationRecordStore 单元测试
- [x] 6.2 IotCardStore.BatchUpdateShopIDAndStatus 单元测试
- [x] 6.3 IotCardStore.GetStandaloneByICCIDRange 单元测试
- [x] 6.4 IotCardStore.GetStandaloneByFilters 单元测试
- [x] 6.5 IotCardStore.GetByICCIDs 单元测试
- [x] 6.6 IotCardStore.GetBoundCardIDs 单元测试
- [x] 6.7 分配 API 集成测试TestStandaloneCardAllocation_AllocateByList
- [x] 6.8 回收 API 集成测试TestStandaloneCardAllocation_Recall
- [x] 6.9 分配记录查询 API 集成测试TestAssetAllocationRecord_List
## 7. 文档更新
- [x] 7.1 同步 delta spec 到主规范