'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const MoneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin'); // 返现记录表 const cashBack = { inviter: { type: String, required: false, zh: '推荐人', ref: 'User.User' }, // time: { type: String, required: false, zh: '返现时间' }, // status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:cashBack_status source: { type: String, required: false, zh: '来源' }, // 字典:cashBack_source source_id: { type: String, required: false, zh: '来源id' }, // }; const schema = new Schema(cashBack, { toJSON: { getters: true, virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ inviter: 1 }); schema.index({ order_detail: 1 }); schema.index({ status: 1 }); schema.plugin(metaPlugin); schema.plugin(MoneyPlugin({ zh: '返现金额', required: false, key: 'money' })); module.exports = app => { const { mongoose } = app; return mongoose.model('CashBack', schema, 'cashBack'); };