'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const moneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin'); // 临时上课申请 const tempLessonApply = { school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, // lesson_id: { type: String, required: false, zh: '课程id', ref: 'Lesson', getProp: [ 'title' ] }, // coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, // student_id: { type: String, required: false, zh: '学员id', ref: 'Student', getProp: [ 'name', 'icon', ' phone' ] }, // name: { type: String, required: false, zh: '学员姓名' }, // phone: { type: String, required: false, zh: '学员电话' }, // file: { type: Array, required: false, zh: '证据' }, // is_pay: { type: String, default: '0', zh: '是否已支付' }, // 0:未支付;1:已支付:-1:支付失败:-3已退款 pay_id: { type: String, required: false, zh: '支付id', ref: 'PayOrder' }, // is_sign: { type: String, required: false, default: '1', zh: '签到' }, // 0:未到;1:已签到 }; const schema = new Schema(tempLessonApply, { toJSON: { getters: true, virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ school_id: 1 }); schema.index({ lesson_id: 1 }); schema.index({ coach_id: 1 }); schema.index({ student_id: 1 }); schema.index({ name: 1 }); schema.index({ phone: 1 }); schema.index({ pay_id: 1 }); schema.plugin(metaPlugin); schema.plugin(moneyPlugin({ zh: '缴费金额' })); module.exports = app => { const { mongoose } = app; return mongoose.model('TempLessonApply', schema, 'tempLessonApply'); };