- storeWarehouse.store.saveApiConfig:新增 resolveContractApiInterfaceType, interface_type_id=3(OPEN_API_WAREHOUSE 仓库开放接口)自动映射为 2(OPEN_API 货主开放接口)落库, 不再要求当前主体为仓库(货主可维护自身签约关系下的接口配置) - callback_url 不再取入参(含 callbackUrl 别名),统一写入 config.openapi.defaultCallbackUrl(新增配置项,默认空) - storeWarehouse.store.listApiConfig:interface_type_id 过滤同步映射(传 3 按 2 查询) - 文档:methods/system.json 升级 0.3.350、methods/changes/system.json 变更记录、docs/openapi-callback-events.md 回调地址来源说明 - 测试:saveApiConfig 新增 4 条用例(3→2 落库、忽略入参回调地址、默认值未配置、货主主体可保存、缺失类型 404),listApiConfig 新增 1 条过滤映射用例 同时提交工作区其余在制品改动: - waybill:移除 wms_order_express_trace 模型并新增 drop 迁移,轨迹查询/取号/打印链路调整 - order:订单 SN 编码(order_item_sn / order_item_sn_log / sn_code_rule、has_sn_item 回填迁移),pendingOrder/recheckOrder/wave/base 调整 - express_platform、order_async、order_export、order_storage_allocation、storage.report、stock_store 配套修复 - lib:新增 jd_client,调整 qimen_client、callback_functions 及配套测试 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
75 lines
3.8 KiB
JavaScript
75 lines
3.8 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 下线运单物流轨迹本地存储:删除 wms_order_express_trace。
|
||
*
|
||
* 背景(2026-11-11 业务调整):
|
||
* - 轨迹查询改为「全部回源」,`waybill.warehouse.getTrace` 实时调用外部 waybill.getTrace 返回,
|
||
* 不再落库;批量同步方法 `waybill.warehouse.updateTrace` / `updateTraceTaskProgress` 一并下线;
|
||
* - 因此轨迹表不再需要,删除以免产生无用数据与维护成本。
|
||
* - 揽收联动保留:查询命中轨迹时仍会把 wms_order_express.is_galaxy_receive 置为 Y。
|
||
*
|
||
* 说明:本迁移不可逆(数据不再保留),down 仅重建空表结构以便回滚版本时可启动。
|
||
*/
|
||
|
||
const TABLE_NAME = 'wms_order_express_trace';
|
||
|
||
module.exports = {
|
||
async up(queryInterface) {
|
||
const tables = await queryInterface.showAllTables();
|
||
const exists = (tables || []).some(t => {
|
||
const name = typeof t === 'string' ? t : (t && (t.tableName || t.name)) || '';
|
||
return String(name).toLowerCase() === TABLE_NAME;
|
||
});
|
||
|
||
if (!exists) {
|
||
console.log(`[${TABLE_NAME}] skip: 表不存在`);
|
||
return;
|
||
}
|
||
|
||
await queryInterface.dropTable(TABLE_NAME);
|
||
console.log(`[${TABLE_NAME}] dropped`);
|
||
},
|
||
|
||
async down(queryInterface, Sequelize) {
|
||
const { BIGINT, STRING, DATE, JSON: JSON_TYPE, DECIMAL } = Sequelize;
|
||
const tables = await queryInterface.showAllTables();
|
||
const exists = (tables || []).some(t => {
|
||
const name = typeof t === 'string' ? t : (t && (t.tableName || t.name)) || '';
|
||
return String(name).toLowerCase() === TABLE_NAME;
|
||
});
|
||
if (exists) {
|
||
console.log(`[${TABLE_NAME}] skip: 表已存在`);
|
||
return;
|
||
}
|
||
|
||
await queryInterface.createTable(TABLE_NAME, {
|
||
id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, allowNull: false, comment: '主键ID' },
|
||
express_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '运单ID(wms_order_express.id)' },
|
||
waybill_code: { type: STRING(50), allowNull: false, comment: '运单号' },
|
||
order_id: { type: BIGINT(20).UNSIGNED, allowNull: true, comment: '订单ID' },
|
||
warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '仓库ID' },
|
||
op_time: { type: DATE, allowNull: true, comment: '操作时间' },
|
||
out_biz_code: { type: STRING(191), allowNull: true, comment: '外部业务码' },
|
||
memo: { type: STRING(500), allowNull: true, comment: '轨迹描述' },
|
||
op_org_city_name: { type: STRING(100), allowNull: true, comment: '操作机构城市' },
|
||
weight: { type: DECIMAL(10, 3), allowNull: true, defaultValue: 0, comment: '重量(来源原值)' },
|
||
scan_type: { type: STRING(50), allowNull: true, comment: '扫描类型' },
|
||
raw_data: { type: JSON_TYPE, allowNull: true, comment: '原始轨迹报文' },
|
||
created_at: { type: DATE, allowNull: false, defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'), comment: '创建时间' },
|
||
updated_at: { type: DATE, allowNull: false, defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'), comment: '更新时间' },
|
||
deleted_at: { type: DATE, allowNull: true, comment: '软删除时间' },
|
||
}, {
|
||
charset: 'utf8mb4',
|
||
collate: 'utf8mb4_general_ci',
|
||
comment: '运单物流轨迹表(已下线本地存储)',
|
||
});
|
||
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'express_id', 'op_time', 'scan_type' ], { unique: true, name: 'uk_express_op_scan' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'waybill_code', 'op_time' ], { name: 'idx_waybill_code' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'order_id' ], { name: 'idx_order_id' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id', 'op_time' ], { name: 'idx_warehouse_op_time' });
|
||
console.log(`[${TABLE_NAME}] recreated (empty)`);
|
||
},
|
||
};
|