'use strict'; /** * 商品结构-包材绑定关系模型。 * 记录订单商品结构指纹与包材的绑定历史,支持智能推荐。 * @param {import('egg').Application} app Egg 应用实例。 * @return {import('sequelize').ModelCtor} Sequelize 模型。 */ module.exports = app => { const { STRING, CHAR, INTEGER, BIGINT, DECIMAL, TINYINT, DATE } = app.Sequelize; const PackageMaterialItemRelation = app.model.define('package_material_item_relation', { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键ID', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '仓库ID', }, items_hash: { type: CHAR(32), allowNull: false, comment: '订单商品结构MD5指纹', }, items_crc: { type: INTEGER.UNSIGNED, allowNull: false, comment: '订单商品结构CRC32校验', }, package_material_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '包材ID', }, package_material_code: { type: STRING(64), allowNull: false, comment: '包材编码(快照)', }, package_material_name: { type: STRING(128), allowNull: false, comment: '包材名称(快照)', }, package_material_spec: { type: STRING(128), defaultValue: '', comment: '规格(快照)', }, package_material_type: { type: STRING(32), defaultValue: '', comment: '类型(快照)', }, length: { type: DECIMAL(10, 2), defaultValue: 0, comment: '长(cm)快照', }, width: { type: DECIMAL(10, 2), defaultValue: 0, comment: '宽(cm)快照', }, height: { type: DECIMAL(10, 2), defaultValue: 0, comment: '高(cm)快照', }, weight: { type: INTEGER(11), defaultValue: 0, comment: '重量(g)快照', }, bind_count: { type: INTEGER.UNSIGNED, defaultValue: 1, comment: '累计绑定次数', }, last_order_id: { type: BIGINT(20).UNSIGNED, comment: '最近订单ID', }, last_waybill_code: { type: STRING(50), defaultValue: '', comment: '最近运单号', }, last_bind_user_id: { type: BIGINT(20).UNSIGNED, comment: '最近操作用户ID', }, last_bind_at: { type: DATE, comment: '最近绑定时间', }, is_active: { type: TINYINT, defaultValue: 1, comment: '包材当前是否启用', }, created_at: { type: DATE, allowNull: false, comment: '创建时间', }, updated_at: { type: DATE, allowNull: false, comment: '更新时间', }, delete_at: { type: DATE, comment: '软删除时间', }, }, { tableName: 'wms_package_material_item_relation', underscored: true, paranoid: true, createdAt: 'created_at', updatedAt: 'updated_at', deletedAt: 'delete_at', }); return PackageMaterialItemRelation; };