فهرست منبع

经营报表导致的排课bug

zouxuan 2 سال پیش
والد
کامیت
4ecf4c5fee

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java

@@ -136,4 +136,6 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
      * @return
      */
     int clearRemainCourseMinutesByMusicGroupId(String musicGroupId);
+
+    void deleteByUserIdAndCalenderId(@Param("userId") Integer userId, @Param("calenderIds") List<Long> calenderIds);
 }

+ 18 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -391,6 +391,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
 		Map<Integer, List<CourseSchedule>> memberCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getMemberFlag));
+		Map<Long,List<Long>> courseCalenderMap = new HashMap<>(10);
 		for (Integer memberFlag : memberCourseMap.keySet()) {
 			List<CourseSchedule> courseScheduleList = memberCourseMap.get(memberFlag);
 			if(courseScheduleList != null && courseScheduleList.size() > 0){
@@ -461,7 +462,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 								cssp.setUserId(studentId);
 								//扣除可排课时长
 								//处理经营报表
-								this.calcCourseMinutes(musicGroupPaymentStudentCourseDetails,courseDuration,cssp,musicGroupPaymentCalenders);
+								this.calcCourseMinutes(musicGroupPaymentStudentCourseDetails,courseDuration,cssp,musicGroupPaymentCalenders,courseCalenderMap);
 								typeCourseStudentPayments.add(cssp);
 							}
 							courseScheduleStudentPayments.addAll(typeCourseStudentPayments);
@@ -472,12 +473,19 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				}
 			}
 		}
+		if(!CollectionUtils.isEmpty(courseCalenderMap)){
+			for (Long calenderId : courseCalenderMap.keySet()) {
+				List<Long> courseIds = courseCalenderMap.get(calenderId);
+				operatingReportCloudService.updateSet(calenderId,courseIds);
+			}
+		}
 	}
 
 	private Boolean calcCourseMinutes(List<MusicGroupPaymentStudentCourseDetail> courseDetails,
 									  Integer courseDuration,
 									  CourseScheduleStudentPayment studentPayment,
-									  List<MusicGroupPaymentCalender> musicGroupPaymentCalenders){
+									  List<MusicGroupPaymentCalender> musicGroupPaymentCalenders,
+									  Map<Long,List<Long>> courseCalenderMap){
 		Boolean result = true;
 		Integer courseMinutes = courseDuration;
 		Map<Long, List<MusicGroupPaymentCalender>> calenderMap = musicGroupPaymentCalenders.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalender::getId));
@@ -519,10 +527,16 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				if(MusicGroupPaymentCalender.PayUserType.SCHOOL.equals(calender.getPayUserType())){
 					studentPayment.setExpectPrice(BigDecimal.ZERO);
 				}
+				//处理经营报表缴费项目相关数据,线上存在问题,先让用户排课
 				if(result){
-					ArrayList<Long> courseIds = new ArrayList<>();
+					List<Long> courseIds = courseCalenderMap.get(calender.getId());
+					if(CollectionUtils.isEmpty(courseIds)){
+						courseIds = new ArrayList<>();
+					}
 					courseIds.add(studentPayment.getCourseScheduleId());
-					operatingReportCloudService.updateSet(calender,courseIds);
+//					ArrayList<Long> courseIds = new ArrayList<>();
+//					courseIds.add(studentPayment.getCourseScheduleId());
+//					operatingReportCloudService.updateSet(calender,courseIds);
 				}
 				if(courseMinutes == 0){
 					return result;

+ 5 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -2158,7 +2158,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         Long id = reqMusicGroupQuit.getId();
         ApprovalStatus status = reqMusicGroupQuit.getStatus();
         String reason = reqMusicGroupQuit.getReason();
-        Date visitDate = reqMusicGroupQuit.getVisitTime();
         MusicGroupReturnFeeDto returnFeeDto = reqMusicGroupQuit.getReturnFeeDto();
 
         MusicGroupQuit musicGroupQuit = musicGroupQuitDao.get(id);
@@ -2225,18 +2224,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		musicGroupQuit.setVisitTime(reqMusicGroupQuit.getVisitTime());
 		musicGroupQuit.setUserComment(reqMusicGroupQuit.getUserComment());
 
-
-/*        if (visitDate != null) {
-            musicGroupQuit.setVisitTime(visitDate);
-            musicGroupQuit.setIsVisit(true);
-        } else {
-            musicGroupQuit.setIsVisit(false);
-        }
-
-        if (StringUtils.isBlank(musicGroupQuit.getUserComment())) {
-            musicGroupQuit.setUserComment(reqMusicGroupQuit.getUserComment());
-        }*/
-
         BigDecimal returnTotalFee = BigDecimal.ZERO;
 
         if (returnFeeDto == null) {
@@ -2252,9 +2239,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (returnFeeDto.getIsReturnMaintenanceFee()) {
             returnTotalFee = returnTotalFee.add(returnFeeDto.getMaintenanceFee());
         }
-//        if (returnFeeDto.getIsReturnMemberFee()) {
-//            returnTotalFee = returnTotalFee.add(returnFeeDto.getMemberFee());
-//        }
         if (returnFeeDto.getIsReturnMusicalFee()) {
             returnTotalFee = returnTotalFee.add(returnFeeDto.getMusicalFee());
         }
@@ -2316,7 +2300,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 musicGroupPaymentCalenderDetailDao.delete(mgpcd.getId());
             }
             //删除用户购买的课程记录
-            musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
+            List<MusicGroupPaymentCalender> paymentCalenders = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
+            if(CollectionUtils.isNotEmpty(paymentCalenders)){
+                List<Long> calenderIds = paymentCalenders.stream().map(e -> e.getId()).collect(Collectors.toList());
+                musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndCalenderId(userId, calenderIds);
+            }
 
             BigDecimal amount = new BigDecimal(0);
 

+ 8 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -277,6 +277,14 @@
             WHERE music_group_id_ = #{musicGroupId}
         )
     </delete>
+    <delete id="deleteByUserIdAndCalenderId">
+        DELETE
+        FROM music_group_payment_student_course_detail
+        WHERE user_id_ = #{userId} AND music_group_payment_calender_id_ IN
+        <foreach collection="calenderIds" open="(" close=")" item="id" separator=",">
+            #{id}
+        </foreach>
+    </delete>
 
     <resultMap id="StudentSubTotalCourseTimesDto" type="com.ym.mec.biz.dal.dto.StudentSubTotalCourseTimesDto">
         <result property="userId" column="user_id_"/>