dock_transcation.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  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 dock_transcation = {
  8. dock_id: { type: ObjectId }, // 展会id
  9. product_id: { type: ObjectId }, // 产品id
  10. s_id: { type: ObjectId }, // 供给者id
  11. s_name: { type: String }, // 供给者姓名
  12. s_phone: { type: String }, // 供给者电话
  13. d_id: { type: ObjectId }, // 需求者id
  14. d_name: { type: String }, // 需求者姓名
  15. d_phone: { type: String }, // 需求者电话
  16. status: { type: String, default: '0' }, // 0-正在洽谈,1-达成意向,2-交易备案,3-交易完成,4-交易失败
  17. contact: { type: String }, // 合同备份
  18. remark: { type: String },
  19. };
  20. const schema = new Schema(dock_transcation, { toJSON: { virtuals: true } });
  21. schema.index({ id: 1 });
  22. schema.index({ dock_id: 1 });
  23. schema.index({ product_id: 1 });
  24. schema.index({ s_id: 1 });
  25. schema.index({ s_name: 1 });
  26. schema.index({ d_id: 1 });
  27. schema.index({ d_name: 1 });
  28. schema.index({ status: 1 });
  29. schema.index({ 'meta.createdAt': 1 });
  30. schema.plugin(metaPlugin);
  31. module.exports = app => {
  32. const { mongoose } = app;
  33. return mongoose.model('Dock_transcation', schema, 'dock_transcation');
  34. };