oms/backend/database/migrations/20261107050000-add-platform-host-to-waybill-fetch-records.js
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

24 lines
882 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

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.

'use strict';
/**
* 取号记录补「订单域名」:`platform_host`。
*
* `PrintHistory/LoadPrintData` 与取号一样必须发到**订单所在的域名**(1688 分销单在 `fxali`、
* 真实抖音单在 `fxdd`),而 `source_platform_code` 可能已被平台换算改写(1688 → DYXD),
* 用它推域名会打错。因此取号时把实际命中的域名一起落库,重取打印数据时直接复用。
*/
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('waybill_fetch_records', 'platform_host', {
type: Sequelize.STRING(100),
allowNull: true,
comment: '实际命中的订单域名(重取打印数据要发到同一个域名)',
after: 'dbname',
});
},
async down(queryInterface) {
await queryInterface.removeColumn('waybill_fetch_records', 'platform_host');
},
};