98 lines
2.3 KiB
JavaScript
98 lines
2.3 KiB
JavaScript
const Sequelize = require('sequelize');
|
||
|
||
/**
|
||
* 价格套餐表模型
|
||
* 存储各种价格套餐的配置信息,支持管理员在后台配置和管理
|
||
*/
|
||
module.exports = (db) => {
|
||
const pricing_plans = db.define("pricing_plans", {
|
||
name: {
|
||
comment: '套餐名称(如:体验套餐、月度套餐等)',
|
||
type: Sequelize.STRING(100),
|
||
allowNull: false,
|
||
defaultValue: ''
|
||
},
|
||
duration: {
|
||
comment: '时长描述(如:7天、30天、永久)',
|
||
type: Sequelize.STRING(50),
|
||
allowNull: false,
|
||
defaultValue: ''
|
||
},
|
||
days: {
|
||
comment: '天数(-1表示永久,0表示无限制)',
|
||
type: Sequelize.INTEGER,
|
||
allowNull: false,
|
||
defaultValue: 0
|
||
},
|
||
price: {
|
||
comment: '售价(元)',
|
||
type: Sequelize.DECIMAL(10, 2),
|
||
allowNull: false,
|
||
defaultValue: 0.00
|
||
},
|
||
original_price: {
|
||
comment: '原价(元),可为空表示无原价',
|
||
type: Sequelize.DECIMAL(10, 2),
|
||
allowNull: true,
|
||
defaultValue: null
|
||
},
|
||
unit: {
|
||
comment: '价格单位',
|
||
type: Sequelize.STRING(20),
|
||
allowNull: false,
|
||
defaultValue: '元'
|
||
},
|
||
discount: {
|
||
comment: '折扣描述(如:8.3折、超值)',
|
||
type: Sequelize.STRING(50),
|
||
allowNull: true,
|
||
defaultValue: null
|
||
},
|
||
features: {
|
||
comment: '功能特性列表(JSON字符串数组)',
|
||
type: Sequelize.TEXT,
|
||
allowNull: false,
|
||
defaultValue: '[]'
|
||
},
|
||
featured: {
|
||
comment: '是否为推荐套餐(1=推荐,0=普通)',
|
||
type: Sequelize.TINYINT(1),
|
||
allowNull: false,
|
||
defaultValue: 0
|
||
},
|
||
is_active: {
|
||
comment: '是否启用(1=启用,0=禁用)',
|
||
type: Sequelize.TINYINT(1),
|
||
allowNull: false,
|
||
defaultValue: 1
|
||
},
|
||
sort_order: {
|
||
comment: '排序顺序(越小越靠前)',
|
||
type: Sequelize.INTEGER,
|
||
allowNull: false,
|
||
defaultValue: 0
|
||
},
|
||
|
||
}, {
|
||
timestamps: false,
|
||
indexes: [
|
||
{
|
||
unique: false,
|
||
fields: ['is_active']
|
||
},
|
||
{
|
||
unique: false,
|
||
fields: ['is_delete']
|
||
},
|
||
{
|
||
unique: false,
|
||
fields: ['sort_order']
|
||
}
|
||
]
|
||
});
|
||
|
||
// pricing_plans.sync({ force: true });
|
||
|
||
return pricing_plans;
|
||
}
|