'use strict'; module.exports = app => { const { STRING, BIGINT, TINYINT, TEXT, DATE } = app.Sequelize; const AfterSaleReply = app.model.define('afterSaleReply', { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: true, defaultValue: null, comment: '仓库ID(NULL=系统级默认回复;非NULL=仓库级自定义回复,覆盖系统级)', }, sub_type_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '售后子类型ID(关联 wms_after_sale_sub_type.id)', }, reply: { type: TEXT, allowNull: false, comment: '自定义回复文案(支持换行,可含占位符)', }, is_reply: { type: TINYINT(1), allowNull: false, defaultValue: 1, comment: '是否回复:1=命中后回复,0=静默不回复', }, create_work_order: { type: TINYINT(1), allowNull: false, defaultValue: 1, comment: '是否登记工单:1=执行函数处理(可能建工单,默认),0=仅回复不执行函数', }, no_number_hint: { type: STRING(500), allowNull: true, defaultValue: null, comment: '未取到单据号时的引导语(如:请提供运单号;为空则用默认引导语)', }, is_enabled: { type: TINYINT(1), allowNull: false, defaultValue: 1, comment: '是否启用:1=启用,0=停用(停用视为未设置,回退系统级)', }, created_at: { type: DATE, comment: '创建时间', }, updated_at: { type: DATE, comment: '更新时间', }, }, { tableName: 'wms_after_sale_reply', underscored: true, timestamps: true, createdAt: 'created_at', updatedAt: 'updated_at', paranoid: false, comment: '售后自定义回复表(仓库级覆盖系统级)', indexes: [ { unique: true, fields: [ 'warehouse_id', 'sub_type_id' ], name: 'uk_warehouse_sub_type', }, { fields: [ 'sub_type_id' ], name: 'idx_sub_type_id', }, { fields: [ 'is_enabled' ], name: 'idx_is_enabled', }, ], }); return AfterSaleReply; };