|
@@ -311,78 +311,79 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds,String batchNo) {
|
|
|
- //获取合班时的缴费项目
|
|
|
- List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
|
|
|
+ public void createForMusicGroup(List<CourseSchedule> courseSchedules, List<Integer> studentIds,Integer musicGroupStudentClassAdjustId) {
|
|
|
//获取提交的合班申请
|
|
|
- MusicGroupStudentClassAdjust classAdjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
|
|
|
- List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
|
+ MusicGroupStudentClassAdjust classAdjust = musicGroupStudentClassAdjustDao.get(musicGroupStudentClassAdjustId);
|
|
|
List<Long> courseIds = JSON.parseArray(classAdjust.getSubLockCourseIds(), Long.class);
|
|
|
+ String batchNo = classAdjust.getBatchNo();
|
|
|
|
|
|
- Map<CourseSchedule.CourseScheduleType, Integer> courseTypeCourseDurationMap = new HashMap<>();
|
|
|
- Map<CourseSchedule.CourseScheduleType, List<CourseSchedule>> typeCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getType));
|
|
|
- for (Map.Entry<CourseSchedule.CourseScheduleType, List<CourseSchedule>> typeCoursesEntry : typeCourseMap.entrySet()) {
|
|
|
- int totalCourseDuration = 0;
|
|
|
- for (CourseSchedule courseSchedule : typeCoursesEntry.getValue()) {
|
|
|
- //课程时长
|
|
|
- int courseDuration = DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime());
|
|
|
- totalCourseDuration += courseDuration;
|
|
|
- }
|
|
|
- courseTypeCourseDurationMap.put(typeCoursesEntry.getKey(), totalCourseDuration);
|
|
|
- }
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
|
|
|
|
//获取默认的排课时长
|
|
|
String courseDefaultMinutes = sysConfigDao.findConfigValue("music_course_default_minutes");
|
|
|
JSONObject jsonObject = JSON.parseObject(courseDefaultMinutes);
|
|
|
|
|
|
for (Integer studentId : studentIds) {
|
|
|
- //优先处理之前剩余的课程
|
|
|
- List<CourseScheduleStudentPayment> studentPayments = courseScheduleStudentPaymentDao.queryCourseByIdsAndStudentId(courseIds,studentId);
|
|
|
- for (int i = 0; i < courseSchedules.size(); i++) {
|
|
|
+ noPayment:for (int i = 0; i < courseSchedules.size(); i++) {
|
|
|
CourseSchedule courseSchedule = courseSchedules.get(i);
|
|
|
//优先处理之前的剩余课程
|
|
|
+ //获取调班之前,学员剩余的课程列表
|
|
|
+ List<CourseScheduleStudentPayment> studentPayments = courseScheduleStudentPaymentDao.queryCourseByIdsAndStudentId(courseIds,studentId,courseSchedule.getType().getCode());
|
|
|
if(studentPayments != null && studentPayments.size() > 0 && i < studentPayments.size()){
|
|
|
for (int j = 0; j < studentPayments.size(); j++) {
|
|
|
- CourseScheduleStudentPayment studentPayment = studentPayments.get(i);
|
|
|
+ CourseScheduleStudentPayment studentPayment = studentPayments.get(j);
|
|
|
studentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
studentPayment.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
studentPayment.setOpenPlayMidi(null);
|
|
|
studentPayment.setSettlementTime(null);
|
|
|
studentPayment.setExamSongDownloadJson(null);
|
|
|
+ studentPayment.setId(null);
|
|
|
courseScheduleStudentPayments.add(studentPayment);
|
|
|
- break;
|
|
|
}
|
|
|
- Set<Long> calenderIds = musicGroupPaymentCalenders.stream().map(e -> e.getId()).collect(Collectors.toSet());
|
|
|
- List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalendersAndCourseType(calenderIds, null);
|
|
|
- Map<Long, List<MusicGroupPaymentCalenderCourseSettings>> collect = musicGroupPaymentCalenderCourseSettings.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalenderCourseSettings::getMusicGroupPaymentCalenderId));
|
|
|
- for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenders) {
|
|
|
- MusicGroupPaymentCalenderCourseSettings courseSetting = collect.get(musicGroupPaymentCalender.getId()).get(0);
|
|
|
- //课程每分钟原价
|
|
|
- BigDecimal unitMinuteOriginalPrice = courseSetting.getCourseOriginalPrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
- //课程每分钟现价
|
|
|
- BigDecimal unitMinuteCurrentPrice = courseSetting.getCourseCurrentPrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
-
|
|
|
- //默认课程时长
|
|
|
- int courseDuration = Integer.parseInt(jsonObject.get(courseSchedule.getType().getCode()).toString());
|
|
|
- BigDecimal courseOriginalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
- //课程现价
|
|
|
- BigDecimal courseCurrentPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
- CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
|
|
|
- cssp.setGroupType(courseSchedule.getGroupType());
|
|
|
- cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
- cssp.setCourseScheduleId(courseSchedule.getId());
|
|
|
- cssp.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
- cssp.setBatchNo(batchNo);
|
|
|
- cssp.setUserId(studentId);
|
|
|
- cssp.setOriginalPrice(courseOriginalPrice);
|
|
|
- cssp.setExpectPrice(courseCurrentPrice);
|
|
|
- cssp.setActualPrice(BigDecimal.ZERO);
|
|
|
- courseScheduleStudentPayments.add(cssp);
|
|
|
-
|
|
|
+ i = studentPayments.size() - 1;
|
|
|
+ break noPayment;
|
|
|
+ }
|
|
|
+ //处理缴费的排课信息
|
|
|
+ List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(batchNo, studentId,courseSchedule.getType());
|
|
|
+ //获取合班时的缴费项目
|
|
|
+ Set<Long> calenderIds = musicGroupPaymentCalenderDao.findByBatchNoAndStudentId(batchNo,studentId);
|
|
|
+ List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalendersAndCourseType(calenderIds, null);
|
|
|
+ MusicGroupPaymentCalenderCourseSettings courseSetting = musicGroupPaymentCalenderCourseSettings.get(0);
|
|
|
+ //课程每分钟原价
|
|
|
+ BigDecimal unitMinuteOriginalPrice = courseSetting.getCourseOriginalPrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ //课程每分钟现价
|
|
|
+ BigDecimal unitMinuteCurrentPrice = courseSetting.getCourseCurrentPrice().divide(new BigDecimal(courseSetting.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+
|
|
|
+ //默认课程时长
|
|
|
+ int courseDuration = Integer.parseInt(jsonObject.get(courseSchedule.getType().getCode()).toString());
|
|
|
+ BigDecimal courseOriginalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ //课程现价
|
|
|
+ BigDecimal courseCurrentPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
|
|
|
+ cssp.setGroupType(courseSchedule.getGroupType());
|
|
|
+ cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
+ cssp.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ cssp.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ cssp.setBatchNo(batchNo);
|
|
|
+ cssp.setUserId(studentId);
|
|
|
+ cssp.setOriginalPrice(courseOriginalPrice);
|
|
|
+ cssp.setExpectPrice(courseCurrentPrice);
|
|
|
+ cssp.setActualPrice(BigDecimal.ZERO);
|
|
|
+ courseScheduleStudentPayments.add(cssp);
|
|
|
+ int typeCourseDuration = Integer.parseInt(jsonObject.get(courseSchedule.getType().getCode()).toString());
|
|
|
+ for (MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail : musicGroupPaymentStudentCourseDetails) {
|
|
|
+ if(typeCourseDuration > musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes()){
|
|
|
+ musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes());
|
|
|
+ typeCourseDuration = typeCourseDuration-musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes();
|
|
|
+ }else{
|
|
|
+ musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(typeCourseDuration);
|
|
|
+ typeCourseDuration = 0;
|
|
|
}
|
|
|
}
|
|
|
+ musicGroupPaymentStudentCourseDetailDao.batchUpdate(musicGroupPaymentStudentCourseDetails);
|
|
|
}
|
|
|
}
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
}
|
|
|
|
|
|
|