rentease-backend-new/models/Order.js

107 lines
2.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;