|
@@ -1,35 +0,0 @@
|
|
|
-'use strict';
|
|
|
-const { CrudService } = require('naf-framework-mongoose-free/lib/service');
|
|
|
-const { BusinessError, ErrorCode } = require('naf-core').Error;
|
|
|
-const _ = require('lodash');
|
|
|
-const assert = require('assert');
|
|
|
-
|
|
|
-//
|
|
|
-class LessonPrivateService extends CrudService {
|
|
|
- constructor(ctx) {
|
|
|
- super(ctx, 'lessonprivate');
|
|
|
- this.model = this.ctx.model.Business.LessonPrivate;
|
|
|
- this.cibService = this.ctx.service.business.coachInBill;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 处理下课的课程进行结算
|
|
|
- * @param {Object} filter 修改条件
|
|
|
- * @param {Object} body 修改内容
|
|
|
- * @param {Object} data 修改后的结果
|
|
|
- * @return {Object} 返回整理后的内容
|
|
|
- */
|
|
|
- async afterUpdate(filter, body, data) {
|
|
|
- const { status, limit, money, student, _id: lesson_id, school_id, coach_id } = data;
|
|
|
- if (status !== '4') return data;
|
|
|
- // 4 是下课,下了课,就给老师结钱
|
|
|
- // 目前按学生人数进行结款,限制的人数不一定是上课的学生人数,可能会临时加人
|
|
|
- const num = student.length;
|
|
|
- const total = num * money;
|
|
|
- // 添加明细,通过明细那边,将工资处理了,这边就不处理了.因为公开课那边也是一样这么做
|
|
|
- const obj = { lesson_id, type: '1', school_id, coach_id, money: total };
|
|
|
- await this.cibService.create(obj);
|
|
|
- return data;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-module.exports = LessonPrivateService;
|