WMS_MAIN/app/model/package_material.js
liufumingren 19c3fe09a7 refactor(weight): 重量字段统一为 INTEGER(g),取代 DECIMAL(kg)
- 8 个 model 重量字段类型 DECIMAL→INTEGER,注释 kg→g

- order_express 称重校验改为正整数(g)

- delivery_order 手动单查 StockStore + warehouse 称重毛重

- openapi.json 毛重/净重描述 kg→g

- 迁移: 20260725120000-unify-weight-fields-to-int-g

- 脚本: update-stock-warehouse-weight.cjs
2026-07-27 03:46:07 +08:00

116 lines
2.5 KiB
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';
/**
* 包材信息模型。
* @param {import('egg').Application} app Egg 应用实例。
* @return {import('sequelize').ModelCtor<import('sequelize').Model>} Sequelize 模型。
*/
module.exports = app => {
const { BIGINT, STRING, DECIMAL, TINYINT, INTEGER, DATE } = app.Sequelize;
const PackageMaterial = app.model.define('package_material', {
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '主键ID',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '仓库ID',
},
material_code: {
type: STRING(64),
allowNull: false,
comment: '包材编码',
},
material_name: {
type: STRING(128),
allowNull: false,
comment: '包材名称',
},
material_type: {
type: STRING(32),
allowNull: true,
comment: '包材类型',
},
spec: {
type: STRING(128),
allowNull: true,
comment: '规格描述',
},
length: {
type: DECIMAL(10, 2),
allowNull: true,
comment: '长度(cm)',
},
width: {
type: DECIMAL(10, 2),
allowNull: true,
comment: '宽度(cm)',
},
height: {
type: DECIMAL(10, 2),
allowNull: true,
comment: '高度(cm)',
},
weight: {
type: INTEGER(11),
allowNull: true,
defaultValue: 0,
comment: '重量(g)',
},
cost_price: {
type: DECIMAL(10, 2),
allowNull: true,
comment: '成本单价',
},
status: {
type: TINYINT(1),
allowNull: false,
defaultValue: 1,
comment: '状态:0=禁用,1=启用',
},
version: {
type: INTEGER.UNSIGNED,
allowNull: false,
defaultValue: 1,
comment: '版本号',
},
created_at: {
type: DATE,
allowNull: false,
comment: '创建时间',
},
updated_at: {
type: DATE,
allowNull: false,
comment: '更新时间',
},
}, {
tableName: 'wms_package_material',
freezeTableName: true,
underscored: true,
timestamps: true,
paranoid: false,
createdAt: 'created_at',
updatedAt: 'updated_at',
comment: '包材信息表',
indexes: [
{
name: 'idx_wms_package_material_warehouse_id',
fields: [ 'warehouse_id' ],
},
{
name: 'uk_wms_package_material_warehouse_material_code',
unique: true,
fields: [ 'warehouse_id', 'material_code' ],
},
],
});
return PackageMaterial;
};