|
@@ -1,6 +1,7 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentApplyInstrumentDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
|
|
@@ -174,8 +175,34 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
|
|
|
musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
|
|
|
}
|
|
|
if (musicGroupPaymentStudentCourseDetails.size() > 0) {
|
|
|
- if(musicGroupPaymentCalender.getPayUserType() == STUDENT && musicalFee.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- distributeTotalAmount(musicGroupPaymentStudentCourseDetails, musicalFee);
|
|
|
+ if(musicGroupPaymentCalender.getPayUserType() == STUDENT && musicGroup.getCourseViewType() == CourseViewTypeEnum.FREE) {
|
|
|
+ List<StudentPaymentOrderDetail> instrumentDtos = studentPaymentOrderDetailDao.getWithUserAndOrderType(userId, musicGroupId, OrderDetailTypeEnum.MUSICAL);
|
|
|
+ //是否买过乐器
|
|
|
+ if(CollectionUtils.isNotEmpty(instrumentDtos)){
|
|
|
+ StudentPaymentOrderDetail orderMusical = instrumentDtos.get(0);
|
|
|
+ //如果是免费团,那么要处理乐器溢出的课程费用
|
|
|
+ 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());
|
|
|
+ //累加充值金额
|
|
|
+ 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);
|
|
|
+ studentRegistrationDao.update(studentRegistration);
|
|
|
+ distributeTotalAmount(musicGroupPaymentStudentCourseDetails,musicalFee);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetails);
|
|
|
}
|