lrf пре 2 година
родитељ
комит
a7a76ae520
1 измењених фајлова са 3 додато и 0 уклоњено
  1. 3 0
      app/service/business/lessonStudent.js

+ 3 - 0
app/service/business/lessonStudent.js

@@ -91,6 +91,9 @@ class LessonStudentService extends CrudService {
     const billModel = this.ctx.model.Business.Bill;
     const data = await this.model.findOne({ lesson_id, student_id });
     if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到数据');
+    const lesson = await this.lessonModel.findById(lesson_id);
+    if (!lesson) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到课程数据');
+    if (!moment().isBefore(lesson.refund_hour)) throw new BusinessError(ErrorCode.DATA_INVALID, '已经超过退课时间,无法退课');
     if (data.is_pay === '-3') throw new BusinessError(ErrorCode.DATA_INVALID, '已经完成退课,无法再次退课');
     if (data.is_try === '1') {
       // 试课 修改退款状态, 而不需要退钱,同时也浪费了试课机会