Skip to content

Commit 897394e

Browse files
committed
优化对账方法
1 parent 74dafd2 commit 897394e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,17 @@
9090
*/
9191
public abstract class BaseWxPayServiceImpl implements WxPayService {
9292
private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com";
93+
private static final String TOTAL_FUND_COUNT = "资金流水总笔数";
94+
private static final String TOTAL_DEAL_COUNT = "总交易单数";
95+
9396
/**
9497
* The Log.
9598
*/
96-
protected final Logger log = LoggerFactory.getLogger(this.getClass());
99+
final Logger log = LoggerFactory.getLogger(this.getClass());
97100
/**
98101
* The constant wxApiData.
99102
*/
100-
protected static ThreadLocal<WxPayApiData> wxApiData = new ThreadLocal<>();
103+
static ThreadLocal<WxPayApiData> wxApiData = new ThreadLocal<>();
101104

102105
private EntPayService entPayService = new EntPayServiceImpl(this);
103106

@@ -523,6 +526,10 @@ public WxPayBillResult downloadBill(WxPayDownloadBillRequest request) throws WxP
523526
}
524527
}
525528

529+
if (StringUtils.isEmpty(responseContent)) {
530+
return null;
531+
}
532+
526533
return this.handleBill(request.getBillType(), responseContent);
527534
}
528535

@@ -563,9 +570,9 @@ private WxPayBillResult handleAllBill(String responseContent) {
563570

564571
String listStr = "";
565572
String objStr = "";
566-
if (responseContent.contains("总交易单数")) {
567-
listStr = responseContent.substring(0, responseContent.indexOf("总交易单数"));
568-
objStr = responseContent.substring(responseContent.indexOf("总交易单数"));
573+
if (responseContent.contains(TOTAL_DEAL_COUNT)) {
574+
listStr = responseContent.substring(0, responseContent.indexOf(TOTAL_DEAL_COUNT));
575+
objStr = responseContent.substring(responseContent.indexOf(TOTAL_DEAL_COUNT));
569576
}
570577

571578
/*
@@ -695,9 +702,9 @@ private WxPayFundFlowResult handleFundFlow(String responseContent) {
695702
String listStr = "";
696703
String objStr = "";
697704

698-
if (StringUtils.isNotBlank(responseContent) && responseContent.contains("资金流水总笔数")) {
699-
listStr = responseContent.substring(0, responseContent.indexOf("资金流水总笔数"));
700-
objStr = responseContent.substring(responseContent.indexOf("资金流水总笔数"));
705+
if (StringUtils.isNotBlank(responseContent) && responseContent.contains(TOTAL_FUND_COUNT)) {
706+
listStr = responseContent.substring(0, responseContent.indexOf(TOTAL_FUND_COUNT));
707+
objStr = responseContent.substring(responseContent.indexOf(TOTAL_FUND_COUNT));
701708
}
702709
/*
703710
* 记账时间:2018-02-01 04:21:23 微信支付业务单号:50000305742018020103387128253 资金流水单号:1900009231201802015884652186 业务名称:退款

0 commit comments

Comments
 (0)