Files
junhong_cmp_fiber/.planning/phases/01-p0/01-04-PLAN.md

165 lines
6.1 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.
---
phase: 01-p0
plan: 04
type: execute
wave: 1
depends_on: []
files_modified:
- internal/service/order/service.go
autonomous: true
requirements:
- CRITICAL-06
must_haves:
truths:
- "场景 5 分支(代理代购下级)的 sellerCostPrice 使用 operatorCostPrice不再是 buyerCostPrice"
- "其他 5 处 sellerCostPrice 赋值经过语义审查,确认正确或按需修正"
- "佣金差额计算基准正确,场景 5 的上级代理能获得应有佣金"
artifacts:
- path: internal/service/order/service.go
provides: "场景 5 sellerCostPrice 修正"
contains: "operatorCostPrice"
key_links:
- from: internal/service/order/service.go
to: "佣金计算链路"
via: "sellerCostPrice 作为佣金差额基准传递"
pattern: "sellerCostPrice"
---
<objective>
逐一审查并修正代购订单中 sellerCostPrice 的 6 处赋值CRITICAL-06确保场景 5代理代购下级使用正确的成本价基准。
Purpose: sellerCostPrice 是佣金差额计算的基准。场景 5 中错误使用 buyerCostPrice下级成本价导致整个佣金链差额为 0所有上级代理无法获得应有佣金。修复后代购场景佣金链正常工作。
Output:
- order/service.go: 场景 5 的 sellerCostPrice 改为 operatorCostPrice其余 5 处经语义审查确认或按需修正
</objective>
<execution_context>
@$HOME/.config/opencode/get-shit-done/workflows/execute-plan.md
@$HOME/.config/opencode/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/phases/01-p0/01-CONTEXT.md
# 修复规格书(方案 A-5第 579-618 行)
@.sisyphus/plans/修正业务-完整方案.md
<interfaces>
<!-- 五种购买场景对应表(来自规格书 A-5
| # | 操作方 | 资产所属 | sellerCostPrice 应为 |
|---|--------|------------|--------------------------|
| 1 | 平台 | 平台自己客户 | N/A线下不计佣金 |
| 2 | 平台 | 某代理客户 | 该代理成本价operatorCostPrice 即代理价)|
| 3 | 平台 | 某代理客户 | 该代理成本价(线下场景) |
| 4 | 代理 | 自己客户 | 自己成本价(即 operatorCostPrice|
| 5 | 代理 | 下级代理客户 | **operatorCostPrice自己的成本价非下级的** ← Bug 在此 |
-->
<!-- 6 处确认位置(来自 CONTEXT.md code_context -->
<!--
internal/service/order/service.go 第 187, 262, 472, 548, 734, 809 行
其中 525-548 行是场景 5sellerCostPrice = buyerCostPrice 是错误的
-->
<!-- 审查决策依据per D-01, D-02, D-03 -->
<!--
- 逐一语义审查,按场景对照表判断
- 不做模式匹配式全量替换
- 有些 buyerCostPrice 赋值是正确的(如场景 1/2/3/4 的某些分支)
-->
</interfaces>
</context>
<tasks>
<task type="auto">
<name>Task 1: 逐一审查并修正 sellerCostPrice 6 处赋值CRITICAL-06</name>
<files>internal/service/order/service.go</files>
<action>
**步骤 1定位 6 处赋值**
```bash
rg -n "sellerCostPrice" internal/service/order/service.go
```
确认规格书所述的 6 处(第 187, 262, 472, 548, 734, 809 行)是否与实际一致(行号可能有偏移)。
**步骤 2对照五种场景表逐一审查**
对每一处 `sellerCostPrice = buyerCostPrice`,阅读其所在分支的上下文,确认:
- 这里的"操作方"是谁?(平台/代理)
- 资产归属是谁?(自己客户/下级代理客户)
- 对照上方场景表sellerCostPrice 应该是哪个变量?
**步骤 3修正确认有问题的位置**
规格书明确指出场景 5代理代购下级代理客户约在第 525-548 行:
```go
// 当前错误sellerCostPrice 用了下级成本价)
buyerCostPrice, _ := s.getCostPrice(ctx, *resourceShopID, firstPackageID) // 下级成本价
operatorCostPrice, _ := s.getCostPrice(ctx, operatorShopID, firstPackageID) // 自己成本价
totalAmount = buyerCostPrice // 下级成本价作为面值(正确)
actualPaidAmount = &operatorCostPrice // 实际扣自己钱包(正确)
sellerCostPrice = buyerCostPrice // ← 错误!应是 operatorCostPrice
// 修正后
sellerCostPrice = operatorCostPrice // ✅ 自己(代理)的成本价作为佣金差额基准
```
对其余 5 处,若语义审查确认正确(即该场景下 sellerCostPrice 本就应等于 buyerCostPrice则**不修改**,并在 SUMMARY 中记录每处审查结论。
**步骤 4执行 `go build ./...`,确认编译通过,提交独立 commitper D-05**
注意只改确认有问题的位置禁止全量替换per D-03
</action>
<verify>
<automated>go build ./... && rg -n "sellerCostPrice" internal/service/order/service.go</automated>
</verify>
<done>
- 6 处 sellerCostPrice 赋值全部经过语义审查
- 场景 5 分支已将 sellerCostPrice = buyerCostPrice 改为 sellerCostPrice = operatorCostPrice
- 其余各处审查结论已记录
- go build ./... 编译通过
- 独立 commit 已提交
</done>
</task>
</tasks>
<verification>
整体验收:
```bash
# 1. 编译验证
go build ./...
# 2. 查看所有 sellerCostPrice 赋值(人工确认场景 5 已修正)
rg -n "sellerCostPrice" internal/service/order/service.go
# 3. 搜索场景 5 分支(代购下级)是否仍然存在 sellerCostPrice = buyerCostPrice
# 需人工确认第 525-548 行附近已修改
```
人工验收(参见修正业务-完整方案.md A-5 验收清单):
- DBHub 抽查"代理代购下级代理客户"的订单和佣金记录
- 预期tb_order.total_amount = 下级成本价,佣金链不再全部为 0
</verification>
<success_criteria>
1. `go build ./...` 编译通过
2. 场景 5代理代购下级sellerCostPrice = operatorCostPrice不再是 buyerCostPrice
3. 其余 5 处经语义审查,结论记录在 SUMMARY 中
4. 独立 commit 已提交
</success_criteria>
<output>
完成后创建 `.planning/phases/01-p0/01-04-SUMMARY.md`,记录:
- 6 处 sellerCostPrice 逐一审查结论(行号 + 场景判断 + 是否修改)
- 场景 5 修改前后代码对比
- 编译验证结果
- CRITICAL-06 完成状态
</output>