moneylog.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 消费记录
  5. const moneylog = {
  6. user_id: { type: String, required: false, zh: '用户id' }, //
  7. user_name: { type: String, required: false, zh: '用户名称' }, //
  8. money_no: { type: String, required: false, zh: '订单号' }, //
  9. type: { type: String, required: false, zh: '交易类型' }, //
  10. create_time: { type: String, required: false, zh: '交易时间' }, //
  11. money: { type: String, required: false, zh: '交易金额' }, //
  12. remark: { type: String, required: false, zh: '备注' }, //
  13. pay_url: { type: Array, required: false, zh: '支付账单明细截图' }, //
  14. pay_no: { type: Number, required: false, zh: '转账单号/订单号' }, //
  15. };
  16. const schema = new Schema(moneylog, { toJSON: { getters: true, virtuals: true } });
  17. schema.index({ id: 1 });
  18. schema.index({ 'meta.createdAt': 1 });
  19. schema.index({ user_id: 1 });
  20. schema.index({ user_name: 1 });
  21. schema.index({ money_no: 1 });
  22. schema.index({ type: 1 });
  23. schema.index({ create_time: 1 });
  24. schema.index({ money: 1 });
  25. schema.index({ pay_no: 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('Moneylog', schema, 'moneylog');
  30. };