oms/backend/database/migrations/20260916030000-create-order-tables.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

34 lines
1.4 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';
/**
* 建立订单(状态分表)表结构。
*
* 表清单:
* 1. order_index 订单索引表:订单 ID 全局唯一,current_table/current_status 记录当前归属表与状态
* 2. order_status_pending 待审核
* 3. order_status_exception 异常
* 4. order_status_outsourcing 委外中
* 5. order_status_delivery 配送
* 6. order_status_history 历史(另含 archived_at 归档时间、transferred_at 转入时间)
*
* 说明:
* - 4 张状态表结构完全一致,订单在各表间流转(来源表删除 + 目标表写入 + 更新索引表);
* - DDL 与「旧命名就地改名」逻辑统一放在 database/orderStatusTables.js(唯一来源),保证可重复执行;
* - 兼容处理:若库里存在旧命名的状态表(split_order_pending 等,模块早期按「拆单」语义命名),
* 本迁移会**就地改名**为当前命名(保留数据与索引),不会重建表、不丢数据;
* 更早的「单活动表」设计残留表(split_order_active 等,表内无数据)会被清理。
*
* 执行:npm run migration:up
*/
const { migrate, dropTables } = require('../orderStatusTables');
module.exports = {
async up(queryInterface, Sequelize) {
await migrate(queryInterface, Sequelize);
},
async down(queryInterface) {
await dropTables(queryInterface);
},
};