| 
					
				 | 
			
			
				@@ -72,7 +72,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void addProfitReceivers(String clientType, String accountType, String mchId, String name) throws IllegalBlockSizeException, IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        mchId = mchId.trim(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String url = "https://api.mch.weixin.qq.com/v3/profitsharing/receivers/add"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<String, Object> param = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (clientType.equals(ClientTypeEnum.app.getType())) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -82,6 +82,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if ("merchant".equals(accountType)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             param.put("type", "MERCHANT_ID"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            name = name.trim(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             param.put("name", wxPayV3Utils.rsaEncryptOAEP(name)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             param.put("type", "PERSONAL_OPENID"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -91,7 +92,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         param.put("custom_relation", "加盟商"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             JSONObject jsonObject = wxPayV3Utils.postRequest(url, JSONUtil.toJsonStr(param), JSONObject.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.info("测试添加分账 result = {}", jsonObject.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("添加分账 result = {}", jsonObject.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -125,7 +126,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<String, Object> retailReceiver = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (askaRetails != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             retailReceiver = getReceiverMap(askaRetails.getAccountType(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    askaRetails.getAccount(), askaRetails.getTripartite(), payMoney, askaRetails.getTripvalue(), askaRetails.getAccountName(), "分账给门店-" + askaRetails.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    askaRetails.getAccount().trim(), askaRetails.getTripartite(), payMoney, askaRetails.getTripvalue(), askaRetails.getAccountName().trim(), "分账给门店-" + askaRetails.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             askaSplitrecord.setRetailId(askaRetails.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             askaSplitrecord.setRetailName(askaRetails.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             retailAmount = Integer.parseInt(retailReceiver.get("amount").toString()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -146,7 +147,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (askaChannelcouponnos != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             AskaChannels askaChannels = askaChannelsMapper.selectByPrimaryKey(askaChannelcouponnos.getChannelId().longValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             channelReceiver = getReceiverMap(askaChannels.getAccountType(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    askaChannels.getAccount(),askaChannels.getTripartite(), payMoney, askaChannels.getTripvalue(), askaChannels.getAccountName(), "分账给渠道-"+askaChannels.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    askaChannels.getAccount().trim(),askaChannels.getTripartite(), payMoney, askaChannels.getTripvalue(), askaChannels.getAccountName().trim(), "分账给渠道-"+askaChannels.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             askaSplitrecord.setChannelName(askaChannels.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             askaSplitrecord.setChannelId(askaChannels.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             channelAmount = Integer.parseInt(channelReceiver.get("amount").toString()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -185,14 +186,14 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (receivers.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 JSONObject jsonObject = wxPayV3Utils.postRequest(url, JSONUtil.toJsonStr(param), JSONObject.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                log.info("测试分账 result = {}", jsonObject.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("分账 result = {}", jsonObject.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if ("PROCESSING".equals(jsonObject.getString("state")) || "FINISHED".equals(jsonObject.getString("state"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     //分账成功 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     handleSplitFailed(askaSplitrecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                log.info("测试分账 exception = {}", e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("分账 exception = {}", e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 handleSplitFailed(askaSplitrecord); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -373,13 +374,19 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         param.put("out_order_no", pOrderSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String orderNo = "R" + pOrderSn; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         param.put("out_return_no", orderNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        account = account.trim(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         param.put("return_mchid", account); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         param.put("amount", amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         param.put("description", "用户退款"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        JSONObject jsonObject = wxPayV3Utils.postRequest(url, JSONUtil.toJsonStr(param), JSONObject.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("测试分账退款 result = {}", jsonObject.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if ("PROCESSING".equals(jsonObject.getString("result")) || "SUCCESS".equals(jsonObject.getString("result"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            JSONObject jsonObject = wxPayV3Utils.postRequest(url, JSONUtil.toJsonStr(param), JSONObject.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("分账退款 result = {}", jsonObject.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if ("PROCESSING".equals(jsonObject.getString("result")) || "SUCCESS".equals(jsonObject.getString("result"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |