12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- '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 = {
- cashing_no: { type: String }, // 兑付申请号(自动生成)
- coupons_id: { type: ObjectId }, // 券的id
- coupons_type: { type: String }, // 券的类别
- coupons_name: { type: String }, // 券的名称
- company_id: { type: ObjectId }, // 使用单位id
- company_name: { type: String }, // 使用单位
- create_time: { type: String }, // 提交时间,服务端生成
- end_time: { type: String }, // 最后审核时间
- mechanism_id: { type: ObjectId }, // 服务提供商_id
- mechanism_name: { type: String }, // 服务提供商
- money: { type: Number }, // 订单金额
- allowance: { type: Number }, // 抵扣金额
- total: { type: Number }, // 应收金额
- status: { type: String, default: '0' }, // 0-待审核;1-通过;-1-拒绝
- remark: { type: String },
- // 需要上传的资料
- contract: { type: Array }, // 上传合同
- accept: { type: Array }, // 官方受理通知书
- cost: { type: Array }, // 官方缴费证明
- result: { type: Array }, // 服务结果证明
- result_else: { type: Array }, // 其他能够证明服务真是发生的材料
- record: { type: Array }, // 记录
- };
- const schema = new Schema(cashing, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ cashing_no: 1 });
- schema.index({ coupons_id: 1 });
- schema.index({ coupons_type: 1 });
- schema.index({ coupons_name: 1 });
- schema.index({ company_id: 1 });
- schema.index({ company_name: 1 });
- schema.index({ create_time: 1 });
- schema.index({ end_time: 1 });
- schema.index({ mechanism_id: 1 });
- schema.index({ mechanism_name: 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');
- };
|