coachInBill.js 1019 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. const { Decimal128 } = require('mongoose').Types;
  5. // 教练费明细
  6. const coachInBill = {
  7. lesson_id: { type: String, required: false, zh: '课程id' }, //
  8. type: { type: String, required: false, zh: '类型' }, // 0:公开课收入;1私教课收入;2提现
  9. school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
  10. coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
  11. money: { type: Decimal128, required: false, zh: '金额' }, //
  12. };
  13. const schema = new Schema(coachInBill, { toJSON: { virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.index({ school_id: 1 });
  17. schema.index({ coach_id: 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('CoachInBill', schema, 'coachInBill');
  22. };