cashBack.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. const MoneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
  5. // 返现记录表
  6. const cashBack = {
  7. inviter: { type: String, required: false, zh: '推荐人', ref: 'User.User' }, //
  8. time: { type: String, required: false, zh: '返现时间' }, //
  9. status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:cashBack_status
  10. source: { type: String, required: false, zh: '来源' }, // 字典:cashBack_source
  11. source_id: { type: String, required: false, zh: '来源id' }, //
  12. };
  13. const schema = new Schema(cashBack, { toJSON: { getters: true, virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.index({ inviter: 1 });
  17. schema.index({ order_detail: 1 });
  18. schema.index({ status: 1 });
  19. schema.plugin(metaPlugin);
  20. schema.plugin(MoneyPlugin({ zh: '返现金额', required: false, key: 'money' }));
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('CashBack', schema, 'cashBack');
  24. };