oms/backend/database/migrations/20261107040000-add-shop-and-dbname-to-waybill-fetch-records.js
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

41 lines
2.0 KiB
JavaScript
Raw Permalink 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';
/**
* 取号记录补「店铺唯一标识 + 分区」:`cai_niao_auth_info_id` / `dbname`。
*
* 店管家的面单打印数据(params)只有 **10 分钟**有效期,WMS 真正打印时需要重新拉一次
* (`POST /PrintHistory/LoadPrintData`,入参 printHistoryIds[] + dbname)。
* 因此取号时把「店铺唯一标识(= 模板绑定的 CaiNiaoAuthInfoId)」与「实际命中的分区 dbname」
* 一起落库,后续按「CaiNiaoAuthInfoId + 运单号」即可定位到取号记录、再回平台换新的打印数据。
*/
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('waybill_fetch_records', 'cai_niao_auth_info_id', {
type: Sequelize.BIGINT.UNSIGNED,
allowNull: true,
comment: '菜鸟授权网点ID(=店铺唯一标识,重取打印数据时按它+运单号定位)',
after: 'print_history_ids',
});
await queryInterface.addColumn('waybill_fetch_records', 'dbname', {
type: Sequelize.STRING(100),
allowNull: true,
comment: '实际命中的打单平台分区(重取打印数据要带同一个 dbname)',
after: 'cai_niao_auth_info_id',
});
// 按运单号回查取号记录(WMS 只带运单号 + 店铺标识)
await queryInterface.addIndex('waybill_fetch_records', [ 'waybill_code' ], {
name: 'idx_waybill_fetch_records_waybill_code',
});
await queryInterface.addIndex('waybill_fetch_records', [ 'principal_id', 'cai_niao_auth_info_id', 'waybill_code' ], {
name: 'idx_waybill_fetch_records_shop_waybill',
});
},
async down(queryInterface) {
await queryInterface.removeIndex('waybill_fetch_records', 'idx_waybill_fetch_records_shop_waybill');
await queryInterface.removeIndex('waybill_fetch_records', 'idx_waybill_fetch_records_waybill_code');
await queryInterface.removeColumn('waybill_fetch_records', 'dbname');
await queryInterface.removeColumn('waybill_fetch_records', 'cai_niao_auth_info_id');
},
};