This commit is contained in:
Ken
2026-01-19 09:33:35 +07:00
parent 374dc12b2d
commit 70838a4bc1
103 changed files with 16929 additions and 2 deletions

View File

@@ -0,0 +1,69 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
/**
* SubscriptionPlan Model - Định nghĩa các gói thẻ tháng
*/
const SubscriptionPlan = sequelize.define('subscription_plans', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
name: {
type: DataTypes.STRING(100),
allowNull: false,
comment: 'Tên gói: VIP Học sinh, Premium Giáo viên, etc.',
},
price: {
type: DataTypes.DECIMAL(10, 2),
allowNull: false,
comment: 'Giá tiền (VND)',
},
duration_days: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 30,
comment: 'Thời hạn gói (ngày)',
},
target_role: {
type: DataTypes.STRING(50),
allowNull: false,
comment: 'Role được phép mua: student, parent, teacher',
},
description: {
type: DataTypes.TEXT,
comment: 'Mô tả gói',
},
features: {
type: DataTypes.JSON,
comment: 'Danh sách tính năng: ["detailed_reports", "priority_support"]',
},
is_active: {
type: DataTypes.BOOLEAN,
defaultValue: true,
comment: 'Trạng thái kích hoạt',
},
created_at: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
updated_at: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
}, {
tableName: 'subscription_plans',
timestamps: true,
underscored: true,
indexes: [
{ fields: ['target_role'] },
{ fields: ['is_active'] },
{ fields: ['price'] },
],
comment: 'Bảng định nghĩa các gói thẻ tháng',
});
module.exports = SubscriptionPlan;