Joburgess 4 lat temu
rodzic
commit
27a92bd5c3

+ 37 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -383,6 +383,10 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
                     .collect(Collectors.groupingBy(StudentAttendance::getCourseScheduleId, Collectors.counting()));
         }
 
+        //课程对应乐团结算方式集合
+        List<Map<String, String>> musicGroupSettlementTypeByCourse = courseScheduleTeacherSalaryDao.findMusicGroupSettlementTypeByCourse(courseScheduleIds);
+        Map<String, String> musicGroupSettlementsMap = MapUtil.convertMybatisMap(musicGroupSettlementTypeByCourse);
+
         //所有老师编号
         List<Integer> allTeacherIds = courseScheduleTeacherSalaries.stream()
                 .map(CourseScheduleTeacherSalary::getUserId)
@@ -427,7 +431,40 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
                     teacherSalary = BigDecimal.ZERO;
                 }
             }else if(CourseSchedule.CourseScheduleType.HIGH.equals(courseSchedule.getType())){
+                //根据课程类型获取对应的默认课酬设置列表
+                List<TeacherDefaultMusicGroupSalary> teacherDefaultMusicGroupSalariesWithCourseType = teacherDefaultMusicGroupSalariesGroupByCourseType.get(courseSchedule.getType());
+                if (CollectionUtils.isEmpty(teacherDefaultMusicGroupSalariesWithCourseType)) {
+                    LOGGER.error("存在未指定结算方式的课程类型[{}]", courseScheduleTeacherSalary.getId());
+                    continue;
+                }
 
+                //根据教师编号将对应结算方式下的默认课酬设置分组
+                Map<Integer, TeacherDefaultMusicGroupSalary> teacherDefaultMusicGroupSalariesGroupByTeacherId = teacherDefaultMusicGroupSalariesWithCourseType.stream().collect(Collectors.toMap(TeacherDefaultMusicGroupSalary::getUserId, teacherDefaultMusicGroupSalary -> teacherDefaultMusicGroupSalary));
+
+                TeacherDefaultMusicGroupSalary teacherDefaultMusicGroupSalaryWithTeacherId = teacherDefaultMusicGroupSalariesGroupByTeacherId.get(courseScheduleTeacherSalary.getUserId());
+
+                Long normalStudentNum = courseNormalStudentsMap.get(courseSchedule.getId());
+                if(Objects.isNull(normalStudentNum)){
+                    normalStudentNum = Long.valueOf(0);
+                }
+
+                //结算方式
+                String settlementType = musicGroupSettlementsMap.get(courseScheduleTeacherSalary.getCourseScheduleId());
+                if(StringUtils.isEmpty(settlementType)){
+                    LOGGER.error("未指定课酬结算方式[{}]", courseScheduleTeacherSalary.getId());
+                    continue;
+                }
+
+                teacherSalary = TeachTypeEnum.BISHOP.equals(courseScheduleTeacherSalary.getTeacherRole()) ? teacherDefaultMusicGroupSalaryWithTeacherId.getMainTeacher30MinSalary() : teacherDefaultMusicGroupSalaryWithTeacherId.getAssistantTeacher30MinSalary();
+                if (settlementType.equals(SalarySettlementTypeEnum.GRADIENT_SALARY)) {
+                    teacherSalary = TeachTypeEnum.BISHOP.equals(courseScheduleTeacherSalary.getTeacherRole()) ? teacherDefaultMusicGroupSalaryWithTeacherId.getMainTeacher90MinSalary() : teacherDefaultMusicGroupSalaryWithTeacherId.getAssistantTeacher90MinSalary();
+                }
+
+                if(Objects.isNull(teacherSalary)){
+                    LOGGER.error("教师课酬设置异常{}", courseSchedule.getId());
+                    continue;
+                }
+                teacherSalary = teacherSalary.multiply(new BigDecimal(normalStudentNum));
             }else{
                 teacherSalary=courseScheduleTeacherSalary.getExpectSalary();
             }