# 站内信 v2 可配置回信引擎 —— HTTP 覆盖测试报告 > 生成时间:2026-09-17T14:44:55.082Z | 执行方式:真实 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:1789656295082`(首推自动登记后开启 store/after_sales + ai_enabled=1 + template_reply_enabled=1) | | 新 express 测试群 | `httpv2expr:1789656295082`(express/after_sales,开启 v2) | | 模块优先测试群 | `httpv2aioff:1789656295082`(ai_enabled=0 + template_reply_enabled=1) | ## 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. 用例结果总览 - 总计:**11** 用例,通过:**11**,失败:**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 | 模块优先(ai_enabled=0 但 template_reply_enabled=1) | `破损 SF1234567890123` | ✅ PASS | ## 4. 用例明细 ### TC01 破损建单(新 v2 群) ✅ PASS - 消息:`破损 SF1234567890123` - ext_id:`api:APP2025011514315678:httpv2-01-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | 入站消息入库 | ✅ | id=2118 | | v2 命中轨迹写入 ai_thoughts(function=handleStoreFeedback) | ✅ | [{"round":0,"action":"rule","params":{"keyword":"SF1234567890123","issue_type":"damaged"},"reason":"v2 关键词命中: 破损","function":"handleStoreFeedback","functionResult":{"error":"未找到当前货主在仓库中的运单「SF1234567890123」,请核实单号后重试","success":false}}] | | 出站回执存在(sys:ack) | ✅ | sys:ack:api:APP2025011514315678:httpv2-01-1789656298793 | | 出站 push_status=2(回调 200) | ✅ | push_status=2 | | 本地 ack 服务收到 notify.reply(type=ai) | ✅ | type=ai | | 出站日志 wms_warehouse_log 记录 notify.reply | ✅ | http_status=200 | | 无工单时函数返回可见(出站文案非空) | ✅ | 本地无该运单,函数返回文案: 未找到当前货主在仓库中的运单「SF1234567890123」,请核实单号后重试 | - 入站消息 id=2118,ai_thoughts: ```json [ { "round": 0, "action": "rule", "params": { "keyword": "SF1234567890123", "issue_type": "damaged" }, "reason": "v2 关键词命中: 破损", "function": "handleStoreFeedback", "functionResult": { "error": "未找到当前货主在仓库中的运单「SF1234567890123」,请核实单号后重试", "success": false } } ] ``` - 出站回执: | ext_id | content | push_status | |---|---|---| | `sys:ack:api:APP2025011514315678:httpv2-01-1789656298793` | 未找到当前货主在仓库中的运单「SF1234567890123」,请核实单号后重试 | 2 | - 本地 ack 服务收到 notify.reply:type=ai - wms_warehouse_log notify.reply 日志:http_status=200 ### TC02 改地址 ✅ PASS - 消息:`改地址 SF1234567890123` - ext_id:`api:APP2025011514315678:httpv2-02-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | v2 命中 changeAddr | ✅ | | | 出站回执存在 | ✅ | push_status=2 | | 函数已执行(工单或错误文案) | ✅ | \| 未找到当前货主在仓库中的运单「SF1234567890123,1234567890123」,请核实单号后重试 | - 入站消息 id=2120,ai_thoughts: ```json [ { "round": 0, "action": "rule", "params": { "keyword": "SF1234567890123,1234567890123", "issue_type": "addr" }, "reason": "v2 关键词命中: 改地址", "function": "changeAddr", "functionResult": { "error": "未找到当前货主在仓库中的运单「SF1234567890123,1234567890123」,请核实单号后重试", "success": false } } ] ``` - 出站回执: | ext_id | content | push_status | |---|---|---| | `sys:ack:api:APP2025011514315678:httpv2-02-1789656298793` | 未找到当前货主在仓库中的运单「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-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | v2 命中 changeExpress | ✅ | | | 取号含 express=圆通 | ✅ | thoughts 含 express 字段 | | 出站回执存在 | ✅ | 未找到订单:SF1234567890123、1234567890123 | - 入站消息 id=2122,ai_thoughts: ```json [ { "round": 0, "action": "rule", "params": { "express": "圆通", "keyword": "SF1234567890123,1234567890123" }, "reason": "v2 关键词命中: 改快递", "function": "changeExpress", "functionResult": { "data": { "changed": 0, "express": "圆通快递", "message": "未找到订单:SF1234567890123、1234567890123", "allocated": 0, "not_found": 2, "direct_reply": true, "not_in_pending": 0 }, "success": true } } ] ``` - 出站回执: | ext_id | content | push_status | |---|---|---| | `sys:ack:api:APP2025011514315678:httpv2-03-1789656298793` | 未找到订单: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-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | v2 命中 interceptWaybill | ✅ | | | 出站回执存在 | ✅ | 请提供运单号 | - 入站消息 id=2124,ai_thoughts: ```json [ { "round": 0, "action": "rule", "params": {}, "reason": "v2 关键词命中: 拦截", "function": "interceptWaybill", "functionResult": { "error": "请提供运单号", "success": false } } ] ``` - 出站回执: | ext_id | content | push_status | |---|---|---| | `sys:ack:api:APP2025011514315678:httpv2-04-1789656298793` | 请提供运单号 | 2 | - 本地 ack 服务收到 notify.reply:type=ai - wms_warehouse_log notify.reply 日志:http_status=200 ### TC05 揽收(上门取件) ✅ PASS - 消息:`上门取件 SF1234567890123` - ext_id:`api:APP2025011514315678:httpv2-05-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | v2 命中 requestPickup | ✅ | | | 出站回执存在 | ✅ | 请提供运单号 | - 入站消息 id=2126,ai_thoughts: ```json [ { "round": 0, "action": "rule", "params": {}, "reason": "v2 关键词命中: 上门取件", "function": "requestPickup", "functionResult": { "error": "请提供运单号", "success": false } } ] ``` - 出站回执: | ext_id | content | push_status | |---|---|---| | `sys:ack:api:APP2025011514315678:httpv2-05-1789656298793` | 请提供运单号 | 2 | - 本地 ack 服务收到 notify.reply:type=ai - wms_warehouse_log notify.reply 日志:http_status=200 ### TC06 取号失败引导语 ✅ PASS - 消息:`破损` - ext_id:`api:APP2025011514315678:httpv2-06-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | 出站回执为取号引导语 | ✅ | 请提供运单号(发送:指令+运单号,多个单号用逗号或空格分隔) | | 未建工单(取号失败不调用函数) | ✅ | | - 入站消息 id=2128,ai_thoughts: ```json [ { "round": 0, "action": "rule", "params": {}, "reason": "v2 关键词命中: 破损,取号失败-引导提示", "function": "handleStoreFeedback", "functionResult": null } ] ``` - 出站回执: | ext_id | content | push_status | |---|---|---| | `sys:ack:api:APP2025011514315678:httpv2-06-1789656298793` | 请提供运单号(发送:指令+运单号,多个单号用逗号或空格分隔) | 2 | - 本地 ack 服务收到 notify.reply:type=ai - wms_warehouse_log notify.reply 日志:http_status=200 ### TC07 v2 未命中静默(模块接管) ✅ PASS - 消息:`今天天气怎么样` - ext_id:`api:APP2025011514315678:httpv2-07-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | 无出站回执(静默) | ✅ | | | 无 ai_thoughts 轨迹 | ✅ | 空 | | 无新工单 | ✅ | 0 条 | - 入站消息 id=2130,ai_thoughts: ```json null ``` ### TC08 历史消息静默跳过 ✅ PASS - 消息:`破损 SF1234567890123` - ext_id:`api:APP2025011514315678:httpv2-08-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | 入站仍入库 | ✅ | id=2131 | | 无出站回执(静默跳过) | ✅ | | | 无新工单 | ✅ | 0 条 | - 入站消息 id=2131,ai_thoughts: ```json null ``` ### TC09 幂等(同 requestId 两次推送) ✅ PASS - 消息:`破损 SF9999999999999` - ext_id:`api:APP2025011514315678:httpv2-09-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | 两次推送均返回成功(flag=success) | ✅ | 第一次 flag=success,第二次 flag=success | | 入站仅 1 条 | ✅ | 1 -> 1 | | 出站仅 1 条(不重复处理) | ✅ | 出站条数 1 -> 1 | - 入站消息 id=2132,ai_thoughts: ```json [ { "round": 0, "action": "rule", "params": { "keyword": "SF9999999999999", "issue_type": "damaged" }, "reason": "v2 关键词命中: 破损", "function": "handleStoreFeedback", "functionResult": { "error": "未找到当前货主在仓库中的运单「SF9999999999999」,请核实单号后重试", "success": false } } ] ``` - 出站回执: | ext_id | content | push_status | |---|---|---| | `sys:ack:api:APP2025011514315678:httpv2-09-1789656298793` | 未找到当前货主在仓库中的运单「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-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | 入站消息入库 | ✅ | id=2134 | | 无出站回执(静默) | ✅ | | | 白名单行存在(express/after_sales 允许 damage 子类型) | ✅ | 行数=1 | | 函数越权拦截(handleStoreFeedback 仅 store 群可用 → 无轨迹) | ✅ | 无轨迹 | - 入站消息 id=2134,ai_thoughts: ```json null ``` ### TC11 模块优先(ai_enabled=0 但 template_reply_enabled=1) ✅ PASS - 消息:`破损 SF1234567890123` - ext_id:`api:APP2025011514315678:httpv2-11-1789656298793` | 校验项 | 结果 | 详情 | |---|---|---| | 不依赖 ai_enabled,仍走 v2(轨迹含 v2 关键词命中) | ✅ | [{"round":0,"action":"rule","params":{"keyword":"SF1234567890123","issue_type":"damaged"},"reason":"v2 关键词命中: 破损","function":"handleStoreFeedback","functionResult":{"error":"未找到当前货主在仓库中的运单「SF123456789 | | 出站回执存在 | ✅ | 未找到当前货主在仓库中的运单「SF1234567890123」,请核实单号后重试 | - 入站消息 id=2135,ai_thoughts: ```json [ { "round": 0, "action": "rule", "params": { "keyword": "SF1234567890123", "issue_type": "damaged" }, "reason": "v2 关键词命中: 破损", "function": "handleStoreFeedback", "functionResult": { "error": "未找到当前货主在仓库中的运单「SF1234567890123」,请核实单号后重试", "success": false } } ] ``` - 出站回执: | ext_id | content | push_status | |---|---|---| | `sys:ack:api:APP2025011514315678:httpv2-11-1789656298793` | 未找到当前货主在仓库中的运单「SF1234567890123」,请核实单号后重试 | 2 | - 本地 ack 服务收到 notify.reply:type=ai - wms_warehouse_log notify.reply 日志:http_status=200 ## 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`)。