diff --git a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatResponseEntity.java b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatResponseEntity.java index e7f7435..687bc92 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatResponseEntity.java +++ b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatResponseEntity.java @@ -2,8 +2,11 @@ package com.enongm.dianji.payment.wechat.v3; import lombok.Data; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import java.util.Objects; + /** * @author Dax * @since 13:20 @@ -17,9 +20,18 @@ public class WechatResponseEntity { public void convert(ResponseEntity responseEntity) { if (log.isDebugEnabled()) { - log.info("wechat response {}", responseEntity); + log.debug("wechat response {}", responseEntity); } - this.httpStatus = responseEntity.getStatusCodeValue(); - this.body = responseEntity.getBody(); + if (Objects.nonNull(responseEntity)) { + this.httpStatus = responseEntity.getStatusCodeValue(); + this.body = responseEntity.getBody(); + } else { + this.httpStatus = HttpStatus.REQUEST_TIMEOUT.value(); + this.body = null; + } + } + + public boolean successful() { + return this.httpStatus == HttpStatus.OK.value(); } }