Files
huang d977000a66
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m40s
feat: 归档佣金计算触发和快照变更,同步规范文档
- 归档 OpenSpec 变更到 archive 目录
- 创建 2 个新的主规范文件:commission-trigger 和 order-commission-snapshot
- 实现订单佣金快照字段和支付自动触发
- 确保事务一致性,所有佣金操作在同一事务内完成
- 提取成本价计算为公共工具函数
2026-01-29 14:58:35 +08:00

25 lines
1.2 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.
# 佣金计算链路修复 - 实现任务
## 1. 订单佣金字段快照
- [x] 1.1 在 `internal/service/order/service.go` 创建订单时,从购买校验结果填充 `SeriesID/SellerShopID/SellerCostPrice`
- [x] 1.2 补充/复用"成本价推导"工具方法,确保口径与佣金计算一致
## 2. 支付成功后自动入队
- [x] 2.1 在首次支付成功路径 enqueue `commission:calculate`payload: order_id
- [x] 2.2 注入队列客户端到订单服务(遵循现有 bootstrap 依赖注入方式)
- [x] 2.3 明确入队失败策略:记录日志,订单保持 `commission_status=pending` 可重试
## 3. 佣金计算一致性与健壮性(可选但推荐)
- [x] 3.1 调整 `internal/service/commission_calculation/service.go`,确保事务内对佣金记录/钱包/订单状态更新使用同一 `tx`
- [x] 3.2 增加必要的空值保护:缺少关键字段时返回业务错误而非 panic
## 4. 测试与验证
- [x] 4.1 新增单元测试:订单创建后佣金快照字段写入正确
- [x] 4.2 新增单元/集成测试:支付成功后会 enqueue 佣金计算任务(可通过可注入的队列 client 验证)
- [x] 4.3 运行 `go test ./...` 确保通过