'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 分数记录表 const record = { mobile: { type: String, required: true }, // 电话 name: { type: String, required: true }, // 姓名 points: { type: Number, default: 600 }, // 积分 opera: { type: String, required: true }, // 操作行为:-1:提现/1:推荐办卡/2:车奖/3,同级奖励/4,直推下级完成业绩反佣金 params: { type: Object }, remark: { type: String, maxLength: 200 }, create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') }, }; const schema = new Schema(record, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Record', schema, 'record'); };