Browse Source

合并定时任务

cy 3 years ago
parent
commit
5e93d8ae6d

+ 2 - 2
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/TeacherFeignService.java

@@ -47,6 +47,6 @@ public interface TeacherFeignService {
      * @Author: cy
      * @Date: 2022/5/24
      */
-    @GetMapping("/task/teacherSalary")
-    HttpResponseResult<Object> teacherSalary();
+//    @GetMapping("/task/teacherSalary")
+//    HttpResponseResult<Object> teacherSalary();
 }

+ 4 - 4
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/fallback/TeacherFeignServiceFallback.java

@@ -27,8 +27,8 @@ public class TeacherFeignServiceFallback implements TeacherFeignService {
         return null;
     }
 
-    @Override
-    public HttpResponseResult<Object> teacherSalary() {
-        return null;
-    }
+//    @Override
+//    public HttpResponseResult<Object> teacherSalary() {
+//        return null;
+//    }
 }

+ 22 - 22
cooleshow-task/src/main/java/com/yonge/cooleshow/task/jobs/TeacherSalaryTask.java

@@ -1,22 +1,22 @@
-package com.yonge.cooleshow.task.jobs;
-
-import com.yonge.cooleshow.api.feign.TeacherFeignService;
-import com.yonge.cooleshow.task.core.BaseTask;
-import com.yonge.cooleshow.task.core.TaskException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-/**
- * @Author: cy
- * @Date: 2022/5/24
- */
-@Service
-public class TeacherSalaryTask extends BaseTask {
-    @Autowired
-    private TeacherFeignService teacherFeignService;
-
-    @Override
-    public void execute() throws TaskException {
-        teacherFeignService.teacherSalary();
-    }
-}
+//package com.yonge.cooleshow.task.jobs;
+//
+//import com.yonge.cooleshow.api.feign.TeacherFeignService;
+//import com.yonge.cooleshow.task.core.BaseTask;
+//import com.yonge.cooleshow.task.core.TaskException;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//
+///**
+// * @Author: cy
+// * @Date: 2022/5/24
+// */
+//@Service
+//public class TeacherSalaryTask extends BaseTask {
+//    @Autowired
+//    private TeacherFeignService teacherFeignService;
+//
+//    @Override
+//    public void execute() throws TaskException {
+//        teacherFeignService.teacherSalary();
+//    }
+//}

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java

@@ -236,7 +236,7 @@ public interface CourseScheduleService extends IService<CourseSchedule> {
 
     void scheduleTask();
 
-    void teacherSalaryTask();
+//    void teacherSalaryTask();
 
     PianoRoomTimeVo selectRemainTime(Long teacherId);
 

+ 22 - 12
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -1556,7 +1556,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
                 courseScheduleTeacherSalaryService.update(null, Wrappers.<CourseScheduleTeacherSalary>lambdaUpdate()
                         .set(CourseScheduleTeacherSalary::getStatus, CourseScheduleEnum.COMPLETE.getCode())
                         .set(CourseScheduleTeacherSalary::getSettlementTime, new Date())
-                        .in(CourseScheduleTeacherSalary::getCourseGroupId, practiceList.stream().map(CourseScheduleStudentVo::getCourseId).collect(Collectors.toList())));
+                        .in(CourseScheduleTeacherSalary::getCourseScheduleId, practiceList.stream().map(CourseScheduleStudentVo::getCourseId).collect(Collectors.toList())));
 
                 //获取教师课酬写入到金额变更表
                 for (CourseScheduleStudentVo practice : practiceList) {
@@ -1632,17 +1632,17 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      * @Author: cy
      * @Date: 2022/5/24
      */
-    @Transactional(rollbackFor = Exception.class)
-    public void teacherSalaryTask() {
-        //课程结算日期(天)
-        Integer settlementDay = Integer.valueOf(sysConfigService.findConfigValue(SysConfigConstant.COURSE_SALARY_SETTLEMENT_DAY));
-        //获取n天前日期
-        String day = DateUtil.getDayAgoOrAftString(-settlementDay);
-        //获取小于n天前所有课程id
-        List<Long> idList = baseMapper.selectIdList(day);
-        //更新老师课酬表
-        baseMapper.updateTeacherSalary(idList);
-    }
+//    @Transactional(rollbackFor = Exception.class)
+//    public void teacherSalaryTask() {
+//        //课程结算日期(天)
+//        Integer settlementDay = Integer.valueOf(sysConfigService.findConfigValue(SysConfigConstant.COURSE_SALARY_SETTLEMENT_DAY));
+//        //获取n天前日期
+//        String day = DateUtil.getDayAgoOrAftString(-settlementDay);
+//        //获取小于n天前所有课程id
+//        List<Long> idList = baseMapper.selectIdList(day);
+//        //更新老师课酬表
+//        baseMapper.updateTeacherSalary(idList);
+//    }
 
     /**
      * @Description: 查询琴房剩余时长、冻结时长、统计学员人数
@@ -1970,6 +1970,16 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         courseTime.setEndTime(endTime);
         List<CourseTimeEntity> timeList = Arrays.asList(courseTime);
 
+        //校验系统配置上下课时间
+        String classDate = DateUtil.dateToString(startTime);
+        String star = sysConfigService.findConfigValue(SysConfigConstant.COURSE_START_SETTING);//系统开课时间
+        String end = sysConfigService.findConfigValue(SysConfigConstant.COURSE_END_SETTING);//系统关课时间
+        Date s = DateUtil.strToDate(classDate + " " + star + ":00");
+        Date e = DateUtil.strToDate(classDate + " " + end + ":00");
+        if (startTime.before(s) || endTime.after(e)) {
+            throw new BizException("排课时间区间为{}~{}",star,end);
+        }
+
         if (startTime.before(new Date())) {
             throw new BizException("上课时间必须大于当前时间");
         }

+ 5 - 5
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/task/TaskController.java

@@ -69,9 +69,9 @@ public class TaskController extends BaseController {
         return HttpResponseResult.succeed();
     }
 
-    @GetMapping("/teacherSalary")
-    public HttpResponseResult<Object> teacherSalary() {
-        scheduleService.teacherSalaryTask();
-        return HttpResponseResult.succeed();
-    }
+//    @GetMapping("/teacherSalary")
+//    public HttpResponseResult<Object> teacherSalary() {
+//        scheduleService.teacherSalaryTask();
+//        return HttpResponseResult.succeed();
+//    }
 }