瀏覽代碼

fix:计算课酬时,学生人数从课程上取

Joburgess 4 年之前
父節點
當前提交
202a0718dd

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -236,6 +236,15 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
     Integer countStudentNum(Integer courseScheduleId);
 
     /**
+     * @describe 统计课程学员数量
+     * @author Joburgess
+     * @date 2021/2/9 0009
+     * @param courseScheduleId:
+     * @return int
+     */
+    int countCourseOnlyStudentNum(@Param("courseScheduleId") Long courseScheduleId);
+
+    /**
      * @param groupId:
      * @param groupType:
      * @return int

+ 4 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -721,12 +721,13 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 								if (StringUtils.equals(settlementType, "GRADIENT_SALARY")) {
 									salary = courseScheduleTeacherSalary.getTeacherRole().equals(TeachTypeEnum.BISHOP) ? tdms.getMainTeacher90MinSalary() : tdms.getAssistantTeacher90MinSalary();
 								}
-								courseScheduleTeacherSalary.setExpectSalary(salary);
+								int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(courseSchedule.getId());
+								courseScheduleTeacherSalary.setExpectSalary(salary.multiply(new BigDecimal(studentNum)));
 							}
 							//线上小班课
 							if(type == CourseScheduleType.HIGH_ONLINE){
-								Integer studentNum = classGroupStudentMapperDao.countClassGroupNormalStudentNum(classGroup.getId());
-								BigDecimal salary = JSON.parseObject(tdms.getSalaryRuleJson()).getBigDecimal(studentNum.toString());
+								int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(courseSchedule.getId());
+								BigDecimal salary = JSON.parseObject(tdms.getSalaryRuleJson()).getBigDecimal(studentNum+"");
 								courseScheduleTeacherSalary.setExpectSalary(salary);
 							}
 

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

@@ -1199,12 +1199,12 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
                 if(Objects.isNull(salary)){
                     throw new BizException("课酬设置异常");
                 }
-                Integer studentNum = classGroupStudentMapperDao.countClassGroupNormalStudentNum(courseSchedule.getClassGroupId());
+                int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(courseSchedule.getId());
                 salary = salary.multiply(new BigDecimal(studentNum));
             }
             //线上小班课
             if (courseSchedule.getType().equals(CourseSchedule.CourseScheduleType.HIGH_ONLINE)) {
-                Integer studentNum = classGroupStudentMapperDao.countClassGroupNormalStudentNum(courseSchedule.getClassGroupId());
+                int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(courseSchedule.getId());
                 if(studentNum>5){
                     studentNum=5;
                 }

+ 10 - 31
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherDefaultMusicGroupSalaryServiceImpl.java

@@ -9,6 +9,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import com.ym.mec.biz.dal.dao.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -17,10 +18,6 @@ import org.springframework.transaction.annotation.Transactional;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao;
-import com.ym.mec.biz.dal.dao.MusicGroupDao;
-import com.ym.mec.biz.dal.dao.TeacherDefaultMusicGroupSalaryDao;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary;
 import com.ym.mec.biz.dal.entity.MusicGroup;
@@ -42,6 +39,9 @@ public class TeacherDefaultMusicGroupSalaryServiceImpl extends BaseServiceImpl<L
 	private TeacherDefaultMusicGroupSalaryDao teacherDefaultMusicGroupSalaryDao;
 
 	@Autowired
+	private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
+
+	@Autowired
 	private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
 	
 	@Autowired
@@ -125,21 +125,15 @@ public class TeacherDefaultMusicGroupSalaryServiceImpl extends BaseServiceImpl<L
 										.getEndClassTime()));
 								int mins = 0;
 								if(tdms.getCourseScheduleType() == CourseScheduleType.HIGH_ONLINE || tdms.getCourseScheduleType() == CourseScheduleType.MUSIC_NETWORK) {
-									if (!classGroupStudentNumMap.containsKey(ts.getClassGroupId())) {
-										// 查询 班级人数
-										String[] strs = classGroupStudentMapperDao.findStudentNumByClassGroupId(ts.getClassGroupId());
-										classGroupStudentNumMap.put(ts.getClassGroupId(), strs.length);
-									}
+									int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(ts.getCourseScheduleId());
+
 									String salaryRuleJson = tdms.getSalaryRuleJson();
 									if (StringUtils.isNotBlank(salaryRuleJson)) {
 										JSONObject obj = JSON.parseObject(salaryRuleJson);
 										if(obj == null){
 											throw new BizException("课酬设置不完整");
 										}
-										Integer studentNum = classGroupStudentNumMap.get(ts.getClassGroupId());
-										if(studentNum == null){
-											studentNum = 0;
-										}
+
 										if(studentNum>5){
 											studentNum = 5;
 										}
@@ -164,15 +158,7 @@ public class TeacherDefaultMusicGroupSalaryServiceImpl extends BaseServiceImpl<L
 										}
 									}
 									if(CourseScheduleType.HIGH.equals(tdms.getCourseScheduleType())){
-										if (!classGroupStudentNumMap.containsKey(ts.getClassGroupId())) {
-											// 查询 班级人数
-											String[] strs = classGroupStudentMapperDao.findStudentNumByClassGroupId(ts.getClassGroupId());
-											classGroupStudentNumMap.put(ts.getClassGroupId(), strs.length);
-										}
-										Integer studentNum = classGroupStudentNumMap.get(ts.getClassGroupId());
-										if(studentNum == null){
-											studentNum = 0;
-										}
+										int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(ts.getCourseScheduleId());
 										ts.setExpectSalary(ts.getExpectSalary().multiply(new BigDecimal(studentNum)));
 									}
 									list.add(ts);
@@ -194,15 +180,8 @@ public class TeacherDefaultMusicGroupSalaryServiceImpl extends BaseServiceImpl<L
 										}
 									}
 									if(CourseScheduleType.HIGH.equals(tdms.getCourseScheduleType())){
-										if (!classGroupStudentNumMap.containsKey(ts.getClassGroupId())) {
-											// 查询 班级人数
-											String[] strs = classGroupStudentMapperDao.findStudentNumByClassGroupId(ts.getClassGroupId());
-											classGroupStudentNumMap.put(ts.getClassGroupId(), strs.length);
-										}
-										Integer studentNum = classGroupStudentNumMap.get(ts.getClassGroupId());
-										if(studentNum == null){
-											studentNum = 0;
-										}
+										int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(ts.getCourseScheduleId());
+										studentNum = 0;
 										ts.setExpectSalary(ts.getExpectSalary().multiply(new BigDecimal(studentNum)));
 									}
 									list.add(ts);

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -340,6 +340,9 @@
 	<select id="countStudentNum" resultType="java.lang.Integer">
 		SELECT COUNT(id_) FROM course_schedule_student_payment WHERE course_schedule_id_ = #{courseScheduleId}
 	</select>
+	<select id="countCourseOnlyStudentNum" resultType="int">
+		SELECT COUNT(user_id_) FROM course_schedule_student_payment WHERE course_schedule_id_ = #{courseScheduleId}
+	</select>
     <select id="findStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
 		SELECT su.id_ user_id_,su.username_,su.avatar_ head_url_,su.gender_
 		FROM course_schedule_student_payment cssp