'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'); }, };