const { DataTypes } = require('sequelize'); const sequelize = require('../config/db'); const TenantResourceUsage = sequelize.define('TenantResourceUsage', { id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, comment: '记录ID' }, tenantId: { type: DataTypes.INTEGER, allowNull: false, comment: '租户ID' }, recordDate: { type: DataTypes.DATEONLY, allowNull: false, comment: '记录日期' }, userCount: { type: DataTypes.INTEGER, defaultValue: 0, comment: '当日用户数' }, apartmentCount: { type: DataTypes.INTEGER, defaultValue: 0, comment: '当日公寓数' }, roomCount: { type: DataTypes.INTEGER, defaultValue: 0, comment: '当日房间数' }, isOverLimit: { type: DataTypes.TINYINT(1), defaultValue: 0, comment: '是否超额:0-否,1-是' }, overageDetails: { type: DataTypes.JSON, allowNull: true, comment: '超额详情(JSON格式)' } }, { tableName: 'tenant_resource_usage', timestamps: false, indexes: [ { fields: ['tenantId', 'recordDate'] }, { fields: ['recordDate'] } ], comment: '租户资源使用记录表' }); module.exports = TenantResourceUsage;