Files
junhong_cmp_fiber/openspec/changes/archive/2026-01-21-add-enterprise-management/tasks.md
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

120 lines
3.0 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.
# 实现任务清单
**Change ID**: `add-enterprise-management`
---
## 阶段 1: DTO 定义 (30 分钟)
### Task 1.1: 创建 DTO 文件
**文件**: `internal/model/enterprise_dto.go`
**实现内容**:
- [x] 1.1.1 `CreateEnterpriseReq` 请求结构(企业信息 + 登录信息)
- [x] 1.1.2 `UpdateEnterpriseReq` 编辑请求
- [x] 1.1.3 `EnterpriseListReq` 列表查询请求
- [x] 1.1.4 `EnterpriseItem` 响应结构
- [x] 1.1.5 `UpdateEnterpriseStatusReq` 状态更新请求
- [x] 1.1.6 `UpdateEnterprisePasswordReq` 密码更新请求
**验证**:
- [x] 验证标签正确
- [x] 字段完整
---
## 阶段 2: Store 层 (45 分钟)
### Task 2.1: 创建/扩展 Enterprise Store
**文件**: `internal/store/postgres/enterprise_store.go`
**实现内容**:
- [x] 2.1.1 `Create(enterprise)` - 创建企业
- [x] 2.1.2 `Update(enterprise)` - 更新企业
- [x] 2.1.3 `GetByID(id)` - 获取单条记录
- [x] 2.1.4 `List(req)` - 分页查询
- [x] 2.1.5 `ExistsByCode(code)` - 检查编号是否存在GetByCode
- [x] 2.1.6 `UpdateStatus(id, status)` - 更新状态在Service层通过事务实现
**验证**:
- [x] 数据权限过滤正确
- [x] 关联查询正确(归属店铺、账号)
---
## 阶段 3: Service 层 (1.5 小时)
### Task 3.1: 创建 Enterprise Service
**文件**: `internal/service/enterprise/service.go`
**实现内容**:
- [x] 3.1.1 `Create(ctx, req)` - 新增企业(含创建账号)
- [x] 3.1.2 `Update(ctx, id, req)` - 编辑企业
- [x] 3.1.3 `List(ctx, req)` - 查询企业列表
- [x] 3.1.4 `UpdateStatus(ctx, id, status)` - 更新状态(同步账号)
- [x] 3.1.5 `UpdatePassword(ctx, id, password)` - 修改密码
**业务逻辑**:
- [x] 3.1.6 创建企业时的事务处理
- [x] 3.1.7 禁用企业时同步禁用账号
- [x] 3.1.8 权限校验
**验证**:
- [x] 事务正确
- [x] 状态同步正确
---
## 阶段 4: Handler 层 (1 小时)
### Task 4.1: 创建 Handler
**文件**: `internal/handler/admin/enterprise.go`
**实现内容**:
- [x] 4.1.1 `CreateEnterprise` - POST /api/admin/enterprises
- [x] 4.1.2 `ListEnterprises` - GET /api/admin/enterprises
- [x] 4.1.3 `UpdateEnterprise` - PUT /api/admin/enterprises/:id
- [x] 4.1.4 `UpdateEnterpriseStatus` - PUT /api/admin/enterprises/:id/status
- [x] 4.1.5 `UpdateEnterprisePassword` - PUT /api/admin/enterprises/:id/password
**验证**:
- [x] 参数校验正确
- [x] 响应格式正确
---
### Task 4.2: 路由注册
**实现内容**:
- [x] 4.2.1 注册五个 API 路由
---
## 阶段 5: 测试 (1 小时)
### Task 5.1: 功能测试
**实现内容**:
- [x] 5.1.1 创建企业测试(含账号创建)
- [x] 5.1.2 编辑企业测试
- [x] 5.1.3 禁用企业测试(验证账号同步禁用)
- [x] 5.1.4 密码修改测试
- [x] 5.1.5 数据权限测试
---
## 完成标准
- [x] 所有 DTO 定义完成
- [x] Store 层方法实现完成
- [x] Service 层业务逻辑完成
- [x] Handler 层 API 实现完成
- [x] 创建企业时账号同步创建
- [x] 禁用企业时账号同步禁用
- [x] 编译通过
- [x] 功能测试通过