'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 兑付申请表 const cashing = { no: { type: String }, // 兑付申请号(自动生成) coupons_id: { type: ObjectId }, // 券的id company: { type: String }, // 申请单位 apply_person: { type: String }, // 申请人 phone: { type: String }, // 联系电话 money: { type: Number }, // 订单金额 allowance: { type: Number }, // 抵扣金额 total: { type: Number }, // 应收金额 create_time: { type: String }, // 提交时间,服务端生成 end_time: { type: String }, // 最后审核时间 contract: { type: Array }, // 上传合同 accept: { type: Array }, // 官方受理通知书 cost: { type: Array }, // 官方缴费证明 result: { type: Array }, // 服务结果证明 result_else: { type: Array }, // 其他能够证明服务真是发生的材料 status: { type: String, default: '0' }, // 0-待审核;1-通过;-1-拒绝 record: { type: Array }, // 记录 user_id: { type: ObjectId }, // 用户id from_id: { type: ObjectId }, // 高企申报/ 研发补贴/奖励兑换的数据id remark: { type: String }, }; const schema = new Schema(cashing, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ no: 1 }); schema.index({ coupons_id: 1 }); schema.index({ company: 1 }); schema.index({ apply_person: 1 }); schema.index({ create_time: 1 }); schema.index({ end_time: 1 }); schema.index({ from_id: 1 }); schema.index({ status: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Cashing', schema, 'cashing'); };