feat(fulfillment): 增加事务 Outbox 同步履约状态

- 用事务 Outbox 和签名 Webhook 替换直接状态回调
- 增加 Outbox 投递 worker、重试与低频对账兜底
- 缓存客户领取页绑定状态并补充签名与迁移测试
This commit is contained in:
yml
2026-11-18 11:00:28 +08:00
parent 54b9f3251d
commit 9b2fcf1d1f
23 changed files with 1324 additions and 130 deletions
+28
View File
@@ -66,6 +66,21 @@ docker compose -f docker-compose.dev.yml logs -f frontend
docker compose -f docker-compose.dev.yml down
```
`order_site` 根目录提供 `./dev.sh` 快捷入口。默认直接启动源码挂载开发环境:
```bash
./dev.sh # 启动/更新 dev 环境
./dev.sh logs # 跟踪全部 dev 日志
./dev.sh logs frontend # 只看 Vite HMR 日志
./dev.sh logs backend # 只看后端热重载日志
./dev.sh ps # 查看 dev 容器
./dev.sh down # 停止 dev 容器
```
开发编排会把 `apps/frontend` 和 `apps/backend` 直接挂载进容器,前端由 Vite
提供 HMR,后端由 `tsx watch` 热重载;不要用生产 `docker-compose.yml` 重建
`web` 看页面改动。
Mac 也可使用:
```bash
@@ -208,6 +223,19 @@ SEMI_AUTO_TASK_TEST_DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5432/ord
npx tsx --test src/services/semi-auto/semi-auto-task.integration.test.ts
```
### 斗鱼履约跨项目同步
订单变化、绑定阶段和二维码投影走“事务 Outbox + 签名 Webhook”:
- 业务变更与 `integration_outbox` 同事务提交,worker 使用
`FOR UPDATE SKIP LOCKED` 领取并指数退避;
- 请求携带 `X-Integration-Key`、`X-Integration-Event-Id`、
`X-Integration-Timestamp`、`X-Integration-Signature`;
- 接收端用 `integration_inbox.event_id` 幂等,重复投递不会重复写业务状态;
- 工作台通过现有 SSE 收到刷新通知,不再定时向 live-hub 拉取状态;
- 15 分钟低频对账只作漏单兜底,可通过
`PLATFORM_FULFILLMENT_RECONCILE_SECONDS` 调整。
## 运行数据
| 环境 | 路径 / Volume |