From 56a271c11cfb650cd4f20762febb247dcf8a889e Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 16 Jul 2020 17:33:36 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20#1671=20=E4=BC=98=E5=8C=96=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=94=AF=E4=BB=98=E5=9B=9E=E8=B0=83=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=AD=BE=E5=90=8D=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/mp/enums/WxMpApiUrl.java | 72 +++++++++---------- .../service/impl/BaseWxPayServiceImpl.java | 12 +++- 2 files changed, 45 insertions(+), 39 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxMpApiUrl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxMpApiUrl.java index 7f3b45d249..7e10867658 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxMpApiUrl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxMpApiUrl.java @@ -62,8 +62,8 @@ enum Device implements WxMpApiUrl { */ DEVICE_TRANSMSG(API_DEFAULT_HOST_URL, "/device/transmsg"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -131,8 +131,8 @@ enum Other implements WxMpApiUrl { */ CLEAR_QUOTA_URL(API_DEFAULT_HOST_URL, "/cgi-bin/clear_quota"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -159,8 +159,8 @@ enum Marketing implements WxMpApiUrl { */ WECHAT_AD_LEADS_GET(API_DEFAULT_HOST_URL, "/marketing/wechat_ad_leads/get"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -308,8 +308,8 @@ enum TemplateMsg implements WxMpApiUrl { */ TEMPLATE_DEL_PRIVATE_TEMPLATE(API_DEFAULT_HOST_URL, "/cgi-bin/template/del_private_template"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -332,8 +332,8 @@ enum UserBlacklist implements WxMpApiUrl { */ BATCHUNBLACKLIST(API_DEFAULT_HOST_URL, "/cgi-bin/tags/members/batchunblacklist"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -402,8 +402,8 @@ enum Wifi implements WxMpApiUrl { */ BIZWIFI_SHOP_UPDATE(API_DEFAULT_HOST_URL, "/bizwifi/shop/update"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -493,8 +493,8 @@ enum Ocr implements WxMpApiUrl { */ FILE_COMM(API_DEFAULT_HOST_URL, "/cv/ocr/comm"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -603,8 +603,8 @@ enum Card implements WxMpApiUrl { CARD_USER_CARD_LIST(API_DEFAULT_HOST_URL, "/card/user/getcardlist"), ; - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -683,8 +683,8 @@ enum DataCube implements WxMpApiUrl { */ GET_INTERFACE_SUMMARY_HOUR(API_DEFAULT_HOST_URL, "/datacube/getinterfacesummaryhour"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -755,8 +755,8 @@ enum Kefu implements WxMpApiUrl { */ CUSTOM_TYPING(API_DEFAULT_HOST_URL, "/cgi-bin/message/custom/typing"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -809,8 +809,8 @@ enum MassMessage implements WxMpApiUrl { */ MESSAGE_MASS_GET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/mass/get"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -865,8 +865,8 @@ enum Material implements WxMpApiUrl { */ MATERIAL_BATCHGET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/material/batchget_material"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -910,8 +910,8 @@ enum MemberCard implements WxMpApiUrl { */ MEMBER_CARD_ACTIVATE_TEMP_INFO(API_DEFAULT_HOST_URL, "/card/membercard/activatetempinfo/get"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -946,8 +946,8 @@ enum Store implements WxMpApiUrl { */ POI_ADD_URL(API_DEFAULT_HOST_URL, "/cgi-bin/poi/addpoi"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -978,8 +978,8 @@ enum User implements WxMpApiUrl { */ USER_CHANGE_OPENID_URL(API_DEFAULT_HOST_URL, "/cgi-bin/changeopenid"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -1029,8 +1029,8 @@ enum Comment implements WxMpApiUrl { */ REPLY_DELETE(API_DEFAULT_HOST_URL, "/cgi-bin/comment/reply/delete"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -1070,8 +1070,8 @@ enum ImgProc implements WxMpApiUrl { */ FILE_AI_CROP(API_DEFAULT_HOST_URL, "/cv/img/aicrop?ratios=%s"); - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { @@ -1145,8 +1145,8 @@ enum Invoice implements WxMpApiUrl { */ GET_PAY_MCH_SET_BIZ_ATTR(API_DEFAULT_HOST_URL, "/card/invoice/setbizattr?action=get_pay_mch"), ; - private String prefix; - private String path; + private final String prefix; + private final String path; @Override public String getUrl(WxMpConfigStorage config) { 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 909b78f257..efe9e70e0a 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 @@ -190,10 +190,16 @@ public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String sign try { log.debug("微信支付异步通知请求参数:{}", xmlData); WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData); - if (result.getSignType() != null) { - // 如果解析的通知对象中signType有值,则使用它进行验签 - signType = result.getSignType(); + if (signType == null) { + if (result.getSignType() != null) { + // 如果解析的通知对象中signType有值,则使用它进行验签 + signType = result.getSignType(); + } else if (this.getConfig().getSignType() != null) { + // 如果配置中signType有值,则使用它进行验签 + signType = this.getConfig().getSignType(); + } } + log.debug("微信支付异步通知请求解析后的对象:{}", result); result.checkResult(this, signType, false); return result;