- 拉单任务:新增 order_sync_tasks 异步任务池,按店铺逐店拉取外部打单平台订单,前端轮询进度 - 外部发货同步:配送后把发货结果同步回店管家,提供数量统计与批量重试(externalSendSync) - 取号:新增 waybill_fetch_records 记录取号过程,外部快递接口补充菜鸟授权信息 - 补齐相关迁移、订单页同步入口/状态展示,并新增对接说明文档 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
70 lines
2.5 KiB
JavaScript
70 lines
2.5 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 状态表 / 历史表增加「同步外部发货」状态字段。
|
||
*
|
||
* 配送后需要把发货结果同步回外部打单平台(店管家 `NewOrder/OnlineSendBatch`):
|
||
* - 逐单记录状态与尝试次数,失败自动重试,超过上限转异常(等人工批量重试);
|
||
* - 订单流转时按字段定义整体搬运,所以所有状态表 + 历史表都要有这几列。
|
||
*/
|
||
|
||
const TABLES = [
|
||
'order_status_pending',
|
||
'order_status_queued',
|
||
'order_status_exception',
|
||
'order_status_outsourcing',
|
||
'order_status_delivery',
|
||
'order_status_void',
|
||
'order_status_canceled',
|
||
'order_status_history',
|
||
];
|
||
|
||
module.exports = {
|
||
async up(queryInterface, Sequelize) {
|
||
for (const table of TABLES) {
|
||
await queryInterface.addColumn(table, 'external_send_status', {
|
||
type: Sequelize.TINYINT.UNSIGNED,
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '同步外部发货状态:0待同步 1已同步 2同步失败待重试 3异常(重试超限)',
|
||
});
|
||
await queryInterface.addColumn(table, 'external_send_times', {
|
||
type: Sequelize.INTEGER.UNSIGNED,
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '同步外部发货已尝试次数',
|
||
});
|
||
await queryInterface.addColumn(table, 'external_send_error', {
|
||
type: Sequelize.STRING(500),
|
||
allowNull: true,
|
||
comment: '最近一次同步失败原因',
|
||
});
|
||
await queryInterface.addColumn(table, 'external_send_at', {
|
||
type: Sequelize.DATE,
|
||
allowNull: true,
|
||
comment: '最近一次同步尝试时间',
|
||
});
|
||
await queryInterface.addColumn(table, 'external_sent_at', {
|
||
type: Sequelize.DATE,
|
||
allowNull: true,
|
||
comment: '同步成功时间',
|
||
});
|
||
}
|
||
|
||
await queryInterface.addIndex('order_status_delivery', [ 'principal_id', 'external_send_status' ], {
|
||
name: 'idx_delivery_external_send_status',
|
||
});
|
||
},
|
||
|
||
async down(queryInterface) {
|
||
await queryInterface.removeIndex('order_status_delivery', 'idx_delivery_external_send_status');
|
||
for (const table of TABLES) {
|
||
await queryInterface.removeColumn(table, 'external_sent_at');
|
||
await queryInterface.removeColumn(table, 'external_send_at');
|
||
await queryInterface.removeColumn(table, 'external_send_error');
|
||
await queryInterface.removeColumn(table, 'external_send_times');
|
||
await queryInterface.removeColumn(table, 'external_send_status');
|
||
}
|
||
},
|
||
};
|