feat: 实现代理钱包订单创建和订单角色追踪功能
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m0s

新增功能:
- 代理在后台使用 wallet 支付时,订单直接完成(扣款 + 激活套餐)
- 支持代理自购和代理代购场景
- 新增订单角色追踪字段(operator_id、operator_type、actual_paid_amount、purchase_role)
- 订单查询支持 OR 逻辑(buyer_id 或 operator_id)
- 钱包流水记录交易子类型和关联店铺
- 佣金逻辑调整:代理代购不产生佣金

数据库变更:
- 订单表新增 4 个字段和 2 个索引
- 钱包流水表新增 2 个字段
- 包含迁移脚本和回滚脚本

文档:
- 功能总结文档
- 部署指南
- OpenAPI 文档更新
- Specs 同步(新增 agent-order-role-tracking capability)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 14:11:42 +08:00
parent c5bf85c8de
commit 8ed3d9da93
24 changed files with 3346 additions and 52 deletions

View File

@@ -1417,6 +1417,10 @@ components:
maxLength: 11
minLength: 11
type: string
default_role_id:
description: 店铺默认角色ID必须是客户角色
minimum: 1
type: integer
district:
description: 区县
maxLength: 50
@@ -1458,6 +1462,7 @@ components:
required:
- shop_name
- shop_code
- default_role_id
- init_password
- init_username
- init_phone
@@ -2487,9 +2492,6 @@ components:
carrier_type:
description: 运营商类型 (CMCC:中国移动, CUCC:中国联通, CTCC:中国电信, CBN:中国广电)
type: string
cost_price:
description: 成本价(分)
type: integer
created_at:
description: 创建时间
format: date-time
@@ -2505,9 +2507,6 @@ components:
data_usage_mb:
description: 累计流量使用(MB)
type: integer
distribute_price:
description: 分销价(分)
type: integer
enable_polling:
description: 是否参与轮询
type: boolean
@@ -2979,6 +2978,10 @@ components:
type: object
DtoOrderResponse:
properties:
actual_paid_amount:
description: 实际支付金额(分)
nullable: true
type: integer
buyer_id:
description: 买家ID
minimum: 0
@@ -3013,12 +3016,26 @@ components:
is_purchase_on_behalf:
description: 是否为代购订单
type: boolean
is_purchased_by_parent:
description: 是否由上级代理购买
type: boolean
items:
description: 订单明细列表
items:
$ref: '#/components/schemas/DtoOrderItemResponse'
nullable: true
type: array
operator_id:
description: 操作者ID
minimum: 0
nullable: true
type: integer
operator_name:
description: 操作者名称
type: string
operator_type:
description: 操作者类型 (platform:平台, agent:代理)
type: string
order_no:
description: 订单号
type: string
@@ -3039,6 +3056,12 @@ components:
payment_status_text:
description: 支付状态文本
type: string
purchase_remark:
description: 购买备注
type: string
purchase_role:
description: 订单角色 (self_purchase:自己购买, purchased_by_parent:上级代理购买, purchased_by_platform:平台代购, purchase_for_subordinate:给下级购买)
type: string
total_amount:
description: 订单总金额(分)
type: integer
@@ -3901,10 +3924,6 @@ components:
minimum: 0
nullable: true
type: integer
from_shop_id:
description: 来源店铺ID被回收方
minimum: 1
type: integer
iccid_end:
description: 结束ICCIDselection_type=range时必填
maxLength: 20
@@ -3931,7 +3950,6 @@ components:
- filter
type: string
required:
- from_shop_id
- selection_type
type: object
DtoRecallStandaloneCardsResponse:
@@ -4739,9 +4757,6 @@ components:
carrier_type:
description: 运营商类型 (CMCC:中国移动, CUCC:中国联通, CTCC:中国电信, CBN:中国广电)
type: string
cost_price:
description: 成本价(分)
type: integer
created_at:
description: 创建时间
format: date-time
@@ -4757,9 +4772,6 @@ components:
data_usage_mb:
description: 累计流量使用(MB)
type: integer
distribute_price:
description: 分销价(分)
type: integer
enable_polling:
description: 是否参与轮询
type: boolean
@@ -12250,6 +12262,12 @@ paths:
description: 订单号(精确查询)
maxLength: 30
type: string
- description: 订单角色 (self_purchase:自己购买, purchased_by_parent:上级代理购买, purchased_by_platform:平台代购, purchase_for_subordinate:给下级购买)
in: query
name: purchase_role
schema:
description: 订单角色 (self_purchase:自己购买, purchased_by_parent:上级代理购买, purchased_by_platform:平台代购, purchase_for_subordinate:给下级购买)
type: string
- description: 创建时间起始
in: query
name: start_time
@@ -18681,6 +18699,12 @@ paths:
description: 订单号(精确查询)
maxLength: 30
type: string
- description: 订单角色 (self_purchase:自己购买, purchased_by_parent:上级代理购买, purchased_by_platform:平台代购, purchase_for_subordinate:给下级购买)
in: query
name: purchase_role
schema:
description: 订单角色 (self_purchase:自己购买, purchased_by_parent:上级代理购买, purchased_by_platform:平台代购, purchase_for_subordinate:给下级购买)
type: string
- description: 创建时间起始
in: query
name: start_time