// models/store_join.js module.exports = app => { const { BIGINT, STRING, DATE, TINYINT, INTEGER, ENUM } = app.Sequelize; const StoreJoin = app.model.define('StoreJoin', { id: { type: INTEGER(11), primaryKey: true, autoIncrement: true, comment: '申请ID', }, account_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '用户账户ID', }, warehouse: { type: TINYINT(1), allowNull: true, comment: '是否为仓库', }, real_name: { type: STRING(50), allowNull: false, comment: '真实姓名', }, store_id: { type: BIGINT(20).UNSIGNED, allowNull: true, comment: '审批的门店/店铺ID', }, apply_time: { type: DATE, allowNull: false, comment: '申请时间', }, apply_username: { type: STRING(50), allowNull: false, comment: '申请人用户名', }, audit_status: { type: ENUM('pending', 'approved', 'rejected', 'processing'), defaultValue: 'pending', comment: '审核状态', }, remark: { type: STRING(500), defaultValue: '', comment: '备注', }, join_token: { type: STRING(100), allowNull: false, unique: true, comment: '加入令牌/验证码', }, token_expiry_time: { type: DATE, allowNull: true, comment: '令牌过期时间', }, audit_real_name: { type: STRING(50), allowNull: true, comment: '审核人工号名字', }, }, { tableName: 'wms_store_join', comment: '加入申请记录表', paranoid: false, // 明确禁用软删除 timestamps: true, createdAt: 'created_at', updatedAt: 'updated_at', indexes: [ { name: 'idx_account_id', fields: [ 'account_id' ], }, { name: 'idx_audit_status', fields: [ 'audit_status' ], }, { name: 'idx_apply_time', fields: [ 'apply_time' ], }, { name: 'idx_store_id', fields: [ 'store_id' ], }, { name: 'uk_account_warehouse_store', fields: [ 'account_id', 'store_id' ], unique: true, }, ], }); return StoreJoin; };