4 Commits

Author SHA1 Message Date
liufumingren
511f7abf94 fix(dgj): 补齐 listOrders 的 scanHost 定义,并补快手 key / 菜鸟 templateURL 打印字段
1) 修正 F47D8CC 的漏提:那次只提交了「补查其它域名」的调用侧
   (`for (const host of hosts) await scanHost(host);`),把 `const scanHost = async host => {`
   的定义留在了工作区,HEAD 上 `listOrders` 会 ReferenceError。本次一并补齐,HEAD 与工作区一致。

2) 面单打印字段按平台口径区分(WMS 侧联调结论):
   - 快手(KS):printinfo = encryptedData,encryptprintinfo / key = 逐单密钥(原口径不变)
   - 菜鸟系(TB / TM / TGC / 1688):平台 printInfo 为空,菜鸟打印只认整包 JSON
     `{ encryptedData, signature, ver, templateURL }`,按该形态回拼 printinfo;
     templateURL 取 `contents[0].templateURL`
   - 其它平台:printinfo 原样用平台下发数据
   - `extractDocumentContents` 增加 template_url 字段(缺失时为空串)

3) 单测:printPlatformDgj.test.js 覆盖 template_url 解析与淘宝/快手/其它平台三种口径,
   test/app/lib 73 passing;eslint 干净

4) 文档:WMS-OMS-取号对接.md 追加 WMS 侧核实记录(快手 printinfo 未落库的报文缺字段结论、
   打印数据形态兼容、菜鸟 templateURL 模板要求与对账表)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-07 20:33:33 +08:00
liufumingren
e0c718af8e fix(waybill): 快手取号补齐 key 与加密面单字段
- dgj: 抽取 contents[0].key;快手单 printinfo 取 encryptedData、encryptprintinfo 取逐单密钥(对齐菠萝派口径)
- waybillGet: deliveryorder.getwaybill 响应新增 key 字段并透传给 WMS
- 探测脚本输出 encryptprintinfo/key 长度;补充单测
- 更新 WMS-OMS 取号对接文档的快手字段说明

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-07 19:05:36 +08:00
liufumingren
7f8cff808b feat(waybill): 取号时解析并留痕打印记录ID(PrintHistoryIds)
平台 ExpressPrint 响应里有 Data.PrintHistoryIds,元素 { Id, Pid, WaybillCode,
WaybillCodeChild, BatchIndex },其中 Id 即 printHistoryId:重打/作废/查打印记录
(PrintHistory/LoadPrintData)都按它回捞。之前只用了 WaybillCode/printinfo,
这块被丢掉了。

- dgj.fetchWaybillNo 解析为 [{ id, pid, waybill_code, batch_index }]
- waybillGet 写入 waybill_fetch_records.print_history_ids(JSON 数组,多包裹对齐)
- 仅本地留痕,不改回 WMS 的响应契约
- 迁移 20261107030000 加列;单测覆盖真实响应样例与多包裹/缺失字段

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-07 06:26:46 +08:00
liufumingren
a4213bfd0d fix(external-print): 拉单只取平台未发货订单,已发货/已终结不再进待审核
问题:店管家 /NewOrder/List 只支持按时间窗查询,不提供发货状态过滤,
原实现仅按 UpFxUserId 归属就整批入库,导致 sended/success/close 的订单
全部堆进「待审核」(实测店铺 19 近 7 天平台返回 385 单,真正待发货只有 11 单)。

- dgj 新增 isOrderFinished():ErpState∈sended/success/close(及各平台等价状态)、
  有 OnlineSendTime、面单 IsSended=true、LogisticStatus>0 任一命中即视为已处理;
  PrintState/ExpressPrintTime 仅表示已打印面单,不作为判定依据
- listOrders 过滤未发货订单,返回 skipped 与 finished 列表
- externalPrintOrder.syncOrders 新增 voidFinishedOrders():本地仍处于待审核、
  平台侧已发货的副本自动作废(写 void_at/void_reason + 操作日志),已审核订单不动
- orderStatus.voidOrder 支持 principalId(定时任务无登录态)
- 手动/自动拉单消息、接口返回、接口契约、前端提示补充「跳过已发货 / 自动作废」统计
- 新增 scripts/cleanup-shipped-pending-orders.js(npm run orders:cleanup-shipped):
  按同一口径清理历史脏单,默认 dry-run,--apply 才删除
- 新增 isOrderFinished 单测(7 项)

已清理历史脏单 103 条(备份见会话 files/backup-shipped-pending-orders.json),
清理后待审核仅剩 2 单真实的平台待发货订单。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-03 04:14:02 +08:00