|
@@ -41,6 +41,9 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -1906,6 +1909,14 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
Map<String, Object> pauseInfos = new HashMap<>();
|
|
|
//学生剩余课时
|
|
|
List<StudentCourseInfoDto> userSurplusCourseInfoByGroup = courseScheduleDao.findUserSurplusCourseInfoByGroup(GroupType.VIP, vipGroupId.toString(), studentId);
|
|
|
+
|
|
|
+ int days = 0;
|
|
|
+ if(!CollectionUtils.isEmpty(userSurplusCourseInfoByGroup)){
|
|
|
+ LocalDate nowDate = LocalDate.now(DateUtil.zoneId);
|
|
|
+ StudentCourseInfoDto studentCourseInfoDto = userSurplusCourseInfoByGroup.stream().max(Comparator.comparing(StudentCourseInfoDto::getClassDate)).get();
|
|
|
+ days = (int) nowDate
|
|
|
+ .until((LocalDateTime.ofInstant(studentCourseInfoDto.getClassDate().toInstant(), DateUtil.zoneId).toLocalDate()), ChronoUnit.DAYS);
|
|
|
+ }
|
|
|
int[] teachModeSequence=new int[userSurplusCourseInfoByGroup.size()];
|
|
|
List<BigDecimal> coursePrices = new ArrayList<>();
|
|
|
List<Long> courseScheduleIds=new ArrayList<>();
|
|
@@ -1916,6 +1927,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
pauseInfos.put("teaChModeSequence", teachModeSequence);
|
|
|
pauseInfos.put("coursePriceInfo",coursePrices);
|
|
|
+ pauseInfos.put("days", days);
|
|
|
|
|
|
StudentPauseInfo studentPauseInfo=new StudentPauseInfo();
|
|
|
studentPauseInfo.setUserId(studentId);
|
|
@@ -2051,6 +2063,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
newCourseSchedules.get(i).setOrganId(vipGroup.getOrganId());
|
|
|
}
|
|
|
+
|
|
|
+ if(courseInfo1.containsKey("days")){
|
|
|
+ int surplusDays = Integer.valueOf(courseInfo1.get("days").toString());
|
|
|
+ LocalDate nowDate = LocalDate.now();
|
|
|
+ CourseSchedule courseSchedule = newCourseSchedules.stream().max(Comparator.comparing(CourseSchedule::getClassDate)).get();
|
|
|
+ int days = (int) nowDate.until(LocalDateTime.ofInstant(courseSchedule.getClassDate().toInstant(), DateUtil.zoneId), ChronoUnit.DAYS);
|
|
|
+ if(days>surplusDays){
|
|
|
+ throw new BizException("您必须在{}天内完成剩余课程", surplusDays);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
courseScheduleService.batchAddCourseSchedule(newCourseSchedules);
|
|
|
|
|
|
ClassGroupTeacherMapper oldClassGroupTeacherMapper = classGroupTeacherMapperDao.findByClassGroupAndTeacher(classGroup.getId(),oldTeacherId);
|
|
@@ -2152,6 +2175,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
Map<BigDecimal, Long> collect = coursePrices.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
|
|
studentRecoverInfoDto.setGiveCourseTimes(Objects.isNull(collect.get(new BigDecimal("0.00")))?0:collect.get(new BigDecimal("0.00")).intValue());
|
|
|
studentRecoverInfoDto.setTotalCourseTimes(coursePrices.size()-studentRecoverInfoDto.getGiveCourseTimes());
|
|
|
+
|
|
|
+ if(courseInfo.containsKey("days")){
|
|
|
+ int surplusDays = Integer.valueOf(courseInfo.get("days").toString());
|
|
|
+ studentRecoverInfoDto.setExpireDate(LocalDate.now().plusDays(surplusDays));
|
|
|
+ }
|
|
|
return studentRecoverInfoDto;
|
|
|
}
|
|
|
|