|
@@ -7,7 +7,6 @@ import com.ym.mec.biz.dal.dto.SimpleUserDto;
|
|
import com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto;
|
|
import com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto;
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
-import com.ym.mec.biz.dal.page.CourseScheduleQueryInfo;
|
|
|
|
import com.ym.mec.biz.dal.page.CourseScheduleStudentPaymentQueryInfo;
|
|
import com.ym.mec.biz.dal.page.CourseScheduleStudentPaymentQueryInfo;
|
|
import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
|
|
import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
|
|
import com.ym.mec.biz.service.SysUserCashAccountService;
|
|
import com.ym.mec.biz.service.SysUserCashAccountService;
|
|
@@ -16,13 +15,9 @@ import com.ym.mec.common.dal.BaseDAO;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.page.PageInfo;
|
|
import com.ym.mec.common.page.PageInfo;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
-import com.ym.mec.thirdparty.yqpay.DateUtils;
|
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
-import io.swagger.models.auth.In;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
-import org.apache.poi.ss.formula.functions.T;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
@@ -327,30 +322,40 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
|
|
for (Map.Entry<CourseSchedule.CourseScheduleType, List<CourseSchedule>> courseScheduleTypeListEntry : typeCourseMap.entrySet()) {
|
|
for (Map.Entry<CourseSchedule.CourseScheduleType, List<CourseSchedule>> courseScheduleTypeListEntry : typeCourseMap.entrySet()) {
|
|
//当前课程类型总课程时长
|
|
//当前课程类型总课程时长
|
|
Integer typeCourseDuration = courseTypeCourseDurationMap.get(courseScheduleTypeListEntry.getKey());
|
|
Integer typeCourseDuration = courseTypeCourseDurationMap.get(courseScheduleTypeListEntry.getKey());
|
|
- MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, studentId, courseScheduleTypeListEntry.getKey(), typeCourseDuration);
|
|
|
|
- if(Objects.isNull(musicGroupPaymentStudentCourseDetail)||musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes().compareTo(typeCourseDuration)<0){
|
|
|
|
|
|
+
|
|
|
|
+ String batchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, studentId, courseScheduleTypeListEntry.getKey());
|
|
|
|
+
|
|
|
|
+ List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(batchNo, studentId, courseScheduleTypeListEntry.getKey());
|
|
|
|
+ int totalCourseMinutes = musicGroupPaymentStudentCourseDetails.stream().mapToInt(MusicGroupPaymentStudentCourseDetail::getTotalCourseMinutes).reduce(0, Integer::sum);
|
|
|
|
+ if(CollectionUtils.isEmpty(musicGroupPaymentStudentCourseDetails)||totalCourseMinutes<typeCourseDuration){
|
|
SysUser user = teacherDao.getUser(studentId);
|
|
SysUser user = teacherDao.getUser(studentId);
|
|
throw new BizException("{}在{}课程类型上的课程时长不足", user.getUsername(), courseScheduleTypeListEntry.getKey().getMsg());
|
|
throw new BizException("{}在{}课程类型上的课程时长不足", user.getUsername(), courseScheduleTypeListEntry.getKey().getMsg());
|
|
}
|
|
}
|
|
|
|
|
|
- MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentStudentCourseDetail.getMusicGroupPaymentCalenderId());
|
|
|
|
- if(Objects.isNull(musicGroupPaymentCalender)||!musicGroupId.equals(musicGroupPaymentCalender.getMusicGroupId())){
|
|
|
|
|
|
+ Set<Long> calenderIds = musicGroupPaymentStudentCourseDetails.stream().map(MusicGroupPaymentStudentCourseDetail::getMusicGroupPaymentCalenderId).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.queryByIds(calenderIds);
|
|
|
|
+ if(CollectionUtils.isEmpty(musicGroupPaymentCalenders)||musicGroupPaymentCalenders.size()!=calenderIds.size()){
|
|
throw new BizException("缴费设置异常");
|
|
throw new BizException("缴费设置异常");
|
|
}
|
|
}
|
|
|
|
|
|
- MusicGroupPaymentCalenderCourseSettings musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalenderAndCourseType(musicGroupPaymentStudentCourseDetail.getMusicGroupPaymentCalenderId(), courseScheduleTypeListEntry.getKey());
|
|
|
|
- if(Objects.isNull(musicGroupPaymentCalenderCourseSettings)||musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties().compareTo(musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes())!=0){
|
|
|
|
|
|
+ List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalendersAndCourseType(calenderIds, courseScheduleTypeListEntry.getKey());
|
|
|
|
+ int originalCourseTotalMinutes = musicGroupPaymentCalenderCourseSettings.stream().mapToInt(MusicGroupPaymentCalenderCourseSettings::getCourseTotalMinuties).reduce(0, Integer::sum);
|
|
|
|
+ if(Objects.isNull(musicGroupPaymentCalenderCourseSettings)||originalCourseTotalMinutes!=totalCourseMinutes){
|
|
throw new BizException("缴费设置异常");
|
|
throw new BizException("缴费设置异常");
|
|
}
|
|
}
|
|
|
|
|
|
- allBatchNos.add(musicGroupPaymentCalender.getBatchNo());
|
|
|
|
|
|
+ allBatchNos.add(batchNo);
|
|
|
|
+
|
|
|
|
+ BigDecimal totalCourseOriginalPrice = musicGroupPaymentCalenderCourseSettings.stream().map(MusicGroupPaymentCalenderCourseSettings::getCourseOriginalPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ BigDecimal totalCourseCurrentPrice = musicGroupPaymentCalenderCourseSettings.stream().map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
//课程每分钟原价
|
|
//课程每分钟原价
|
|
- BigDecimal unitMinuteOriginalPrice = musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().divide(new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
|
|
|
+ BigDecimal unitMinuteOriginalPrice = totalCourseOriginalPrice.divide(new BigDecimal(originalCourseTotalMinutes), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
//课程每分钟现价
|
|
//课程每分钟现价
|
|
- BigDecimal unitMinuteCurrentPrice = musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().divide(new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
|
|
|
+ BigDecimal unitMinuteCurrentPrice = totalCourseCurrentPrice.divide(new BigDecimal(originalCourseTotalMinutes), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
|
|
|
- if(MusicGroupPaymentCalender.PayUserType.SCHOOL.equals(musicGroupPaymentCalender.getPayUserType())){
|
|
|
|
|
|
+ if(MusicGroupPaymentCalender.PayUserType.SCHOOL.equals(musicGroupPaymentCalenders.get(0).getPayUserType())){
|
|
unitMinuteCurrentPrice = new BigDecimal("0");
|
|
unitMinuteCurrentPrice = new BigDecimal("0");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -374,7 +379,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
|
|
cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
cssp.setCourseScheduleId(courseSchedule.getId());
|
|
cssp.setCourseScheduleId(courseSchedule.getId());
|
|
cssp.setClassGroupId(courseSchedule.getClassGroupId());
|
|
cssp.setClassGroupId(courseSchedule.getClassGroupId());
|
|
- cssp.setBatchNo(musicGroupPaymentCalender.getBatchNo());
|
|
|
|
|
|
+ cssp.setBatchNo(batchNo);
|
|
cssp.setUserId(studentId);
|
|
cssp.setUserId(studentId);
|
|
cssp.setOriginalPrice(courseOriginalPrice);
|
|
cssp.setOriginalPrice(courseOriginalPrice);
|
|
cssp.setExpectPrice(courseCurrentPrice);
|
|
cssp.setExpectPrice(courseCurrentPrice);
|
|
@@ -382,13 +387,21 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
|
|
typeCourseStudentPayments.add(cssp);
|
|
typeCourseStudentPayments.add(cssp);
|
|
}
|
|
}
|
|
|
|
|
|
- typeCourseStudentPayments.get(0).setOriginalPrice(typeCourseStudentPayments.get(0).getOriginalPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().subtract(typeCourseTotalOriginalPrice)));
|
|
|
|
- if(MusicGroupPaymentCalender.PayUserType.STUDENT.equals(musicGroupPaymentCalender.getPayUserType())) {
|
|
|
|
- typeCourseStudentPayments.get(0).setExpectPrice(typeCourseStudentPayments.get(0).getExpectPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().subtract(typeCourseTotalCurrentPrice)));
|
|
|
|
|
|
+ typeCourseStudentPayments.get(0).setOriginalPrice(typeCourseStudentPayments.get(0).getOriginalPrice().add(totalCourseOriginalPrice.subtract(typeCourseTotalOriginalPrice)));
|
|
|
|
+ if(MusicGroupPaymentCalender.PayUserType.STUDENT.equals(musicGroupPaymentCalenders.get(0).getPayUserType())) {
|
|
|
|
+ typeCourseStudentPayments.get(0).setExpectPrice(typeCourseStudentPayments.get(0).getExpectPrice().add(totalCourseCurrentPrice.subtract(typeCourseTotalCurrentPrice)));
|
|
}
|
|
}
|
|
courseScheduleStudentPayments.addAll(typeCourseStudentPayments);
|
|
courseScheduleStudentPayments.addAll(typeCourseStudentPayments);
|
|
- musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(typeCourseDuration);
|
|
|
|
- musicGroupPaymentStudentCourseDetailDao.update(musicGroupPaymentStudentCourseDetail);
|
|
|
|
|
|
+ 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);
|
|
courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|