fix: 修复梯度佣金档位字段缺失,补全授权接口响应字段及强充有效状态
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m27s

- OneTimeCommissionTierDTO 补充 operator 字段映射
- GrantCommissionTierItem 补充 dimension/stat_scope 字段(从全局配置合并)
- 系列授权列表/详情补充强充锁定状态和强充金额的有效值计算
- 同步 OpenSpec 主规范并归档变更文档
This commit is contained in:
2026-03-05 11:23:28 +08:00
parent de9eacd273
commit b52cb9a078
12 changed files with 451 additions and 27 deletions

View File

@@ -46,27 +46,28 @@
### Requirement: 创建系列授权(梯度模式)
系统 SHALL 支持梯度模式的系列授权创建。梯度模式下,`commission_tiers` MUST 为必填,且必须包含与 PackageSeries 完全相同数量和阈值的阶梯(不多不少)。若某档位不希望给下级佣金,应将该档位的 amount 设为 0不可省略该档位。
系统 SHALL 支持梯度模式的系列授权创建。梯度模式下,`commission_tiers` MUST 为必填,且必须包含与 PackageSeries 完全相同数量和阈值的阶梯(不多不少)。若某档位不希望给下级佣金,应将该档位的 amount 设为 0不可省略该档位。创建成功后的响应中,`commission_tiers` 每个档位 MUST 包含 `operator``dimension``stat_scope` 字段(从全局配置合并)。
#### Scenario: 代理成功创建梯度模式授权
- **WHEN** 代理A 的专属阶梯为 [{operator:">=", threshold:100, amount:80}, {operator:">=", threshold:150, amount:120}]A 为代理B 创建授权,传入 commission_tiers=[{threshold:100, amount:50}, {threshold:150, amount:100}]
- **THEN** 系统创建授权commission_tiers_json 存储 [{threshold:100, amount:50}, {threshold:150, amount:100}],响应中 commission_tiers=[{operator:">=", threshold:100, amount:50}, {operator:">=", threshold:150, amount:100}]operator 从 PackageSeries 读取后合并)
- **WHEN** 代理A 的专属阶梯为 `[{operator:">=" , threshold:100, amount:80}, {operator:">=" , threshold:150, amount:120}]`A 为代理B 创建授权,传入 `commission_tiers=[{threshold:100, amount:50}, {threshold:150, amount:100}]`
- **THEN** 系统创建授权,`commission_tiers_json` 存储 `[{threshold:100, amount:50}, {threshold:150, amount:100}]`
- **AND** 响应中 `commission_tiers=[{operator:">=" , dimension:"sales_count", stat_scope:"self", threshold:100, amount:50}, ...]`
#### Scenario: 平台成功创建梯度模式授权
- **WHEN** 平台为顶级代理A 创建授权PackageSeries 阶梯为 [{operator:">=", threshold:100, amount:100}, {operator:"<", threshold:50, amount:30}],传入 commission_tiers=[{threshold:100, amount:80}, {threshold:50, amount:20}]
- **THEN** 系统创建授权,A 的专属阶梯存入 commission_tiers_json响应中 commission_tiers 包含对应的 operator
- **WHEN** 平台为顶级代理A 创建授权PackageSeries 阶梯`operator`/`dimension`/`stat_scope`
- **THEN** 系统创建授权,响应中 `commission_tiers` 包含 PackageSeries 全局 `operator``dimension``stat_scope`
#### Scenario: 梯度模式某档位金额超过父级
- **WHEN** 代理A 的阶梯第一档 amount=80A 为 B 创建授权时传入第一档 amount=90
- **THEN** 系统返回错误"梯度佣金档位金额不能超过上级同档位限额"
- **WHEN** 代理A 的阶梯第一档 `amount=80`A 为 B 创建授权时传入第一档 `amount=90`
- **THEN** 系统返回错误“某档位佣金金额超过上级天花板”
#### Scenario: 梯度模式传入了不存在的阈值
- **WHEN** PackageSeries 只有 threshold=100 和 150 两档,请求中传入 threshold=200
- **THEN** 系统返回错误"阶梯阈值与系列配置不匹配"
- **WHEN** PackageSeries 只有 `threshold=100``150` 两档,请求中传入 `threshold=200`
- **THEN** 系统返回错误“梯度阶梯 threshold 与系列配置不匹配
#### Scenario: 梯度模式 commission_tiers 为必填
- **WHEN** 请求中不包含 commission_tiers 或为空数组
- **THEN** 系统返回参数错误"梯度模式必须提供阶梯金额配置"
- **WHEN** 请求中不包含 `commission_tiers` 或为空数组
- **THEN** 系统返回参数错误梯度模式必须填写阶梯配置
---
@@ -90,19 +91,33 @@
### Requirement: 查询系列授权详情
系统 SHALL 提供 `GET /shop-series-grants/:id` 接口,返回包含套餐列表的聚合视图。
系统 SHALL 提供 `GET /shop-series-grants/:id` 接口,返回包含套餐列表的聚合视图。梯度模式下,`commission_tiers` 中每个档位 MUST 包含 `dimension`(统计维度)和 `stat_scope`(统计范围)字段,这两个字段从 PackageSeries 全局配置按 `threshold` 合并,对代理只读。
#### Scenario: 固定模式详情
- **WHEN** 查询固定模式系列授权详情
- **THEN** 响应包含 commission_type="fixed"one_time_commission_amount=有效值commission_tiers=[]
- **THEN** 响应包含 `commission_type="fixed"``one_time_commission_amount=有效值``commission_tiers=[]`
#### Scenario: 梯度模式详情
- **WHEN** 查询梯度模式系列授权详情
- **THEN** 响应包含 commission_type="tiered"one_time_commission_amount=0commission_tiers=[{threshold, amount}, ...]
- **THEN** 响应包含 `commission_type="tiered"``one_time_commission_amount=0`
- **AND** `commission_tiers` 中每个档位包含 `operator``dimension``stat_scope``threshold``amount` 五个字段
- **AND** `operator``dimension``stat_scope` 的值来自 PackageSeries 全局配置(对应 threshold 的档位),代理的 `amount` 来自 `ShopSeriesAllocation.commission_tiers_json`
#### Scenario: 梯度模式 dimension 为销售量
- **WHEN** 查询梯度模式授权详情PackageSeries 阶梯 `dimension = "sales_count"`
- **THEN** 响应中对应档位 `dimension = "sales_count"`,前端展示“销售量”条件
#### Scenario: 梯度模式 dimension 为销售额
- **WHEN** 查询梯度模式授权详情PackageSeries 阶梯 `dimension = "sales_amount"`
- **THEN** 响应中对应档位 `dimension = "sales_amount"`,前端展示“销售额”条件
#### Scenario: 梯度模式 stat_scope 区分
- **WHEN** 查询梯度模式授权详情
- **THEN** 响应中 `stat_scope` 正确反映 PackageSeries 配置的统计范围(`"self"``"self_and_sub"`
#### Scenario: 查询不存在的授权
- **WHEN** 查询不存在的授权 ID
- **THEN** 系统返回错误"授权记录不存在"
- **THEN** 系统返回错误授权记录不存在
---
@@ -179,3 +194,31 @@
#### Scenario: 有下级依赖时禁止删除
- **WHEN** 删除一个已被下级代理用于创建子授权的记录
- **THEN** 系统返回错误"存在下级依赖,无法删除,请先删除下级授权"
---
### Requirement: 系列授权列表强充状态正确反映
系列授权列表 (`GET /shop-series-grants`) MUST 在每个列表项中返回 `force_recharge_locked`(是否被套餐系列锁定)和 `force_recharge_amount`(强充金额)。`force_recharge_enabled` MUST 反映有效状态:当锁定时为 `true`(无论分配记录自身如何);未锁定时取分配记录的实际设置。
#### Scenario: 套餐系列锁定强充
- **WHEN** 套餐系列配置 `enable_force_recharge=true``trigger_type=first_recharge`,查询列表
- **THEN** 列表项中 `force_recharge_locked=true``force_recharge_enabled=true``force_recharge_amount`=系列配置的 `force_amount`
#### Scenario: 代理自身开启强充(未锁定)
- **WHEN** 套餐系列未锁定强充,分配记录中 `enable_force_recharge=true`,查询列表
- **THEN** 列表项中 `force_recharge_locked=false``force_recharge_enabled=true``force_recharge_amount`=分配记录的实际金额
#### Scenario: 代理未开启强充(未锁定)
- **WHEN** 套餐系列未锁定强充,分配记录中 `enable_force_recharge=false`,查询列表
- **THEN** 列表项中 `force_recharge_locked=false``force_recharge_enabled=false``force_recharge_amount=0`
---
### Requirement: 查询系列授权详情强充有效状态
系列授权详情 (`GET /shop-series-grants/:id`) 中,`force_recharge_enabled` MUST 反映有效状态:当锁定时为 `true``force_recharge_amount` 锁定时应返回系列配置的 `force_amount`
#### Scenario: 锁定强充时详情响应
- **WHEN** 套餐系列锁定强充,查询对应分配记录详情
- **THEN** `force_recharge_locked=true``force_recharge_enabled=true``force_recharge_amount`=系列配置的 `force_amount`