| 
					
				 | 
			
			
				@@ -1260,7 +1260,35 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if(surplusCourses<=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			throw new BizException("此vip课程没有剩余排课"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		BigDecimal surplusCourseFee = studentPaymentOrderDao.sumSurplusCourseFee(vipGroup.getId().toString(), userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Date now=new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal surplusCourseFee; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<StudentCourseInfoDto> userCourseInfos = courseScheduleDao.findUserCourseInfos(GroupType.VIP, vipGroupId.toString(), userId, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(CollectionUtils.isEmpty(userCourseInfos)&&vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(Objects.isNull(studentPaymentOrder)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                surplusCourseFee=new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                surplusCourseFee=studentPaymentOrder.getActualAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else if(!CollectionUtils.isEmpty(userCourseInfos)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal historyPrice=new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal allPrice=new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (StudentCourseInfoDto userCourseInfo : userCourseInfos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                allPrice=allPrice.add(userCourseInfo.getExpectPrice()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(now.after(userCourseInfo.getStartClassTime())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    historyPrice=historyPrice.add(userCourseInfo.getTeachMode().equals(TeachModeEnum.ONLINE)?vipGroup.getOnlineClassesUnitPrice():vipGroup.getOfflineClassesUnitPrice()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            surplusCourseFee=allPrice.subtract(historyPrice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(surplusCourseFee.longValue()<0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                surplusCourseFee=new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            surplusCourseFee=new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(Objects.isNull(surplusCourseFee)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            surplusCourseFee = new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        surplusCourseFee = surplusCourseFee.multiply(new BigDecimal(0.8)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		studentApplyRefunds.setExpectAmount(surplusCourseFee); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		studentApplyRefunds.setStatus(StudentApplyRefundsStatus.ING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		String orderNo=StringUtils.join(new String[]{userId.toString(),String.valueOf(System.currentTimeMillis())}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1619,26 +1647,37 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if(vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			throw new BizException("不能对已停止的课程进行退课操作"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Map<String,BigDecimal> result=new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if(Objects.isNull(studentPaymentOrder)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				BigDecimal surplusCourseFee = studentPaymentOrderDao.sumSurplusCourseFee(vipGroupId.toString(), studentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if(Objects.isNull(surplusCourseFee)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					result.put("suplusCourseFee",new BigDecimal(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				}else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					result.put("suplusCourseFee",surplusCourseFee); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				result.put("suplusCourseFee",studentPaymentOrder.getActualAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Date now = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal bigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<StudentCourseInfoDto> userCourseInfos = courseScheduleDao.findUserCourseInfos(GroupType.VIP, vipGroupId.toString(), studentId, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if(CollectionUtils.isEmpty(userCourseInfos)&&vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(Objects.isNull(studentPaymentOrder)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                bigDecimal=new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                bigDecimal=studentPaymentOrder.getActualAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else if(!CollectionUtils.isEmpty(userCourseInfos)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal historyPrice=new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal allPrice=new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (StudentCourseInfoDto userCourseInfo : userCourseInfos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                allPrice=allPrice.add(userCourseInfo.getExpectPrice()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(now.after(userCourseInfo.getStartClassTime())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    historyPrice=historyPrice.add(userCourseInfo.getTeachMode().equals(TeachModeEnum.ONLINE)?vipGroup.getOnlineClassesUnitPrice():vipGroup.getOfflineClassesUnitPrice()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bigDecimal=allPrice.subtract(historyPrice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(bigDecimal.longValue()<0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                bigDecimal=new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		    bigDecimal=new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String,BigDecimal> result=new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if(Objects.isNull(classGroup)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			throw new BizException("未找到对应班级"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		BigDecimal bigDecimal = courseScheduleStudentPaymentDao.countSurplusCourseFee(classGroup.getId(), studentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if(Objects.isNull(bigDecimal)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			bigDecimal = new BigDecimal(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 |