record.js 930 B

12345678910111213141516171819202122
  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. // 分数记录表
  6. const record = {
  7. mobile: { type: String, required: true }, // 电话
  8. name: { type: String, required: true }, // 姓名
  9. points: { type: Number, default: 600 }, // 积分
  10. opera: { type: String, required: true }, // 操作行为:-1:提现/1:推荐办卡/2:车奖/3,同级奖励/4,直推下级完成业绩反佣金
  11. params: { type: Object },
  12. remark: { type: String, maxLength: 200 },
  13. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  14. };
  15. const schema = new Schema(record, { toJSON: { virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ 'meta.createdAt': 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('Record', schema, 'record');
  22. };