Skip to content

Commit b4833d1

Browse files
committed
尽量使用常量
1 parent f379769 commit b4833d1

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import org.apache.commons.lang3.builder.ToStringStyle;
88

99
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
10+
import com.github.binarywang.wxpay.constant.WxPayConstants;
1011
import com.github.binarywang.wxpay.converter.WxPayOrderNotifyResultConverter;
12+
import com.github.binarywang.wxpay.exception.WxPayException;
13+
import com.github.binarywang.wxpay.service.WxPayService;
1114
import com.github.binarywang.wxpay.util.SignUtils;
1215
import com.thoughtworks.xstream.XStream;
1316
import com.thoughtworks.xstream.annotations.XStreamAlias;
@@ -285,18 +288,10 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult {
285288
@XStreamAlias("version")
286289
private String version;
287290

288-
/**
289-
* 校验返回结果签名.
290-
*
291-
* @param wxPayService the wx pay service
292-
* @param signType 签名类型
293-
* @param checkSuccess 是否同时检查结果是否成功
294-
* @throws WxPayException the wx pay exception
295-
*/
296291
@Override
297292
public void checkResult(WxPayService wxPayService, String signType, boolean checkSuccess) throws WxPayException {
298293
//防止伪造成功通知
299-
if ("SUCCESS".equals(getReturnCode()) && getSign() == null) {
294+
if (WxPayConstants.ResultCode.SUCCESS.equals(getReturnCode()) && getSign() == null) {
300295
throw new WxPayException("伪造的通知!");
301296
}
302297

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.apache.commons.lang3.builder.ToStringStyle;
1212

1313
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
14+
import com.github.binarywang.wxpay.constant.WxPayConstants;
1415
import com.github.binarywang.wxpay.exception.WxPayException;
1516
import com.thoughtworks.xstream.XStream;
1617
import com.thoughtworks.xstream.annotations.XStreamAlias;
@@ -46,7 +47,7 @@ public class WxPayRefundNotifyResult extends BaseWxPayResult implements Serializ
4647
*/
4748
public static WxPayRefundNotifyResult fromXML(String xmlString, String mchKey) throws WxPayException {
4849
WxPayRefundNotifyResult result = BaseWxPayResult.fromXML(xmlString, WxPayRefundNotifyResult.class);
49-
if ("FAIL".equals(result.getReturnCode())) {
50+
if (WxPayConstants.ResultCode.FAIL.equals(result.getReturnCode())) {
5051
return result;
5152
}
5253

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.w3c.dom.NodeList;
2323
import org.xml.sax.SAXException;
2424

25+
import com.github.binarywang.wxpay.constant.WxPayConstants;
2526
import com.github.binarywang.wxpay.exception.WxPayException;
2627
import com.github.binarywang.wxpay.service.WxPayService;
2728
import com.github.binarywang.wxpay.util.SignUtils;
@@ -254,7 +255,7 @@ public void checkResult(WxPayService wxPayService, String signType, boolean chec
254255

255256
//校验结果是否成功
256257
if (checkSuccess) {
257-
List<String> successStrings = Lists.newArrayList("SUCCESS", "");
258+
List<String> successStrings = Lists.newArrayList(WxPayConstants.ResultCode.SUCCESS, "");
258259
if (!successStrings.contains(StringUtils.trimToEmpty(getReturnCode()).toUpperCase())
259260
|| !successStrings.contains(StringUtils.trimToEmpty(getResultCode()).toUpperCase())) {
260261
StringBuilder errorMsg = new StringBuilder();

0 commit comments

Comments
 (0)