| 
					
				 | 
			
			
				@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.GoodsProcurementDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.HfMemberDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.SysConfigDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dto.AmountChannelDto; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -31,6 +32,7 @@ import com.ym.mec.biz.dal.entity.StudentPaymentOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.SysPaymentConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.enums.FeeTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.enums.OrderTypeEnum; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -82,6 +84,9 @@ public class PayServiceImpl implements PayService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private RedisCache<String, Object> redisCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private GoodsProcurementDao goodsProcurementDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private StudentPaymentOrderDao studentPaymentOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public Map<String, Object> getPayMap(BigDecimal amount, BigDecimal balanceAmount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, Integer organId, String receiver) throws Exception { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -896,6 +901,79 @@ public class PayServiceImpl implements PayService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             newRouteScaleDtos.add(routeScaleDto); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * 2022-10-14日添加规则 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * 如果是武汉分部,且 服务收入选择的是“武汉小学”,服务费逻辑会发生变更 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * 1.课程费用进入“武汉市武昌大雅艺术培训学校”-H004215 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * 2.其他费用进入“武汉大雅文化艺术有限公司”-H004219 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (organId == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//删除服务费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Iterator<RouteScaleDto> routeScaleDtoIterator = newRouteScaleDtos.iterator(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			RouteScaleDto dto = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			BigDecimal totalCashAmount = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			BigDecimal totalBalanceAmount = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			while(routeScaleDtoIterator.hasNext()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				dto = routeScaleDtoIterator.next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if(dto != null && dto.getFeeType() == FeeTypeEnum.SERVICE && dto.getOrganId() == 39){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					totalCashAmount = totalCashAmount.add(dto.getAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					totalBalanceAmount = totalBalanceAmount.add(dto.getBalance()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					routeScaleDtoIterator.remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(totalCashAmount.add(totalBalanceAmount).compareTo(BigDecimal.ZERO) <= 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				return newRouteScaleDtos; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			StudentPaymentOrder order = studentPaymentOrderDao.findOrderByOrderNo(orderNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (order == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			BigDecimal musicGroupCourseTotalAmount = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(order.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (studentPaymentOrderDetailList != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				musicGroupCourseTotalAmount = studentPaymentOrderDetailList 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.filter(t -> (t.getType() == OrderDetailTypeEnum.COURSE || t.getType() == OrderDetailTypeEnum.HIGH_ONLINE_COURSE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								|| t.getType() == OrderDetailTypeEnum.SINGLE || t.getType() == OrderDetailTypeEnum.MIX 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								|| t.getType() == OrderDetailTypeEnum.HIGH || t.getType() == OrderDetailTypeEnum.COMPREHENSIVE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								|| t.getType() == OrderDetailTypeEnum.ENLIGHTENMENT || t.getType() == OrderDetailTypeEnum.TRAINING_SINGLE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								|| t.getType() == OrderDetailTypeEnum.TRAINING_MIX || t.getType() == OrderDetailTypeEnum.HIGH_ONLINE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								|| t.getType() == OrderDetailTypeEnum.MUSIC_NETWORK || t.getType() == OrderDetailTypeEnum.CLASSROOM)).map(t -> t.getPrice()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						.reduce(BigDecimal.ZERO, BigDecimal::add); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			RouteScaleDto routeScaleDto1 = new RouteScaleDto(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			routeScaleDto1.setAmount(totalCashAmount.multiply(musicGroupCourseTotalAmount).divide(totalBalanceAmount.add(totalCashAmount), 2, BigDecimal.ROUND_DOWN)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto1.setBalance(totalBalanceAmount.multiply(musicGroupCourseTotalAmount).divide(totalBalanceAmount.add(totalCashAmount), 2, BigDecimal.ROUND_DOWN)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto1.setSaleAmount(BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto1.setServiceAmount(routeScaleDto1.getAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto1.setOrganId(50); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto1.setFeeType(FeeTypeEnum.SERVICE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto1.setMerNo("H004215"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto1.setPayType(PaymentChannelEnum.ADAPAY); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            newRouteScaleDtos.add(routeScaleDto1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			RouteScaleDto routeScaleDto2 = new RouteScaleDto(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			routeScaleDto2.setAmount(totalCashAmount.subtract(routeScaleDto1.getAmount())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto2.setBalance(totalBalanceAmount.subtract(routeScaleDto1.getBalance())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto2.setSaleAmount(BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto2.setServiceAmount(routeScaleDto2.getAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto2.setOrganId(52); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto2.setFeeType(FeeTypeEnum.SERVICE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto2.setMerNo("H004219"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            routeScaleDto2.setPayType(PaymentChannelEnum.ADAPAY); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            newRouteScaleDtos.add(routeScaleDto2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return newRouteScaleDtos; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |