WMS_MAIN/app/model/order_items.js

151 lines
3.2 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.

// model/order_items.js
'use strict';
module.exports = app => {
const { Sequelize, model } = app;
const { STRING, BIGINT, DECIMAL, INTEGER, JSON, TEXT } = 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: TEXT,
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',
},
item_snapshot: {
type: JSON,
allowNull: true,
comment: '商品快照',
},
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;
};