coachInBill.js 1.2 KB

1234567891011121314151617181920212223242526
  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 coachInBill = {
  7. lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'title' ] }, //
  8. type: { type: String, required: false, zh: '类型' }, // 0:公开课收入;1私教课收入
  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. is_settle: { type: String, required: false, default: '0', zh: '是否结算' }, // 0:未结算;1已结算
  12. };
  13. const schema = new Schema(coachInBill, { toJSON: { getters: true, 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.index({ is_settle: 1 });
  19. schema.plugin(metaPlugin);
  20. schema.plugin(moneyPlugin({ zh: '金额' }));
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('CoachInBill', schema, 'coachInBill');
  24. };