oms/backend/database/migrations/20260916060000-merge-delivery-menus-into-order.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

55 lines
2.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 { applyOrderMenu, LEGACY_DELIVERY_MENUS } = require('../orderMenu');
/**
* 把老发货单菜单并入「订单」
*
* 背景:老发货单(order_deliveries)的数据与全部能力(创建 / 审核+锁库存 / 推送仓库 / 驳回换号 /
* 取消 / 作废 / 恢复 / 明细维护 / 换仓库换店铺 / 回传确认)已迁到新表(order_index + order_status_*),
* 且「订单」页(views/Order/Status.vue)已实现同样的操作,故下线这两个独立菜单入口:
* - 创建发货单 /order-create
* - 发货单 /order-delivery
* 代码文件保留(views/Order/Create.vue、views/Order/Index.vue),菜单不再展示。
* 幂等:重复执行结果一致(DELETE 不存在的行不做任何事)。
*/
module.exports = {
async up(queryInterface) {
await applyOrderMenu(queryInterface);
console.log(`[order] 已下线老发货单菜单:${LEGACY_DELIVERY_MENUS.map(m => `${m.name}(${m.path})`).join('、')}(能力已并入「订单」页)`);
},
async down(queryInterface) {
const sequelize = queryInterface.sequelize;
const [ orderMgmt ] = await sequelize.query(
"SELECT id FROM menus WHERE name = '订单管理' AND parent_id = 0 LIMIT 1",
{ type: sequelize.QueryTypes.SELECT }
);
if (!orderMgmt) return;
const restore = [
{ name: '创建发货单', path: '/order-create', component: 'views/Order/Create.vue', icon: 'Plus', permission: 'orderDelivery:create', sort: 80 },
{ name: '发货单', path: '/order-delivery', component: 'views/Order/Index.vue', icon: 'Van', permission: 'orderDelivery:list', sort: 75 },
];
for (const menu of restore) {
const [ exist ] = await sequelize.query(
'SELECT id FROM menus WHERE path = ? LIMIT 1',
{ replacements: [ menu.path ], type: sequelize.QueryTypes.SELECT }
);
if (exist) continue;
await sequelize.query(
`INSERT INTO menus
(parent_id, name, type, path, icon, permission, component, sort, status, created_at, updated_at)
VALUES (?, ?, 2, ?, ?, ?, ?, ?, 1, NOW(), NOW())`,
{
replacements: [
Number(orderMgmt.id), menu.name, menu.path, menu.icon,
menu.permission, menu.component, menu.sort,
],
}
);
}
console.log('[order] 已恢复老发货单菜单入口');
},
};