127 lines
2.8 KiB
JavaScript
127 lines
2.8 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
||
const sequelize = require('../config/db');
|
||
|
||
const Tenant = sequelize.define('Tenant', {
|
||
id: {
|
||
type: DataTypes.INTEGER,
|
||
primaryKey: true,
|
||
autoIncrement: true,
|
||
comment: '租户ID'
|
||
},
|
||
code: {
|
||
type: DataTypes.STRING(50),
|
||
allowNull: false,
|
||
unique: true,
|
||
comment: '租户编码(唯一标识)'
|
||
},
|
||
contactName: {
|
||
type: DataTypes.STRING(50),
|
||
allowNull: true,
|
||
comment: '联系人姓名'
|
||
},
|
||
contactPhone: {
|
||
type: DataTypes.STRING(20),
|
||
allowNull: true,
|
||
comment: '联系人电话'
|
||
},
|
||
contactEmail: {
|
||
type: DataTypes.STRING(100),
|
||
allowNull: true,
|
||
comment: '联系人邮箱'
|
||
},
|
||
status: {
|
||
type: DataTypes.ENUM('active', 'suspended'),
|
||
defaultValue: 'active',
|
||
comment: '租户状态:active-正常,suspended-暂停'
|
||
},
|
||
planId: {
|
||
type: DataTypes.INTEGER,
|
||
allowNull: true,
|
||
comment: '当前套餐ID'
|
||
},
|
||
billingStatus: {
|
||
type: DataTypes.ENUM('trial_active', 'trial_expired', 'paid_active', 'paid_expired', 'suspended'),
|
||
defaultValue: 'trial_active',
|
||
comment: '计费状态'
|
||
},
|
||
trialStartDate: {
|
||
type: DataTypes.DATE,
|
||
allowNull: true,
|
||
comment: '试用期开始日期'
|
||
},
|
||
trialEndDate: {
|
||
type: DataTypes.DATE,
|
||
allowNull: true,
|
||
comment: '试用期结束日期'
|
||
},
|
||
paidStartDate: {
|
||
type: DataTypes.DATE,
|
||
allowNull: true,
|
||
comment: '付费期开始日期'
|
||
},
|
||
paidEndDate: {
|
||
type: DataTypes.DATE,
|
||
allowNull: true,
|
||
comment: '付费期结束日期'
|
||
},
|
||
currentPeriodStart: {
|
||
type: DataTypes.DATE,
|
||
allowNull: true,
|
||
comment: '当前计费周期开始'
|
||
},
|
||
currentPeriodEnd: {
|
||
type: DataTypes.DATE,
|
||
allowNull: true,
|
||
comment: '当前计费周期结束'
|
||
},
|
||
maxUsers: {
|
||
type: DataTypes.INTEGER,
|
||
defaultValue: 10,
|
||
comment: '最大用户数'
|
||
},
|
||
maxApartments: {
|
||
type: DataTypes.INTEGER,
|
||
defaultValue: 5,
|
||
comment: '最大公寓数'
|
||
},
|
||
maxRooms: {
|
||
type: DataTypes.INTEGER,
|
||
defaultValue: 50,
|
||
comment: '最大房间数'
|
||
},
|
||
createBy: {
|
||
type: DataTypes.INTEGER,
|
||
allowNull: true,
|
||
comment: '创建人ID'
|
||
},
|
||
updateBy: {
|
||
type: DataTypes.INTEGER,
|
||
allowNull: true,
|
||
comment: '修改人ID'
|
||
},
|
||
isDeleted: {
|
||
type: DataTypes.INTEGER,
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '删除状态(0:未删除,1:已删除)'
|
||
},
|
||
createTime: {
|
||
type: DataTypes.DATE,
|
||
allowNull: false,
|
||
defaultValue: DataTypes.NOW,
|
||
comment: '创建时间'
|
||
},
|
||
updateTime: {
|
||
type: DataTypes.DATE,
|
||
allowNull: false,
|
||
defaultValue: DataTypes.NOW,
|
||
comment: '更新时间'
|
||
}
|
||
}, {
|
||
tableName: 'tenants',
|
||
timestamps: false,
|
||
comment: '租户表'
|
||
});
|
||
|
||
module.exports = Tenant;
|