'use strict'; /** * 续期套餐(subject_plans) * * 一行 = 一个可选的续期套餐(天数 + 售价)。续期时前端只传套餐 id, * 金额由服务端按 `price` 计算,避免被前端篡改。 * * - `code`:稳定编码(p30 / p180 / p365 …),接口与日志里用 * - `status`:1 上架 0 下架(下架后历史订单不受影响) * - `sort`:展示顺序(小的在前) */ module.exports = (app) => { const { BIGINT, STRING, TINYINT, INTEGER, DECIMAL, DATE } = app.Sequelize; const SubjectPlan = app.model.define('subject_plan', { id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' }, code: { type: STRING(32), allowNull: false, unique: true, comment: '套餐编码(稳定标识)' }, name: { type: STRING(64), allowNull: false, comment: '套餐名称(展示用)' }, days: { type: INTEGER.UNSIGNED, allowNull: false, comment: '续期天数' }, price: { type: DECIMAL(10, 2), allowNull: false, defaultValue: 0, comment: '售价(元)' }, originalPrice: { type: DECIMAL(10, 2), allowNull: true, comment: '划线原价(可选)' }, tag: { type: STRING(16), allowNull: true, comment: '角标文案(推荐 / 最划算)' }, description: { type: STRING(255), allowNull: true, comment: '副标题说明' }, sort: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 0, comment: '排序(小的在前)' }, status: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 1, comment: '状态:1上架 0下架' }, }, { tableName: 'subject_plans', paranoid: true, comment: '主体续期套餐表', }); return SubjectPlan; };