charge.js 1.2 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 charge = {
  7. school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
  8. payer_id: { type: String, required: false, zh: '充值用户角色id', refPath: 'payer_role', getProp: [ 'name' ] }, //
  9. payer_role: { type: String, required: false, zh: '充值用户角色' }, //
  10. pay_id: { type: String, required: false, zh: '支付id', ref: 'Payorder' }, //
  11. is_pay: { type: String, required: false, zh: '支付状态' }, // 0:未支付;1:支付成功;-1:支付失败;-3:已退款
  12. time: { type: String, required: false, zh: '时间' }, //
  13. };
  14. const schema = new Schema(charge, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ 'meta.createdAt': 1 });
  17. schema.index({ school_id: 1 });
  18. schema.index({ payer_id: 1 });
  19. schema.index({ payer_role: 1 });
  20. schema.index({ is_pay: 1 });
  21. schema.plugin(metaPlugin);
  22. schema.plugin(moneyPlugin({ zh: '充值金额' }));
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('Charge', schema, 'charge');
  26. };