|
@@ -221,6 +221,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void updateVipGiveCourse(Long vipGroupId) {
|
|
|
List<VipGroupGiveCourseSortDto> vipGroupSortCourseByGroup = courseScheduleStudentPaymentDao.findVipGroupSortCourseByGroup(vipGroupId.toString());
|
|
|
Map<BigDecimal, Long> expectPriceCountMap = vipGroupSortCourseByGroup.stream()
|
|
@@ -230,6 +231,24 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
|
|
|
if(zeroPriceNum<=0){
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ List<CourseScheduleStudentPayment> needUpdatePayments=new ArrayList<>();
|
|
|
+
|
|
|
+ List<VipGroupGiveCourseSortDto> zeroExpectPricePayments = vipGroupSortCourseByGroup.stream()
|
|
|
+ .filter(vipGroupGiveCourseSortDto -> vipGroupGiveCourseSortDto.getExpectPrice().compareTo(zero)==0)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vipGroupSortCourseByGroup.sort(Comparator.comparing(VipGroupGiveCourseSortDto::getCourseStartTime).reversed());
|
|
|
+ for (int i=0;i<vipGroupSortCourseByGroup.size();i++) {
|
|
|
+ VipGroupGiveCourseSortDto vipGroupGiveCourseSortDto=vipGroupSortCourseByGroup.get(i);
|
|
|
+ VipGroupGiveCourseSortDto zeroVipGroupGiveCoursePayment = zeroExpectPricePayments.get(i);
|
|
|
+ if(!vipGroupGiveCourseSortDto.getId().equals(zeroVipGroupGiveCoursePayment)
|
|
|
+ &&!vipGroupGiveCourseSortDto.getTeachMode().equals(zeroVipGroupGiveCoursePayment.getTeachMode())){
|
|
|
+ throw new BizException("不支持将不同教学形式的课程调整的赠送课时后");
|
|
|
+ }
|
|
|
+ if(!vipGroupGiveCourseSortDto.getId().equals(zeroVipGroupGiveCoursePayment)){
|
|
|
+ needUpdatePayments.add(new CourseScheduleStudentPayment(vipGroupGiveCourseSortDto.getId(),zeroVipGroupGiveCoursePayment.getCourseScheduleId()));
|
|
|
+ needUpdatePayments.add(new CourseScheduleStudentPayment(zeroVipGroupGiveCoursePayment.getId(),vipGroupGiveCourseSortDto.getCourseScheduleId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|