oms/backend/database/migrations/20260916070000-add-order-queued-status-table.js
liufumingren 6c03a20364 feat(backend): 订单状态分表、WMS 推送与归档
- 新增 order_index 索引表 + 6 张同构状态表(待审核/异常/委外中/配送/已作废/已取消)与历史表,
  订单 ID 全局唯一,状态由业务事务推动:审核、驳回、取消、作废、恢复、归档
- 明细表 order_status_items、收件人文本智能解析、批量切换仓库/店铺并刷新快照
- WMS deliveryorder.create 推送(单条/批量)、推送失败定时重试、订单归档定时任务
- 迁移:建表、旧发货单数据迁入新表、菜单合并与迁移记录清理
- routes / swagger contract 补充订单状态接口

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-30 23:06:18 +08:00

29 lines
1.3 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';
const { migrate, STATUS_TABLES } = require('../orderStatusTables');
const { ORDER_STATUS, ORDER_TABLE_BY_STATUS } = require('../../app/lib/orderStatus');
/**
* 新增「待推送(queued)」状态表
*
* 背景(2026-09-16 按用户要求):原来「审核通过」直接进「委外中」,把「已审核待推送」与
* 「已推送成功」混在同一个状态里。现在拆开:
* 待审核 →(审核+锁库存)待推送 →(推送仓库成功)委外中 →(仓库回传确认)配送
* 推送失败 → 异常
* 本迁移建表 + 补齐列(结构与其它状态表完全一致,字段定义来自 app/lib/orderFields.js);
* 存量「委外中」未推送成功的单据由下一条迁移搬到本表。
*
* 幂等:`migrate()` 会按需建表/补列,重复执行无副作用。
*/
module.exports = {
async up(queryInterface, Sequelize) {
await migrate(queryInterface, Sequelize);
console.log(`[order] 已确保 ${STATUS_TABLES.length} 张状态表就绪(含新增 ${ORDER_TABLE_BY_STATUS[ORDER_STATUS.QUEUED]})`);
},
async down(queryInterface) {
await queryInterface.dropTable(ORDER_TABLE_BY_STATUS[ORDER_STATUS.QUEUED]);
console.log(`[order] 已删除 ${ORDER_TABLE_BY_STATUS[ORDER_STATUS.QUEUED]}`);
},
};