oms/backend/database/migrations/20261104060000-add-cai-niao-auth-info-id-to-express-interfaces.js
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

37 lines
1.5 KiB
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';
/**
* 快递接口(面单模板)增加菜鸟授权网点ID独立字段。
*
* 平台模板列表里 `CaiNiaoAuthInfoId` 表示该模板绑定的菜鸟授权网点(同平台下不同网点取值不同),
* 之前只存在 `raw` JSON 里;独立出来便于:
* - 取号时回传给 WMS(WMS 需要按网点归集/对账);
* - 后续多网点取号、按网点筛选。
*/
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('external_print_express_interfaces', 'cai_niao_auth_info_id', {
type: Sequelize.BIGINT.UNSIGNED,
allowNull: true,
comment: '菜鸟授权网点ID(平台模板 CaiNiaoAuthInfoId)',
});
// 从已有 raw 回填(JSON 里的值可能是字符串或数字)
await queryInterface.sequelize.query(`
UPDATE \`external_print_express_interfaces\`
SET \`cai_niao_auth_info_id\` = CAST(JSON_UNQUOTE(JSON_EXTRACT(\`raw\`, '$.CaiNiaoAuthInfoId')) AS UNSIGNED)
WHERE JSON_EXTRACT(\`raw\`, '$.CaiNiaoAuthInfoId') IS NOT NULL
AND JSON_UNQUOTE(JSON_EXTRACT(\`raw\`, '$.CaiNiaoAuthInfoId')) REGEXP '^[0-9]+$'
`);
await queryInterface.addIndex('external_print_express_interfaces', [ 'cai_niao_auth_info_id' ], {
name: 'idx_express_interface_cai_niao_auth',
});
},
async down(queryInterface) {
await queryInterface.removeIndex('external_print_express_interfaces', 'idx_express_interface_cai_niao_auth');
await queryInterface.removeColumn('external_print_express_interfaces', 'cai_niao_auth_info_id');
},
};