|  | @@ -2093,7 +2093,15 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 | 
	
		
			
				|  |  |          if(Objects.isNull(groupId)){
 | 
	
		
			
				|  |  |              throw new BizException("请选择续费的课程");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        return practiceGroupDao.findUserPracticeGroup2(userId, groupId);
 | 
	
		
			
				|  |  | +        Date now=new Date();
 | 
	
		
			
				|  |  | +        PracticeGroupDto userPracticeGroup = practiceGroupDao.findUserPracticeGroup2(userId, groupId);
 | 
	
		
			
				|  |  | +        if(Objects.isNull(userPracticeGroup)){
 | 
	
		
			
				|  |  | +            throw new BizException("需要续费的课程组不存在");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(userPracticeGroup.getCoursesExpireDate().before(now)){
 | 
	
		
			
				|  |  | +            throw new BizException("此课程组已超过可续费期限");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return userPracticeGroup;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
	
		
			
				|  | @@ -2222,16 +2230,17 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Map<Integer, List<String>> getEnableApplyDatesWithWeek() {
 | 
	
		
			
				|  |  |          Map<Integer, List<String>> result = new HashMap<>();
 | 
	
		
			
				|  |  | -        SysConfig practiceApplyStartTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
 | 
	
		
			
				|  |  | -        SysConfig practiceApplyEndTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
 | 
	
		
			
				|  |  |          SysConfig practiceApplyIntervalTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_INTERVAL_TIME);
 | 
	
		
			
				|  |  |          Integer practiceApplyIntervalMinutes = practiceApplyIntervalTimeConfig.getParanValue(Integer.class);
 | 
	
		
			
				|  |  | -        LocalTime dayStartTime=LocalTime.parse(practiceApplyStartTimeConfig.getParanValue(),DateUtil.timeFormatter);
 | 
	
		
			
				|  |  | -        LocalTime dayEndTime=LocalTime.parse(practiceApplyEndTimeConfig.getParanValue(),DateUtil.timeFormatter);
 | 
	
		
			
				|  |  | +        LocalTime dayStartTime=LocalTime.parse("00:00:00",DateUtil.timeFormatter);
 | 
	
		
			
				|  |  | +        LocalTime dayEndTime=LocalTime.parse("00:00:00",DateUtil.timeFormatter);
 | 
	
		
			
				|  |  |          List<String> dayApplyTimes=new ArrayList<>();
 | 
	
		
			
				|  |  | -        while (dayEndTime.isAfter(dayStartTime)){
 | 
	
		
			
				|  |  | +        while (true){
 | 
	
		
			
				|  |  |              dayApplyTimes.add(dayStartTime.format(DateUtil.timeFormatter));
 | 
	
		
			
				|  |  |              dayStartTime=dayStartTime.plusMinutes(practiceApplyIntervalMinutes);
 | 
	
		
			
				|  |  | +            if(dayStartTime.compareTo(dayEndTime)==0){
 | 
	
		
			
				|  |  | +                break;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          for (int i = 1; i <= 7; i++) {
 | 
	
		
			
				|  |  |              List<String> tempTimes = new ArrayList<>();
 | 
	
	
		
			
				|  | @@ -2329,21 +2338,14 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 | 
	
		
			
				|  |  |          WeekFields weekFields = WeekFields.of(DayOfWeek.MONDAY, 1);
 | 
	
		
			
				|  |  |          ZoneId zoneId = ZoneId.systemDefault();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        Date today=new Date();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          LocalDate now = LocalDate.now();
 | 
	
		
			
				|  |  |          if(renew){
 | 
	
		
			
				|  |  |              PracticeGroup userLatestPracticeGroup = practiceGroupDao.findUserPracticeGroup(userId,groupId);
 | 
	
		
			
				|  |  |              if(Objects.nonNull(userLatestPracticeGroup)){
 | 
	
		
			
				|  |  | -                if(userLatestPracticeGroup.getCoursesExpireDate().after(today)){
 | 
	
		
			
				|  |  | -                    throw new BizException("此课程组已超过可续费期限");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).toLocalDate();
 | 
	
		
			
				|  |  | +                LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).plusSeconds(1).toLocalDate();
 | 
	
		
			
				|  |  |                  if(Objects.nonNull(lastExpiredDay)&&lastExpiredDay.compareTo(now)>=0){
 | 
	
		
			
				|  |  |                      now=lastExpiredDay;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -            }else{
 | 
	
		
			
				|  |  | -                throw new BizException("需要续费的课程组不存在");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          now.plusDays(1);
 | 
	
	
		
			
				|  | @@ -2353,7 +2355,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 | 
	
		
			
				|  |  |          Date secondSunday = DateUtil.getWeekDayWithDate(applyEndDate, Calendar.SUNDAY);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          Map<Integer, List<String>> weekNumApplyTimesMap = getEnableApplyDatesWithWeek();
 | 
	
		
			
				|  |  | -        List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeacherCoursesWithDateRange(teacherId, firstMonday, secondSunday);
 | 
	
		
			
				|  |  | +        List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeacherCoursesWithDateRange(teacherId, applyStartDate, secondSunday);
 | 
	
		
			
				|  |  |          allTeacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          JSONObject teacherLeaveData = null;
 | 
	
	
		
			
				|  | @@ -2444,9 +2446,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if (CollectionUtils.isEmpty(allTeacherCourses)) {
 | 
	
		
			
				|  |  | -            if(weekNumApplyTimesMap.size()<=1){
 | 
	
		
			
				|  |  | -                weekNumApplyTimesMap=new HashMap<>();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  |              result.put("teacherFreeDays", weekNumApplyTimesMap);
 | 
	
		
			
				|  |  |              return result;
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -2498,7 +2497,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 | 
	
		
			
				|  |  |                      continue;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            weekNumApplyTimesMap.put(courseStartTime.getDayOfWeek().getValue(), applyTimeStrs);
 | 
	
		
			
				|  |  | +            if(CollectionUtils.isEmpty(applyTimeStrs)){
 | 
	
		
			
				|  |  | +                weekNumApplyTimesMap.remove(courseStartTime.getDayOfWeek().getValue());
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                weekNumApplyTimesMap.put(courseStartTime.getDayOfWeek().getValue(), applyTimeStrs);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if(weekNumApplyTimesMap.size()<=1){
 | 
	
		
			
				|  |  |              weekNumApplyTimesMap=new HashMap<>();
 | 
	
	
		
			
				|  | @@ -2555,10 +2558,15 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              PracticeGroup userLatestPracticeGroup = practiceGroupDao.findUserPracticeGroup(practiceGroupBuyParams.getStudentId(),practiceGroupBuyParams.getGroupId());
 | 
	
		
			
				|  |  |              if(Objects.nonNull(userLatestPracticeGroup)){
 | 
	
		
			
				|  |  | +                if(userLatestPracticeGroup.getCoursesExpireDate().before(now)){
 | 
	
		
			
				|  |  | +                    throw new BizException("此课程组已超过可续费期限");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  LocalDate lastExpiredDay=LocalDateTime.ofInstant(userLatestPracticeGroup.getCoursesExpireDate().toInstant(),DateUtil.zoneId).toLocalDate();
 | 
	
		
			
				|  |  |                  if(Objects.nonNull(lastExpiredDay)&&lastExpiredDay.compareTo(courseStartDay)>=0){
 | 
	
		
			
				|  |  |                      courseStartDay=lastExpiredDay;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "需要续费的课程组不存在");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2895,6 +2903,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 | 
	
		
			
				|  |  |          if(order.getStatus().equals(DealStatusEnum.SUCCESS)){
 | 
	
		
			
				|  |  |              courseScheduleDao.updateGroupCourseLock(order.getMusicGroupId(),GroupType.PRACTICE,0);
 | 
	
		
			
				|  |  |          }else{
 | 
	
		
			
				|  |  | +            if(Objects.nonNull(order.getBalancePaymentAmount())){
 | 
	
		
			
				|  |  | +                sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "陪练课购买失败");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              studentPaymentOrderDao.update(order);
 | 
	
		
			
				|  |  |              groupService.deleteGroupInfo(order.getMusicGroupId(),GroupType.PRACTICE);
 | 
	
		
			
				|  |  |              return;
 |