const { DataTypes } = require('sequelize'); const sequelize = require('../config/db'); const Order = sequelize.define('Order', { id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, comment: '订单ID' }, orderNo: { type: DataTypes.STRING(50), allowNull: false, comment: '订单编号' }, tenantId: { type: DataTypes.INTEGER, allowNull: false, comment: '租户ID' }, planId: { type: DataTypes.INTEGER, allowNull: false, comment: '套餐ID' }, planName: { type: DataTypes.STRING(100), allowNull: false, comment: '套餐名称' }, months: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 1, comment: '购买月数' }, amount: { type: DataTypes.DECIMAL(10, 2), allowNull: false, comment: '订单金额' }, discountAmount: { type: DataTypes.DECIMAL(10, 2), defaultValue: 0.00, comment: '优惠金额' }, actualAmount: { type: DataTypes.DECIMAL(10, 2), allowNull: false, comment: '实付金额' }, status: { type: DataTypes.ENUM('pending', 'paid', 'cancelled'), defaultValue: 'pending', comment: '状态:pending-待支付,paid-已支付,cancelled-已取消' }, paidTime: { type: DataTypes.DATE, allowNull: true, comment: '支付时间' }, expireTime: { type: DataTypes.DATE, allowNull: false, comment: '过期时间' }, remark: { type: DataTypes.STRING(255), allowNull: true, 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: 'orders', timestamps: false, comment: '订单表' }); module.exports = Order;