From a9e07a81db1cf653ef41c80f47914ff14480673a Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期四, 03 六月 2021 16:48:37 +0800
Subject: [PATCH] 优化代码

---
 service-front/src/main/java/com/java110/front/smo/payment/adapt/wechatPay/WechatPayNotifyAdapt.java |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/service-front/src/main/java/com/java110/front/smo/payment/adapt/wechatPay/WechatPayNotifyAdapt.java b/service-front/src/main/java/com/java110/front/smo/payment/adapt/wechatPay/WechatPayNotifyAdapt.java
index b77bfa5..b853208 100755
--- a/service-front/src/main/java/com/java110/front/smo/payment/adapt/wechatPay/WechatPayNotifyAdapt.java
+++ b/service-front/src/main/java/com/java110/front/smo/payment/adapt/wechatPay/WechatPayNotifyAdapt.java
@@ -29,6 +29,7 @@
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.DateUtil;
 import com.java110.utils.util.PayUtil;
+import com.java110.utils.util.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -137,17 +138,20 @@
         } else {
             openId = map.get("openid").toString();
         }
+        String useId = "-1";
+        if(!StringUtil.isEmpty(openId)) {
 
-        responseEntity = getUserInfoByOpenId(restTemplate, openId);
+            responseEntity = getUserInfoByOpenId(restTemplate, openId);
 
-        logger.debug("鏌ヨ鐢ㄦ埛淇℃伅杩斿洖鎶ユ枃锛�" + responseEntity);
-        if (responseEntity.getStatusCode() != HttpStatus.OK) {
-            throw new IllegalArgumentException("鏍圭粷openId 鏌ヨ鐢ㄦ埛淇℃伅寮傚父" + openId);
+            logger.debug("鏌ヨ鐢ㄦ埛淇℃伅杩斿洖鎶ユ枃锛�" + responseEntity);
+            if (responseEntity.getStatusCode() != HttpStatus.OK) {
+                throw new IllegalArgumentException("鏍圭粷openId 鏌ヨ鐢ㄦ埛淇℃伅寮傚父" + openId);
+            }
+
+            JSONObject userResult = JSONObject.parseObject(responseEntity.getBody());
+            JSONObject realUserInfo = userResult.getJSONArray("data").getJSONObject(0);
+            useId = realUserInfo.getString("userId");
         }
-
-        JSONObject userResult = JSONObject.parseObject(responseEntity.getBody());
-        JSONObject realUserInfo = userResult.getJSONArray("data").getJSONObject(0);
-        String useId = realUserInfo.getString("userId");
 
         //鏌ヨ鐢ㄦ埛ID
         JSONObject paramIn = new JSONObject();

--
Gitblit v1.8.0