- order_index 与各订单状态表新增 subsidiary_id(跟随店铺货主),历史数据按店铺回填 - 订单列表/详情/导出按货主范围过滤,货主权限仅可见自己所属公司的订单 - 订单 id 级操作统一在 _loadIndexRows 校验货主:审核/推送/驳回/取消/作废/恢复/改仓库物流/删除/明细维护越界返回 403 - 新建订单货主跟随店铺,货主权限只能为自己公司店铺建单;平台拉单写入时同步店铺货主 - 内部任务/平台回调无登录态时按系统操作处理,不受货主范围限制 - 订单列表与导出新增货主列 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
34 lines
1.8 KiB
JavaScript
34 lines
1.8 KiB
JavaScript
'use strict';
|
||
|
||
const { ORDER_INDEX_TABLE } = require('../lib/orderStatus');
|
||
|
||
/**
|
||
* 订单索引表(order_index)
|
||
*
|
||
* 订单的**全局唯一 ID 以本表为准**:各状态表与历史表的主键都取自本表 id,
|
||
* 另通过 current_table 记录订单当前所在状态表、current_status 记录当前状态,
|
||
* 便于「不依赖具体状态表」地定位任一订单(批量流转时按索引表分组处理)。
|
||
* @param {Egg.Application} app egg application
|
||
* @return {object} orderIndex model
|
||
*/
|
||
module.exports = app => {
|
||
const { BIGINT, STRING, DATE } = app.Sequelize;
|
||
|
||
const OrderIndex = app.model.define(ORDER_INDEX_TABLE, {
|
||
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键(订单全局唯一 ID)' },
|
||
order_no: { type: STRING(50), allowNull: false, comment: '订单号' },
|
||
parent_order_no: { type: STRING(50), comment: '来源订单号(外部平台唯一单号;店管家为系统编号 LogicOrderId)' },
|
||
principal_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属主体ID(主体隔离)' },
|
||
subsidiary_id: { type: BIGINT.UNSIGNED, comment: '所属货主(下属公司ID)' },
|
||
current_table: { type: STRING(16), allowNull: false, defaultValue: 'pending', comment: '当前所在表:pending/exception/outsourcing/delivery/history' },
|
||
current_status: { type: STRING(16), allowNull: false, defaultValue: 'pending', comment: '当前状态:pending 待审核 / exception 异常 / outsourcing 委外中 / delivery 配送 / history 历史' },
|
||
created_at: { type: DATE, comment: '创建时间(用于超 3 个月自动归档判断)' },
|
||
updated_at: { type: DATE, comment: '更新时间' },
|
||
}, {
|
||
tableName: ORDER_INDEX_TABLE,
|
||
comment: '订单索引表(订单 ID 以此为准)',
|
||
});
|
||
|
||
return OrderIndex;
|
||
};
|