Files
huang 91c9bbfeb8
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m35s
feat: 实现账号与佣金管理模块
新增功能:
- 店铺佣金查询:店铺佣金统计、店铺佣金记录列表、店铺提现记录
- 佣金提现审批:提现申请列表、审批通过、审批拒绝
- 提现配置管理:配置列表、新增配置、获取当前生效配置
- 企业管理:企业列表、创建、更新、删除、获取详情
- 企业卡授权:授权列表、批量授权、批量取消授权、统计
- 客户账号管理:账号列表、创建、更新状态、重置密码
- 我的佣金:佣金统计、佣金记录、提现申请、提现记录

数据库变更:
- 扩展 tb_commission_withdrawal_request 新增提现单号等字段
- 扩展 tb_account 新增 is_primary 字段
- 扩展 tb_commission_record 新增 shop_id、balance_after
- 扩展 tb_commission_withdrawal_setting 新增每日提现次数限制
- 扩展 tb_iot_card、tb_device 新增 shop_id 冗余字段
- 新建 tb_enterprise_card_authorization 企业卡授权表
- 新建 tb_asset_allocation_record 资产分配记录表
- 数据迁移:owner_type 枚举值 agent 统一为 shop

测试:
- 新增 7 个单元测试文件覆盖各服务
- 修复集成测试 Redis 依赖问题
2026-01-21 18:20:44 +08:00

121 lines
3.1 KiB
Markdown
Raw Permalink 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.
# 实现任务清单
**Change ID**: `add-my-commission`
---
## 阶段 1: DTO 定义 (20 分钟)
### Task 1.1: 创建 DTO 文件
**文件**: `internal/model/my_commission_dto.go`
**实现内容**:
- [x] 1.1.1 `MyCommissionSummaryResp` 佣金概览响应
- [x] 1.1.2 `CreateMyWithdrawalReq` 发起提现请求
- [x] 1.1.3 `CreateMyWithdrawalResp` 发起提现响应
- [x] 1.1.4 `MyWithdrawalListReq` 提现记录查询请求
- [x] 1.1.5 `MyCommissionRecordListReq` 佣金明细查询请求
- [x] 1.1.6 `MyCommissionRecordItem` 佣金记录列表项
- [x] 1.1.7 `MyCommissionRecordPageResult` 佣金记录分页响应
**验证**:
- [x] 字段完整
- [x] 验证标签正确
---
## 阶段 2: Service 层 (1.5 小时)
### Task 2.1: 创建 MyCommission Service
**文件**: `internal/service/my_commission/service.go`
**实现内容**:
- [x] 2.1.1 `GetCommissionSummary(ctx)` - 我的佣金概览
- [x] 2.1.2 `CreateWithdrawalRequest(ctx, req)` - 发起提现
- [x] 2.1.3 `ListMyWithdrawalRequests(ctx, req)` - 我的提现记录
- [x] 2.1.4 `ListMyCommissionRecords(ctx, req)` - 我的佣金明细
**业务逻辑**:
- [x] 2.1.5 从上下文获取当前用户的 shop_id
- [x] 2.1.6 提现验证(金额、余额、次数限制)
- [x] 2.1.7 计算手续费
- [x] 2.1.8 冻结钱包余额
- [x] 2.1.9 生成提现单号
**验证**:
- [x] 提现验证逻辑正确
- [x] 钱包操作正确
---
## 阶段 3: Handler 层 (45 分钟)
### Task 3.1: 创建 Handler
**文件**: `internal/handler/admin/my_commission.go`
**实现内容**:
- [x] 3.1.1 `GetSummary` - GET /api/admin/my/commission-summary
- [x] 3.1.2 `CreateWithdrawal` - POST /api/admin/my/withdrawal-requests
- [x] 3.1.3 `ListWithdrawals` - GET /api/admin/my/withdrawal-requests
- [x] 3.1.4 `ListRecords` - GET /api/admin/my/commission-records
**验证**:
- [x] 参数校验正确
- [x] 仅代理商用户可访问Service 层校验)
---
### Task 3.2: 路由注册
**文件**: `internal/routes/my_commission.go`
**实现内容**:
- [x] 3.2.1 注册四个 API 路由
- [x] 3.2.2 配置权限仅代理商用户Service 层校验)
---
### Task 3.3: Bootstrap 注册
**实现内容**:
- [x] 3.3.1 `internal/bootstrap/services.go` - 添加 MyCommission Service
- [x] 3.3.2 `internal/bootstrap/handlers.go` - 添加 MyCommission Handler
- [x] 3.3.3 `internal/bootstrap/types.go` - 添加 MyCommission Handler 类型
- [x] 3.3.4 `internal/routes/admin.go` - 注册 MyCommission 路由
---
## 阶段 4: 测试 (45 分钟)
### Task 4.1: 功能测试
**实现内容**:
- [x] 4.1.1 佣金概览测试
- [x] 4.1.2 发起提现测试
- [x] 4.1.3 提现记录查询测试
- [x] 4.1.4 佣金明细查询测试
### Task 4.2: 边界测试
**实现内容**:
- [x] 4.2.1 最低金额验证
- [x] 4.2.2 每日次数限制验证
- [x] 4.2.3 余额不足验证
- [x] 4.2.4 无提现配置时的处理
---
## 完成标准
- [x] 所有 DTO 定义完成
- [x] Service 层业务逻辑完成
- [x] Handler 层 API 实现完成
- [x] 提现验证逻辑正确
- [x] 钱包冻结操作正确
- [x] 仅代理商用户可访问
- [x] 编译通过
- [x] 功能测试通过