Bladeren bron

经营报表相关改动

zouxuan 2 jaren geleden
bovenliggende
commit
e6078fe295

+ 28 - 26
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentStudentCourseDetailServiceImpl.java

@@ -111,33 +111,35 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
 			MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 			//免费团,并且购买乐器
 			BigDecimal musicalFee = BigDecimal.ZERO;
-			if(musicGroup.getCourseViewType() == CourseViewTypeEnum.FREE && orderDetailTypes.contains(OrderDetailTypeEnum.MUSICAL.getCode())){
-				//如果是免费团,那么要处理乐器溢出的课程费用
-				CourseViewTypeEnum courseViewType = musicGroup.getCourseViewType();
-				StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
-				Integer subjectId = studentRegistration.getActualSubjectId();
-				ChargeTypeSubjectMapper chargeType = chargeTypeSubjectMapperDao.findByViewTypeANdSubject(courseViewType,subjectId,musicGroup.getTenantId());
+			if(musicGroup.getCourseViewType() == CourseViewTypeEnum.FREE){
 				StudentPaymentOrderDetail orderMusical = studentPaymentOrderDetailDao.findApplyOrderMusical(paymentOrderId);
-				if(Objects.nonNull(chargeType) && chargeType.getFee() != null && orderMusical.getPrice().compareTo(BigDecimal.ZERO) > 0
-						&& chargeType.getFee().compareTo(orderMusical.getPrice()) < 0){
-					musicalFee = orderMusical.getPrice().subtract(chargeType.getFee());
-					studentMusicCourseFeeService.addExpectPrice(studentRegistration.getUserId(),
-							musicGroup.getId(),musicalFee);
-					//累加充值金额
-					studentRegistration.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().add(musicalFee));
-					//添加日志
-					StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
-					studentCourseFeeDetail.setTenantId(musicGroup.getTenantId());
-					studentCourseFeeDetail.setStudentRegistrationId(studentRegistration.getId());
-					studentCourseFeeDetail.setAmount(musicalFee);
-					studentCourseFeeDetail.setSurplusCourseFee(studentRegistration.getSurplusCourseFee());
-					studentCourseFeeDetail.setMemo("免费团,购买乐器赠送课费");
-					studentCourseFeeDetail.setOperator(userId);
-					studentCourseFeeDetailDao.insert(studentCourseFeeDetail);
-					List<MusicGroupPaymentStudentCourseDetail> courseDetails = musicGroupPaymentStudentCourseDetailDao.findByCalenderAndUserId(musicGroupPaymentCalender.getId().toString(), userId);
-					if(CollectionUtils.isNotEmpty(courseDetails)){
-						distributeTotalAmount(courseDetails,musicalFee);
-						musicGroupPaymentStudentCourseDetailDao.batchUpdate(courseDetails);
+				if(Objects.nonNull(orderMusical)){
+					//如果是免费团,那么要处理乐器溢出的课程费用
+					CourseViewTypeEnum courseViewType = musicGroup.getCourseViewType();
+					StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
+					Integer subjectId = studentRegistration.getActualSubjectId();
+					ChargeTypeSubjectMapper chargeType = chargeTypeSubjectMapperDao.findByViewTypeANdSubject(courseViewType,subjectId,musicGroup.getTenantId());
+					if(Objects.nonNull(chargeType) && chargeType.getFee() != null && orderMusical.getPrice().compareTo(BigDecimal.ZERO) > 0
+							&& chargeType.getFee().compareTo(orderMusical.getPrice()) < 0){
+						musicalFee = orderMusical.getPrice().subtract(chargeType.getFee());
+						studentMusicCourseFeeService.addExpectPrice(studentRegistration.getUserId(),
+								musicGroup.getId(),musicalFee);
+						//累加充值金额
+						studentRegistration.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().add(musicalFee));
+						//添加日志
+						StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
+						studentCourseFeeDetail.setTenantId(musicGroup.getTenantId());
+						studentCourseFeeDetail.setStudentRegistrationId(studentRegistration.getId());
+						studentCourseFeeDetail.setAmount(musicalFee);
+						studentCourseFeeDetail.setSurplusCourseFee(studentRegistration.getSurplusCourseFee());
+						studentCourseFeeDetail.setMemo("免费团,购买乐器赠送课费");
+						studentCourseFeeDetail.setOperator(userId);
+						studentCourseFeeDetailDao.insert(studentCourseFeeDetail);
+						List<MusicGroupPaymentStudentCourseDetail> courseDetails = musicGroupPaymentStudentCourseDetailDao.findByCalenderAndUserId(musicGroupPaymentCalender.getId().toString(), userId);
+						if(CollectionUtils.isNotEmpty(courseDetails)){
+							distributeTotalAmount(courseDetails,musicalFee);
+							musicGroupPaymentStudentCourseDetailDao.batchUpdate(courseDetails);
+						}
 					}
 				}
 			}