71 lines
1.7 KiB
JavaScript
71 lines
1.7 KiB
JavaScript
|
|
const { DataTypes } = require('sequelize');
|
|||
|
|
const sequelize = require('../config/db');
|
|||
|
|
|
|||
|
|
const Payment = sequelize.define('Payment', {
|
|||
|
|
id: {
|
|||
|
|
type: DataTypes.INTEGER,
|
|||
|
|
primaryKey: true,
|
|||
|
|
autoIncrement: true,
|
|||
|
|
comment: '支付ID'
|
|||
|
|
},
|
|||
|
|
orderId: {
|
|||
|
|
type: DataTypes.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '订单ID,外键关联orders表'
|
|||
|
|
},
|
|||
|
|
tenantId: {
|
|||
|
|
type: DataTypes.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '租户ID,外键关联tenants表'
|
|||
|
|
},
|
|||
|
|
amount: {
|
|||
|
|
type: DataTypes.DECIMAL(10, 2),
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '支付金额'
|
|||
|
|
},
|
|||
|
|
paymentMethod: {
|
|||
|
|
type: DataTypes.ENUM('alipay', 'wechat', 'bank', 'other'),
|
|||
|
|
defaultValue: 'other',
|
|||
|
|
comment: '支付方式:alipay-支付宝,wechat-微信支付,bank-银行转账,other-其他(线下转账)'
|
|||
|
|
},
|
|||
|
|
status: {
|
|||
|
|
type: DataTypes.ENUM('pending', 'success', 'failed'),
|
|||
|
|
defaultValue: 'pending',
|
|||
|
|
comment: '支付状态:pending-待支付,success-支付成功,failed-支付失败'
|
|||
|
|
},
|
|||
|
|
transactionId: {
|
|||
|
|
type: DataTypes.STRING(100),
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '交易流水号'
|
|||
|
|
},
|
|||
|
|
paidAt: {
|
|||
|
|
type: DataTypes.DATE,
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '支付完成时间'
|
|||
|
|
},
|
|||
|
|
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: 'payments',
|
|||
|
|
timestamps: false,
|
|||
|
|
comment: '支付表'
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
module.exports = Payment;
|