| 
					
				 | 
			
			
				@@ -3,14 +3,22 @@ package com.ym.mec.biz.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.auth.api.client.SysUserFeignService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.auth.api.entity.SysUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.StudentRepairDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.SysConfigDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dto.BasicUserDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.StudentPaymentOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.StudentRepair; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.DealStatusEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.GroupType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.OrderTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.service.PayService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.service.StudentPaymentOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.service.StudentRepairService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.common.config.RequestAttributeHystrixConcurrencyStrategy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.service.SysConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.dal.BaseDAO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.exception.BizException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.page.PageInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.common.service.IdGeneratorService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.service.impl.BaseServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.util.collection.MapUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.Logger; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -18,6 +26,8 @@ import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -27,6 +37,14 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private StudentRepairDao studentRepairDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private SysUserFeignService sysUserFeignService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private PayService payService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IdGeneratorService idGeneratorService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SysConfigDao sysConfigDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private StudentPaymentOrderService studentPaymentOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -53,6 +71,78 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Map addRepair(StudentRepair repairInfo) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date date = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal amount = repairInfo.getAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String orderNo = idGeneratorService.generatorId("payment") + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        repairInfo.setTransNo(orderNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentRepairDao.insert(repairInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String channelType = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setUserId(repairInfo.getStudentId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setGroupType(GroupType.REPAIR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setOrderNo(orderNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setType(OrderTypeEnum.REPAIR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setExpectAmount(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setActualAmount(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setStatus(DealStatusEnum.ING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setMusicGroupId(repairInfo.getId().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setPaymentChannel("BALANCE"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setUpdateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setOrganId(repairInfo.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setRoutingOrganId(repairInfo.getOrganId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrderService.insert(studentPaymentOrder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setVersion(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (amount.compareTo(BigDecimal.ZERO) == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, String> notifyMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            notifyMap.put("tradeState", "1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            notifyMap.put("channelType", channelType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            notifyMap.put("orderNo", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            studentPaymentOrderService.updateOrder(notifyMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return notifyMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String baseApiUrl = sysConfigDao.findConfigValue(SysConfigService.EDU_TEACHER_BASE_URL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, BigDecimal> classFee = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        classFee.put("course", BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        classFee.put("instrument", BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        classFee.put("accessories", BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        classFee.put("other", amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map payMap = payService.getPayMap( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                amount, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                orderNo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                baseApiUrl + "/api-web/studentOrder/notify", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                baseApiUrl + "/api-web/studentOrder/paymentResult?orderNo=" + orderNo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "乐器维修", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "乐器维修", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                repairInfo.getStudentId(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                classFee, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                repairInfo.getOrganId() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, BigDecimal> routingFee = (Map<String, BigDecimal>) payMap.get("routingFee"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setRoutingOrganId((Integer) payMap.get("routingOrganId")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setComAmount(routingFee.get("COM")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setPerAmount(routingFee.get("PER")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setPaymentChannel((String) payMap.get("type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setUpdateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrderService.update(studentPaymentOrder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return payMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void repairSuccess(Integer id, String description) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         SysUser sysUser = sysUserFeignService.queryUserInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (sysUser == null) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -68,4 +158,5 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentRepairDao.update(studentRepair); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.info("操作人 :" + sysUser.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |