rentease-backend-new/models/Payment.js

71 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

2026-04-20 06:43:09 +00:00
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;