|
@@ -1,11 +1,9 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
|
|
|
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
|
|
|
import com.ym.mec.biz.service.MusicGroupPaymentStudentCourseDetailService;
|
|
|
import com.ym.mec.biz.service.StudentMusicCourseFeeService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
@@ -16,10 +14,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.SCHOOL;
|
|
@@ -35,6 +30,14 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
|
|
|
private StudentMusicCourseFeeService studentMusicCourseFeeService;
|
|
|
@Autowired
|
|
|
private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupDao musicGroupDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentRegistrationDao studentRegistrationDao;
|
|
|
+ @Autowired
|
|
|
+ private ChargeTypeSubjectMapperDao chargeTypeSubjectMapperDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentCourseFeeDetailDao studentCourseFeeDetailDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, MusicGroupPaymentStudentCourseDetail> getDAO() {
|
|
@@ -104,7 +107,35 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
|
|
|
List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao
|
|
|
.getWithPaymentCalender(musicGroupPaymentCalender.getId());
|
|
|
Boolean cloudTeacherPaymentFlag = musicGroupPaymentCalender.getCloudTeacherPaymentFlag();
|
|
|
- BigDecimal reduce = BigDecimal.ZERO;
|
|
|
+ String musicGroupId = musicGroupPaymentCalender.getMusicGroupId();
|
|
|
+ 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());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
for (MusicGroupPaymentCalenderCourseSettings courseSetting : courseSettingsList) {
|
|
|
if (musicGroupPaymentCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT)
|
|
|
&& !orderDetailTypes.contains(courseSetting.getCourseType().getCode())) {
|
|
@@ -122,9 +153,9 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
|
|
|
musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
|
|
|
musicGroupPaymentStudentCourseDetail.setSubCourseMinutes(courseSetting.getCourseTotalMinuties());
|
|
|
musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
|
|
|
- musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSetting.getOverflowCoursePrice());
|
|
|
+ musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSetting.getOverflowCoursePrice().add(musicalFee));
|
|
|
musicGroupPaymentStudentCourseDetail.setSubCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
|
|
|
- musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(courseSetting.getOverflowCoursePrice());
|
|
|
+ musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(courseSetting.getOverflowCoursePrice().add(musicalFee));
|
|
|
if(musicGroupPaymentCalender.getPayUserType() == SCHOOL){
|
|
|
musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(BigDecimal.ZERO);
|
|
|
musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(BigDecimal.ZERO);
|
|
@@ -133,10 +164,6 @@ public class MusicGroupPaymentStudentCourseDetailServiceImpl extends BaseService
|
|
|
musicGroupPaymentStudentCourseDetail.setCloudTeacherPaymentFlag(cloudTeacherPaymentFlag);
|
|
|
musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
|
|
|
}
|
|
|
- if(reduce.compareTo(BigDecimal.ZERO) > 0){
|
|
|
- //汇总学员乐团课费,如果有溢出的乐器费用、云教练费用,也一并汇总,用于计算经营报表
|
|
|
- studentMusicCourseFeeService.addExpectPrice(userId,musicGroupPaymentCalender.getMusicGroupId(),reduce);
|
|
|
- }
|
|
|
if (musicGroupPaymentStudentCourseDetails.size() > 0) {
|
|
|
musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetails);
|
|
|
}
|