From e6d1cb162a7688030983d27375570ce2d52f69ff Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 15 六月 2020 15:35:14 +0800
Subject: [PATCH] 上传代码

---
 service-front/src/main/java/com/java110/front/smo/payment/impl/ToPaySMOImpl.java |   47 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/service-front/src/main/java/com/java110/front/smo/payment/impl/ToPaySMOImpl.java b/service-front/src/main/java/com/java110/front/smo/payment/impl/ToPaySMOImpl.java
index a1080c3..607b46a 100644
--- a/service-front/src/main/java/com/java110/front/smo/payment/impl/ToPaySMOImpl.java
+++ b/service-front/src/main/java/com/java110/front/smo/payment/impl/ToPaySMOImpl.java
@@ -1,12 +1,16 @@
 package com.java110.front.smo.payment.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.java110.core.context.IPageData;
+import com.java110.core.context.PageData;
+import com.java110.dto.smallWeChat.SmallWeChatDto;
 import com.java110.front.properties.WechatAuthProperties;
 import com.java110.front.smo.AppAbstractComponentSMO;
 import com.java110.front.smo.payment.IToPaySMO;
-import com.java110.core.context.IPageData;
 import com.java110.utils.constant.ServiceConstant;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -55,6 +59,17 @@
     protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) throws Exception {
 
         ResponseEntity responseEntity = null;
+
+        SmallWeChatDto smallWeChatDto = getSmallWechat(pd, paramIn);
+
+        if (smallWeChatDto == null) { //浠庨厤缃枃浠朵腑鑾峰彇 灏忕▼搴忛厤缃俊鎭�
+            smallWeChatDto = new SmallWeChatDto();
+            smallWeChatDto.setAppId(wechatAuthProperties.getAppId());
+            smallWeChatDto.setAppSecret(wechatAuthProperties.getSecret());
+            smallWeChatDto.setMchId(wechatAuthProperties.getMchId());
+            smallWeChatDto.setPayPassword(wechatAuthProperties.getKey());
+        }
+
         //鏌ヨ鐢ㄦ埛ID
         paramIn.put("userId", pd.getUserId());
         String url = ServiceConstant.SERVICE_API_URL + "/api/fee.payFeePre";
@@ -84,16 +99,40 @@
         JSONObject realUserInfo = userResult.getJSONArray("users").getJSONObject(0);
 
         String openId = realUserInfo.getString("openId");
-        String payAppId = orderInfo.getString("payAppId");
-        String payMchId = orderInfo.getString("payMchId");
+//        String payAppId = orderInfo.getString("payAppId");
+//        String payMchId = orderInfo.getString("payMchId");
 
 
-        Map result = super.java110Payment(outRestTemplate,paramIn.getString("feeName"),paramIn.getString("tradeType"), orderId, money, openId,payAppId,payMchId);
+        Map result = super.java110Payment(outRestTemplate, paramIn.getString("feeName"), paramIn.getString("tradeType"), orderId, money, openId, smallWeChatDto);
         responseEntity = new ResponseEntity(JSONObject.toJSONString(result), HttpStatus.OK);
 
         return responseEntity;
     }
 
 
+    private SmallWeChatDto getSmallWechat(IPageData pd, JSONObject paramIn) {
+
+        ResponseEntity responseEntity = null;
+
+        pd = PageData.newInstance().builder(pd.getUserId(), "", "", pd.getReqData(),
+                "", "", "", "",
+                pd.getAppId());
+        responseEntity = this.callCenterService(restTemplate, pd, "",
+                ServiceConstant.SERVICE_API_URL + "/api/smallWeChat.listSmallWeChats?appId="
+                        + paramIn.getString("appId") + "&page=1&row=1", HttpMethod.GET);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            return null;
+        }
+        JSONObject smallWechatObj = JSONObject.parseObject(responseEntity.getBody().toString());
+        JSONArray smallWeChats = smallWechatObj.getJSONArray("smallWeChats");
+
+        if (smallWeChats == null || smallWeChats.size() < 1) {
+            return null;
+        }
+
+        return BeanConvertUtil.covertBean(smallWeChats.get(0), SmallWeChatDto.class);
+    }
+
 
 }

--
Gitblit v1.8.0