5 Commits

Author SHA1 Message Date
liufumingren
4c2cfe1793 修复取号回调的订单级幂等与重放
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-17 17:16:14 +08:00
liufumingren
09587bc3e7 feat(waybill): 新增 deliveryorder.getprintdata,打印前按运单号换新 params
店管家面单打印数据(params)只有 10 分钟有效期,取号返回的 printinfo 存着不能用,
WMS 真正打印前必须换新的。新增对外方法:

  method = deliveryorder.getprintdata
  入参:{ caiNiaoAuthInfoIds: [6838859], waybillCodes: ["770357408441408"] }
       也支持直传 { printHistoryIds: ["10000078656212"] }(命中即跳过查库)
  出参:{ total, success, failed, expires_in: 600, results: [...] }
       每单含 print_data / printer_config / document(documentID = 运单号)

实现:
- app/lib/waybillPrintData.js:按「店铺标识 + 运单号」查 waybill_fetch_records 定位打印记录,
  同账号同分区合并成一次 PrintHistory/LoadPrintData(只读,不消耗面单)
- 取号记录补 platform_host(实际命中的订单域名):1688 分销单在 fxali、真实抖音单在 fxdd,
  用被换算过的 source_platform_code 推域名会打错
- waybillGet 落 platform_host;迁移 20261107050000 加列

实测(只读):运单号 770357408441408 → 新 params 7888 字符,documentID 770357408441408,
printer 默认打印机;不存在的运单号返回「未找到该运单号的取号记录」。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-07 06:38:34 +08:00
liufumingren
9252763aba feat(waybill): 取号记录补店铺标识与分区,新增回捞打印数据能力
抖店面单打印数据(params)只有 10 分钟有效期,WMS 真正打印前必须回平台换一次新的,
因此取号时要留下「定位用」的信息。

- waybill_fetch_records 新增 cai_niao_auth_info_id(=店铺唯一标识)与 dbname(取号命中的分区)
- 迁移 20261107040000 加列 + 运单号索引(principal_id + cai_niao_auth_info_id + waybill_code)
- dgj.fetchWaybillNo 回传实际命中的 dbname;waybillGet 落库并把 CaiNiaoAuthInfoId 写入留痕上下文
- dgj.loadPrintData:POST /PrintHistory/LoadPrintData(printHistoryIds[] + dbname),
  解析 Data[].ID/ExpressWaybillCode/TemplateId/PrintDataJson,只读不消耗面单

实测(只读):打印记录 10000078656212 → 运单号 770357408441408,模板 10776786,
print_data 长度 7888。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-07 06:33:15 +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
e1e3bb638f feat(order): 拉单任务、外部发货同步与取号记录
- 拉单任务:新增 order_sync_tasks 异步任务池,按店铺逐店拉取外部打单平台订单,前端轮询进度
- 外部发货同步:配送后把发货结果同步回店管家,提供数量统计与批量重试(externalSendSync)
- 取号:新增 waybill_fetch_records 记录取号过程,外部快递接口补充菜鸟授权信息
- 补齐相关迁移、订单页同步入口/状态展示,并新增对接说明文档

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-04 20:53:35 +08:00