java110 5 lat temu
rodzic
commit
a9e07a81db

+ 12 - 8
service-front/src/main/java/com/java110/front/smo/payment/adapt/wechatPay/WechatPayNotifyAdapt.java

@@ -29,6 +29,7 @@ import com.java110.utils.constant.ServiceConstant;
 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 @@ public class WechatPayNotifyAdapt implements IPayNotifyAdapt {
         } 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);
-        String useId = realUserInfo.getString("userId");
+            JSONObject userResult = JSONObject.parseObject(responseEntity.getBody());
+            JSONObject realUserInfo = userResult.getJSONArray("data").getJSONObject(0);
+            useId = realUserInfo.getString("userId");
+        }
 
         //查询用户ID
         JSONObject paramIn = new JSONObject();