浏览代码

Merge branch 'Joburgess'

Joburgess 4 年之前
父节点
当前提交
12bac839d8

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentRecoverInfoDto.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.dal.dto;
 
+import java.time.LocalDate;
+
 /**
  * @Author Joburgess
  * @Date 2019/12/24
@@ -18,6 +20,16 @@ public class StudentRecoverInfoDto {
 
     private int giveCourseTimes;
 
+    private LocalDate expireDate;
+
+    public LocalDate getExpireDate() {
+        return expireDate;
+    }
+
+    public void setExpireDate(LocalDate expireDate) {
+        this.expireDate = expireDate;
+    }
+
     public Integer getVipGroupId() {
         return vipGroupId;
     }

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -4291,6 +4291,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                 }
                 if (courseTime.getDayOfWeek() == i) {
                     String dateYmdStr = DateUtil.dateToString(calendar.getTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT);
+                    if(StringUtils.isBlank(courseTime.getStartClassTime())){
+                    	throw new BizException("排课循环周期错误");
+					}
                     dateYmdStr = dateYmdStr + " " + courseTime.getStartClassTime();
                     Date courseStartTime = DateUtil.stringToDate(dateYmdStr, "yyyy-MM-dd HH:mm");
                     if(excludePastCourse&&courseStartTime.before(now)){

+ 28 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -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;
     }