cashing.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 兑付申请表
  7. const cashing = {
  8. cashing_no: { type: String }, // 兑付申请号(自动生成)
  9. coupons_id: { type: ObjectId }, // 券的id
  10. coupons_type: { type: String }, // 券的类别
  11. coupons_name: { type: String }, // 券的名称
  12. company_id: { type: ObjectId }, // 使用单位id
  13. company_name: { type: String }, // 使用单位
  14. create_time: { type: String }, // 提交时间,服务端生成
  15. end_time: { type: String }, // 最后审核时间
  16. mechanism_id: { type: ObjectId }, // 服务提供商_id
  17. mechanism_name: { type: String }, // 服务提供商
  18. money: { type: Number }, // 订单金额
  19. allowance: { type: Number }, // 抵扣金额
  20. total: { type: Number }, // 应收金额
  21. status: { type: String, default: '0' }, // 0-待审核;1-通过;-1-拒绝
  22. remark: { type: String },
  23. // 需要上传的资料
  24. contract: { type: Array }, // 上传合同
  25. accept: { type: Array }, // 官方受理通知书
  26. cost: { type: Array }, // 官方缴费证明
  27. result: { type: Array }, // 服务结果证明
  28. result_else: { type: Array }, // 其他能够证明服务真是发生的材料
  29. record: { type: Array }, // 记录
  30. };
  31. const schema = new Schema(cashing, { toJSON: { virtuals: true } });
  32. schema.index({ id: 1 });
  33. schema.index({ cashing_no: 1 });
  34. schema.index({ coupons_id: 1 });
  35. schema.index({ coupons_type: 1 });
  36. schema.index({ coupons_name: 1 });
  37. schema.index({ company_id: 1 });
  38. schema.index({ company_name: 1 });
  39. schema.index({ create_time: 1 });
  40. schema.index({ end_time: 1 });
  41. schema.index({ mechanism_id: 1 });
  42. schema.index({ mechanism_name: 1 });
  43. schema.index({ status: 1 });
  44. schema.index({ 'meta.createdAt': 1 });
  45. schema.plugin(metaPlugin);
  46. module.exports = app => {
  47. const { mongoose } = app;
  48. return mongoose.model('Cashing', schema, 'cashing');
  49. };