1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { Secret } = require('naf-framework-mongoose/lib/model/schema');
- const { ObjectId } = require('mongoose').Types;
- // 合同备案
- const pact = new Schema({
- file_path: { type: String }, // 合同图片
- desc: { type: String }, // 描述
- status: { type: String, default: '0' }, // 状态(0:待审核 1:通过审核)
- });
- // 交易表
- const transaction = {
- dock_id: { type: ObjectId }, // 展会id
- supplier: { type: ObjectId }, // 供给者
- s_name: { type: String }, // 供给者姓名
- s_phone: { type: String }, // 供给者联系电话
- demander: { type: ObjectId }, // 需求者
- d_name: { type: String }, // 需求者姓名
- d_phone: { type: String }, // 需求者联系电话
- product_id: { type: ObjectId }, // 产品id
- product: { type: String }, // 产品名称
- pact: { type: pact }, // 合同备案
- status: { type: String, default: '0' }, // 状态(0-正在洽谈;1-达成意向;2-交易备案(待确定);3-交易完成;4-交易失败)
- remark: { type: String, maxLength: 200 },
- create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
- };
- const schema = new Schema(transaction, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ dock_id: 1 });
- schema.index({ supplier: 1 });
- schema.index({ demander: 1 });
- schema.index({ product: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Transaction', schema, 'transaction');
- };
|