浏览代码

跨团合班逻辑调整

zouxuan 4 年之前
父节点
当前提交
c8b25a766d

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

@@ -464,4 +464,13 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
                                                @Param("monday") String monday,
                                                @Param("groupId") String groupId,
                                                @Param("courseType")CourseSchedule.CourseScheduleType courseType);
+
+    /**
+     * 获取学员对应课程类型剩余课程价值
+     * @param studentId
+     * @param classGroupId
+     * @param courseType
+     * @return
+     */
+    BigDecimal querySubCoursePriceMap(@Param("studentId") Integer studentId, @Param("classGroupId") Integer classGroupId, @Param("courseType") String courseType);
 }

+ 19 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -3672,8 +3672,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         Map<Integer, Integer> studentCLassMap = new HashMap<>();
         List<Map<Integer, BigDecimal>> surplusCourseFeeMapList = new ArrayList<>();
         List<Map<String,String>> classGroupStudents = (List<Map<String,String>>)JSON.parse(classGroupStudentMap);
-        Map<Integer,Map<String, BigDecimal>> classGroupUnitPriceMap = new HashMap<>();
-        Map<Integer,Map<String, BigDecimal>> classSubCoursePriceMap = new HashMap<>();
+//        Map<Integer,Map<String, BigDecimal>> classGroupUnitPriceMap = new HashMap<>();
+//        Map<Integer,Map<String, BigDecimal>> classSubCoursePriceMap = new HashMap<>();
         for (Map<String, String> classGroupStudent : classGroupStudents) {
             for (String integer : classGroupStudent.keySet()) {
                 //获取学员剩余课程费用
@@ -3683,9 +3683,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                     throw new BizException("操作失败:班级所在乐团状态不支持");
                 }
                 //学员可能来自不同的分部,获取对应的课程单价
-                classGroupUnitPriceMap.put(Integer.parseInt(integer),MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(byClassId.getChargeTypeId(), byClassId.getOrganId())));
+//                classGroupUnitPriceMap.put(Integer.parseInt(integer),MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(byClassId.getChargeTypeId(), byClassId.getOrganId())));
+
                 //获取班级剩余课程时长
-                classSubCoursePriceMap.put(Integer.parseInt(integer),MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseTimeMap(Integer.parseInt(integer))));
+//                classSubCoursePriceMap.put(Integer.parseInt(integer),MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseTimeMap(Integer.parseInt(integer))));
                 String[] s = classGroupStudent.get(integer).split(",");
                 for (String s1 : s) {
                     studentCLassMap.put(Integer.parseInt(s1),Integer.parseInt(integer));
@@ -3718,23 +3719,25 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             Map<Integer, BigDecimal> totalPriceMap = new HashMap<>();
             //课程余额转移
             for (Integer studentId : studentCLassMap.keySet()) {
+                //学员剩余课程价值
+                BigDecimal totalPrice = courseScheduleStudentPaymentDao.querySubCoursePriceMap(studentId,studentCLassMap.get(studentId),s);
                 //学员剩余课程余额
                 BigDecimal bigDecimal = surplusCourseFeeMap.get(studentId);
                 //创建学员缴费项目
                 MusicGroupPaymentCalenderStudentDetail calenderDto = new MusicGroupPaymentCalenderStudentDetail();
                 calenderDto.setClassGroupId(studentCLassMap.get(studentId));
                 //学员班级剩余课程价值
-                Map<String, BigDecimal> subCoursePriceMap = classSubCoursePriceMap.get(calenderDto.getClassGroupId());
-                Map<String, BigDecimal> unitPriceMap = classGroupUnitPriceMap.get(calenderDto.getClassGroupId());
-                BigDecimal courseTime = subCoursePriceMap.get(s);
-                BigDecimal unitPrice = unitPriceMap.get(s);
-                if (unitPrice == null) {
-                    throw new BizException("分部默认课程类型单价不存在,请设置");
-                }
-                if(courseTime == null){
-                    courseTime = BigDecimal.ZERO;
-                }
-                BigDecimal totalPrice = unitPrice.multiply(courseTime).setScale(0, BigDecimal.ROUND_HALF_UP);
+//                Map<String, BigDecimal> subCoursePriceMap = classSubCoursePriceMap.get(calenderDto.getClassGroupId());
+//                Map<String, BigDecimal> unitPriceMap = classGroupUnitPriceMap.get(calenderDto.getClassGroupId());
+//                BigDecimal courseTime = subCoursePriceMap.get(s);
+//                BigDecimal unitPrice = unitPriceMap.get(s);
+//                if (unitPrice == null) {
+//                    throw new BizException("分部默认课程类型单价不存在,请设置");
+//                }
+                if(totalPrice == null){
+                    totalPrice = BigDecimal.ZERO;
+                }
+//                BigDecimal totalPrice = unitPrice.multiply(courseTime).setScale(0, BigDecimal.ROUND_HALF_UP);
                 totalPriceMap.put(studentId,totalPrice);
                 calenderDto.setMasterSubCoursePrice(masterTotalPrice);
                 BigDecimal subCourseAmount = new BigDecimal(Math.min(Math.min(masterTotalPrice.doubleValue(), totalPrice.doubleValue()), bigDecimal.doubleValue()));
@@ -3758,7 +3761,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 //                    bigDecimal = bigDecimal.subtract(totalPrice);
                     surplusCourseFeeMap.put(studentId,bigDecimal.subtract(masterTotalPrice));
                 }
-                calenderDto.setCourseTime(courseTime.intValue());
+//                calenderDto.setCourseTime(courseTime.intValue());
                 calenderDto.setCourseType(s);
 
                 calenderDto.setPhone(phoneMaps.get(studentId));

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

@@ -711,4 +711,10 @@
 			LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
 		WHERE cs.new_course_id_=#{mainMergeCourseId}
 	</select>
+    <select id="querySubCoursePriceMap" resultType="java.math.BigDecimal">
+		SELECT SUM(cssp.expect_price_) FROM course_schedule_student_payment cssp
+		LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+		WHERE cssp.class_group_id_ = #{classGroupId} AND cssp.user_id_ = #{studentId} AND CONCAT(cs.class_date_,' ',cs.start_class_time_) > NOW()
+		AND cs.type_ = #{courseType}
+	</select>
 </mapper>