3 Commits

Author SHA1 Message Date
liufumingren
3b98a1c3dc feat(waybill): getprintdata 改走「原单号打印」重签,拿到新鲜的 params
上一版用 PrintHistory/LoadPrintData,实测它只回放那次打印的签名(timestamp = 打印记录
CreateDate,换 FxPageType / IsRePrint / IsRefresh 都不重签),10 分钟后必过期。

实测出真正的重签方式(复用原运单号、不消耗面单):
  ExpressPrint + PrintMethod=Normal + IsIgnoreWaybillRepeat=true
→ 返回的运单号与原来一致,params.timestamp = 当前时间。

- dgj.reprintPrintData:原单号打印并解析 documents[].contents[].params
- dgj.expressPrint 支持 reprint 选项(Normal + IsIgnoreWaybillRepeat=true)
- getprintdata 改为:回读平台订单行 → 原单号打印 → 返回新 params / template_url;
  安全闸:若平台返回了新运单号(说明已消耗面单)直接判失败并 error 日志
- 仍逐张串行 + 300ms 间隔限流;参数归一化/定位逻辑不变

实测:请求 07:39:44 → params timestamp 2026-11-07 07:39:45,运单号 770357415909002 未变。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-07 07:40:30 +08:00
liufumingren
82879cdef5 feat(waybill): getprintdata 只回 params 串,并按 printHistoryId 逐个限流回源
- 返回精简:每单只给定位字段 + params(contents[].params,形如
  access_token=…&app_key=…&method=logistics.getShopKey&…&sign=…)与 template_url;
  不再回整包 print_data / printer_config / document
- 限流:平台该接口有限流,改为一次只带一个 printHistoryId,逐张串行并间隔 300ms;
  单张失败不影响其它张,失败原因逐单返回
- params 为空时直接判失败(平台的打印数据里没有 params)

实测:{ printHistoryId: "10000078656212" } → params 为 access_token=uo7…
&method=logistics.getShopKey&…&sign=8849…,template_url 为申通 76x130 模板。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-07 06:56:20 +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