transaction.js 1.4 KB

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 交易记录表
  5. const TransactionSchema = {
  6. dockid: { type: String, required: false, maxLength: 500 }, // 对接id
  7. create_userid: { type: String, required: false, maxLength: 500 }, // 对接id
  8. userid: { type: String, required: true, maxLength: 500 }, // 购买人ID
  9. username: { type: String, required: false, maxLength: 500 }, // 购买人名称
  10. product_id: { type: String, required: true, maxLength: 500 }, // 产品ID
  11. product_name: { type: String, required: false, maxLength: 500 }, // 产品名称
  12. market_userid: { type: String, required: true, maxLength: 500 }, // 营销人ID
  13. market_username: { type: String, required: false, maxLength: 500 }, // 营销人名称
  14. description: { type: String, required: false, maxLength: 500 }, // 说明
  15. type: { type: String, required: false, maxLength: 20, default: '0' }, // 类别0、产品、1、专家
  16. status: { type: String, required: true, maxLength: 500 }, // 交易状态,0-发起交易,1-交易中,2-交易成功,3-交易取消
  17. };
  18. const schema = new Schema(TransactionSchema, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.plugin(metaPlugin);
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('Transaction', schema, 'market_transaction');
  24. };