| 
					
				 | 
			
			
				@@ -1,9 +1,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.ym.mec.biz.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dao.OperatingReportCloudDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dao.OrganCourseTypeOriginalCostDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.OperatingReportCloud; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -37,6 +34,8 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private StudentPaymentOrderDao studentPaymentOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public BaseDAO<Integer, OperatingReportCloud> getDAO() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -63,6 +62,10 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			amount = studentPaymentOrderDao.get(orderId).getActualAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if(calender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_STUDENT){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			this.saveMonthOperating(calender,amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//找出非当月结算的缴费项目预算,如果为空则创建。如果已结算则创建当月结转的云教练预收、否则修改云教练预算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//获取云教练信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calender.getId()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -74,18 +77,7 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			operatingReportCloudDao.insert(reportCloud); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if(reportCloud.getSettlementFlag()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				OperatingReportCloud currentReportCloud = operatingReportCloudDao.findByCurrentCalenderId(calender.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if(Objects.isNull(currentReportCloud)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					currentReportCloud = new OperatingReportCloud(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					currentReportCloud.setCalenderId(calender.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					currentReportCloud.setCloudPrice(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					currentReportCloud.setOrganId(calender.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					currentReportCloud.setMonthFlag(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					operatingReportCloudDao.insert(currentReportCloud); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				}else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					currentReportCloud.setCloudPrice(currentReportCloud.getCloudPrice().add(amount)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					operatingReportCloudDao.update(currentReportCloud); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				this.saveMonthOperating(calender,amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			}else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				reportCloud.setCloudPrice(reportCloud.getCloudPrice().add(amount)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				reportCloud.setUpdateTime(new Date()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -94,9 +86,29 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private void saveMonthOperating(MusicGroupPaymentCalender calender,BigDecimal amount){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		OperatingReportCloud currentReportCloud = operatingReportCloudDao.findByCurrentCalenderId(calender.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if(Objects.isNull(currentReportCloud)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			currentReportCloud = new OperatingReportCloud(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			currentReportCloud.setCalenderId(calender.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			currentReportCloud.setCloudPrice(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			currentReportCloud.setOrganId(calender.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			currentReportCloud.setMonthFlag(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			operatingReportCloudDao.insert(currentReportCloud); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		}else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			currentReportCloud.setCloudPrice(currentReportCloud.getCloudPrice().add(amount)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			operatingReportCloudDao.update(currentReportCloud); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public void updateSet(Long calenderId,List<Long> scheduleIdList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//如果是进行中加学员,全部算在当月云教练结转。不用摊到课程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(calenderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if(calender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_STUDENT){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calenderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if(Objects.isNull(reportCloud)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			throw new BizException("操作失败,请联系管理员"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -121,6 +133,9 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			reportCloud.setCalenderId(musicGroupPaymentCalender.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			reportCloud.setCloudPrice(BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			reportCloud.setOrganId(musicGroupPaymentCalender.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(musicGroupPaymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_STUDENT){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				reportCloud.setMonthFlag(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			operatingReportCloudDao.insert(reportCloud); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 |