WMS_MAIN/INBOX_V2_HTTP_TEST_REPORT.md
liufumingren c2a761ca26 feat(inbox): 新增开门/到货/进场/离场车牌登记与 extend_props 持久化
- functions 新增 openDoor/registerLicensePlate/enter/departure(规则表+权限分组)
- 到货登记表 wms_inbox_arrival_register(含消费字段,离场闭环,货主收货群优先推送)
- 回执 extend_props 持久化落库与定时补发送下发(重推兜底回读)
- 车牌提取正则兼容异体字(粤/粵)
- 售后类型/关键字/函数/回复 v2 模型与迁移
- INBOX V2 HTTP 测试报告与指南
2026-09-17 02:41:43 +08:00

350 lines
11 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

# 站内信 v2 可配置回信引擎 —— HTTP 覆盖测试报告
> 生成时间:2026-09-16T18:11:52.145Z | 执行方式:真实 HTTP 链路(POST /warehouse?method=inbox.push)
## 1. 测试环境
| 项 | 值 |
|---|---|
| 服务 | http://127.0.0.1:6060(本地 egg 服务,运行中) |
| 回调接收服务 | http://127.0.0.1:9001/ack(本地 ack 服务,返回 {code:200}) |
| 数据库 | 127.0.0.1:3307/wms(本地库) |
| API 应用 | wms_api_app id=3,app_key=APP2025011514315678,warehouse_id=100000 |
| 原 callback_url | `http://localhost:6061/push` → 测试期间改为本地 ack 服务(**未自动恢复**) |
| 新 v2 测试群 | `httpv2:1789582312145`(首推自动登记后开启 store/after_sales + ai_enabled=1 + template_reply_enabled=1) |
| 新 express 测试群 | `httpv2expr:1789582312145`(express/after_sales,开启 v2) |
| 存量 v1 对照群 | `test-enter-store-aftersales`(template_reply_enabled=0) |
| 存量 ai_enabled=0 群 | `g_st_finance_debug` |
## 2. 链路
```mermaid
flowchart LR
A[测试脚本] -->|POST /warehouse inbox.push 验签| B[warehouseMethods/inbox.push]
B --> C[receiver.receive 幂等写库 + 自动登记群]
C -->|source_type=api setImmediate| D[processor.handleApiMessage]
D --> E{群校验 ai_enabled / group_type / 历史消息}
E -->|template_reply_enabled=1| F[inbox.v2.rules 可配置引擎]
F --> G[关键词→白名单→取号→callFunction→回复表]
G --> H[writeOutboundReply]
H -->|POST notify.reply| I[本地 ack 服务 9001]
I --> J[push_status=2]
```
## 3. 用例结果总览
- 总计:**12** 用例,通过:**12**,失败:**0**
| # | 用例 | 内容 | 结果 |
|---|---|---|---|
| TC01 | 破损建单(新 v2 群) | `破损 SF1234567890123` | ✅ PASS |
| TC02 | 改地址 | `改地址 SF1234567890123` | ✅ PASS |
| TC03 | 换快递(express 取号) | `改快递 SF1234567890123 圆通` | ✅ PASS |
| TC04 | 拦截 | `拦截 SF1234567890123` | ✅ PASS |
| TC05 | 揽收(上门取件) | `上门取件 SF1234567890123` | ✅ PASS |
| TC06 | 取号失败引导语 | `破损` | ✅ PASS |
| TC07 | v2 未命中静默(模块接管) | `今天天气怎么样` | ✅ PASS |
| TC08 | 历史消息静默跳过 | `破损 SF1234567890123` | ✅ PASS |
| TC09 | 幂等(同 requestId 两次推送) | `破损 SF9999999999999` | ✅ PASS |
| TC10 | express 群白名单放行但函数越权拦截(静默) | `破损 SF1234567890123` | ✅ PASS |
| TC11 | v1 分叉确认(template_reply_enabled=0 群) | `破损 SF1234567890123` | ✅ PASS |
| TC12 | ai_enabled=0 群跳过 | `破损 SF1234567890123` | ✅ PASS |
## 4. 用例明细
### TC01 破损建单(新 v2 群) ✅ PASS
- 消息:`破损 SF1234567890123`
- ext_id:`api:APP2025011514315678:httpv2-01-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| 入站消息入库 | ✅ | id=2016 |
| v2 命中轨迹写入 ai_thoughts(function=handleStoreFeedback) | ✅ | [object Object] |
| 出站回执存在(sys:ack) | ✅ | sys:ack:api:APP2025011514315678:httpv2-01-1789582314626 |
| 出站 push_status=2(回调 200) | ✅ | push_status=2 |
| 本地 ack 服务收到 notify.reply(type=ai) | ✅ | type=ai |
| 出站日志 wms_warehouse_log 记录 notify.reply | ✅ | http_status=200 |
| 无工单时函数返回可见(出站文案非空) | ✅ | 本地无该运单,函数返回文案: 未找到当前货主在仓库中的运单「SF1234567890123」,请核实单号后重试 |
- 入站消息 id=2016,ai_thoughts:
```json
[object Object]
```
- 出站回执:
| ext_id | content | push_status |
|---|---|---|
| `sys:ack:api:APP2025011514315678:httpv2-01-1789582314626` | 未找到当前货主在仓库中的运单「SF1234567890123」,请核实单号后重试 | 2 |
- 本地 ack 服务收到 notify.reply:type=ai
- wms_warehouse_log notify.reply 日志:http_status=200
### TC02 改地址 ✅ PASS
- 消息:`改地址 SF1234567890123`
- ext_id:`api:APP2025011514315678:httpv2-02-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| v2 命中 changeAddr | ✅ | |
| 出站回执存在 | ✅ | push_status=2 |
| 函数已执行(工单或错误文案) | ✅ | \| 未找到当前货主在仓库中的运单「SF1234567890123,1234567890123」,请核实单号后重试 |
- 入站消息 id=2018,ai_thoughts:
```json
[object Object]
```
- 出站回执:
| ext_id | content | push_status |
|---|---|---|
| `sys:ack:api:APP2025011514315678:httpv2-02-1789582314626` | 未找到当前货主在仓库中的运单「SF1234567890123,1234567890123」,请核实单号后重试 | 2 |
- 本地 ack 服务收到 notify.reply:type=ai
- wms_warehouse_log notify.reply 日志:http_status=200
### TC03 换快递(express 取号) ✅ PASS
- 消息:`改快递 SF1234567890123 圆通`
- ext_id:`api:APP2025011514315678:httpv2-03-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| v2 命中 changeExpress | ✅ | |
| 取号含 express=圆通 | ✅ | thoughts 含 express 字段 |
| 出站回执存在 | ✅ | 未找到订单:SF1234567890123、1234567890123 |
- 入站消息 id=2020,ai_thoughts:
```json
[object Object]
```
- 出站回执:
| ext_id | content | push_status |
|---|---|---|
| `sys:ack:api:APP2025011514315678:httpv2-03-1789582314626` | 未找到订单:SF1234567890123、1234567890123 | 2 |
- 本地 ack 服务收到 notify.reply:type=ai
- wms_warehouse_log notify.reply 日志:http_status=200
### TC04 拦截 ✅ PASS
- 消息:`拦截 SF1234567890123`
- ext_id:`api:APP2025011514315678:httpv2-04-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| v2 命中 interceptWaybill | ✅ | |
| 出站回执存在 | ✅ | 请提供运单号 |
- 入站消息 id=2022,ai_thoughts:
```json
[object Object]
```
- 出站回执:
| ext_id | content | push_status |
|---|---|---|
| `sys:ack:api:APP2025011514315678:httpv2-04-1789582314626` | 请提供运单号 | 2 |
- 本地 ack 服务收到 notify.reply:type=ai
- wms_warehouse_log notify.reply 日志:http_status=200
### TC05 揽收(上门取件) ✅ PASS
- 消息:`上门取件 SF1234567890123`
- ext_id:`api:APP2025011514315678:httpv2-05-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| v2 命中 requestPickup | ✅ | |
| 出站回执存在 | ✅ | 请提供运单号 |
- 入站消息 id=2024,ai_thoughts:
```json
[object Object]
```
- 出站回执:
| ext_id | content | push_status |
|---|---|---|
| `sys:ack:api:APP2025011514315678:httpv2-05-1789582314626` | 请提供运单号 | 2 |
- 本地 ack 服务收到 notify.reply:type=ai
- wms_warehouse_log notify.reply 日志:http_status=200
### TC06 取号失败引导语 ✅ PASS
- 消息:`破损`
- ext_id:`api:APP2025011514315678:httpv2-06-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| 出站回执为取号引导语 | ✅ | 请提供运单号(发送:指令+运单号,多个单号用逗号或空格分隔) |
| 未建工单(取号失败不调用函数) | ✅ | |
- 入站消息 id=2026,ai_thoughts:
```json
[object Object]
```
- 出站回执:
| ext_id | content | push_status |
|---|---|---|
| `sys:ack:api:APP2025011514315678:httpv2-06-1789582314626` | 请提供运单号(发送:指令+运单号,多个单号用逗号或空格分隔) | 2 |
- 本地 ack 服务收到 notify.reply:type=ai
- wms_warehouse_log notify.reply 日志:http_status=200
### TC07 v2 未命中静默(模块接管) ✅ PASS
- 消息:`今天天气怎么样`
- ext_id:`api:APP2025011514315678:httpv2-07-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| 无出站回执(静默) | ✅ | |
| 无 ai_thoughts 轨迹 | ✅ | 空 |
| 无新工单 | ✅ | 0 条 |
- 入站消息 id=2028,ai_thoughts:
```json
null
```
### TC08 历史消息静默跳过 ✅ PASS
- 消息:`破损 SF1234567890123`
- ext_id:`api:APP2025011514315678:httpv2-08-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| 入站仍入库 | ✅ | id=2029 |
| 无出站回执(静默跳过) | ✅ | |
| 无新工单 | ✅ | 0 条 |
- 入站消息 id=2029,ai_thoughts:
```json
null
```
### TC09 幂等(同 requestId 两次推送) ✅ PASS
- 消息:`破损 SF9999999999999`
- ext_id:`api:APP2025011514315678:httpv2-09-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| 两次推送均返回成功(flag=success) | ✅ | 第一次 flag=success,第二次 flag=success |
| 入站仅 1 条 | ✅ | 1 -> 1 |
| 出站仅 1 条(不重复处理) | ✅ | 出站条数 1 -> 1 |
- 入站消息 id=2030,ai_thoughts:
```json
[object Object]
```
- 出站回执:
| ext_id | content | push_status |
|---|---|---|
| `sys:ack:api:APP2025011514315678:httpv2-09-1789582314626` | 未找到当前货主在仓库中的运单「SF9999999999999」,请核实单号后重试 | 2 |
- 本地 ack 服务收到 notify.reply:type=ai
- wms_warehouse_log notify.reply 日志:http_status=200
### TC10 express 群白名单放行但函数越权拦截(静默) ✅ PASS
- 消息:`破损 SF1234567890123`
- ext_id:`api:APP2025011514315678:httpv2-10-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| 入站消息入库 | ✅ | id=2032 |
| 无出站回执(静默) | ✅ | |
| 白名单行存在(express/after_sales 允许 damage 子类型) | ✅ | 行数=1 |
| 函数越权拦截(handleStoreFeedback 仅 store 群可用 → 无轨迹) | ✅ | 无轨迹 |
- 入站消息 id=2032,ai_thoughts:
```json
null
```
### TC11 v1 分叉确认(template_reply_enabled=0 群) ✅ PASS
- 消息:`破损 SF1234567890123`
- ext_id:`api:APP2025011514315678:httpv2-11-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| 未走 v2 引擎(thoughts 无 v2 轨迹特征) | ✅ | [{"round":0,"action":"rule","params":{"keyword":"SF1234567890123","issue_type":"damaged"},"reason":"关键词规则命中: 破损","function":"handleStoreFeedback","functionResult":{"error":"未找到当前货主在仓库中的运单「SF1234567890 |
| 群配置 template_reply_enabled=0 已确认 | ✅ | |
- 入站消息 id=2033,ai_thoughts:
```json
[object Object]
```
- 出站回执:
| ext_id | content | push_status |
|---|---|---|
| `sys:ack:api:APP2025011514315678:httpv2-11-1789582314626` | 未找到当前货主在仓库中的运单「SF1234567890123」,请核实单号后重试 | 2 |
- 本地 ack 服务收到 notify.reply:type=ai
- wms_warehouse_log notify.reply 日志:http_status=200
### TC12 ai_enabled=0 群跳过 ✅ PASS
- 消息:`破损 SF1234567890123`
- ext_id:`api:APP2025011514315678:httpv2-12-1789582314626`
| 校验项 | 结果 | 详情 |
|---|---|---|
| 无出站回执 | ✅ | |
| 无新工单 | ✅ | 0 条 |
- 入站消息 id=2035,ai_thoughts:
```json
null
```
## 5. 说明与后续
1. 测试产生的入站/出站消息、工单等数据**已保留**(未自动清理),可直接在库中核对。
2. `wms_api_app` id=3 的 callback_url 测试期间被改为本地 ack 服务,如需恢复:
```sql
UPDATE wms_api_app SET callback_url = 'http://localhost:6061/push' WHERE id = 3;
```
3. 测试脚本与明细数据位于 `temp/inbox_v2_http_test/`(`run_http_test.js`、`ack_server.js`、`report.json`)。