'use strict'; /** * 主体续期订单 * * 真实支付渠道还没接:先把「下单 → 渠道回调 → 主体续期」的链路落库, * 回调格式见 `app/controller/pay/notify.js`(模拟回调见 README)。 */ module.exports = { async up(queryInterface, Sequelize) { const { BIGINT, STRING, TINYINT, INTEGER, DECIMAL, DATE } = Sequelize; await queryInterface.createTable('subject_orders', { id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, allowNull: false }, order_no: { type: STRING(32), allowNull: false, unique: true, comment: '订单号(对外唯一)' }, subject_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '主体 subjects.id' }, user_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '下单用户 users.id' }, days: { type: INTEGER.UNSIGNED, allowNull: false, comment: '续期天数' }, amount: { type: DECIMAL(10, 2), allowNull: true, comment: '应付金额(为空表示不校验)' }, status: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 0, comment: '状态:0待支付 1已支付 2已关闭' }, channel: { type: STRING(16), allowNull: true, comment: '支付渠道(mock 等)' }, transaction_id: { type: STRING(64), allowNull: true, comment: '渠道流水号' }, paid_at: { type: DATE, allowNull: true, comment: '支付时间' }, expire_before: { type: DATE, allowNull: true, comment: '续期前的到期时间' }, expire_after: { type: DATE, allowNull: true, comment: '续期后的到期时间' }, remark: { type: STRING(255), allowNull: true, comment: '备注' }, created_at: { type: DATE, allowNull: false, defaultValue: Sequelize.literal('CURRENT_TIMESTAMP') }, updated_at: { type: DATE, allowNull: false, defaultValue: Sequelize.literal('CURRENT_TIMESTAMP') }, deleted_at: { type: DATE, allowNull: true }, }, { comment: '主体续期订单表' }); await queryInterface.addIndex('subject_orders', [ 'subject_id' ], { name: 'idx_subject_orders_subject' }); await queryInterface.addIndex('subject_orders', [ 'status' ], { name: 'idx_subject_orders_status' }); }, async down(queryInterface) { await queryInterface.dropTable('subject_orders'); }, };