feat: 实现账号与佣金管理模块
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m35s

新增功能:
- 店铺佣金查询:店铺佣金统计、店铺佣金记录列表、店铺提现记录
- 佣金提现审批:提现申请列表、审批通过、审批拒绝
- 提现配置管理:配置列表、新增配置、获取当前生效配置
- 企业管理:企业列表、创建、更新、删除、获取详情
- 企业卡授权:授权列表、批量授权、批量取消授权、统计
- 客户账号管理:账号列表、创建、更新状态、重置密码
- 我的佣金:佣金统计、佣金记录、提现申请、提现记录

数据库变更:
- 扩展 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 依赖问题
This commit is contained in:
2026-01-21 18:20:44 +08:00
parent 1489abe668
commit 91c9bbfeb8
89 changed files with 11958 additions and 159 deletions

View File

@@ -0,0 +1,111 @@
# 实现任务清单
**Change ID**: `add-customer-account-management`
---
## 阶段 1: DTO 定义 (20 分钟)
### Task 1.1: 创建 DTO 文件
**文件**: `internal/model/customer_account_dto.go`
**实现内容**:
- [x] 1.1.1 `CustomerAccountListReq` 列表请求(分页、筛选条件)
- [x] 1.1.2 `CustomerAccountItem` 列表响应项
- [x] 1.1.3 `CreateCustomerAccountReq` 新增请求
- [x] 1.1.4 `UpdateCustomerAccountReq` 编辑请求
- [x] 1.1.5 `UpdateCustomerAccountPasswordReq` 密码修改请求
- [x] 1.1.6 `UpdateCustomerAccountStatusReq` 状态修改请求
- [x] 1.1.7 `CustomerAccountPageResult` 分页响应
**验证**:
- [x] 字段完整
- [x] 验证标签正确
---
## 阶段 2: Service 层 (1 小时)
### Task 2.1: 创建 CustomerAccount Service
**文件**: `internal/service/customer_account/service.go`
**实现内容**:
- [x] 2.1.1 `List(ctx, req)` - 查询账号列表
- [x] 2.1.2 `Create(ctx, req)` - 新增代理商账号
- [x] 2.1.3 `Update(ctx, id, req)` - 编辑账号
- [x] 2.1.4 `UpdatePassword(ctx, id, password)` - 修改密码
- [x] 2.1.5 `UpdateStatus(ctx, id, status)` - 更新状态
**业务逻辑**:
- [x] 2.1.6 查询时过滤 `user_type IN (3, 4)`
- [x] 2.1.7 新增时只允许 UserType=3
- [x] 2.1.8 权限校验(账号所属店铺/企业在可见范围内)
**验证**:
- [x] 业务逻辑正确
- [x] 数据权限正确
---
## 阶段 3: Handler 层 (45 分钟)
### Task 3.1: 创建 Handler
**文件**: `internal/handler/admin/customer_account.go`
**实现内容**:
- [x] 3.1.1 `List` - GET /api/admin/customer-accounts
- [x] 3.1.2 `Create` - POST /api/admin/customer-accounts
- [x] 3.1.3 `Update` - PUT /api/admin/customer-accounts/:id
- [x] 3.1.4 `UpdatePassword` - PUT /api/admin/customer-accounts/:id/password
- [x] 3.1.5 `UpdateStatus` - PUT /api/admin/customer-accounts/:id/status
**验证**:
- [x] 参数校验正确
---
### Task 3.2: 路由注册
**文件**: `internal/routes/customer_account.go`
**实现内容**:
- [x] 3.2.1 注册五个 API 路由
---
### Task 3.3: Bootstrap 注册
**实现内容**:
- [x] 3.3.1 `internal/bootstrap/services.go` - 添加 CustomerAccount Service
- [x] 3.3.2 `internal/bootstrap/handlers.go` - 添加 CustomerAccount Handler
- [x] 3.3.3 `internal/bootstrap/types.go` - 添加 CustomerAccount Handler 类型
- [x] 3.3.4 `internal/routes/admin.go` - 注册 CustomerAccount 路由
---
## 阶段 4: 测试 (45 分钟)
### Task 4.1: 功能测试
**实现内容**:
- [x] 4.1.1 列表查询测试
- [x] 4.1.2 新增代理商账号测试
- [x] 4.1.3 编辑账号测试
- [x] 4.1.4 密码修改测试
- [x] 4.1.5 状态修改测试
- [x] 4.1.6 数据权限测试
---
## 完成标准
- [x] 所有 DTO 定义完成
- [x] Service 层业务逻辑完成
- [x] Handler 层 API 实现完成
- [x] 只能新增代理商账号
- [x] 数据权限正确
- [x] 编译通过
- [x] 功能测试通过