Browse Source

feat:乐团费用改造

Joburgess 5 years ago
parent
commit
818d247e47

+ 14 - 20
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -1430,19 +1430,27 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     @Transactional(rollbackFor = Exception.class)
     public ClassGroup classGroupAdjust(List<ClassGroup4MixDto> classGroup4MixDtos) {
         Date date = new Date();
-
         String musicGroupId = classGroup4MixDtos.get(0).getMusicGroupId();
         MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
         if (musicGroup == null) {
             throw new BizException("乐团不存在");
         }
+        if (classGroup4MixDtos.get(0).getCourseTimes().compareTo(0) <= 0) {
+            throw new BizException("排课次数必须大于0");
+        }
+        Date entryDate = DateUtil.stringToDate(sysConfigDao.findByParamName(SysConfigService.TEACHER_ENTRY_DATE).getParanValue(), "yyyy-MM-dd");
         Integer schoolId = musicGroup.getSchoolId();
 
         List<Integer> studentIdList = classGroup4MixDtos.get(0).getStudents();
-        List<StudentRegistration> studentList = studentRegistrationService.findStudentListByUserIdList(classGroup4MixDtos.get(0).getMusicGroupId(), studentIdList);
+        List<StudentRegistration> studentList = studentRegistrationService.findStudentListByUserIdList(musicGroupId, studentIdList);
 
         List<Integer> subjectIdList = studentList.stream().map(student -> student.getActualSubjectId()).collect(Collectors.toList());
         TeachModeEnum teachMode = TeachModeEnum.OFFLINE;
+        if (classGroup4MixDtos.get(0).getType().equals(ClassGroupTypeEnum.HIGH_ONLINE)) {
+            subjectIdList.clear();
+            subjectIdList.add(classGroup4MixDtos.get(0).getSubjectId());
+            teachMode = TeachModeEnum.ONLINE;
+        }
 
         List<Subject> subjectList = subjectService.findBySubjectByIdList(subjectIdList);
 
@@ -1452,13 +1460,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         if (classGroup4MixDtos.get(0).getType() == null) {
             classGroup4MixDtos.get(0).setType(ClassGroupTypeEnum.NORMAL);
         }
-
-        if (classGroup4MixDtos.get(0).getType().equals(ClassGroupTypeEnum.HIGH_ONLINE)) {
-            subjectIdList.clear();
-            subjectIdList.add(classGroup4MixDtos.get(0).getSubjectId());
-            teachMode = TeachModeEnum.ONLINE;
-        }
-
         //1、新建班级
         ClassGroup classGroup = new ClassGroup();
         classGroup.setMusicGroupId(classGroup4MixDtos.get(0).getMusicGroupId());
@@ -1527,21 +1528,14 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         //创建IM群组
         addImGroup(classGroup, userIds);
 
+        //5、插入班级排课信息
+        LocalDateTime now = LocalDate.parse(classGroup4MixDtos.get(0).getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
+
         //计算每节课的课酬
         List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaryList = new ArrayList<>();
         List<CourseSchedule> courseScheduleList = new ArrayList<>();
 
         for (ClassGroup4MixDto classGroup4MixDto : classGroup4MixDtos) {
-            if (classGroup4MixDto.getCourseTimes().compareTo(0) <= 0) {
-                throw new BizException("排课次数必须大于0");
-            }
-            Date entryDate = DateUtil.stringToDate(sysConfigDao.findByParamName(SysConfigService.TEACHER_ENTRY_DATE).getParanValue(), "yyyy-MM-dd");
-
-
-
-            //5、插入班级排课信息
-            LocalDateTime now = LocalDate.parse(classGroup4MixDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
-
             int times = 0;
 
             Set<String> holidayDays = new HashSet<>();
@@ -1704,7 +1698,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             courseScheduleTeacherSalaryService.batchInsert(courseScheduleTeacherSalaryList);
         }
         //学生结算表
-        if(!CollectionUtils.isEmpty(studentIdList)){
+        if (!CollectionUtils.isEmpty(studentIdList)) {
             courseScheduleStudentPaymentService.createForMusicGroup(musicGroupId, courseScheduleList, studentIdList);
         }
         return classGroup;