oms/backend/database/migrations/20260915002000-outbound-express-columns-comment.js
liufumingren 39c19a4de7 feat(backend): 出入库记录与库存锁定链路、出库单快递/收件人与推送队列
- 出入库记录(库存流水):新增 stock_records 表/模型/只读接口(列表 + 业务动作选项)与「出入库记录」菜单;
  库存变动统一收敛到 app/utils/stockRecord.js#applyStockChange,与流水写入同事务(含变动前后总/锁定/可用数量)
- 发货单:审核(1→2) 按明细锁定库存、发货确认(3→4) 扣减、推送失败退回/驳回/取消/作废释放(新增 stock_locked 列);
  恢复(9→1) 时曾推送过的单据换号(WMS 取消后原单号仍被占用,沿用旧号重推会被判「订单已存在」)
- 出库单:新增快递(express_code/express_name)、收件人(receiver_*) 与多运单号(express_codes) 字段;
  推送报文补齐 logisticsCode/receiverInfo;新增出库单推送服务与定时任务
- 快递:多运单号回填、仓库快递映射(warehouse_express_mappings) 与快递字典补录等迁移
- 契约:补充出入库记录、出库单快递/收件人等定义(swagger.json 为本地生成、不入库)
2026-09-14 00:59:23 +08:00

46 lines
1.9 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';
/**
* 出库单快递公司列注释同步:express_code / express_name
*
* 背景:WMS 可能「转快递」处理(推送 ZT 自提、实际发 YTO 圆通),`stockout.confirm` 回传的
* `packages[].logisticsCode/logisticsName` 才是实际承运;OMS 现按回传值**覆盖**这两列
* (见 app/lib/orderCallback.js#buildExpressOverride),故列语义由「推送值」变为「以回传为准」。
*
* 幂等:仅当现有注释与目标评论不同时才 MODIFY(可重复执行)。
*/
const TARGET = {
express_code: '快递公司编码:推送为 deliveryOrder.logisticsCode,出库确认回传后按 WMS 实际承运覆盖(可能转快递)',
express_name: '快递公司名称:推送时按字典解析,出库确认回传后按 WMS 实际承运覆盖',
};
module.exports = {
async up(queryInterface, Sequelize) {
const columns = await queryInterface.describeTable('outbound_orders');
for (const [ name, comment ] of Object.entries(TARGET)) {
const col = columns[name];
if (!col || col.comment === comment) continue;
await queryInterface.changeColumn('outbound_orders', name, {
type: name === 'express_code' ? Sequelize.STRING(50) : Sequelize.STRING(200),
allowNull: true,
comment,
});
}
},
async down(queryInterface, Sequelize) {
// 注释回滚到改动前的文本(列本身不新增/不删除)
const previous = {
express_code: '快递公司编码(推送 deliveryOrder.logisticsCode,如 SF/STO)',
express_name: '快递公司名称(按 express_companies 字典解析的快照)',
};
for (const [ name, comment ] of Object.entries(previous)) {
await queryInterface.changeColumn('outbound_orders', name, {
type: name === 'express_code' ? Sequelize.STRING(50) : Sequelize.STRING(200),
allowNull: true,
comment,
});
}
},
};