diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java index 591b4a24..291a646a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java @@ -90,14 +90,17 @@ import static com.github.binarywang.wxpay.constant.WxPayConstants.TarType; */ public abstract class BaseWxPayServiceImpl implements WxPayService { private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com"; + private static final String TOTAL_FUND_COUNT = "资金流水总笔数"; + private static final String TOTAL_DEAL_COUNT = "总交易单数"; + /** * The Log. */ - protected final Logger log = LoggerFactory.getLogger(this.getClass()); + final Logger log = LoggerFactory.getLogger(this.getClass()); /** * The constant wxApiData. */ - protected static ThreadLocal wxApiData = new ThreadLocal<>(); + static ThreadLocal wxApiData = new ThreadLocal<>(); private EntPayService entPayService = new EntPayServiceImpl(this); @@ -523,6 +526,10 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { } } + if (StringUtils.isEmpty(responseContent)) { + return null; + } + return this.handleBill(request.getBillType(), responseContent); } @@ -563,9 +570,9 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { String listStr = ""; String objStr = ""; - if (responseContent.contains("总交易单数")) { - listStr = responseContent.substring(0, responseContent.indexOf("总交易单数")); - objStr = responseContent.substring(responseContent.indexOf("总交易单数")); + if (responseContent.contains(TOTAL_DEAL_COUNT)) { + listStr = responseContent.substring(0, responseContent.indexOf(TOTAL_DEAL_COUNT)); + objStr = responseContent.substring(responseContent.indexOf(TOTAL_DEAL_COUNT)); } /* @@ -695,9 +702,9 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { String listStr = ""; String objStr = ""; - if (StringUtils.isNotBlank(responseContent) && responseContent.contains("资金流水总笔数")) { - listStr = responseContent.substring(0, responseContent.indexOf("资金流水总笔数")); - objStr = responseContent.substring(responseContent.indexOf("资金流水总笔数")); + if (StringUtils.isNotBlank(responseContent) && responseContent.contains(TOTAL_FUND_COUNT)) { + listStr = responseContent.substring(0, responseContent.indexOf(TOTAL_FUND_COUNT)); + objStr = responseContent.substring(responseContent.indexOf(TOTAL_FUND_COUNT)); } /* * 记账时间:2018-02-01 04:21:23 微信支付业务单号:50000305742018020103387128253 资金流水单号:1900009231201802015884652186 业务名称:退款