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 依赖问题
81 lines
2.5 KiB
Markdown
81 lines
2.5 KiB
Markdown
# Change: 佣金提现审批模块
|
||
|
||
## Why
|
||
|
||
平台需要对代理商的佣金提现申请进行审批管理:
|
||
1. 查看所有待处理的提现申请列表
|
||
2. 审批通过提现申请(扣除佣金、记录流水)
|
||
3. 拒绝提现申请(解冻佣金)
|
||
|
||
这是账号管理-佣金提现模块的核心功能。
|
||
|
||
## What Changes
|
||
|
||
### 新增 API 接口
|
||
|
||
| 方法 | 路径 | 说明 |
|
||
|------|------|------|
|
||
| GET | `/api/admin/commission/withdrawal-requests` | 提现申请列表(审批视图) |
|
||
| POST | `/api/admin/commission/withdrawal-requests/:id/approve` | 审批通过 |
|
||
| POST | `/api/admin/commission/withdrawal-requests/:id/reject` | 拒绝 |
|
||
|
||
### 技术实现
|
||
|
||
- 新增 Handler:`internal/handler/admin/commission_withdrawal.go`
|
||
- 新增 Service:`internal/service/commission_withdrawal/service.go`
|
||
- 新增 DTO:`internal/model/dto/commission_withdrawal_dto.go`
|
||
- 扩展 Store:钱包操作、流水记录
|
||
|
||
### 业务逻辑
|
||
|
||
**审批通过流程**:
|
||
1. 验证提现申请存在且状态为待审批
|
||
2. 验证当前用户有审批权限
|
||
3. 如果修正了金额,重新计算手续费和实际到账金额
|
||
4. 更新状态为已通过(status=2)
|
||
5. 从店铺佣金钱包扣除对应金额(解冻并扣除)
|
||
6. 记录钱包交易流水
|
||
7. 记录处理人和处理时间
|
||
|
||
**拒绝流程**:
|
||
1. 验证提现申请存在且状态为待审批
|
||
2. 更新状态为已拒绝(status=3)
|
||
3. 解冻店铺佣金钱包中的冻结金额
|
||
4. 记录钱包交易流水
|
||
5. 记录处理人、处理时间和拒绝原因
|
||
|
||
**审批状态**:
|
||
- 1:待审批
|
||
- 2:已通过
|
||
- 3:已拒绝
|
||
|
||
## Impact
|
||
|
||
### 影响的规范
|
||
- **新增 Capability**:`commission-withdrawal-approval`
|
||
|
||
### 影响的代码
|
||
|
||
**新增文件**(约 350 行):
|
||
- `internal/handler/admin/commission_withdrawal.go`(~100 行)
|
||
- `internal/service/commission_withdrawal/service.go`(~200 行)
|
||
- `internal/model/dto/commission_withdrawal_dto.go`(~50 行)
|
||
|
||
**修改文件**(约 50 行):
|
||
- `internal/store/postgres/wallet_store.go`(扣款、解冻方法)
|
||
- `internal/store/postgres/wallet_transaction_store.go`(创建流水)
|
||
|
||
### 兼容性
|
||
- ✅ 向后兼容:新增 API,不影响现有功能
|
||
|
||
## Dependencies
|
||
|
||
- 依赖提案:`add-commission-model-changes`
|
||
- 依赖现有模型:`CommissionWithdrawalRequest`、`Wallet`、`WalletTransaction`
|
||
|
||
## Testing Strategy
|
||
|
||
1. **单元测试**:审批流程、钱包操作
|
||
2. **集成测试**:完整审批流程(申请→通过/拒绝)
|
||
3. **并发测试**:同一申请的并发审批处理
|