bindbox-game/.trae/documents/订单详情枚举与退款闭环完善.md
邹方成 6ee627139c
Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 40s
feat: 新增支付测试小程序与微信支付集成
feat(pay): 添加支付API基础结构
feat(miniapp): 创建支付测试小程序页面与配置
feat(wechatpay): 配置微信支付参数与证书
fix(guild): 修复成员列表查询条件
docs: 更新代码规范文档与需求文档
style: 统一前后端枚举显示与注释格式
refactor(admin): 重构用户奖励发放接口参数处理
test(title): 添加称号效果参数验证测试
2025-11-17 00:42:08 +08:00

24 lines
1.3 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) 管理端退款记录补充:在 `POST /api/admin/pay/refunds` 现有逻辑基础上,新增一条 `user_points_ledger(action='refund_amount', points=退款金额, ref_table='orders', ref_id=order_no, remark=reason)` 记录每笔退款金额(不新建表)。
2) 订单详情聚合退款:在 `GET /api/admin/pay/orders/:order_no` 增加字段:
- `refunds[]`:来源于 `user_points_ledger(action='refund_amount')`;包含金额、原因、时间
- `refundable_amount``actual_amount - sum(refunds.amount)`(分)
3) 边界与幂等:
- 仅允许 `status=2已支付` 发起退款;金额需 `>0 且 <= refundable_amount`
- 全额退款后置 `status=4已退款`;部分退款维持 `status=2`
## 前端
1) 列表与详情使用中文枚举(已完成基础替换)
2) 详情页:
- 显示“可退款金额(分)”
- 新增“退款记录”表格(金额/原因/时间)
- 退款按钮支持部分退款;提交后刷新详情与可退余额
## 验收
- 管理端可主动发起退款并记录到“退款记录”
- 详情页展示可退余额与每笔退款信息
- 编译与联调通过