forked from wangziqi/gongxue-base
feat: add commerce refund workflow
This commit is contained in:
@@ -872,6 +872,60 @@ GET /api/commerce/entitlements
|
||||
|
||||
订单详情会返回 `pricing`、`payments`、`items`、`couponRedemptions`,可用于收银台、订单详情页和售后排查。订单状态轮询页只需消费 `status/payment`,避免频繁拉取全量明细。
|
||||
|
||||
### 退款和售后
|
||||
|
||||
学生端不直接发起后台退款命令。普通用户订单页只展示 `GET /api/commerce/orders/status` 和 `GET /api/commerce/orders/detail` 返回的订单状态、支付状态、`refundedAmountCents`,并提供客服/工单入口。租户后台或运营后台才接退款接口。
|
||||
|
||||
租户后台退款列表:
|
||||
|
||||
```text
|
||||
GET /api/commerce/refunds?status=requested&orderNo=<orderNo>
|
||||
权限:tenant:refund:read
|
||||
```
|
||||
|
||||
创建退款申请:
|
||||
|
||||
```text
|
||||
POST /api/commerce/refunds
|
||||
权限:tenant:refund:write
|
||||
body: {
|
||||
"orderNo": "<orderNo>",
|
||||
"refundNo": "<可选,前端幂等键>",
|
||||
"amountCents": 500,
|
||||
"reason": "用户协商退款",
|
||||
"entitlementAction": "revoke_on_success | none"
|
||||
}
|
||||
```
|
||||
|
||||
退款状态流转:
|
||||
|
||||
```text
|
||||
POST /api/commerce/refunds/status
|
||||
body: {
|
||||
"refundId": "<refundId>",
|
||||
"action": "approve | reject | mark_processing | mark_succeeded | mark_failed | cancel",
|
||||
"providerRefundNo": "<支付平台退款单号,可选>",
|
||||
"note": "<处理备注>"
|
||||
}
|
||||
```
|
||||
|
||||
状态说明:
|
||||
|
||||
```text
|
||||
requested -> approved -> processing -> succeeded
|
||||
requested/approved -> rejected
|
||||
requested/approved -> cancelled
|
||||
approved/processing -> failed
|
||||
```
|
||||
|
||||
注意:
|
||||
|
||||
- 金额单位一律是分,前端不要传元。
|
||||
- `refundNo` 是幂等键;同一订单同一金额重复提交会返回原退款申请。
|
||||
- 后端会限制累计退款金额不能超过实付金额。
|
||||
- 全额退款成功后订单和支付会进入 `refunded`,相关订单权益会被置为 `revoked`;部分退款进入 `partially_refunded`,默认不撤销权益。
|
||||
- 当前接口完成内部退款状态机和人工成功登记;真实微信/支付宝退款 API、自动对账和补偿 worker 后续接入。前端不要假设点击退款后已经实时调用支付平台。
|
||||
|
||||
### 激活码预检查与兑换
|
||||
|
||||
兑换前建议先调用:
|
||||
|
||||
Reference in New Issue
Block a user