feat: add commerce adjustment operations

This commit is contained in:
Codex
2026-06-29 22:28:19 +08:00
parent f3577e257c
commit 9b17f25dd9
12 changed files with 1444 additions and 12 deletions

View File

@@ -287,16 +287,23 @@ body: { "code": "<qq oauth code>", "redirectUri": "https://h5.example.com/auth/q
- `GET /api/commerce/reconciliation/issues`:按状态、严重级别、负责人、批次、订单号筛选差错工单。
- `POST /api/commerce/reconciliation/issues/status`:执行 `start/assign/resolve/ignore/escalate/reopen` 状态流转。
- `GET /api/commerce/reconciliation/issues/events`:查看工单创建、分配、处理、解决、忽略、重开等事件轨迹。
- `GET /api/commerce/operations/anomalies`:聚合未关闭对账工单、失败官方账单任务、支付事件错误、长时间 pending 支付/退款,供租户财务/售后运营台使用。
- `GET /api/commerce/adjustment-vouchers`:查询人工调整凭证。
- `POST /api/commerce/adjustment-vouchers`:创建人工调整凭证,可关联差错工单、对账明细、订单、支付或退款。
- `POST /api/commerce/adjustment-vouchers/status`:执行 `submitted/approved/rejected/voided` 复核流转。
- `GET /api/commerce/adjustment-vouchers/events`:查看凭证事件轨迹。
- `GET /api/commerce/adjustment-vouchers/report`:按日期输出凭证状态、类型、来源和日趋势统计。
权限点:
- `tenant:reconciliation:read`:查看/预览对账。
- `tenant:reconciliation:write`:导入对账批次、创建/处理差错工单。
- `tenant:reconciliation:review`:审批、驳回或作废人工调整凭证。
- `tenant:reconciliation:download`:创建微信/支付宝官方账单下载任务。
官方账单下载由 `apps/worker --job provider-bills` 执行。API 只创建 `commerce_bill_download_jobs`,不会在前端返回供应商 `download_url`、商户私钥、微信 API v3 key 或支付宝应用私钥。worker 使用租户 `tenant_payment_accounts.config_public.secretRef` 找到 `app_private.tenant_secrets(secret_scope='payment')`,在后端签名申请下载 URL校验微信返回的 `hash_type/hash_value`,解析 JSON/CSV/ZIP 账单后复用 `importReconciliationBatch` 写入 `commerce_reconciliation_batches/items``source='provider_download'`
对账差错工单只生成差异台账、处理记录和审计,不自动修改订单、支付、退款和权益。`resolve/ignore` 只是财务审核结论,例如 `manual_adjustment``provider_confirmed``false_positive`最终落账仍必须走退款状态机、支付补偿、手工支付确认或后续专门的人工调整命令。人工调整凭证附件、财务复核报表、异常订单运营台和真实生产账单格式抽样验收仍需要继续补。
对账差错工单和人工调整凭证只生成差异台账、处理记录、凭证附件引用和审计,不自动修改订单、支付、退款和权益。`resolve/ignore` 只是财务审核结论,例如 `manual_adjustment``provider_confirmed``false_positive`;调整凭证审批也只表示财务复核通过。最终落账仍必须走退款状态机、支付补偿、手工支付确认或后续专门的落账命令。真实生产账单格式抽样验收和前端财务操作台仍需要继续补。
B 端合作商年费、服务费、服务器资源费不走学生端 `orders`,而是走平台账务: