credit.js 790 B

1234567891011121314151617181920212223
  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. const { ObjectId } = require('mongoose').Types;
  6. // 充值表
  7. const credit = {
  8. vip_id: { type: ObjectId }, // 会员id
  9. order_no: { type: String }, // 支付订单号
  10. money: { type: Number }, // 充值金额
  11. status: { type: String, default: '0' }, // 状态
  12. remark: { type: String },
  13. };
  14. const schema = new Schema(credit, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ vip_id: 1 });
  17. schema.index({ order_no: 1 });
  18. schema.index({ 'meta.createdAt': 1 });
  19. schema.plugin(metaPlugin);
  20. module.exports = app => {
  21. const { mongoose } = app;
  22. return mongoose.model('Credit', schema, 'credit');
  23. };