- trace 为空数组(暂无轨迹)不再计为失败:只计入 result.empty,不落库, 任务状态仍为 success;提示语补充「无轨迹 Z 单」 - weight 支持字符串小数(如 "0.99"):新增 parseTraceWeight 统一转数字保留 3 位小数 - wms_order_express_trace.weight 由 INT(11) 改为 DECIMAL(10,3)(迁移 20261111203500, 已在开发库与生产库执行;MySQL 不支持 INT→DECIMAL 的 INPLACE,走 COPY 重建) - 文档:methods/system.json(0.3.327)、变更记录、设计文档与出站回调说明同步 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
96 lines
2.7 KiB
JavaScript
96 lines
2.7 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 运单物流轨迹模型。
|
||
* 一个运单(express_id)对应多条轨迹,由外部快递/轨迹接口回传。
|
||
* @param {import('egg').Application} app Egg 应用实例。
|
||
* @return {import('sequelize').ModelCtor<import('sequelize').Model>} Sequelize 模型。
|
||
*/
|
||
module.exports = app => {
|
||
const { BIGINT, STRING, DECIMAL, DATE, JSON: JSON_TYPE } = app.Sequelize;
|
||
|
||
const OrderExpressTrace = app.model.define('order_express_trace', {
|
||
id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
primaryKey: true,
|
||
autoIncrement: true,
|
||
allowNull: false,
|
||
comment: '主键ID',
|
||
},
|
||
express_id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
allowNull: false,
|
||
comment: '运单ID(wms_order_express.id)',
|
||
},
|
||
waybill_code: {
|
||
type: STRING(50),
|
||
allowNull: false,
|
||
comment: '运单号(冗余,便于按运单号直查)',
|
||
},
|
||
order_id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
allowNull: true,
|
||
comment: '订单ID(冗余,便于按订单查轨迹)',
|
||
},
|
||
warehouse_id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
allowNull: false,
|
||
comment: '仓库ID(数据隔离维度)',
|
||
},
|
||
op_time: {
|
||
type: DATE,
|
||
allowNull: true,
|
||
comment: '操作时间(opTime)',
|
||
},
|
||
out_biz_code: {
|
||
type: STRING(191),
|
||
allowNull: true,
|
||
comment: '外部业务码(outBizCode)',
|
||
},
|
||
memo: {
|
||
type: STRING(500),
|
||
allowNull: true,
|
||
comment: '轨迹描述(memo)',
|
||
},
|
||
op_org_city_name: {
|
||
type: STRING(100),
|
||
allowNull: true,
|
||
comment: '操作机构所在城市(opOrgCityName)',
|
||
},
|
||
weight: {
|
||
type: DECIMAL(10, 3),
|
||
allowNull: true,
|
||
defaultValue: 0,
|
||
comment: '重量(weight,来源原值,支持小数如 0.99)',
|
||
},
|
||
scan_type: {
|
||
type: STRING(50),
|
||
allowNull: true,
|
||
comment: '扫描类型(scanType),如 发件/到件/派件/签收',
|
||
},
|
||
raw_data: {
|
||
type: JSON_TYPE,
|
||
allowNull: true,
|
||
comment: '原始轨迹报文(未落库字段的兜底存储)',
|
||
},
|
||
}, {
|
||
tableName: 'wms_order_express_trace',
|
||
freezeTableName: true,
|
||
underscored: true,
|
||
timestamps: true,
|
||
createdAt: 'created_at',
|
||
updatedAt: 'updated_at',
|
||
deletedAt: 'deleted_at',
|
||
paranoid: true,
|
||
comment: '运单物流轨迹表(1 运单 : N 轨迹)',
|
||
indexes: [
|
||
{ name: 'uk_express_op_scan', unique: true, fields: [ 'express_id', 'op_time', 'scan_type' ] },
|
||
{ name: 'idx_waybill_code', fields: [ 'waybill_code', 'op_time' ] },
|
||
{ name: 'idx_order_id', fields: [ 'order_id' ] },
|
||
{ name: 'idx_warehouse_op_time', fields: [ 'warehouse_id', 'op_time' ] },
|
||
],
|
||
});
|
||
|
||
return OrderExpressTrace;
|
||
};
|