74 lines
1.6 KiB
JavaScript
74 lines
1.6 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const sequelize = require('../config/db');
|
|
|
|
const BillingLog = sequelize.define('BillingLog', {
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
primaryKey: true,
|
|
autoIncrement: true,
|
|
comment: '日志ID'
|
|
},
|
|
tenantId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
comment: '租户ID'
|
|
},
|
|
actionType: {
|
|
type: DataTypes.ENUM('trial_start', 'trial_end', 'plan_change', 'order_create', 'payment_success', 'payment_fail', 'renewal', 'suspend', 'resume'),
|
|
allowNull: false,
|
|
comment: '操作类型'
|
|
},
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
comment: '操作描述'
|
|
},
|
|
oldValue: {
|
|
type: DataTypes.JSON,
|
|
allowNull: true,
|
|
comment: '旧值'
|
|
},
|
|
newValue: {
|
|
type: DataTypes.JSON,
|
|
allowNull: true,
|
|
comment: '新值'
|
|
},
|
|
orderId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true,
|
|
comment: '关联订单ID'
|
|
},
|
|
paymentId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true,
|
|
comment: '关联支付ID'
|
|
},
|
|
operatorId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true,
|
|
comment: '操作人ID'
|
|
},
|
|
operatorType: {
|
|
type: DataTypes.ENUM('system', 'user', 'admin'),
|
|
defaultValue: 'system',
|
|
comment: '操作者类型'
|
|
},
|
|
ipAddress: {
|
|
type: DataTypes.STRING(50),
|
|
allowNull: true,
|
|
comment: 'IP地址'
|
|
}
|
|
}, {
|
|
tableName: 'billing_logs',
|
|
timestamps: false,
|
|
createdAt: 'createdAt',
|
|
updatedAt: false,
|
|
indexes: [
|
|
{ fields: ['tenantId', 'actionType'] },
|
|
{ fields: ['createdAt'] }
|
|
],
|
|
comment: '计费系统操作日志表'
|
|
});
|
|
|
|
module.exports = BillingLog;
|