oms/backend/app/model/orderStatusHistory.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

28 lines
951 B
JavaScript
Raw Permalink 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 { businessFields, historyFields } = require('../lib/orderFields');
const { ORDER_STATUS, ORDER_TABLE_BY_STATUS } = require('../lib/orderStatus');
/**
* 历史订单表(order_status_history)
*
* 结构与 4 张状态表一致,另加:
* - archived_at 归档时间(转入历史表时写入)
* - transferred_at 转入时间(状态流转进入历史的时间)
* 归档为物理迁移(状态表删除 + 本表插入),页面「历史」tab 只读展示。
* @param {Egg.Application} app egg application
* @return {object} orderStatusHistory model
*/
module.exports = app => {
const tableName = ORDER_TABLE_BY_STATUS[ORDER_STATUS.HISTORY];
const OrderStatusHistory = app.model.define(tableName, {
...businessFields(app.Sequelize, ORDER_STATUS.HISTORY),
...historyFields(app.Sequelize),
}, {
tableName,
comment: '订单-历史(归档)',
});
return OrderStatusHistory;
};