146 lines
3.1 KiB
JavaScript
146 lines
3.1 KiB
JavaScript
// model/order_items.js
|
||
'use strict';
|
||
|
||
module.exports = app => {
|
||
const { Sequelize, model } = app;
|
||
const { STRING, BIGINT, DECIMAL, TEXT, INTEGER, JSON } = Sequelize;
|
||
|
||
const OrderItems = model.define('wms_order_items', {
|
||
id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
primaryKey: true,
|
||
autoIncrement: true,
|
||
},
|
||
order_id: {
|
||
type: BIGINT(20).UNSIGNED,
|
||
allowNull: true,
|
||
comment: '订单ID',
|
||
},
|
||
actual_price: {
|
||
type: DECIMAL(18, 2),
|
||
allowNull: false,
|
||
defaultValue: 0.00,
|
||
comment: '实际价格',
|
||
},
|
||
retail_price: {
|
||
type: DECIMAL(18, 2),
|
||
allowNull: true,
|
||
comment: '零售价格',
|
||
},
|
||
ext_code: {
|
||
type: STRING(50),
|
||
allowNull: true,
|
||
comment: '外部编码',
|
||
},
|
||
inventory_type: {
|
||
type: STRING(50),
|
||
allowNull: true,
|
||
comment: '库存类型',
|
||
},
|
||
item_code: {
|
||
type: STRING(50),
|
||
allowNull: true,
|
||
comment: '商品编码',
|
||
},
|
||
item_id: {
|
||
type: BIGINT(20),
|
||
allowNull: true,
|
||
comment: '商品ID',
|
||
},
|
||
item_name: {
|
||
type: STRING(200),
|
||
allowNull: true,
|
||
comment: '商品名称',
|
||
},
|
||
order_line_no: {
|
||
type: STRING(50),
|
||
allowNull: true,
|
||
comment: '订单行号',
|
||
},
|
||
owner_code: {
|
||
type: STRING(50),
|
||
allowNull: true,
|
||
comment: '货主编码',
|
||
},
|
||
plan_qty: {
|
||
type: INTEGER(11),
|
||
allowNull: true,
|
||
comment: '计划数量',
|
||
},
|
||
source_order_code: {
|
||
type: STRING(50),
|
||
allowNull: true,
|
||
comment: '源订单编码',
|
||
},
|
||
sub_source_order_code: {
|
||
type: STRING(50),
|
||
allowNull: true,
|
||
comment: '子源订单编码',
|
||
},
|
||
extend_props: {
|
||
type: JSON, // 改为JSON类型,便于查询
|
||
allowNull: true,
|
||
comment: '扩展属性(JSON格式)',
|
||
},
|
||
stock_id: {
|
||
type: BIGINT(20),
|
||
allowNull: true,
|
||
comment: '库存ID',
|
||
},
|
||
created_at: {
|
||
type: Sequelize.DATE,
|
||
allowNull: false,
|
||
defaultValue: Sequelize.NOW,
|
||
comment: '创建时间',
|
||
},
|
||
updated_at: {
|
||
type: Sequelize.DATE,
|
||
allowNull: false,
|
||
defaultValue: Sequelize.NOW,
|
||
comment: '更新时间',
|
||
},
|
||
}, {
|
||
tableName: 'wms_order_items',
|
||
timestamps: true, // 启用时间戳
|
||
underscored: true, // 使用下划线命名
|
||
paranoid: false, // 不启用软删除
|
||
indexes: [
|
||
{
|
||
name: 'idx_order_id',
|
||
fields: [ 'order_id' ],
|
||
},
|
||
{
|
||
name: 'idx_item_id',
|
||
fields: [ 'item_id' ],
|
||
},
|
||
{
|
||
name: 'idx_item_code',
|
||
fields: [ 'item_code' ],
|
||
},
|
||
{
|
||
name: 'idx_source_order_code',
|
||
fields: [ 'source_order_code' ],
|
||
},
|
||
{
|
||
name: 'idx_stock_id',
|
||
fields: [ 'stock_id' ],
|
||
},
|
||
{
|
||
name: 'idx_owner_code',
|
||
fields: [ 'owner_code' ],
|
||
},
|
||
{
|
||
name: 'idx_order_item',
|
||
fields: [ 'order_id', 'item_id' ],
|
||
},
|
||
{
|
||
name: 'idx_created_at',
|
||
fields: [ 'created_at' ],
|
||
},
|
||
],
|
||
comment: '订单商品明细表',
|
||
});
|
||
|
||
return OrderItems;
|
||
};
|