'use strict'; const { businessFields, historyFields } = require('../lib/orderFields'); const { ORDER_STATUS, ORDER_TABLE_BY_STATUS } = require('../lib/orderStatus'); /** * 历史订单表(order_status_history) * * 结构与 4 张状态表一致,另加: * - archived_at 归档时间(转入历史表时写入) * - transferred_at 转入时间(状态流转进入历史的时间) * 归档为物理迁移(状态表删除 + 本表插入),页面「历史」tab 只读展示。 * @param {Egg.Application} app egg application * @return {object} orderStatusHistory model */ module.exports = app => { const tableName = ORDER_TABLE_BY_STATUS[ORDER_STATUS.HISTORY]; const OrderStatusHistory = app.model.define(tableName, { ...businessFields(app.Sequelize, ORDER_STATUS.HISTORY), ...historyFields(app.Sequelize), }, { tableName, comment: '订单-历史(归档)', }); return OrderStatusHistory; };