From 73114635647cbdc462604665a43a2ebc1a0d8dcd Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 27 Jun 2017 11:04:21 +0800 Subject: [PATCH 001/165] =?UTF-8?q?jodd-http=E5=AF=B9=E4=BA=8E=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=94=AF=E4=BB=98=E6=9D=A5=E8=AF=B4=E6=98=AF=E5=BF=85?= =?UTF-8?q?=E9=A1=BB=E4=BE=9D=E8=B5=96=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weixin-java-pay/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 4f24b0a9c3..859d982248 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -26,6 +26,7 @@ org.jodd jodd-http + compile From 9771977d7a742e346f5f715ef75100bea4e4fbdd Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 27 Jun 2017 18:10:36 +0800 Subject: [PATCH 002/165] =?UTF-8?q?WxPayUnifiedOrderRequest=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=BB=98=E8=AE=A4=E6=9E=84=E9=80=A0=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/bean/request/WxPayUnifiedOrderRequest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index a5560c20df..fb4b5e09c4 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -4,11 +4,8 @@ import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; import me.chanjar.weixin.common.annotation.Required; -import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; -import java.util.Arrays; - /** *
  * 统一下单请求参数对象
@@ -274,6 +271,9 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest {
   @XStreamAlias("openid")
   private String openid;
 
+  public WxPayUnifiedOrderRequest() {
+  }
+
   private WxPayUnifiedOrderRequest(Builder builder) {
     setAppid(builder.appid);
     setDeviceInfo(builder.deviceInfo);

From 0de1c7245b314d4ea524ffd67e9955a98031e2ce Mon Sep 17 00:00:00 2001
From: Binary Wang 
Date: Tue, 27 Jun 2017 18:22:35 +0800
Subject: [PATCH 003/165] =?UTF-8?q?#257=20=E5=BE=AE=E4=BF=A1=E6=94=AF?=
 =?UTF-8?q?=E4=BB=98=E7=94=B3=E8=AF=B7=E9=80=80=E6=AC=BE=E6=8E=A5=E5=8F=A3?=
 =?UTF-8?q?=E5=A2=9E=E5=8A=A0refund=5Fdesc=E5=B1=9E=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../bean/request/WxPayRefundRequest.java      | 63 +++++++++++++------
 1 file changed, 45 insertions(+), 18 deletions(-)

diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
index 59111da5f8..7fae6fa0f5 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
@@ -142,17 +142,26 @@ public class WxPayRefundRequest extends WxPayBaseRequest {
    */
   @XStreamAlias("refund_account")
   private String refundAccount;
-
-  public WxPayRefundRequest() {
-  }
+  /**
+   * 
+   * 退款原因
+   * refund_account
+   * 否
+   * String(80)
+   * 商品已售完
+   * 若商户传入,会在下发给用户的退款消息中体现退款原因
+   * 
+ */ + @XStreamAlias("refund_desc") + private String refundDesc; private WxPayRefundRequest(Builder builder) { setDeviceInfo(builder.deviceInfo); setAppid(builder.appid); setTransactionId(builder.transactionId); setMchId(builder.mchId); - setOutTradeNo(builder.outTradeNo); setSubAppId(builder.subAppId); + setOutTradeNo(builder.outTradeNo); setSubMchId(builder.subMchId); setOutRefundNo(builder.outRefundNo); setNonceStr(builder.nonceStr); @@ -162,21 +171,13 @@ private WxPayRefundRequest(Builder builder) { setRefundFeeType(builder.refundFeeType); setOpUserId(builder.opUserId); setRefundAccount(builder.refundAccount); + setRefundDesc(builder.refundDesc); } public static Builder newBuilder() { return new Builder(); } - @Override - public void checkAndSign(WxPayConfig config) throws WxPayException { - if (StringUtils.isBlank(this.getOpUserId())) { - this.setOpUserId(config.getMchId()); - } - - super.checkAndSign(config); - } - public String getDeviceInfo() { return this.deviceInfo; } @@ -249,6 +250,26 @@ public void setRefundAccount(String refundAccount) { this.refundAccount = refundAccount; } + public String getRefundDesc() { + return this.refundDesc; + } + + public void setRefundDesc(String refundDesc) { + this.refundDesc = refundDesc; + } + + public WxPayRefundRequest() { + } + + @Override + public void checkAndSign(WxPayConfig config) throws WxPayException { + if (StringUtils.isBlank(this.getOpUserId())) { + this.setOpUserId(config.getMchId()); + } + + super.checkAndSign(config); + } + @Override protected void checkConstraints() { if (StringUtils.isNotBlank(this.getRefundAccount())) { @@ -268,8 +289,8 @@ public static final class Builder { private String appid; private String transactionId; private String mchId; - private String outTradeNo; private String subAppId; + private String outTradeNo; private String subMchId; private String outRefundNo; private String nonceStr; @@ -279,6 +300,7 @@ public static final class Builder { private String refundFeeType; private String opUserId; private String refundAccount; + private String refundDesc; private Builder() { } @@ -303,13 +325,13 @@ public Builder mchId(String mchId) { return this; } - public Builder outTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; + public Builder subAppId(String subAppId) { + this.subAppId = subAppId; return this; } - public Builder subAppId(String subAppId) { - this.subAppId = subAppId; + public Builder outTradeNo(String outTradeNo) { + this.outTradeNo = outTradeNo; return this; } @@ -358,6 +380,11 @@ public Builder refundAccount(String refundAccount) { return this; } + public Builder refundDesc(String refundDesc) { + this.refundDesc = refundDesc; + return this; + } + public WxPayRefundRequest build() { return new WxPayRefundRequest(this); } From 12eaa5b71ada375c3ec9a0e8995b1aa63d288739 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 27 Jun 2017 18:27:37 +0800 Subject: [PATCH 004/165] =?UTF-8?q?#255=20=E6=9C=8D=E5=8A=A1=E5=95=86?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=BB=9F=E4=B8=80=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0sub=5Fopenid=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/WxPayUnifiedOrderRequest.java | 52 +++++++++++++++---- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index fb4b5e09c4..f5b58245d9 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -271,14 +271,29 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { @XStreamAlias("openid") private String openid; + /** + *
+   * 用户子标识
+   * sub_openid
+   * 否
+   * String(128)
+   * oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+   * trade_type=JSAPI,此参数必传,用户在子商户appid下的唯一标识。
+   * openid和sub_openid可以选传其中之一,如果选择传sub_openid,则必须传sub_appid。
+   * 下单前需要调用【网页授权获取用户信息】接口获取到用户的Openid。
+   * 
+ */ + @XStreamAlias("sub_openid") + private String subOpenid; + public WxPayUnifiedOrderRequest() { } private WxPayUnifiedOrderRequest(Builder builder) { - setAppid(builder.appid); setDeviceInfo(builder.deviceInfo); - setMchId(builder.mchId); + setAppid(builder.appid); setBody(builder.body); + setMchId(builder.mchId); setSubAppId(builder.subAppId); setSubMchId(builder.subMchId); setNonceStr(builder.nonceStr); @@ -297,6 +312,7 @@ private WxPayUnifiedOrderRequest(Builder builder) { setProductId(builder.productId); setLimitPay(builder.limitPay); setOpenid(builder.openid); + setSubOpenid(builder.subOpenid); } public static Builder newBuilder() { @@ -441,6 +457,14 @@ public void setOpenid(String openid) { this.openid = openid; } + public String getSubOpenid() { + return this.subOpenid; + } + + public void setSubOpenid(String subOpenid) { + this.subOpenid = subOpenid; + } + @Override protected void checkConstraints() { // if (!ArrayUtils.contains(TRADE_TYPES, this.getTradeType())) { @@ -471,10 +495,10 @@ public void checkAndSign(WxPayConfig config) throws WxPayException { } public static final class Builder { - private String appid; private String deviceInfo; - private String mchId; + private String appid; private String body; + private String mchId; private String subAppId; private String subMchId; private String nonceStr; @@ -493,22 +517,18 @@ public static final class Builder { private String productId; private String limitPay; private String openid; + private String subOpenid; private Builder() { } - public Builder appid(String appid) { - this.appid = appid; - return this; - } - public Builder deviceInfo(String deviceInfo) { this.deviceInfo = deviceInfo; return this; } - public Builder mchId(String mchId) { - this.mchId = mchId; + public Builder appid(String appid) { + this.appid = appid; return this; } @@ -517,6 +537,11 @@ public Builder body(String body) { return this; } + public Builder mchId(String mchId) { + this.mchId = mchId; + return this; + } + public Builder subAppId(String subAppId) { this.subAppId = subAppId; return this; @@ -607,6 +632,11 @@ public Builder openid(String openid) { return this; } + public Builder subOpenid(String subOpenid) { + this.subOpenid = subOpenid; + return this; + } + public WxPayUnifiedOrderRequest build() { return new WxPayUnifiedOrderRequest(this); } From 518d1d60f51ab018652adbbe13f8b17c11284047 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 27 Jun 2017 18:28:18 +0800 Subject: [PATCH 005/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.7.1.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index a167cd8f48..fc5d27b6e7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.7.0 + 2.7.1.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 66e32664ca..fa1a9feff8 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.0 + 2.7.1.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index bcc4e73bb3..fad1f7fd7b 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.0 + 2.7.1.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 71601ef3a4..99681a1099 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.0 + 2.7.1.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index bd8f147cb0..ddf830b934 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.0 + 2.7.1.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 859d982248..d3c5990473 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.7.0 + 2.7.1.BETA 4.0.0 From ed7f97ebe44a55e5239be7e083fde5c5f9098d13 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 29 Jun 2017 20:07:35 +0800 Subject: [PATCH 006/165] =?UTF-8?q?#260=20=E4=BF=AE=E5=A4=8D=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=8F=91=E9=80=81=E6=A8=A1=E7=89=88=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E5=8F=A3=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E9=87=8D=E6=96=B0=E6=95=B4=E7=90=86javadoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/binarywang/wx/miniapp/api/WxMaMsgService.java | 9 ++++----- .../wx/miniapp/api/impl/WxMaMsgServiceImpl.java | 8 +++----- .../binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java | 6 +++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMsgService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMsgService.java index 040e81e530..65522f4b75 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMsgService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaMsgService.java @@ -18,7 +18,7 @@ public interface WxMaMsgService { /** *
    * 发送客服消息
-   * 详情请见: 发送客服消息
+   * 详情请见: 发送客服消息
    * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
    * 
*/ @@ -27,10 +27,9 @@ public interface WxMaMsgService { /** *
    * 发送模板消息
-   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
+   * 详情请见: 发送模板消息
+   * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN
    * 
- * - * @return 消息Id */ - String sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException; + void sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java index 238bbe0e7f..70a4e50445 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java @@ -27,14 +27,12 @@ public boolean sendKefuMsg(WxMaKefuMessage message) throws WxErrorException { } @Override - public String sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException { + public void sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException { String responseContent = this.wxMaService.post(TEMPLATE_MSG_SEND_URL, templateMessage.toJson()); JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); - if (jsonObject.get("errcode").getAsInt() == 0) { - return jsonObject.get("msgid").getAsString(); + if (jsonObject.get("errcode").getAsInt() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent)); } - - throw new WxErrorException(WxError.fromJson(responseContent)); } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java index 167341265a..c8605d25de 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java @@ -193,7 +193,7 @@ public synchronized T executeInternal(RequestExecutor executor, Str try { T result = executor.execute(uriWithAccessToken, data); - this.log.debug("\n[URL]: {}\n[PARAMS]: {}\n[RESPONSE]: {}", uriWithAccessToken, data, result); + this.log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, data, result); return result; } catch (WxErrorException e) { WxError error = e.getError(); @@ -212,12 +212,12 @@ public synchronized T executeInternal(RequestExecutor executor, Str } if (error.getErrorCode() != 0) { - this.log.error("\n[URL]: {}\n[PARAMS]: {}\n[RESPONSE]: {}", uriWithAccessToken, data, error); + this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, data, error); throw new WxErrorException(error); } return null; } catch (IOException e) { - this.log.error("\n[URL]: {}\n[PARAMS]: {}\n[EXCEPTION]: {}", uriWithAccessToken, data, e.getMessage()); + this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, data, e.getMessage()); throw new RuntimeException(e); } } From d6bb355cd10fbcd029f6212042fc4c3bd678ed4c Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 29 Jun 2017 20:07:50 +0800 Subject: [PATCH 007/165] =?UTF-8?q?#260=20=E4=BF=AE=E5=A4=8D=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=8F=91=E9=80=81=E6=A8=A1=E7=89=88=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E5=8F=A3=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E9=87=8D=E6=96=B0=E6=95=B4=E7=90=86javadoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wx/miniapp/bean/WxMaTemplateMessage.java | 47 ++++++++++++++++--- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java index 7a89dfa8a5..79f955c6d2 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java @@ -13,34 +13,67 @@ */ public class WxMaTemplateMessage implements Serializable { private static final long serialVersionUID = 5063374783759519418L; + /** - * touser 是 接收者(用户)的 openid + *
+   * 参数:touser
+   * 是否必填: 是
+   * 描述: 接收者(用户)的 openid
+   * 
*/ private String toUser; + /** - * template_id 是 所需下发的模板消息的id + *
+   * 参数:template_id
+   * 是否必填: 是
+   * 描述: 所需下发的模板消息的id
+   * 
*/ private String templateId; + /** *
-   * page	否	点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
+   * 参数:page
+   * 是否必填: 否
+   * 描述: 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
    * 
*/ private String page; + /** - * form_id 是 表单提交场景下,为 submit 事件带上的 formId;支付场景下,为本次支付的 prepay_id + *
+   * 参数:form_id
+   * 是否必填: 是
+   * 描述: 表单提交场景下,为 submit 事件带上的 formId;支付场景下,为本次支付的 prepay_id
+   * 
*/ private String formId; + /** - * data 是 模板内容,不填则下发空模板 + *
+   * 参数:data
+   * 是否必填: 是
+   * 描述: 模板内容,不填则下发空模板
+   * 
*/ private List data = new ArrayList<>(); + /** - * color 否 模板内容字体的颜色,不填默认黑色 + *
+   * 参数:color
+   * 是否必填: 否
+   * 描述: 模板内容字体的颜色,不填默认黑色
+   * 
*/ private String color; + /** - * emphasis_keyword 否 模板需要放大的关键词,不填则默认无放大 + *
+   * 参数:emphasis_keyword
+   * 是否必填: 否
+   * 描述: 模板需要放大的关键词,不填则默认无放大
+   * 
*/ private String emphasisKeyword; From 57f5cf3eecef4fd6b1e2524e3f434712d6544fa2 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 30 Jun 2017 10:47:42 +0800 Subject: [PATCH 008/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84javadoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/github/binarywang/wxpay/service/WxPayService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java index 495ecb5eb9..03640eb067 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java @@ -112,7 +112,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri /** * 读取支付结果通知 - * 详见http://com.github.binarywang.wechat.pay.bean.pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7 + * 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7 */ WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayException; From 9a928f2601acf978c8f41b37b6904d2459ab65c4 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 30 Jun 2017 16:54:13 +0800 Subject: [PATCH 009/165] fix test case --- .../wx/miniapp/api/impl/WxMaMsgServiceImplTest.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java index c5d8f1e86a..9604a25691 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java @@ -9,9 +9,7 @@ import com.google.inject.Inject; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.exception.WxErrorException; -import org.testng.Assert; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; +import org.testng.annotations.*; import java.text.SimpleDateFormat; import java.util.Date; @@ -68,9 +66,7 @@ public void testSendTemplateMsg() throws WxErrorException { .emphasisKeyword("keyword1.DATA") .build(); - String msgId = this.wxService.getMsgService().sendTemplateMsg(templateMessage); - Assert.assertNotNull(msgId); - System.out.println(msgId); + this.wxService.getMsgService().sendTemplateMsg(templateMessage); } } From c494fbe71d85bfa012e7865af0fad3b6e9198e71 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 30 Jun 2017 16:55:55 +0800 Subject: [PATCH 010/165] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E8=AF=81=E4=B9=A6=E8=B7=AF=E5=BE=84=E5=88=A4=E6=96=AD=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binarywang/wxpay/config/WxPayConfig.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java index e6c587a13b..d05259ceeb 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java @@ -158,18 +158,27 @@ public SSLContext initSSLContext() throws WxPayException { InputStream inputStream; final String prefix = "classpath:"; + String fileHasProblemMsg = "证书文件【" + this.keyPath + "】有问题,请核实!"; + String fileNotFoundMsg = "证书文件【" + this.keyPath + "】不存在,请核实!"; if (this.keyPath.startsWith(prefix)) { - inputStream = WxPayConfig.class.getResourceAsStream(this.keyPath.replace(prefix, "")); + String path = StringUtils.removeFirst(this.keyPath, prefix); + if (!path.startsWith("/")) { + path = "/" + path; + } + inputStream = WxPayConfig.class.getResourceAsStream(path); + if (inputStream == null) { + throw new WxPayException(fileNotFoundMsg); + } } else { try { File file = new File(this.keyPath); if (!file.exists()) { - throw new WxPayException("证书文件【" + file.getPath() + "】不存在!"); + throw new WxPayException(fileNotFoundMsg); } inputStream = new FileInputStream(file); } catch (IOException e) { - throw new WxPayException("证书文件有问题,请核实!", e); + throw new WxPayException(fileHasProblemMsg, e); } } @@ -180,7 +189,7 @@ public SSLContext initSSLContext() throws WxPayException { this.sslContext = SSLContexts.custom().loadKeyMaterial(keystore, partnerId2charArray).build(); return this.sslContext; } catch (Exception e) { - throw new WxPayException("证书文件有问题,请核实!", e); + throw new WxPayException(fileHasProblemMsg, e); } finally { IOUtils.closeQuietly(inputStream); } From 61d933196ce3f7849eb5b6ad318032be150bfb4d Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 30 Jun 2017 17:14:55 +0800 Subject: [PATCH 011/165] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E8=AF=B7=E6=B1=82=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/bean/request/WxPayBaseRequest.java | 2 +- .../wxpay/service/impl/WxPayServiceImpl.java | 68 ++++++++++--------- .../service/impl/WxPayServiceImplTest.java | 10 +-- 3 files changed, 41 insertions(+), 39 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java index b44822483b..0d4fc08b9d 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java @@ -119,7 +119,7 @@ protected void checkFields() throws WxPayException { try { BeanUtils.checkRequiredFields(this); } catch (WxErrorException e) { - throw new WxPayException(e.getError().getErrorMsg()); + throw new WxPayException(e.getError().getErrorMsg(), e); } //check other parameters diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java index 14c34d0360..bcf425d792 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java @@ -11,14 +11,13 @@ import jodd.http.HttpRequest; import jodd.http.HttpResponse; import jodd.http.net.SSLSocketHttpConnectionProvider; -import org.apache.commons.lang3.CharEncoding; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.net.ssl.SSLContext; import java.io.File; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -76,7 +75,7 @@ public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeN request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/pay/refundquery"; - String responseContent = this.post(url, request.toXML(), true); + String responseContent = this.post(url, request.toXML()); WxPayRefundQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundQueryResult.class); result.composeRefundRecords(); result.checkResult(this); @@ -96,7 +95,7 @@ public WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayE throw e; } catch (Exception e) { log.error(e.getMessage(), e); - throw new WxPayException("发生异常," + e.getMessage()); + throw new WxPayException("发生异常," + e.getMessage(), e); } } @@ -139,7 +138,7 @@ public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/pay/orderquery"; - String responseContent = this.post(url, request.toXML(), true); + String responseContent = this.post(url, request.toXML()); if (StringUtils.isBlank(responseContent)) { throw new WxPayException("无响应结果"); } @@ -161,7 +160,7 @@ public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/pay/closeorder"; - String responseContent = this.post(url, request.toXML(), true); + String responseContent = this.post(url, request.toXML()); WxPayOrderCloseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderCloseResult.class); result.checkResult(this); @@ -173,7 +172,7 @@ public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) th request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/pay/unifiedorder"; - String responseContent = this.post(url, request.toXML(), true); + String responseContent = this.post(url, request.toXML()); WxPayUnifiedOrderResult result = WxPayBaseResult.fromXML(responseContent, WxPayUnifiedOrderResult.class); result.checkResult(this); return result; @@ -294,7 +293,7 @@ public void report(WxPayReportRequest request) throws WxPayException { request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/payitil/report"; - String responseContent = this.post(url, request.toXML(), true); + String responseContent = this.post(url, request.toXML()); WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class); result.checkResult(this); } @@ -310,7 +309,7 @@ public WxPayBillResult downloadBill(String billDate, String billType, String tar request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/pay/downloadbill"; - String responseContent = this.post(url, request.toXML(), true); + String responseContent = this.post(url, request.toXML()); if (responseContent.startsWith("<")) { WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class); result.checkResult(this); @@ -397,7 +396,7 @@ public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxPayEx request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/pay/micropay"; - String responseContent = this.post(url, request.toXML(), true); + String responseContent = this.post(url, request.toXML()); WxPayMicropayResult result = WxPayBaseResult.fromXML(responseContent, WxPayMicropayResult.class); result.checkResult(this); return result; @@ -419,7 +418,7 @@ public String shorturl(WxPayShorturlRequest request) throws WxPayException { request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/tools/shorturl"; - String responseContent = this.post(url, request.toXML(), true); + String responseContent = this.post(url, request.toXML()); WxPayShorturlResult result = WxPayBaseResult.fromXML(responseContent, WxPayShorturlResult.class); result.checkResult(this); return result.getShortUrl(); @@ -435,7 +434,7 @@ public String authcode2Openid(WxPayAuthcode2OpenidRequest request) throws WxPayE request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/tools/authcodetoopenid"; - String responseContent = this.post(url, request.toXML(), true); + String responseContent = this.post(url, request.toXML()); WxPayAuthcode2OpenidResult result = WxPayBaseResult.fromXML(responseContent, WxPayAuthcode2OpenidResult.class); result.checkResult(this); return result.getOpenid(); @@ -452,26 +451,21 @@ public String getSandboxSignKey() throws WxPayException { request.checkAndSign(this.getConfig()); String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey"; - String responseContent = this.post(url, request.toXML(), false); + String responseContent = this.post(url, request.toXML()); WxPaySandboxSignKeyResult result = WxPayBaseResult.fromXML(responseContent, WxPaySandboxSignKeyResult.class); result.checkResult(this); return result.getSandboxSignKey(); } /** - * @param url 请求地址 - * @param xmlParam 请求字符串 - * @param needTransferEncoding 是否需要对结果进行重编码 + * 执行post请求 + * + * @param url 请求地址 + * @param xmlParam 请求字符串 * @return 返回请求结果 */ - private String post(String url, String xmlParam, boolean needTransferEncoding) { - String requestString = xmlParam; - try { - requestString = new String(xmlParam.getBytes(CharEncoding.UTF_8), CharEncoding.ISO_8859_1); - } catch (UnsupportedEncodingException e) { - //实际上不会发生该异常 - e.printStackTrace(); - } + private String post(String url, String xmlParam) throws WxPayException { + String requestString = new String(xmlParam.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); HttpRequest request = HttpRequest.post(url).body(requestString); String responseString = this.getResponseString(request.send()); @@ -481,7 +475,10 @@ private String post(String url, String xmlParam, boolean needTransferEncoding) { } /** - * ecoolper(20170418),修改为jodd-http方式 + * 带证书发送post请求 + * + * @param url 请求地址 + * @param requestStr 请求信息 */ private String postWithKey(String url, String requestStr) throws WxPayException { try { @@ -501,22 +498,27 @@ private String postWithKey(String url, String requestStr) throws WxPayException return responseString; } catch (Exception e) { this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", url, requestStr, e.getMessage()); - throw new WxPayException(e.getMessage()); + throw new WxPayException(e.getMessage(), e); } } - private String getResponseString(HttpResponse response) { - this.log.debug("【微信服务器响应头信息】:\n{}", response.toString(false)); + private String getResponseString(HttpResponse response) throws WxPayException { + try { + this.log.debug("【微信服务器响应头信息】:\n{}", response.toString(false)); + } catch (NullPointerException e) { + throw new WxPayException("response.toString() 居然抛出空指针异常了", e); + } String responseString = response.bodyText(); + if (StringUtils.isBlank(responseString)) { + throw new WxPayException("响应信息为空"); + } + if (StringUtils.isBlank(response.charset())) { - try { - responseString = new String(response.bodyText().getBytes(CharEncoding.ISO_8859_1), CharEncoding.UTF_8); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + responseString = new String(responseString.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); } + return responseString; } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImplTest.java index 995aa8275b..1cba44c59b 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImplTest.java @@ -83,7 +83,7 @@ public void testRefund() throws Exception { } /** - * Test method for {@link WxPayService#refundQuery(java.lang.String, java.lang.String, java.lang.String, java.lang.String)} . + * Test method for {@link WxPayService#refundQuery(String, String, String, String)} . */ @Test public void testRefundQuery() throws Exception { @@ -121,7 +121,7 @@ public void testSendRedpack() throws Exception { } /** - * Test method for {@link WxPayService#queryRedpack(java.lang.String)}. + * Test method for {@link WxPayService#queryRedpack(String)}. */ @Test public void testQueryRedpack() throws Exception { @@ -148,7 +148,7 @@ public void testUnifiedOrder() throws WxPayException { } /** - * Test method for {@link WxPayService#queryOrder(java.lang.String, java.lang.String)} . + * Test method for {@link WxPayService#queryOrder(String, String)} . */ @Test public void testQueryOrder() throws WxPayException { @@ -157,7 +157,7 @@ public void testQueryOrder() throws WxPayException { } /** - * Test method for {@link WxPayService#closeOrder(java.lang.String)} . + * Test method for {@link WxPayService#closeOrder(String)} . */ @Test public void testCloseOrder() throws WxPayException { @@ -174,7 +174,7 @@ public void testEntPay() throws WxPayException { } /** - * Test method for {@link WxPayService#queryEntPay(java.lang.String)}. + * Test method for {@link WxPayService#queryEntPay(String)}. */ @Test public void testQueryEntPay() throws WxPayException { From ca52260f320b63bac6b21e703f39920fe528be5a Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sun, 2 Jul 2017 15:03:20 +0800 Subject: [PATCH 012/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.7.2.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 ++-- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index fc5d27b6e7..84de33cb46 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.7.1.BETA + 2.7.2.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM @@ -288,7 +288,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.5 + 1.7-SNAPSHOT sign-artifacts diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index fa1a9feff8..71e09c8f49 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.1.BETA + 2.7.2.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index fad1f7fd7b..86c5994f4a 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.1.BETA + 2.7.2.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 99681a1099..b1bb6a27d9 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.1.BETA + 2.7.2.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index ddf830b934..2f1a0d6ef9 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.1.BETA + 2.7.2.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index d3c5990473..e930a48178 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.7.1.BETA + 2.7.2.BETA 4.0.0 From 131402f8f6edfd46ff54d3ca6a17e06b35a7b436 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sun, 2 Jul 2017 15:30:08 +0800 Subject: [PATCH 013/165] =?UTF-8?q?#265=20=E5=87=A0=E4=B8=AANewsBuilder?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=9B=B4=E6=8E=A5=E8=AE=BE=E7=BD=AEArticle?= =?UTF-8?q?=E6=88=96Item=E5=AF=B9=E8=B1=A1=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/bean/messagebuilder/MpnewsBuilder.java | 10 ++++++++-- .../weixin/cp/bean/messagebuilder/NewsBuilder.java | 10 ++++++++-- .../weixin/cp/bean/outxmlbuilder/NewsBuilder.java | 11 ++++++++--- .../me/chanjar/weixin/cp/bean/WxCpMessageTest.java | 10 ++++------ .../chanjar/weixin/mp/builder/kefu/NewsBuilder.java | 11 ++++++++--- .../chanjar/weixin/mp/builder/outxml/NewsBuilder.java | 11 ++++++++--- .../mp/bean/message/WxMpXmlOutNewsMessageTest.java | 5 ++--- 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java index 21ab2549a7..55ed20abab 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java @@ -5,6 +5,7 @@ import me.chanjar.weixin.cp.bean.article.MpnewsArticle; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -30,8 +31,13 @@ public MpnewsBuilder mediaId(String mediaId) { return this; } - public MpnewsBuilder addArticle(MpnewsArticle article) { - this.articles.add(article); + public MpnewsBuilder addArticle(MpnewsArticle... articles) { + Collections.addAll(this.articles, articles); + return this; + } + + public MpnewsBuilder articles(List articles) { + this.articles = articles; return this; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java index e0df095e3d..dd23941244 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java @@ -5,6 +5,7 @@ import me.chanjar.weixin.cp.bean.article.NewArticle; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -24,8 +25,13 @@ public NewsBuilder() { this.msgType = WxConsts.CUSTOM_MSG_NEWS; } - public NewsBuilder addArticle(NewArticle article) { - this.articles.add(article); + public NewsBuilder addArticle(NewArticle... articles) { + Collections.addAll(this.articles, articles); + return this; + } + + public NewsBuilder articles(List articles) { + this.articles = articles; return this; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/outxmlbuilder/NewsBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/outxmlbuilder/NewsBuilder.java index 3e910d8dba..5a67056ab6 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/outxmlbuilder/NewsBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/outxmlbuilder/NewsBuilder.java @@ -4,6 +4,7 @@ import me.chanjar.weixin.cp.bean.WxCpXmlOutNewsMessage.Item; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -12,11 +13,15 @@ * @author Daniel Qian */ public final class NewsBuilder extends BaseBuilder { + private List articles = new ArrayList<>(); - protected final List articles = new ArrayList<>(); + public NewsBuilder addArticle(Item... items) { + Collections.addAll(this.articles, items); + return this; + } - public NewsBuilder addArticle(Item item) { - this.articles.add(item); + public NewsBuilder articles(List articles){ + this.articles = articles; return this; } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpMessageTest.java index f41f3a55a7..f97c0c79b0 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpMessageTest.java @@ -3,9 +3,9 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.cp.bean.article.MpnewsArticle; import me.chanjar.weixin.cp.bean.article.NewArticle; -import org.testng.annotations.Test; +import org.testng.annotations.*; -import static org.testng.Assert.assertEquals; +import static org.testng.Assert.*; @Test public class WxCpMessageTest { @@ -127,11 +127,9 @@ public void testMpnewsBuild_with_articles() { .thumbMediaId("thumb") .build(); - WxCpMessage reply = WxCpMessage.MPNEWS().toUser("OPENID").addArticle(article1).addArticle(article2).build(); + WxCpMessage reply = WxCpMessage.MPNEWS().toUser("OPENID").addArticle(article1, article2).build(); - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"mpnews\"," + - "\"mpnews\":{\"articles\":[{\"title\":\"Happy Day\",\"thumb_media_id\":\"thumb\",\"author\":\"aaaaaa\",\"content_source_url\":\"nice url\",\"content\":\"hahaha\",\"digest\":\"digest\",\"show_cover_pic\":\"heihei\"}," + - "{\"title\":\"Happy Day\",\"thumb_media_id\":\"thumb\",\"author\":\"aaaaaa\",\"content_source_url\":\"nice url\",\"content\":\"hahaha\",\"digest\":\"digest\",\"show_cover_pic\":\"heihei\"}]}}"); + assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"mpnews\",\"safe\":\"0\",\"mpnews\":{\"articles\":[{\"title\":\"Happy Day\",\"thumb_media_id\":\"thumb\",\"author\":\"aaaaaa\",\"content_source_url\":\"nice url\",\"content\":\"hahaha\",\"digest\":\"digest\",\"show_cover_pic\":\"heihei\"},{\"title\":\"Happy Day\",\"thumb_media_id\":\"thumb\",\"author\":\"aaaaaa\",\"content_source_url\":\"nice url\",\"content\":\"hahaha\",\"digest\":\"digest\",\"show_cover_pic\":\"heihei\"}]}}"); } public void testMpnewsBuild_with_media_id() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/NewsBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/NewsBuilder.java index 1626f77e2c..11e866e84a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/NewsBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/NewsBuilder.java @@ -4,6 +4,7 @@ import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -16,15 +17,19 @@ * @author chanjarster */ public final class NewsBuilder extends BaseBuilder { - private List articles = new ArrayList<>(); public NewsBuilder() { this.msgType = WxConsts.CUSTOM_MSG_NEWS; } - public NewsBuilder addArticle(WxMpKefuMessage.WxArticle article) { - this.articles.add(article); + public NewsBuilder addArticle(WxMpKefuMessage.WxArticle... articles) { + Collections.addAll(this.articles, articles); + return this; + } + + public NewsBuilder articles(List articles) { + this.articles = articles; return this; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/NewsBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/NewsBuilder.java index 4f9e22e67f..01af0d627f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/NewsBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/NewsBuilder.java @@ -3,6 +3,7 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -11,11 +12,15 @@ * @author chanjarster */ public final class NewsBuilder extends BaseBuilder { + private List articles = new ArrayList<>(); - protected final List articles = new ArrayList<>(); + public NewsBuilder addArticle(WxMpXmlOutNewsMessage.Item... items) { + Collections.addAll(this.articles, items); + return this; + } - public NewsBuilder addArticle(WxMpXmlOutNewsMessage.Item item) { - this.articles.add(item); + public NewsBuilder articles(List articles){ + this.articles = articles; return this; } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessageTest.java index c9a1f98264..f8f72c9e5e 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessageTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessageTest.java @@ -54,15 +54,13 @@ public void testBuild() { WxMpXmlOutNewsMessage m = WxMpXmlOutMessage.NEWS() .fromUser("fromUser") .toUser("toUser") - .addArticle(item) - .addArticle(item) + .addArticle(item,item) .build(); String expected = "" + "" + "" + "1122" + "" - + " 2" + " " + " " + " <![CDATA[title]]>" @@ -77,6 +75,7 @@ public void testBuild() { + " " + " " + " " + + " 2" + ""; System.out.println(m.toXml()); Assert.assertEquals( From 22344ebe2ce52c70e427ea1acd1da6bfef5f4e12 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sun, 2 Jul 2017 17:01:51 +0800 Subject: [PATCH 014/165] =?UTF-8?q?#256=20=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E5=8D=A1=E7=89=87=E6=B6=88=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/common/api/WxConsts.java | 1 + .../chanjar/weixin/cp/bean/WxCpMessage.java | 15 ++++ .../cp/bean/messagebuilder/BaseBuilder.java | 4 +- .../bean/messagebuilder/TextCardBuilder.java | 47 ++++++++++++ .../cp/util/json/WxCpMessageGsonAdapter.java | 8 ++ .../weixin/cp/api/WxCpMessageAPITest.java | 1 - .../weixin/cp/bean/WxCpMessageTest.java | 75 +++---------------- 7 files changed, 85 insertions(+), 66 deletions(-) create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java index e04dc45682..e416323e02 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java @@ -35,6 +35,7 @@ public class WxConsts { public static final String CUSTOM_MSG_NEWS = "news";//图文消息(点击跳转到外链) public static final String CUSTOM_MSG_MPNEWS = "mpnews";//图文消息(点击跳转到图文消息页面) public static final String CUSTOM_MSG_FILE = "file";//发送文件(CP专用) + public static final String CUSTOM_MSG_TEXTCARD = "textcard";//文本卡片消息(CP专用) public static final String CUSTOM_MSG_WXCARD = "wxcard";//卡券消息 public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; public static final String CUSTOM_MSG_SAFE_NO = "0"; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java index 2d07fcf867..c59ca87e1f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java @@ -30,6 +30,7 @@ public class WxCpMessage implements Serializable { private String musicUrl; private String hqMusicUrl; private String safe; + private String url; private List articles = new ArrayList<>(); private List mpnewsArticles = new ArrayList<>(); @@ -40,6 +41,13 @@ public static TextBuilder TEXT() { return new TextBuilder(); } + /** + * 获得文本卡片消息builder + */ + public static TextCardBuilder TEXTCARD() { + return new TextCardBuilder(); + } + /** * 获得图片消息builder */ @@ -220,4 +228,11 @@ public String toJson() { return WxCpGsonBuilder.INSTANCE.create().toJson(this); } + public String getUrl() { + return this.url; + } + + public void setUrl(String url) { + this.url = url; + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java index ea3e710c64..784de9a769 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java @@ -2,6 +2,7 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.cp.bean.WxCpMessage; +import org.apache.commons.lang3.StringUtils; public class BaseBuilder { protected String msgType; @@ -43,8 +44,7 @@ public WxCpMessage build() { m.setToUser(this.toUser); m.setToParty(this.toParty); m.setToTag(this.toTag); - m.setSafe( - (this.safe == null || "".equals(this.safe)) ? WxConsts.CUSTOM_MSG_SAFE_NO : this.safe); + m.setSafe(StringUtils.defaultIfBlank(this.safe, WxConsts.CUSTOM_MSG_SAFE_NO)); return m; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java new file mode 100644 index 0000000000..a30b9d4059 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.cp.bean.messagebuilder; + +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.cp.bean.WxCpMessage; + +/** + *
+ * 文本卡片消息Builder
+ * 用法: WxCustomMessage m = WxCustomMessage.TEXTCARD().title(...)....toUser(...).build();
+ * Created by Binary Wang on 2017-7-2.
+ * 
+ * + * @author Binary Wang + */ +public class TextCardBuilder extends BaseBuilder { + private String title; + private String description; + private String url; + + public TextCardBuilder() { + this.msgType = WxConsts.CUSTOM_MSG_TEXTCARD; + } + + public TextCardBuilder title(String title) { + this.title = title; + return this; + } + + public TextCardBuilder description(String description) { + this.description = description; + return this; + } + + public TextCardBuilder url(String url) { + this.url = url; + return this; + } + + @Override + public WxCpMessage build() { + WxCpMessage m = super.build(); + m.setTitle(this.title); + m.setDescription(this.description); + m.setUrl(this.url); + return m; + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java index a74c17b64c..67e43c4ccc 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java @@ -43,6 +43,14 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat messageJson.add("text", text); } + if (WxConsts.CUSTOM_MSG_TEXTCARD.equals(message.getMsgType())) { + JsonObject text = new JsonObject(); + text.addProperty("title", message.getTitle()); + text.addProperty("description", message.getDescription()); + text.addProperty("url", message.getUrl()); + messageJson.add("textcard", text); + } + if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) { JsonObject image = new JsonObject(); image.addProperty("media_id", message.getMediaId()); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java index ece6d5348b..1e0d40b05b 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java @@ -57,6 +57,5 @@ public void testSendMessage1() throws WxErrorException { System.out.println(messageSendResult.getInvalidPartyList()); System.out.println(messageSendResult.getInvalidUserList()); System.out.println(messageSendResult.getInvalidTagList()); - } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpMessageTest.java index f97c0c79b0..e02cc6672d 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpMessageTest.java @@ -1,6 +1,5 @@ package me.chanjar.weixin.cp.bean; -import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.cp.bean.article.MpnewsArticle; import me.chanjar.weixin.cp.bean.article.NewArticle; import org.testng.annotations.*; @@ -10,82 +9,32 @@ @Test public class WxCpMessageTest { - public void testTextReply() { - WxCpMessage reply = new WxCpMessage(); - reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT); - reply.setContent("sfsfdsdf"); - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); - } - public void testTextBuild() { WxCpMessage reply = WxCpMessage.TEXT().toUser("OPENID").content("sfsfdsdf").build(); - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); + assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"},\"safe\":\"0\"}"); } - public void testImageReply() { - WxCpMessage reply = new WxCpMessage(); - reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE); - reply.setMediaId("MEDIA_ID"); - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); + public void testTextCardBuild() { + WxCpMessage reply = WxCpMessage.TEXTCARD().toUser("OPENID") + .title("领奖通知") + .description( "
2016年9月26日
恭喜你抽中iPhone 7一台,领奖码:xxxx
请于2016年10月10日前联系行政同事领取
") + .url("http://www.qq.com").build(); + assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"textcard\",\"textcard\":{\"title\":\"领奖通知\",\"description\":\"
2016年9月26日
恭喜你抽中iPhone 7一台,领奖码:xxxx
请于2016年10月10日前联系行政同事领取
\",\"url\":\"http://www.qq.com\"},\"safe\":\"0\"}"); } public void testImageBuild() { WxCpMessage reply = WxCpMessage.IMAGE().toUser("OPENID").mediaId("MEDIA_ID").build(); - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); - } - - public void testVoiceReply() { - WxCpMessage reply = new WxCpMessage(); - reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_VOICE); - reply.setMediaId("MEDIA_ID"); - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}"); + assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"},\"safe\":\"0\"}"); } public void testVoiceBuild() { WxCpMessage reply = WxCpMessage.VOICE().toUser("OPENID").mediaId("MEDIA_ID").build(); - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}"); - } - - public void testVideoReply() { - WxCpMessage reply = new WxCpMessage(); - reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_VIDEO); - reply.setMediaId("MEDIA_ID"); - reply.setThumbMediaId("MEDIA_ID"); - reply.setTitle("TITLE"); - reply.setDescription("DESCRIPTION"); - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"video\",\"video\":{\"media_id\":\"MEDIA_ID\",\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"}}"); + assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"},\"safe\":\"0\"}"); } public void testVideoBuild() { WxCpMessage reply = WxCpMessage.VIDEO().toUser("OPENID").title("TITLE").mediaId("MEDIA_ID").thumbMediaId("MEDIA_ID").description("DESCRIPTION").build(); - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"video\",\"video\":{\"media_id\":\"MEDIA_ID\",\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"}}"); - } - - public void testNewsReply() { - WxCpMessage reply = new WxCpMessage(); - reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS); - - NewArticle article1 = new NewArticle(); - article1.setUrl("URL"); - article1.setPicUrl("PIC_URL"); - article1.setDescription("Is Really A Happy Day"); - article1.setTitle("Happy Day"); - reply.getArticles().add(article1); - - NewArticle article2 = new NewArticle(); - article2.setUrl("URL"); - article2.setPicUrl("PIC_URL"); - article2.setDescription("Is Really A Happy Day"); - article2.setTitle("Happy Day"); - reply.getArticles().add(article2); - - - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"},{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}}"); + assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"video\",\"safe\":\"0\",\"video\":{\"media_id\":\"MEDIA_ID\",\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"}}"); } public void testNewsBuild() { @@ -103,7 +52,7 @@ public void testNewsBuild() { WxCpMessage reply = WxCpMessage.NEWS().toUser("OPENID").addArticle(article1).addArticle(article2).build(); - assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"},{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}}"); + assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"news\",\"safe\":\"0\",\"news\":{\"articles\":[{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"},{\"title\":\"Happy Day\",\"description\":\"Is Really A Happy Day\",\"url\":\"URL\",\"picurl\":\"PIC_URL\"}]}}"); } public void testMpnewsBuild_with_articles() { @@ -136,7 +85,7 @@ public void testMpnewsBuild_with_media_id() { WxCpMessage reply = WxCpMessage.MPNEWS().toUser("OPENID").mediaId("mmm").build(); assertEquals(reply.toJson(), - "{\"touser\":\"OPENID\",\"msgtype\":\"mpnews\",\"mpnews\":{\"media_id\":\"mmm\"}}"); + "{\"touser\":\"OPENID\",\"msgtype\":\"mpnews\",\"safe\":\"0\",\"mpnews\":{\"media_id\":\"mmm\"}}"); } } From 554fd08fb8868b679d8fed692de772b2ecdfeb00 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sun, 2 Jul 2017 17:17:35 +0800 Subject: [PATCH 015/165] =?UTF-8?q?#195=20=E6=8A=BD=E5=8F=96=E7=B4=A0?= =?UTF-8?q?=E6=9D=90=E7=AE=A1=E7=90=86=E8=AF=B7=E6=B1=82URL=E5=88=B0?= =?UTF-8?q?=E5=B8=B8=E9=87=8F=E7=B1=BB=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/WxMpMaterialService.java | 14 +++++- .../mp/api/impl/WxMpMaterialServiceImpl.java | 45 +++++++------------ 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMaterialService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMaterialService.java index 8e769d3e2d..05ca87eab7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMaterialService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMaterialService.java @@ -16,6 +16,16 @@ *
*/ public interface WxMpMaterialService { + String MEDIA_GET_URL = "https://api.weixin.qq.com/cgi-bin/media/get"; + String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/upload?type=%s"; + String IMG_UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/uploadimg"; + String MATERIAL_ADD_URL = "https://api.weixin.qq.com/cgi-bin/material/add_material?type=%s"; + String NEWS_ADD_URL = "https://api.weixin.qq.com/cgi-bin/material/add_news"; + String MATERIAL_GET_URL = "https://api.weixin.qq.com/cgi-bin/material/get_material"; + String NEWS_UPDATE_URL = "https://api.weixin.qq.com/cgi-bin/material/update_news"; + String MATERIAL_DEL_URL = "https://api.weixin.qq.com/cgi-bin/material/del_material"; + String MATERIAL_GET_COUNT_URL = "https://api.weixin.qq.com/cgi-bin/material/get_materialcount"; + String MATERIAL_BATCHGET_URL = "https://api.weixin.qq.com/cgi-bin/material/batchget_material"; /** *
@@ -73,11 +83,11 @@ public interface WxMpMaterialService {
    * 接口url格式:https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID
    * 
* - * @param media_id + * @param mediaId 媒体文件Id * @return 保存到本地的临时文件 * @throws WxErrorException */ - File mediaDownload(String media_id) throws WxErrorException; + File mediaDownload(String mediaId) throws WxErrorException; /** *
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
index bb5857be83..99a63f914b 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
@@ -25,8 +25,7 @@
  * Created by Binary Wang on 2016/7/21.
  */
 public class WxMpMaterialServiceImpl implements WxMpMaterialService {
-  private static final String MEDIA_API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/media";
-  private static final String MATERIAL_API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/material";
+
   private WxMpService wxMpService;
 
   public WxMpMaterialServiceImpl(WxMpService wxMpService) {
@@ -45,28 +44,26 @@ public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputS
 
   @Override
   public WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException {
-    String url = MEDIA_API_URL_PREFIX + "/upload?type=" + mediaType;
+    String url = String.format(MEDIA_UPLOAD_URL, mediaType);
     return this.wxMpService.execute(MediaUploadRequestExecutor.create(this.wxMpService.getRequestHttp()), url, file);
   }
 
   @Override
-  public File mediaDownload(String media_id) throws WxErrorException {
-    String url = MEDIA_API_URL_PREFIX + "/get";
+  public File mediaDownload(String mediaId) throws WxErrorException {
     return this.wxMpService.execute(
       MediaDownloadRequestExecutor.create(this.wxMpService.getRequestHttp(), this.wxMpService.getWxMpConfigStorage().getTmpDirFile()),
-      url,
-      "media_id=" + media_id);
+      MEDIA_GET_URL,
+      "media_id=" + mediaId);
   }
 
   @Override
   public WxMediaImgUploadResult mediaImgUpload(File file) throws WxErrorException {
-    String url = MEDIA_API_URL_PREFIX + "/uploadimg";
-    return this.wxMpService.execute(MediaImgUploadRequestExecutor.create(this.wxMpService.getRequestHttp()), url, file);
+    return this.wxMpService.execute(MediaImgUploadRequestExecutor.create(this.wxMpService.getRequestHttp()), IMG_UPLOAD_URL, file);
   }
 
   @Override
   public WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material) throws WxErrorException {
-    String url = MATERIAL_API_URL_PREFIX + "/add_material?type=" + mediaType;
+    String url = String.format(MATERIAL_ADD_URL, mediaType);
     return this.wxMpService.execute(MaterialUploadRequestExecutor.create(this.wxMpService.getRequestHttp()), url, material);
   }
 
@@ -75,33 +72,29 @@ public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws
     if (news == null || news.isEmpty()) {
       throw new IllegalArgumentException("news is empty!");
     }
-    String url = MATERIAL_API_URL_PREFIX + "/add_news";
-    String responseContent = this.wxMpService.post(url, news.toJson());
+    String responseContent = this.wxMpService.post(NEWS_ADD_URL, news.toJson());
     return WxMpMaterialUploadResult.fromJson(responseContent);
   }
 
   @Override
   public InputStream materialImageOrVoiceDownload(String media_id) throws WxErrorException {
-    String url = MATERIAL_API_URL_PREFIX + "/get_material";
-    return this.wxMpService.execute(MaterialVoiceAndImageDownloadRequestExecutor.create(this.wxMpService.getRequestHttp(), this.wxMpService.getWxMpConfigStorage().getTmpDirFile()), url, media_id);
+    return this.wxMpService.execute(MaterialVoiceAndImageDownloadRequestExecutor
+      .create(this.wxMpService.getRequestHttp(), this.wxMpService.getWxMpConfigStorage().getTmpDirFile()), MATERIAL_GET_URL, media_id);
   }
 
   @Override
   public WxMpMaterialVideoInfoResult materialVideoInfo(String media_id) throws WxErrorException {
-    String url = MATERIAL_API_URL_PREFIX + "/get_material";
-    return this.wxMpService.execute(MaterialVideoInfoRequestExecutor.create(this.wxMpService.getRequestHttp()), url, media_id);
+    return this.wxMpService.execute(MaterialVideoInfoRequestExecutor.create(this.wxMpService.getRequestHttp()), MATERIAL_GET_URL, media_id);
   }
 
   @Override
   public WxMpMaterialNews materialNewsInfo(String media_id) throws WxErrorException {
-    String url = MATERIAL_API_URL_PREFIX + "/get_material";
-    return this.wxMpService.execute(MaterialNewsInfoRequestExecutor.create(this.wxMpService.getRequestHttp()), url, media_id);
+    return this.wxMpService.execute(MaterialNewsInfoRequestExecutor.create(this.wxMpService.getRequestHttp()), MATERIAL_GET_URL, media_id);
   }
 
   @Override
   public boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate) throws WxErrorException {
-    String url = MATERIAL_API_URL_PREFIX + "/update_news";
-    String responseText = this.wxMpService.post(url, wxMpMaterialArticleUpdate.toJson());
+    String responseText = this.wxMpService.post(NEWS_UPDATE_URL, wxMpMaterialArticleUpdate.toJson());
     WxError wxError = WxError.fromJson(responseText);
     if (wxError.getErrorCode() == 0) {
       return true;
@@ -112,14 +105,12 @@ public boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleU
 
   @Override
   public boolean materialDelete(String media_id) throws WxErrorException {
-    String url = MATERIAL_API_URL_PREFIX + "/del_material";
-    return this.wxMpService.execute(MaterialDeleteRequestExecutor.create(this.wxMpService.getRequestHttp()), url, media_id);
+    return this.wxMpService.execute(MaterialDeleteRequestExecutor.create(this.wxMpService.getRequestHttp()), MATERIAL_DEL_URL, media_id);
   }
 
   @Override
   public WxMpMaterialCountResult materialCount() throws WxErrorException {
-    String url = MATERIAL_API_URL_PREFIX + "/get_materialcount";
-    String responseText = this.wxMpService.get(url, null);
+    String responseText = this.wxMpService.get(MATERIAL_GET_COUNT_URL, null);
     WxError wxError = WxError.fromJson(responseText);
     if (wxError.getErrorCode() == 0) {
       return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialCountResult.class);
@@ -130,12 +121,11 @@ public WxMpMaterialCountResult materialCount() throws WxErrorException {
 
   @Override
   public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException {
-    String url = MATERIAL_API_URL_PREFIX + "/batchget_material";
     Map params = new HashMap<>();
     params.put("type", WxConsts.MATERIAL_NEWS);
     params.put("offset", offset);
     params.put("count", count);
-    String responseText = this.wxMpService.post(url, WxGsonBuilder.create().toJson(params));
+    String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params));
     WxError wxError = WxError.fromJson(responseText);
     if (wxError.getErrorCode() == 0) {
       return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialNewsBatchGetResult.class);
@@ -146,12 +136,11 @@ public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count
 
   @Override
   public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException {
-    String url = MATERIAL_API_URL_PREFIX + "/batchget_material";
     Map params = new HashMap<>();
     params.put("type", type);
     params.put("offset", offset);
     params.put("count", count);
-    String responseText = this.wxMpService.post(url, WxGsonBuilder.create().toJson(params));
+    String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params));
     WxError wxError = WxError.fromJson(responseText);
     if (wxError.getErrorCode() == 0) {
       return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class);

From eaad6367de1ee3aba5f1ca7de67da88dd718eb03 Mon Sep 17 00:00:00 2001
From: Binary Wang 
Date: Sun, 2 Jul 2017 18:23:21 +0800
Subject: [PATCH 016/165] =?UTF-8?q?#252=20=E5=8E=9F=E6=9C=89=E5=9B=BE?=
 =?UTF-8?q?=E6=96=87=E7=B4=A0=E6=9D=90=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3?=
 =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=95=99=E8=A8=80=E7=AE=A1=E7=90=86=E6=89=80?=
 =?UTF-8?q?=E9=9C=80=E4=B8=A4=E4=B8=AA=E5=8F=82=E6=95=B0=EF=BC=9Aneed=5Fop?=
 =?UTF-8?q?en=5Fcomment=20=E5=92=8C=20only=5Ffans=5Fcan=5Fcomment?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../mp/api/impl/WxMpMaterialServiceImpl.java  | 16 +++---
 .../mp/bean/material/WxMpMaterialNews.java    | 52 ++++++++++++++++++-
 .../material/WxMpMaterialUploadResult.java    | 25 +++++++--
 ...lVoiceAndImageDownloadRequestExecutor.java |  2 -
 ...ApacheMaterialNewsInfoRequestExecutor.java |  5 ++
 ...lVoiceAndImageDownloadRequestExecutor.java |  5 +-
 .../JoddMaterialNewsInfoRequestExecutor.java  |  4 ++
 ...lVoiceAndImageDownloadRequestExecutor.java |  3 +-
 ...OkhttpMaterialNewsInfoRequestExecutor.java |  4 ++
 ...lVoiceAndImageDownloadRequestExecutor.java |  3 +-
 .../WxMpMaterialNewsArticleGsonAdapter.java   | 21 ++++++++
 .../json/WxMpMaterialNewsGsonAdapter.java     | 13 +++++
 .../api/impl/WxMpMaterialServiceImplTest.java |  5 +-
 13 files changed, 137 insertions(+), 21 deletions(-)

diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
index 99a63f914b..90594fe031 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
@@ -77,19 +77,19 @@ public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws
   }
 
   @Override
-  public InputStream materialImageOrVoiceDownload(String media_id) throws WxErrorException {
+  public InputStream materialImageOrVoiceDownload(String mediaId) throws WxErrorException {
     return this.wxMpService.execute(MaterialVoiceAndImageDownloadRequestExecutor
-      .create(this.wxMpService.getRequestHttp(), this.wxMpService.getWxMpConfigStorage().getTmpDirFile()), MATERIAL_GET_URL, media_id);
+      .create(this.wxMpService.getRequestHttp(), this.wxMpService.getWxMpConfigStorage().getTmpDirFile()), MATERIAL_GET_URL, mediaId);
   }
 
   @Override
-  public WxMpMaterialVideoInfoResult materialVideoInfo(String media_id) throws WxErrorException {
-    return this.wxMpService.execute(MaterialVideoInfoRequestExecutor.create(this.wxMpService.getRequestHttp()), MATERIAL_GET_URL, media_id);
+  public WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId) throws WxErrorException {
+    return this.wxMpService.execute(MaterialVideoInfoRequestExecutor.create(this.wxMpService.getRequestHttp()), MATERIAL_GET_URL, mediaId);
   }
 
   @Override
-  public WxMpMaterialNews materialNewsInfo(String media_id) throws WxErrorException {
-    return this.wxMpService.execute(MaterialNewsInfoRequestExecutor.create(this.wxMpService.getRequestHttp()), MATERIAL_GET_URL, media_id);
+  public WxMpMaterialNews materialNewsInfo(String mediaId) throws WxErrorException {
+    return this.wxMpService.execute(MaterialNewsInfoRequestExecutor.create(this.wxMpService.getRequestHttp()), MATERIAL_GET_URL, mediaId);
   }
 
   @Override
@@ -104,8 +104,8 @@ public boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleU
   }
 
   @Override
-  public boolean materialDelete(String media_id) throws WxErrorException {
-    return this.wxMpService.execute(MaterialDeleteRequestExecutor.create(this.wxMpService.getRequestHttp()), MATERIAL_DEL_URL, media_id);
+  public boolean materialDelete(String mediaId) throws WxErrorException {
+    return this.wxMpService.execute(MaterialDeleteRequestExecutor.create(this.wxMpService.getRequestHttp()), MATERIAL_DEL_URL, mediaId);
   }
 
   @Override
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNews.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNews.java
index a107facaed..51f2d0c6bd 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNews.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNews.java
@@ -4,12 +4,16 @@
 import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
 
 import java.io.Serializable;
+import java.util.Date;
 import java.util.ArrayList;
 import java.util.List;
 
 public class WxMpMaterialNews implements Serializable {
   private static final long serialVersionUID = -3283203652013494976L;
 
+  private Date createdTime;
+  private Date updatedTime;
+
   private List articles = new ArrayList<>();
 
   public List getArticles() {
@@ -28,9 +32,25 @@ public boolean isEmpty() {
     return this.articles == null || this.articles.isEmpty();
   }
 
+  public Date getCreatedTime() {
+    return this.createdTime;
+  }
+
+  public void setCreatedTime(Date createdTime) {
+    this.createdTime = createdTime;
+  }
+
+  public Date getUpdatedTime() {
+    return this.updatedTime;
+  }
+
+  public void setUpdatedTime(Date updatedTime) {
+    this.updatedTime = updatedTime;
+  }
+
   @Override
   public String toString() {
-    return ToStringUtils.toSimpleString(this);
+    return this.toJson();
   }
 
   /**
@@ -44,6 +64,8 @@ public String toString() {
    * 6. digest          图文消息的描述
    * 7. showCoverPic  是否显示封面,true为显示,false为不显示
    * 8. url           点击图文消息跳转链接
+   * 9. need_open_comment(新增字段)	否	Uint32	是否打开评论,0不打开,1打开
+   * 10. only_fans_can_comment(新增字段)	否	Uint32	是否粉丝才可评论,0所有人可评论,1粉丝才可评论
    * 
* * @author chanjarster @@ -87,6 +109,18 @@ public static class WxMpMaterialNewsArticle { */ private String url; + /** + * need_open_comment + * 是否打开评论,0不打开,1打开 + */ + private Boolean needOpenComment; + + /** + * only_fans_can_comment + * 是否粉丝才可评论,0所有人可评论,1粉丝才可评论 + */ + private Boolean onlyFansCanComment; + public String getThumbMediaId() { return this.thumbMediaId; } @@ -159,6 +193,22 @@ public void setThumbUrl(String thumbUrl) { this.thumbUrl = thumbUrl; } + public Boolean getNeedOpenComment() { + return this.needOpenComment; + } + + public void setNeedOpenComment(Boolean needOpenComment) { + this.needOpenComment = needOpenComment; + } + + public Boolean getOnlyFansCanComment() { + return this.onlyFansCanComment; + } + + public void setOnlyFansCanComment(Boolean onlyFansCanComment) { + this.onlyFansCanComment = onlyFansCanComment; + } + @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialUploadResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialUploadResult.java index ec1d115496..0e5546b9aa 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialUploadResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialUploadResult.java @@ -1,17 +1,16 @@ package me.chanjar.weixin.mp.bean.material; +import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; public class WxMpMaterialUploadResult implements Serializable { - - /** - * - */ private static final long serialVersionUID = -128818731449449537L; private String mediaId; private String url; + private Integer errCode; + private String errMsg; public static WxMpMaterialUploadResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMpMaterialUploadResult.class); @@ -33,9 +32,25 @@ public void setUrl(String url) { this.url = url; } + public Integer getErrCode() { + return this.errCode; + } + + public void setErrCode(Integer errCode) { + this.errCode = errCode; + } + + public String getErrMsg() { + return this.errMsg; + } + + public void setErrMsg(String errMsg) { + this.errMsg = errMsg; + } + @Override public String toString() { - return "WxMpMaterialUploadResult [media_id=" + this.mediaId + ", url=" + this.url + "]"; + return ToStringUtils.toSimpleString(this); } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java index 8bf55d03e0..09cb70d0f5 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java @@ -13,13 +13,11 @@ public abstract class MaterialVoiceAndImageDownloadRequestExecutor impleme protected RequestHttp requestHttp; protected File tmpDirFile; - public MaterialVoiceAndImageDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { this.requestHttp = requestHttp; this.tmpDirFile = tmpDirFile; } - public static RequestExecutor create(RequestHttp requestHttp, File tmpDirFile) { switch (requestHttp.getRequestType()) { case APACHE_HTTP: diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java index 77d22659ec..5298160f35 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java @@ -14,6 +14,8 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.HashMap; @@ -23,6 +25,8 @@ * Created by ecoolper on 2017/5/5. */ public class ApacheMaterialNewsInfoRequestExecutor extends MaterialNewsInfoRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + public ApacheMaterialNewsInfoRequestExecutor(RequestHttp requestHttp) { super(requestHttp); } @@ -40,6 +44,7 @@ public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorExc httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(params))); try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); + this.logger.debug("响应原始数据:{}", responseContent); WxError error = WxError.fromJson(responseContent); if (error.getErrorCode() != 0) { throw new WxErrorException(error); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialVoiceAndImageDownloadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialVoiceAndImageDownloadRequestExecutor.java index 87d7b545c6..b1011a5282 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialVoiceAndImageDownloadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialVoiceAndImageDownloadRequestExecutor.java @@ -18,6 +18,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -41,10 +42,10 @@ public InputStream execute(String uri, String materialId) throws WxErrorExceptio params.put("media_id", materialId); httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(params))); try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost); - InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);) { + InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response)) { // 下载媒体文件出错 byte[] responseContent = IOUtils.toByteArray(inputStream); - String responseContentString = new String(responseContent, "UTF-8"); + String responseContentString = new String(responseContent, StandardCharsets.UTF_8); if (responseContentString.length() < 100) { try { WxError wxError = WxGsonBuilder.create().fromJson(responseContentString, WxError.class); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialNewsInfoRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialNewsInfoRequestExecutor.java index a5d5ad1fd3..181a640787 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialNewsInfoRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialNewsInfoRequestExecutor.java @@ -12,6 +12,8 @@ import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; @@ -19,6 +21,7 @@ * Created by ecoolper on 2017/5/5. */ public class JoddMaterialNewsInfoRequestExecutor extends MaterialNewsInfoRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); public JoddMaterialNewsInfoRequestExecutor(RequestHttp requestHttp) { super(requestHttp); } @@ -36,6 +39,7 @@ public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorExc response.charset(StringPool.UTF_8); String responseContent = response.bodyText(); + this.logger.debug("响应原始数据:{}", responseContent); WxError error = WxError.fromJson(responseContent); if (error.getErrorCode() != 0) { throw new WxErrorException(error); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialVoiceAndImageDownloadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialVoiceAndImageDownloadRequestExecutor.java index a6317d5a00..ca43a1455d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialVoiceAndImageDownloadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialVoiceAndImageDownloadRequestExecutor.java @@ -17,6 +17,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; /** * Created by ecoolper on 2017/5/5. @@ -40,7 +41,7 @@ public InputStream execute(String uri, String materialId) throws WxErrorExceptio try (InputStream inputStream = new ByteArrayInputStream(response.bodyBytes())) { // 下载媒体文件出错 byte[] responseContent = IOUtils.toByteArray(inputStream); - String responseContentString = new String(responseContent, "UTF-8"); + String responseContentString = new String(responseContent, StandardCharsets.UTF_8); if (responseContentString.length() < 100) { try { WxError wxError = WxGsonBuilder.create().fromJson(responseContentString, WxError.class); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java index d51fbbe481..a0a1c05231 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java @@ -8,6 +8,8 @@ import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; @@ -15,6 +17,7 @@ * Created by ecoolper on 2017/5/5. */ public class OkhttpMaterialNewsInfoRequestExecutor extends MaterialNewsInfoRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); public OkhttpMaterialNewsInfoRequestExecutor(RequestHttp requestHttp) { super(requestHttp); } @@ -44,6 +47,7 @@ public Request authenticate(Route route, Response response) throws IOException { Response response = client.newCall(request).execute(); String responseContent = response.body().string(); + this.logger.debug("响应原始数据:{}", responseContent); WxError error = WxError.fromJson(responseContent); if (error.getErrorCode() != 0) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVoiceAndImageDownloadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVoiceAndImageDownloadRequestExecutor.java index 336b3a989e..1d0a5f7f65 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVoiceAndImageDownloadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVoiceAndImageDownloadRequestExecutor.java @@ -13,6 +13,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; /** * Created by ecoolper on 2017/5/5. @@ -50,7 +51,7 @@ public Request authenticate(Route route, Response response) throws IOException { // 下载媒体文件出错 byte[] responseContent = IOUtils.toByteArray(inputStream); - String responseContentString = new String(responseContent, "UTF-8"); + String responseContentString = new String(responseContent, StandardCharsets.UTF_8); if (responseContentString.length() < 100) { try { WxError wxError = WxGsonBuilder.create().fromJson(responseContentString, WxError.class); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsArticleGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsArticleGsonAdapter.java index a74877f126..5a17a7bdb8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsArticleGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsArticleGsonAdapter.java @@ -11,6 +11,7 @@ import com.google.gson.*; import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; +import org.apache.commons.lang3.BooleanUtils; import java.lang.reflect.Type; @@ -37,6 +38,16 @@ public JsonElement serialize(WxMpMaterialNews.WxMpMaterialNewsArticle article, T if (null != article.getUrl()) { articleJson.addProperty("url", article.getUrl()); } + + if (null != article.getNeedOpenComment()) { + articleJson.addProperty("need_open_comment", + BooleanUtils.toInteger(article.getNeedOpenComment(), 1, 0)); + } + + if (null != article.getOnlyFansCanComment()) { + articleJson.addProperty("only_fans_can_comment", + BooleanUtils.toInteger(article.getOnlyFansCanComment(), 1, 0)); + } return articleJson; } @@ -81,6 +92,16 @@ public WxMpMaterialNews.WxMpMaterialNewsArticle deserialize(JsonElement jsonElem if (url != null && !url.isJsonNull()) { article.setUrl(GsonHelper.getAsString(url)); } + + JsonElement needOpenComment = articleInfo.get("need_open_comment"); + if (needOpenComment != null && !needOpenComment.isJsonNull()) { + article.setNeedOpenComment(GsonHelper.getAsBoolean(needOpenComment)); + } + + JsonElement onlyFansCanComment = articleInfo.get("only_fans_can_comment"); + if (onlyFansCanComment != null && !onlyFansCanComment.isJsonNull()) { + article.setOnlyFansCanComment(GsonHelper.getAsBoolean(onlyFansCanComment)); + } return article; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsGsonAdapter.java index 8da6dacdc4..a77a209814 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsGsonAdapter.java @@ -9,9 +9,11 @@ package me.chanjar.weixin.mp.util.json; import com.google.gson.*; +import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; import java.lang.reflect.Type; +import java.util.Date; public class WxMpMaterialNewsGsonAdapter implements JsonSerializer, JsonDeserializer { @@ -41,6 +43,17 @@ public WxMpMaterialNews deserialize(JsonElement jsonElement, Type type, JsonDese wxMpMaterialNews.addArticle(article); } } + + if (json.get("create_time") != null && !json.get("create_time").isJsonNull()) { + Date createTime = new Date(GsonHelper.getAsLong(json.get("create_time"))); + wxMpMaterialNews.setCreatedTime(createTime); + } + + if (json.get("update_time") != null && !json.get("update_time").isJsonNull()) { + Date updateTime = new Date(GsonHelper.getAsLong(json.get("update_time"))); + wxMpMaterialNews.setUpdatedTime(updateTime); + } + return wxMpMaterialNews; } } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java index b175114af1..309c4e0e47 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java @@ -175,7 +175,7 @@ public void testDownloadMaterial(String mediaId) throws WxErrorException, IOExce } } - @Test(dependsOnMethods = {"testAddNews"}) + @Test(dependsOnMethods = {"testAddNews","testUploadMaterial"}) public void testGetNewsInfo() throws WxErrorException { WxMpMaterialNews wxMpMaterialNewsSingle = this.wxService .getMaterialService().materialNewsInfo(this.singleNewsMediaId); @@ -183,6 +183,9 @@ public void testGetNewsInfo() throws WxErrorException { .getMaterialService().materialNewsInfo(this.multiNewsMediaId); assertNotNull(wxMpMaterialNewsSingle); assertNotNull(wxMpMaterialNewsMultiple); + + System.out.println(wxMpMaterialNewsSingle); + System.out.println(wxMpMaterialNewsMultiple); } @Test(dependsOnMethods = {"testGetNewsInfo"}) From b12a7a859085c9a9fb140e8d792204525adcf0bd Mon Sep 17 00:00:00 2001 From: Jink2005 Date: Mon, 3 Jul 2017 10:37:47 +0800 Subject: [PATCH 017/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=9B=9E=E8=B0=83sign=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84bug=20(#266)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/result/WxPayOrderNotifyResult.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java index 723702a455..bfeb98f0b4 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java @@ -89,6 +89,24 @@ public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializa @XStreamAlias("bank_type") private String bankType; + /** + *
+   *     用户是否关注子公众账号
+   *     String(1)
+   *     Y-关注,N-未关注,仅在公众账号类型支付有效
+   * 
+ */ + @XStreamAlias("sub_is_subscribe") + private String subIsSubscribe; + + /** + *
+   *     用户在子商户appid下的唯一标识
+   *     String(128)
+   * 
+ */ + @XStreamAlias("sub_openid") + private String subOpenId; /** *
@@ -293,6 +311,22 @@ public void setBankType(String bankType) {
     this.bankType = bankType;
   }
 
+  public String getSubIsSubscribe() {
+    return subIsSubscribe;
+  }
+
+  public void setSubIsSubscribe(String subIsSubscribe) {
+    this.subIsSubscribe = subIsSubscribe;
+  }
+
+  public String getSubOpenId() {
+    return subOpenId;
+  }
+
+  public void setSubOpenId(String subOpenId) {
+    this.subOpenId = subOpenId;
+  }
+
   public Integer getTotalFee() {
     return totalFee;
   }

From 04e115ce03d57ec6786b4512b622853809173c00 Mon Sep 17 00:00:00 2001
From: Binary Wang 
Date: Mon, 3 Jul 2017 15:48:17 +0800
Subject: [PATCH 018/165] =?UTF-8?q?=E4=BC=98=E5=8C=96javadoc?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../bean/result/WxPayOrderNotifyResult.java   | 260 +++++++++---------
 1 file changed, 134 insertions(+), 126 deletions(-)

diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java
index bfeb98f0b4..a411cd2c70 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java
@@ -25,12 +25,12 @@ public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializa
 
   /**
    * 
-   * 设备号
-   * device_info
-   * 否
-   * String(32)
-   * 013467007045764
-   * 微信支付分配的终端设备号,
+   * 字段名:设备号
+   * 变量名:device_info
+   * 是否必填:否
+   * 类型:String(32)
+   * 示例值:013467007045764
+   * 描述:微信支付分配的终端设备号,
    * 
*/ @XStreamAlias("device_info") @@ -38,12 +38,12 @@ public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializa /** *
-   * 用户标识
-   * openid
-   * 是
-   * String(128)
-   * wxd930ea5d5a258f4f
-   * 用户在商户appid下的唯一标识
+   * 字段名:用户标识
+   * 变量名:openid
+   * 是否必填:是
+   * 类型:String(128)
+   * 示例值:wxd930ea5d5a258f4f
+   * 描述:用户在商户appid下的唯一标识
    * 
*/ @XStreamAlias("openid") @@ -51,131 +51,139 @@ public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializa /** *
-   * 是否关注公众账号
-   * is_subscribe
-   * 否
-   * String(1)
-   * Y
-   * 用户是否关注公众账号,Y-关注,N-未关注,仅在公众账号类型支付有效
+   * 字段名:是否关注公众账号
+   * 变量名:is_subscribe
+   * 是否必填:否
+   * 类型:String(1)
+   * 示例值:Y
+   * 描述:用户是否关注公众账号,Y-关注,N-未关注,仅在公众账号类型支付有效
    * 
*/ @XStreamAlias("is_subscribe") private String isSubscribe; - /** *
-   * 交易类型
-   * trade_type
-   * 是
-   * String(16)
-   * JSAPI	JSAPI、NATIVE、APP
+   * 字段名:用户子标识
+   * 变量名:sub_openid
+   * 是否必填:是
+   * 类型:String(128)
+   * 示例值:wxd930ea5d5a258f4f
+   * 描述:用户在子商户appid下的唯一标识
    * 
*/ - @XStreamAlias("trade_type") - private String tradeType; - + @XStreamAlias("sub_openid") + private String subOpenid; /** *
-   * 付款银行
-   * bank_type
-   * 是
-   * String(16)
-   * CMC
-   * 银行类型,采用字符串类型的银行标识,银行类型见银行列表
+   * 字段名:是否关注子公众账号
+   * 变量名:sub_is_subscribe
+   * 是否必填:否
+   * 类型:String(1)
+   * 示例值:Y
+   * 描述:用户是否关注子公众账号,Y-关注,N-未关注,仅在公众账号类型支付有效
    * 
*/ - @XStreamAlias("bank_type") - private String bankType; + @XStreamAlias("sub_is_subscribe") + private String subIsSubscribe; + /** *
-   *     用户是否关注子公众账号
-   *     String(1)
-   *     Y-关注,N-未关注,仅在公众账号类型支付有效
+   * 字段名:交易类型
+   * 变量名:trade_type
+   * 是否必填:是
+   * 类型:String(16)
+   * 示例值:JSAPI
+   * JSA描述:PI、NATIVE、APP
    * 
*/ - @XStreamAlias("sub_is_subscribe") - private String subIsSubscribe; + @XStreamAlias("trade_type") + private String tradeType; + /** *
-   *     用户在子商户appid下的唯一标识
-   *     String(128)
+   * 字段名:付款银行
+   * 变量名:bank_type
+   * 是否必填:是
+   * 类型:String(16)
+   * 示例值:CMC
+   * 描述:银行类型,采用字符串类型的银行标识,银行类型见银行列表
    * 
*/ - @XStreamAlias("sub_openid") - private String subOpenId; + @XStreamAlias("bank_type") + private String bankType; /** *
-   * 订单金额
-   * total_fee
-   * 是
-   * Int
-   * 100
-   * 订单总金额,单位为分
+   * 字段名:订单金额
+   * 变量名:total_fee
+   * 是否必填:是
+   * 类型:Int
+   * 示例值:100
+   * 描述:订单总金额,单位为分
    * 
*/ @XStreamAlias("total_fee") private Integer totalFee; /** *
-   * 应结订单金额
-   * settlement_total_fee
-   * 否
-   * Int
-   * 100
-   * 应结订单金额=订单金额-非充值代金券金额,应结订单金额<=订单金额。
+   * 字段名:应结订单金额
+   * 变量名:settlement_total_fee
+   * 是否必填:否
+   * 类型:Int
+   * 示例值:100
+   * 描述:应结订单金额=订单金额-非充值代金券金额,应结订单金额<=订单金额。
    * 
*/ @XStreamAlias("settlement_total_fee") private Integer settlementTotalFee; /** *
-   * 货币种类
-   * fee_type
-   * 否
-   * String(8)
-   * CNY
-   * 货币类型,符合ISO4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
+   * 字段名:货币种类
+   * 变量名:fee_type
+   * 是否必填:否
+   * 类型:String(8)
+   * 示例值:CNY
+   * 描述:货币类型,符合ISO4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
    * 
*/ @XStreamAlias("fee_type") private String feeType; /** *
-   * 现金支付金额
-   * cash_fee
-   * 是
-   * Int
-   * 100
-   * 现金支付金额订单现金支付金额,详见支付金额
+   * 字段名:现金支付金额
+   * 变量名:cash_fee
+   * 是否必填:是
+   * 类型:Int
+   * 示例值:100
+   * 描述:现金支付金额订单现金支付金额,详见支付金额
    * 
*/ @XStreamAlias("cash_fee") private Integer cashFee; /** *
-   * 现金支付货币类型
-   * cash_fee_type
-   * 否
-   * String(16)
-   * CNY
-   * 货币类型,符合ISO4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
+   * 字段名:现金支付货币类型
+   * 变量名:cash_fee_type
+   * 是否必填:否
+   * 类型:String(16)
+   * 示例值:CNY
+   * 描述:货币类型,符合ISO4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
    * 
*/ @XStreamAlias("cash_fee_type") private String cashFeeType; /** *
-   * 总代金券金额
-   * coupon_fee
-   * 否
-   * Int
-   * 10
-   * 代金券金额<=订单金额,订单金额-代金券金额=现金支付金额,详见支付金额
+   * 字段名:总代金券金额
+   * 变量名:coupon_fee
+   * 是否必填:否
+   * 类型:Int
+   * 示例值:10
+   * 描述:代金券金额<=订单金额,订单金额-代金券金额=现金支付金额,详见支付金额
    * 
*/ @XStreamAlias("coupon_fee") @@ -183,12 +191,12 @@ public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializa /** *
-   * 代金券使用数量
-   * coupon_count
-   * 否
-   * Int
-   * 1
-   * 代金券使用数量
+   * 字段名:代金券使用数量
+   * 变量名:coupon_count
+   * 是否必填:否
+   * 类型:Int
+   * 示例值:1
+   * 描述:代金券使用数量
    * 
*/ @XStreamAlias("coupon_count") @@ -198,12 +206,12 @@ public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializa /** *
-   * 微信支付订单号
-   * transaction_id
-   * 是
-   * String(32)
-   * 1217752501201407033233368018
-   * 微信支付订单号
+   * 字段名:微信支付订单号
+   * 变量名:transaction_id
+   * 是否必填:是
+   * 类型:String(32)
+   * 示例值:1217752501201407033233368018
+   * 描述:微信支付订单号
    * 
*/ @XStreamAlias("transaction_id") @@ -211,36 +219,36 @@ public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializa /** *
-   * 商户订单号
-   * out_trade_no
-   * 是
-   * String(32)
-   * 1212321211201407033568112322
-   * 商户系统的订单号,与请求一致。
+   * 字段名:商户订单号
+   * 变量名:out_trade_no
+   * 是否必填:是
+   * 类型:String(32)
+   * 示例值:1212321211201407033568112322
+   * 描述:商户系统的订单号,与请求一致。
    * 
*/ @XStreamAlias("out_trade_no") private String outTradeNo; /** *
-   * 商家数据包
-   * attach
-   * 否
-   * String(128)
-   * 123456
-   * 商家数据包,原样返回
+   * 字段名:商家数据包
+   * 变量名:attach
+   * 是否必填:否
+   * 类型:String(128)
+   * 示例值:123456
+   * 描述:商家数据包,原样返回
    * 
*/ @XStreamAlias("attach") private String attach; /** *
-   * 支付完成时间
-   * time_end
-   * 是
-   * String(14)
-   * 20141030133525
-   * 支付完成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则
+   * 字段名:支付完成时间
+   * 变量名:time_end
+   * 是否必填:是
+   * 类型:String(14)
+   * 示例值:20141030133525
+   * 描述:支付完成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则
    * 
*/ @XStreamAlias("time_end") @@ -311,22 +319,6 @@ public void setBankType(String bankType) { this.bankType = bankType; } - public String getSubIsSubscribe() { - return subIsSubscribe; - } - - public void setSubIsSubscribe(String subIsSubscribe) { - this.subIsSubscribe = subIsSubscribe; - } - - public String getSubOpenId() { - return subOpenId; - } - - public void setSubOpenId(String subOpenId) { - this.subOpenId = subOpenId; - } - public Integer getTotalFee() { return totalFee; } @@ -407,6 +399,22 @@ public void setTimeEnd(String timeEnd) { this.timeEnd = timeEnd; } + public String getSubOpenid() { + return this.subOpenid; + } + + public void setSubOpenid(String subOpenid) { + this.subOpenid = subOpenid; + } + + public String getSubIsSubscribe() { + return this.subIsSubscribe; + } + + public void setSubIsSubscribe(String subIsSubscribe) { + this.subIsSubscribe = subIsSubscribe; + } + @Override public Map toMap() { Map resultMap = BeanUtils.xmlBean2Map(this); From d7b32d24f9c706553d5f0f820535143048904ae0 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 3 Jul 2017 15:49:18 +0800 Subject: [PATCH 019/165] fix time --- .../mp/util/json/WxMpMaterialNewsGsonAdapter.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsGsonAdapter.java index a77a209814..084e355cbc 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsGsonAdapter.java @@ -13,6 +13,7 @@ import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; import java.lang.reflect.Type; +import java.text.SimpleDateFormat; import java.util.Date; public class WxMpMaterialNewsGsonAdapter implements JsonSerializer, JsonDeserializer { @@ -28,6 +29,16 @@ public JsonElement serialize(WxMpMaterialNews wxMpMaterialNews, Type typeOfSrc, } newsJson.add("articles", articleJsonArray); + if (wxMpMaterialNews.getCreatedTime() != null) { + newsJson.addProperty("create_time", + SimpleDateFormat.getDateTimeInstance().format(wxMpMaterialNews.getCreatedTime())); + } + + if (wxMpMaterialNews.getUpdatedTime() != null) { + newsJson.addProperty("update_time", + SimpleDateFormat.getDateTimeInstance().format(wxMpMaterialNews.getUpdatedTime())); + } + return newsJson; } @@ -45,12 +56,12 @@ public WxMpMaterialNews deserialize(JsonElement jsonElement, Type type, JsonDese } if (json.get("create_time") != null && !json.get("create_time").isJsonNull()) { - Date createTime = new Date(GsonHelper.getAsLong(json.get("create_time"))); + Date createTime = new Date(GsonHelper.getAsLong(json.get("create_time"))* 1000); wxMpMaterialNews.setCreatedTime(createTime); } if (json.get("update_time") != null && !json.get("update_time").isJsonNull()) { - Date updateTime = new Date(GsonHelper.getAsLong(json.get("update_time"))); + Date updateTime = new Date(GsonHelper.getAsLong(json.get("update_time"))* 1000); wxMpMaterialNews.setUpdatedTime(updateTime); } From 82171685031760e996515ee2bc354fd5768ac638 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 3 Jul 2017 17:36:10 +0800 Subject: [PATCH 020/165] =?UTF-8?q?=E4=BC=98=E5=8C=96javadoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/WxPayUnifiedOrderRequest.java | 214 +++++++++--------- 1 file changed, 104 insertions(+), 110 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index f5b58245d9..342a3eb2d2 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -10,13 +10,6 @@ *
  * 统一下单请求参数对象
  * 参考文档:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1
- * 注释中各行每个字段描述对应如下:
- * 
  • 字段名 - *
  • 变量名 - *
  • 是否必填 - *
  • 类型 - *
  • 示例值 - *
  • 描述 *
  • * Created by Binary Wang on 2016/9/25. * @@ -24,16 +17,16 @@ */ @XStreamAlias("xml") public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { - private static final String[] TRADE_TYPES = new String[]{"JSAPI", "NATIVE", "APP","MWEB"}; + private static final String[] TRADE_TYPES = new String[]{"JSAPI", "NATIVE", "APP", "MWEB"}; /** *
    -   * 设备号
    -   * device_info
    -   * 否
    -   * String(32)
    -   * 013467007045764
    -   * 终端设备号(门店号或收银设备Id),注意:PC网页或公众号内支付请传"WEB"
    +   * 字段名:设备号
    +   * 变量名:device_info
    +   * 是否必填:否
    +   * 类型:String(32)
    +   * 示例值:013467007045764
    +   * 描述:终端设备号(门店号或收银设备Id),注意:PC网页或公众号内支付请传"WEB"
        * 
    */ @XStreamAlias("device_info") @@ -41,12 +34,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 商品描述
    -   * body
    -   * 是
    -   * String(128)
    -   * 腾讯充值中心-QQ会员充值
    -   * 商品简单描述,该字段须严格按照规范传递,具体请见参数规定
    +   * 字段名:商品描述
    +   * 变量名:body
    +   * 是否必填:是
    +   * 类型:String(128)
    +   * 示例值: 腾讯充值中心-QQ会员充值
    +   * 描述:商品简单描述,该字段须严格按照规范传递,具体请见参数规定
        * 
    */ @Required @@ -55,12 +48,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 商品详情
    -   * detail
    -   * 否
    -   * String(6000)
    -   *  {  "goods_detail":[
    -   * {
    +   * 字段名:商品详情
    +   * 变量名:detail
    +   * 是否必填:否
    +   * 类型:String(6000)
    +   * 示例值: {  "goods_detail":[
    +   *  {
        * "goods_id":"iphone6s_16G",
        * "wxpay_goods_id":"1001",
        * "goods_name":"iPhone6s 16G",
    @@ -80,7 +73,7 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest {
        * }
        * ]
        * }
    -   * 商品详细列表,使用Json格式,传输签名前请务必使用CDATA标签将JSON文本串保护起来。
    +   * 描述:商品详细列表,使用Json格式,传输签名前请务必使用CDATA标签将JSON文本串保护起来。
        * goods_detail []:
        * └ goods_id String 必填 32 商品的编号
        * └ wxpay_goods_id String 可选 32 微信支付定义的统一商品编号
    @@ -96,12 +89,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest {
     
       /**
        * 
    -   * 附加数据
    -   * attach
    -   * 否
    -   * String(127)
    -   * 深圳分店
    -   *  附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
    +   * 字段名:附加数据
    +   * 变量名:attach
    +   * 是否必填:否
    +   * 类型:String(127)
    +   * 示例值: 深圳分店
    +   * 描述:  附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
        * 
    */ @XStreamAlias("attach") @@ -109,12 +102,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 商户订单号
    -   * out_trade_no
    -   * 是
    -   * String(32)
    -   * 20150806125346
    -   * 商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号
    +   * 字段名:商户订单号
    +   * 变量名:out_trade_no
    +   * 是否必填:是
    +   * 类型:String(32)
    +   * 示例值:20150806125346
    +   * 描述:商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号
        * 
    */ @Required @@ -123,12 +116,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 货币类型
    -   * fee_type
    -   * 否
    -   * String(16)
    -   * CNY
    -   * 符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
    +   * 字段名:货币类型
    +   * 变量名:fee_type
    +   * 是否必填:否
    +   * 类型:String(16)
    +   * 示例值:CNY
    +   * 描述: 符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
        * 
    */ @XStreamAlias("fee_type") @@ -136,12 +129,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 总金额
    -   * total_fee
    -   * 是
    -   * Int
    -   * 888
    -   * 订单总金额,单位为分,详见支付金额
    +   * 字段名:总金额
    +   * 变量名:total_fee
    +   * 是否必填:是
    +   * 类型:Int
    +   * 示例值: 888
    +   * 描述:订单总金额,单位为分,详见支付金额
        * 
    */ @Required @@ -150,12 +143,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 终端IP
    -   * spbill_create_ip
    -   * 是
    -   * String(16)
    -   * 123.12.12.123
    -   * APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。
    +   * 字段名:终端IP
    +   * 变量名:spbill_create_ip
    +   * 是否必填:是
    +   * 类型:String(16)
    +   * 示例值:123.12.12.123
    +   * 描述:APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。
        * 
    */ @Required @@ -164,12 +157,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 交易起始时间
    -   * time_start
    -   * 否
    -   * String(14)
    -   * 20091225091010
    -   * 订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则
    +   * 字段名:交易起始时间
    +   * 变量名:time_start
    +   * 是否必填:否
    +   * 类型:String(14)
    +   * 示例值:20091225091010
    +   * 描述:订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则
        * 
    */ @XStreamAlias("time_start") @@ -177,12 +170,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 交易结束时间
    -   * time_expire
    -   * 否
    -   * String(14)
    -   * 20091227091010
    -   * 订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则
    +   * 字段名:交易结束时间
    +   * 变量名:time_expire
    +   * 是否必填:否
    +   * 类型:String(14)
    +   * 示例值:20091227091010
    +   * 描述:订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则
        *   注意:最短失效时间间隔必须大于5分钟
        * 
    */ @@ -191,12 +184,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 商品标记
    -   * goods_tag
    -   * 否
    -   * String(32)
    -   * WXG
    -   * 商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠
    +   * 字段名:商品标记
    +   * 变量名:goods_tag
    +   * 是否必填:否
    +   * 类型:String(32)
    +   * 示例值:WXG
    +   * 描述:商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠
        * 
    */ @XStreamAlias("goods_tag") @@ -204,12 +197,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 通知地址
    -   * notify_url
    -   * 是
    -   * String(256)
    -   * http://www.weixin.qq.com/wxpay/pay.php
    -   * 接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。
    +   * 字段名:通知地址
    +   * 变量名:notify_url
    +   * 是否必填:是
    +   * 类型:String(256)
    +   * 示例值:http://www.weixin.qq.com/wxpay/pay.php
    +   * 描述:接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。
        * 
    */ @Required @@ -218,12 +211,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 交易类型
    -   * trade_type
    -   * 是
    -   * String(16)
    -   * JSAPI
    -   * 取值如下:JSAPI,NATIVE,APP,详细说明见参数规定:
    +   * 字段名:交易类型
    +   * 变量名:trade_type
    +   * 是否必填:是
    +   * 类型:String(16)
    +   * 示例值: JSAPI
    +   * 描述: 取值如下:JSAPI,NATIVE,APP,详细说明见参数规定:
        * JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付,统一下单接口trade_type的传参可参考这里
        * 
    */ @@ -233,12 +226,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 商品Id
    -   * product_id
    -   * 否
    -   * String(32)
    -   * 12235413214070356458058
    -   * trade_type=NATIVE,此参数必传。此id为二维码中包含的商品Id,商户自行定义。
    +   * 字段名:商品Id
    +   * 变量名:product_id
    +   * 是否必填:否
    +   * 类型:String(32)
    +   * 示例值:12235413214070356458058
    +   * 描述:trade_type=NATIVE,此参数必传。此id为二维码中包含的商品Id,商户自行定义。
        * 
    */ @XStreamAlias("product_id") @@ -246,11 +239,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 指定支付方式
    -   * limit_pay
    -   * 否
    -   * String(32)
    -   * no_credit no_credit--指定不能使用信用卡支付
    +   * 字段名:指定支付方式
    +   * 变量名:limit_pay
    +   * 是否必填:否
    +   * 类型:String(32)
    +   * 示例值:no_credit
    +   * 描述:no_credit--指定不能使用信用卡支付
        * 
    */ @XStreamAlias("limit_pay") @@ -258,12 +252,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 用户标识
    -   * openid
    -   * 否
    -   * String(128)
    -   * oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
    -   * trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。
    +   * 字段名:用户标识
    +   * 变量名:openid
    +   * 是否必填:否
    +   * 类型:String(128)
    +   * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
    +   * 描述:trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。
        * openid如何获取,可参考【获取openid】。
        * 企业号请使用【企业号OAuth2.0接口】获取企业号内成员userid,再调用【企业号userid转openid接口】进行转换
        * 
    @@ -273,12 +267,12 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    -   * 用户子标识
    -   * sub_openid
    -   * 否
    -   * String(128)
    -   * oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
    -   * trade_type=JSAPI,此参数必传,用户在子商户appid下的唯一标识。
    +   * 字段名:用户子标识
    +   * 变量名:sub_openid
    +   * 是否必填:否
    +   * 类型:String(128)
    +   * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
    +   * 描述:trade_type=JSAPI,此参数必传,用户在子商户appid下的唯一标识。
        * openid和sub_openid可以选传其中之一,如果选择传sub_openid,则必须传sub_appid。
        * 下单前需要调用【网页授权获取用户信息】接口获取到用户的Openid。
        * 
    From 1352d7247fa236712ec903cbf0c78bb8f4b997d9 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 3 Jul 2017 17:38:37 +0800 Subject: [PATCH 021/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.7.3.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 84de33cb46..a718c699bb 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.7.2.BETA + 2.7.3.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 71e09c8f49..61e4cb7842 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.2.BETA + 2.7.3.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 86c5994f4a..0fa4104a2e 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.2.BETA + 2.7.3.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index b1bb6a27d9..fc4c3f43c0 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.2.BETA + 2.7.3.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 2f1a0d6ef9..5030f42b1e 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.2.BETA + 2.7.3.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index e930a48178..0f9e4c8d8b 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.7.2.BETA + 2.7.3.BETA 4.0.0 From 55cfcb9abd23ca2a392471bd6ab4f8c532b90287 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 3 Jul 2017 17:57:44 +0800 Subject: [PATCH 022/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=89=93=E5=8C=85=E6=97=B6=E5=8F=91=E7=8E=B0=E7=9A=84=E4=B8=8D?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E7=9A=84javadoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/common/util/crypto/WxCryptUtil.java | 12 +++++------- .../common/util/http/okhttp/OkHttpProxyInfo.java | 3 +-- .../wx/miniapp/message/WxMaMessageRouterRule.java | 2 -- .../java/me/chanjar/weixin/mp/api/WxMpService.java | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java index e80419d716..e362e64b2f 100755 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java @@ -13,21 +13,23 @@ import javax.xml.parsers.ParserConfigurationException; import java.io.StringReader; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Random; /** + *
      * 对公众平台发送给公众账号的消息加解密示例代码.
    - *
    - * @copyright Copyright (c) 1998-2014 Tencent Inc.
    + * Copyright (c) 1998-2014 Tencent Inc.
      * 针对org.apache.commons.codec.binary.Base64,
      * 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本)
      * 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi
    + * 
    */ public class WxCryptUtil { private static final Base64 base64 = new Base64(); - private static final Charset CHARSET = Charset.forName("utf-8"); + private static final Charset CHARSET = StandardCharsets.UTF_8; private static final ThreadLocal builderLocal = new ThreadLocal() { @Override @@ -76,8 +78,6 @@ static String extractEncryptPart(String xml) { /** * 将一个数字转换成生成4个字节的网络字节序bytes数组 - * - * @param number */ private static byte[] number2BytesInNetworkOrder(int number) { byte[] orderBytes = new byte[4]; @@ -90,8 +90,6 @@ private static byte[] number2BytesInNetworkOrder(int number) { /** * 4个字节的网络字节序bytes数组还原成一个数字 - * - * @param bytesInNetworkOrder */ private static int bytesNetworkOrder2Number(byte[] bytesInNetworkOrder) { int sourceNumber = 0; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpProxyInfo.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpProxyInfo.java index 5515b0f713..eb9f7ac908 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpProxyInfo.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpProxyInfo.java @@ -13,6 +13,7 @@ public class OkHttpProxyInfo { private final String proxyUsername; private final String proxyPassword; private final ProxyType proxyType; + public OkHttpProxyInfo(ProxyType proxyType, String proxyHost, int proxyPort, String proxyUser, String proxyPassword) { this.proxyType = proxyType; this.proxyAddress = proxyHost; @@ -91,8 +92,6 @@ public String getProxyPassword() { /** * 返回 java.net.Proxy - * - * @return */ public Proxy getProxy() { Proxy proxy = null; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java index 9fce8b1a04..835eb2894a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java @@ -189,8 +189,6 @@ protected boolean test(WxMaMessage wxMessage) { /** * 处理微信推送过来的消息 - * - * @return true 代表继续执行别的router,false 代表停止执行别的router */ protected void service(WxMaMessage wxMessage, Map context, diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java index 71a5413523..7199d4e05c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java @@ -422,7 +422,7 @@ public interface WxMpService { void initHttp(); /** - * @return + * @return RequestHttp对象 */ RequestHttp getRequestHttp(); From 8dc2b4d0af02ce2357d3da08659f12c94a301ced Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 5 Jul 2017 12:03:44 +0800 Subject: [PATCH 023/165] =?UTF-8?q?#268=20=E4=BF=AE=E5=A4=8DWxCpUserServic?= =?UTF-8?q?eImpl=E5=88=A0=E9=99=A4=E7=94=A8=E6=88=B7=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java index c49c1ffd69..13009427c6 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java @@ -42,15 +42,12 @@ public void update(WxCpUser user) throws WxErrorException { this.mainService.post(url, user.toJson()); } - public void deleteOne(String userId) throws WxErrorException { - String url = "https://qyapi.weixin.qq.com/cgi-bin/user/delete?userid=" + userId; - this.mainService.get(url, null); - } - @Override public void delete(String... userIds) throws WxErrorException { if (userIds.length == 1) { - this.deleteOne(userIds[0]); + String url = "https://qyapi.weixin.qq.com/cgi-bin/user/delete?userid=" + userIds[0]; + this.mainService.get(url, null); + return; } String url = "https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete"; From 15d7773f8a5e1585331b35f78dafded0669210ca Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 6 Jul 2017 15:21:42 +0800 Subject: [PATCH 024/165] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/cp/api/impl/AbstractWxCpServiceImpl.java | 2 +- .../cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java | 2 +- .../chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/AbstractWxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/AbstractWxCpServiceImpl.java index 6cff26485e..be1b311857 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/AbstractWxCpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/AbstractWxCpServiceImpl.java @@ -405,7 +405,7 @@ protected synchronized T executeInternal(RequestExecutor executor, if (error.getErrorCode() != 0) { this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, data, error); - throw new WxErrorException(error); + throw new WxErrorException(error, e); } return null; } catch (IOException e) { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java index c8605d25de..023306634b 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java @@ -213,7 +213,7 @@ public synchronized T executeInternal(RequestExecutor executor, Str if (error.getErrorCode() != 0) { this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, data, error); - throw new WxErrorException(error); + throw new WxErrorException(error, e); } return null; } catch (IOException e) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java index 9dc1d755dd..d3075aa11d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java @@ -306,7 +306,7 @@ public synchronized T executeInternal(RequestExecutor executor, Str if (error.getErrorCode() != 0) { this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, data, error); - throw new WxErrorException(error); + throw new WxErrorException(error, e); } return null; } catch (IOException e) { @@ -397,7 +397,7 @@ public WxMpDeviceService getDeviceService() { } @Override - public WxMpShakeService getShakeService(){ + public WxMpShakeService getShakeService() { return this.shakeService; } From 368dbc97218960139d9d1d05433178784a9ff7f6 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 6 Jul 2017 15:44:58 +0800 Subject: [PATCH 025/165] fix javadoc --- .../java/me/chanjar/weixin/common/annotation/Required.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/annotation/Required.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/annotation/Required.java index 9370561fb7..e18be69e96 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/annotation/Required.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/annotation/Required.java @@ -6,9 +6,10 @@ import java.lang.annotation.Target; /** + *
      * 标识某个字段是否是必填的
    - * 

    * Created by Binary Wang on 2016/9/25. + *

    * * @author binarywang (https://github.com/binarywang) */ From e9f55665ec5784ed35a0d77a550ebf018946e38b Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 6 Jul 2017 15:47:06 +0800 Subject: [PATCH 026/165] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weixin-java-common/src/test/resources/logback-test.xml | 3 +-- weixin-java-cp/src/test/resources/logback-test.xml | 3 +-- weixin-java-miniapp/src/test/resources/logback-test.xml | 3 +-- weixin-java-mp/src/test/resources/logback-test.xml | 3 +-- weixin-java-pay/src/test/resources/logback-test.xml | 1 - 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/weixin-java-common/src/test/resources/logback-test.xml b/weixin-java-common/src/test/resources/logback-test.xml index e206e178ec..9a6fe3eea1 100644 --- a/weixin-java-common/src/test/resources/logback-test.xml +++ b/weixin-java-common/src/test/resources/logback-test.xml @@ -5,9 +5,8 @@ - + - diff --git a/weixin-java-cp/src/test/resources/logback-test.xml b/weixin-java-cp/src/test/resources/logback-test.xml index ec3deca97f..e4a33acd88 100644 --- a/weixin-java-cp/src/test/resources/logback-test.xml +++ b/weixin-java-cp/src/test/resources/logback-test.xml @@ -6,9 +6,8 @@ - + - diff --git a/weixin-java-miniapp/src/test/resources/logback-test.xml b/weixin-java-miniapp/src/test/resources/logback-test.xml index 14d6a9a79b..e4a33acd88 100644 --- a/weixin-java-miniapp/src/test/resources/logback-test.xml +++ b/weixin-java-miniapp/src/test/resources/logback-test.xml @@ -6,9 +6,8 @@ - + - diff --git a/weixin-java-mp/src/test/resources/logback-test.xml b/weixin-java-mp/src/test/resources/logback-test.xml index 8e87c71af2..e4a33acd88 100644 --- a/weixin-java-mp/src/test/resources/logback-test.xml +++ b/weixin-java-mp/src/test/resources/logback-test.xml @@ -6,9 +6,8 @@ - + - diff --git a/weixin-java-pay/src/test/resources/logback-test.xml b/weixin-java-pay/src/test/resources/logback-test.xml index 75de28c04c..35deb2ed28 100644 --- a/weixin-java-pay/src/test/resources/logback-test.xml +++ b/weixin-java-pay/src/test/resources/logback-test.xml @@ -12,5 +12,4 @@ - From dde7c643fa998d6a9c640c4af8ef816cc6de95c8 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 6 Jul 2017 15:59:13 +0800 Subject: [PATCH 027/165] =?UTF-8?q?#269=20=E4=BF=AE=E5=A4=8Dokhttp?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=B4=A0=E6=9D=90=E4=B8=8A=E4=BC=A0=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OkHttpMediaUploadRequestExecutor.java | 8 +++-- .../OkhttpMaterialUploadRequestExecutor.java | 35 ++++++++++--------- .../OkhttpMediaImgUploadRequestExecutor.java | 16 +++++---- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java index c01b373808..91b36d7da6 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java @@ -39,8 +39,12 @@ public Request authenticate(Route route, Response response) throws IOException { //得到httpClient OkHttpClient client = clientBuilder.build(); - RequestBody fileBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); - RequestBody body = new MultipartBody.Builder().addFormDataPart("media", null, fileBody).build(); + RequestBody body = new MultipartBody.Builder() + .setType(MediaType.parse("multipart/form-data")) + .addFormDataPart("media", + file.getName(), + RequestBody.create(MediaType.parse("application/octet-stream"), file)) + .build(); Request request = new Request.Builder().url(uri).post(body).build(); Response response = client.newCall(request).execute(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java index 27a9b5bfc7..3770aa1b67 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java @@ -25,6 +25,14 @@ public OkhttpMaterialUploadRequestExecutor(RequestHttp requestHttp) { @Override public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material) throws WxErrorException, IOException { + if (material == null) { + throw new WxErrorException(WxError.newBuilder().setErrorMsg("非法请求,material参数为空").build()); + } + File file = material.getFile(); + if (file == null || !file.exists()) { + throw new FileNotFoundException(); + } + OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); //设置代理 if (requestHttp.getRequestHttpProxy() != null) { @@ -40,27 +48,19 @@ public Request authenticate(Route route, Response response) throws IOException { .build(); } }); - //得到httpClient - OkHttpClient client = clientBuilder.build(); - - if (material == null) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg("非法请求,material参数为空").build()); - } - - File file = material.getFile(); - if (file == null || !file.exists()) { - throw new FileNotFoundException(); - } - RequestBody fileBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); - MultipartBody.Builder bodyBuilder = new MultipartBody.Builder().addFormDataPart("media", null, fileBody); + MultipartBody.Builder bodyBuilder = new MultipartBody.Builder() + .setType(MediaType.parse("multipart/form-data")) + .addFormDataPart("media", + file.getName(), + RequestBody.create(MediaType.parse("application/octet-stream"), file)); Map form = material.getForm(); - if (material.getForm() != null) { + if (form != null) { bodyBuilder.addFormDataPart("description", WxGsonBuilder.create().toJson(form)); } - RequestBody body = bodyBuilder.build(); - Request request = new Request.Builder().url(uri).post(body).build(); - Response response = client.newCall(request).execute(); + + Request request = new Request.Builder().url(uri).post(bodyBuilder.build()).build(); + Response response = clientBuilder.build().newCall(request).execute(); String responseContent = response.body().string(); WxError error = WxError.fromJson(responseContent); if (error.getErrorCode() != 0) { @@ -69,4 +69,5 @@ public Request authenticate(Route route, Response response) throws IOException { return WxMpMaterialUploadResult.fromJson(responseContent); } } + } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMediaImgUploadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMediaImgUploadRequestExecutor.java index 3d8abd394a..3b10f63bcf 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMediaImgUploadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMediaImgUploadRequestExecutor.java @@ -21,7 +21,7 @@ public OkhttpMediaImgUploadRequestExecutor(RequestHttp requestHttp) { } @Override - public WxMediaImgUploadResult execute(String uri, File data) throws WxErrorException, IOException { + public WxMediaImgUploadResult execute(String uri, File file) throws WxErrorException, IOException { OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); //设置代理 if (requestHttp.getRequestHttpProxy() != null) { @@ -37,14 +37,16 @@ public Request authenticate(Route route, Response response) throws IOException { .build(); } }); - //得到httpClient - OkHttpClient client = clientBuilder.build(); - RequestBody fileBody = RequestBody.create(MediaType.parse("multipart/form-data"), data); - RequestBody body = new MultipartBody.Builder().addFormDataPart("media", null, fileBody).build(); - Request request = new Request.Builder().url(uri).post(body).build(); + RequestBody body = new MultipartBody.Builder() + .setType(MediaType.parse("multipart/form-data")) + .addFormDataPart("media", + file.getName(), + RequestBody.create(MediaType.parse("application/octet-stream"), file)) + .build(); - Response response = client.newCall(request).execute(); + Request request = new Request.Builder().url(uri).post(body).build(); + Response response = clientBuilder.build().newCall(request).execute(); String responseContent = response.body().string(); WxError error = WxError.fromJson(responseContent); if (error.getErrorCode() != 0) { From fd4b8e1541deec55c002b24d3b013a224821e6ce Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 6 Jul 2017 16:02:07 +0800 Subject: [PATCH 028/165] =?UTF-8?q?=E8=AE=A9httpclient=E6=94=AF=E6=8C=81sl?= =?UTF-8?q?f4j=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weixin-java-common/pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 61e4cb7842..f198bd70d9 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -37,11 +37,23 @@ org.apache.httpcomponents httpclient + + + commons-logging + commons-logging + + org.apache.httpcomponents httpmime + + org.slf4j + jcl-over-slf4j + 1.7.24 + + com.google.code.gson gson From b3f50e26c21965c4b983f79519bce62e28dbe187 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 6 Jul 2017 16:29:46 +0800 Subject: [PATCH 029/165] add maven-checkstyle-plugin --- pom.xml | 20 +++ quality-checks/google_checks.xml | 217 +++++++++++++++++++++++++++++++ 2 files changed, 237 insertions(+) create mode 100644 quality-checks/google_checks.xml diff --git a/pom.xml b/pom.xml index a718c699bb..3383cb0fb7 100644 --- a/pom.xml +++ b/pom.xml @@ -349,6 +349,26 @@ UTF-8 + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.17 + + quality-checks/google_checks.xml + true + true + true + + + + verify + + check + + + + diff --git a/quality-checks/google_checks.xml b/quality-checks/google_checks.xml new file mode 100644 index 0000000000..925172dab6 --- /dev/null +++ b/quality-checks/google_checks.xml @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c5c204b25db4c10fb91f2be8eefe80e6779de829 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 8 Jul 2017 15:55:48 +0800 Subject: [PATCH 030/165] =?UTF-8?q?#270=20NewArticle=E5=92=8CMpnewsArticle?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=BA=8F=E5=88=97=E5=8C=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/cp/bean/article/MpnewsArticle.java | 6 +++++- .../java/me/chanjar/weixin/cp/bean/article/NewArticle.java | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/MpnewsArticle.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/MpnewsArticle.java index 82c4e2aaa6..b3f4acf402 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/MpnewsArticle.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/MpnewsArticle.java @@ -1,5 +1,7 @@ package me.chanjar.weixin.cp.bean.article; +import java.io.Serializable; + /** *
      *  Created by BinaryWang on 2017/3/27.
    @@ -7,7 +9,9 @@
      *
      * @author Binary Wang
      */
    -public class MpnewsArticle {
    +public class MpnewsArticle implements Serializable {
    +  private static final long serialVersionUID = 6985871812170756481L;
    +
       private String title;
       private String thumbMediaId;
       private String author;
    diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java
    index d4c056d5ad..02b0b1086f 100644
    --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java
    +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java
    @@ -1,5 +1,7 @@
     package me.chanjar.weixin.cp.bean.article;
     
    +import java.io.Serializable;
    +
     /**
      * 
      *  Created by BinaryWang on 2017/3/27.
    @@ -7,7 +9,8 @@
      *
      * @author Binary Wang
      */
    -public class NewArticle {
    +public class NewArticle implements Serializable {
    +  private static final long serialVersionUID = 4087852055781140659L;
     
       private String title;
       private String description;
    
    From d3c691af094884e0766e1b76418341d91457bac5 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Sat, 8 Jul 2017 16:01:46 +0800
    Subject: [PATCH 031/165] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?=
     =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=AF=B7=E6=B1=82=E5=A2=9E=E5=8A=A0=E8=B6=85?=
     =?UTF-8?q?=E6=97=B6=E6=97=B6=E9=97=B4=E7=9A=84=E8=AE=BE=E7=BD=AE=E5=8F=82?=
     =?UTF-8?q?=E6=95=B0?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../binarywang/wxpay/config/WxPayConfig.java  | 33 +++++++++++++++++++
     .../wxpay/service/impl/WxPayServiceImpl.java  | 10 ++++--
     2 files changed, 40 insertions(+), 3 deletions(-)
    
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java
    index d05259ceeb..aeab939a06 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java
    @@ -18,6 +18,17 @@
      * @author Binary Wang (https://github.com/binarywang)
      */
     public class WxPayConfig {
    +
    +  /**
    +   * http请求连接超时时间
    +   */
    +  private int httpConnectionTimeout = 5000;
    +
    +  /**
    +   * http请求数据读取等待时间
    +   */
    +  private int httpTimeout = 10000;
    +
       private String appId;
       private String subAppId;
       private String mchId;
    @@ -194,4 +205,26 @@ public SSLContext initSSLContext() throws WxPayException {
           IOUtils.closeQuietly(inputStream);
         }
       }
    +
    +  /**
    +   * http请求连接超时时间
    +   */
    +  public int getHttpConnectionTimeout() {
    +    return this.httpConnectionTimeout;
    +  }
    +
    +  public void setHttpConnectionTimeout(int httpConnectionTimeout) {
    +    this.httpConnectionTimeout = httpConnectionTimeout;
    +  }
    +
    +  /**
    +   * http请求数据读取等待时间
    +   */
    +  public int getHttpTimeout() {
    +    return this.httpTimeout;
    +  }
    +
    +  public void setHttpTimeout(int httpTimeout) {
    +    this.httpTimeout = httpTimeout;
    +  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java
    index bcf425d792..a2b036e8e8 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java
    @@ -465,9 +465,11 @@ public String getSandboxSignKey() throws WxPayException {
        * @return 返回请求结果
        */
       private String post(String url, String xmlParam) throws WxPayException {
    -    String requestString = new String(xmlParam.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
    -
    -    HttpRequest request = HttpRequest.post(url).body(requestString);
    +    HttpRequest request = HttpRequest
    +      .post(url)
    +      .timeout(this.config.getHttpTimeout())
    +      .connectionTimeout(this.config.getHttpConnectionTimeout())
    +      .body(new String(xmlParam.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
         String responseString = this.getResponseString(request.send());
     
         this.log.info("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", url, xmlParam, responseString);
    @@ -489,6 +491,8 @@ private String postWithKey(String url, String requestStr) throws WxPayException
     
           HttpRequest request = HttpRequest
             .post(url)
    +        .timeout(this.config.getHttpTimeout())
    +        .connectionTimeout(this.config.getHttpConnectionTimeout())
             .withConnectionProvider(new SSLSocketHttpConnectionProvider(sslContext))
             .bodyText(requestStr);
     
    
    From c3cb050a8aad56e0a5fb78cb2c5c33038620537e Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Sat, 8 Jul 2017 16:14:03 +0800
    Subject: [PATCH 032/165] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AE=80=E5=8C=96?=
     =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E8=AF=B7=E6=B1=82=E4=BB=A3?=
     =?UTF-8?q?=E7=A0=81?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../wxpay/service/impl/WxPayServiceImpl.java  | 75 ++++++++-----------
     1 file changed, 30 insertions(+), 45 deletions(-)
    
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java
    index a2b036e8e8..f799a2c974 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java
    @@ -57,7 +57,7 @@ public WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayExceptio
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/secapi/pay/refund";
    -    String responseContent = this.postWithKey(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), true);
         WxPayRefundResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundResult.class);
         result.checkResult(this);
         return result;
    @@ -75,7 +75,7 @@ public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeN
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/pay/refundquery";
    -    String responseContent = this.post(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), false);
         WxPayRefundQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundQueryResult.class);
         result.composeRefundRecords();
         result.checkResult(this);
    @@ -109,7 +109,7 @@ public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throw
           url = this.getPayBaseUrl() + "/mmpaymkttransfers/sendgroupredpack";
         }
     
    -    String responseContent = this.postWithKey(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), true);
         WxPaySendRedpackResult result = WxPayBaseResult.fromXML(responseContent, WxPaySendRedpackResult.class);
         //毋须校验,因为没有返回签名信息
         // this.checkResult(result);
    @@ -124,7 +124,7 @@ public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayExcept
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo";
    -    String responseContent = this.postWithKey(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), true);
         WxPayRedpackQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRedpackQueryResult.class);
         result.checkResult(this);
         return result;
    @@ -138,7 +138,7 @@ public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo)
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/pay/orderquery";
    -    String responseContent = this.post(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), false);
         if (StringUtils.isBlank(responseContent)) {
           throw new WxPayException("无响应结果");
         }
    @@ -160,7 +160,7 @@ public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/pay/closeorder";
    -    String responseContent = this.post(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), false);
         WxPayOrderCloseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderCloseResult.class);
         result.checkResult(this);
     
    @@ -172,7 +172,7 @@ public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) th
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/pay/unifiedorder";
    -    String responseContent = this.post(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), false);
         WxPayUnifiedOrderResult result = WxPayBaseResult.fromXML(responseContent, WxPayUnifiedOrderResult.class);
         result.checkResult(this);
         return result;
    @@ -227,7 +227,7 @@ public WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException {
         request.checkAndSign(this.getConfig());
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/promotion/transfers";
     
    -    String responseContent = this.postWithKey(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), true);
         WxEntPayResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayResult.class);
         result.checkResult(this);
         return result;
    @@ -240,7 +240,7 @@ public WxEntPayQueryResult queryEntPay(String partnerTradeNo) throws WxPayExcept
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gettransferinfo";
    -    String responseContent = this.postWithKey(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), true);
         WxEntPayQueryResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayQueryResult.class);
         result.checkResult(this);
         return result;
    @@ -293,7 +293,7 @@ public void report(WxPayReportRequest request) throws WxPayException {
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/payitil/report";
    -    String responseContent = this.post(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), false);
         WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class);
         result.checkResult(this);
       }
    @@ -309,7 +309,7 @@ public WxPayBillResult downloadBill(String billDate, String billType, String tar
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/pay/downloadbill";
    -    String responseContent = this.post(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), false);
         if (responseContent.startsWith("<")) {
           WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class);
           result.checkResult(this);
    @@ -396,7 +396,7 @@ public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxPayEx
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/pay/micropay";
    -    String responseContent = this.post(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), false);
         WxPayMicropayResult result = WxPayBaseResult.fromXML(responseContent, WxPayMicropayResult.class);
         result.checkResult(this);
         return result;
    @@ -407,7 +407,7 @@ public WxPayOrderReverseResult reverseOrder(WxPayOrderReverseRequest request) th
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/secapi/pay/reverse";
    -    String responseContent = this.postWithKey(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), true);
         WxPayOrderReverseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderReverseResult.class);
         result.checkResult(this);
         return result;
    @@ -418,7 +418,7 @@ public String shorturl(WxPayShorturlRequest request) throws WxPayException {
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/tools/shorturl";
    -    String responseContent = this.post(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), false);
         WxPayShorturlResult result = WxPayBaseResult.fromXML(responseContent, WxPayShorturlResult.class);
         result.checkResult(this);
         return result.getShortUrl();
    @@ -434,7 +434,7 @@ public String authcode2Openid(WxPayAuthcode2OpenidRequest request) throws WxPayE
         request.checkAndSign(this.getConfig());
     
         String url = this.getPayBaseUrl() + "/tools/authcodetoopenid";
    -    String responseContent = this.post(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), false);
         WxPayAuthcode2OpenidResult result = WxPayBaseResult.fromXML(responseContent, WxPayAuthcode2OpenidResult.class);
         result.checkResult(this);
         return result.getOpenid();
    @@ -451,57 +451,42 @@ public String getSandboxSignKey() throws WxPayException {
         request.checkAndSign(this.getConfig());
     
         String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey";
    -    String responseContent = this.post(url, request.toXML());
    +    String responseContent = this.post(url, request.toXML(), false);
         WxPaySandboxSignKeyResult result = WxPayBaseResult.fromXML(responseContent, WxPaySandboxSignKeyResult.class);
         result.checkResult(this);
         return result.getSandboxSignKey();
       }
     
       /**
    -   * 执行post请求
    -   *
    -   * @param url      请求地址
    -   * @param xmlParam 请求字符串
    -   * @return 返回请求结果
    -   */
    -  private String post(String url, String xmlParam) throws WxPayException {
    -    HttpRequest request = HttpRequest
    -      .post(url)
    -      .timeout(this.config.getHttpTimeout())
    -      .connectionTimeout(this.config.getHttpConnectionTimeout())
    -      .body(new String(xmlParam.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
    -    String responseString = this.getResponseString(request.send());
    -
    -    this.log.info("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", url, xmlParam, responseString);
    -    return responseString;
    -  }
    -
    -  /**
    -   * 带证书发送post请求
    +   * 发送post请求
        *
        * @param url        请求地址
        * @param requestStr 请求信息
    +   * @param useKey     是否使用证书
    +   * @return 返回请求结果字符串
        */
    -  private String postWithKey(String url, String requestStr) throws WxPayException {
    +  private String post(String url, String requestStr, boolean useKey) throws WxPayException {
         try {
    -      SSLContext sslContext = this.getConfig().getSslContext();
    -      if (null == sslContext) {
    -        sslContext = this.getConfig().initSSLContext();
    -      }
    -
           HttpRequest request = HttpRequest
             .post(url)
             .timeout(this.config.getHttpTimeout())
             .connectionTimeout(this.config.getHttpConnectionTimeout())
    -        .withConnectionProvider(new SSLSocketHttpConnectionProvider(sslContext))
             .bodyText(requestStr);
     
    +      if (useKey) {
    +        SSLContext sslContext = this.getConfig().getSslContext();
    +        if (null == sslContext) {
    +          sslContext = this.getConfig().initSSLContext();
    +        }
    +        request.withConnectionProvider(new SSLSocketHttpConnectionProvider(sslContext));
    +      }
    +
           String responseString = this.getResponseString(request.send());
     
    -      this.log.info("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", url, requestStr, responseString);
    +      this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, responseString);
           return responseString;
         } catch (Exception e) {
    -      this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", url, requestStr, e.getMessage());
    +      this.log.error("\n【请求地址】:{}\n【请求数据】:{}\n【异常信息】:{}", url, requestStr, e.getMessage());
           throw new WxPayException(e.getMessage(), e);
         }
       }
    
    From 1cd6618f82b1f734be18274963018eafd73de633 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Sat, 8 Jul 2017 16:16:15 +0800
    Subject: [PATCH 033/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?=
     =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.7.4.BETA?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     pom.xml                     | 2 +-
     weixin-java-common/pom.xml  | 2 +-
     weixin-java-cp/pom.xml      | 2 +-
     weixin-java-miniapp/pom.xml | 2 +-
     weixin-java-mp/pom.xml      | 2 +-
     weixin-java-pay/pom.xml     | 2 +-
     6 files changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/pom.xml b/pom.xml
    index 3383cb0fb7..5f1d901d4b 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -6,7 +6,7 @@
       4.0.0
       com.github.binarywang
       weixin-java-parent
    -  2.7.3.BETA
    +  2.7.4.BETA
       pom
       WeiXin Java Tools - Parent
       微信公众号、企业号上级POM
    diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml
    index f198bd70d9..3800522ceb 100644
    --- a/weixin-java-common/pom.xml
    +++ b/weixin-java-common/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.7.3.BETA
    +    2.7.4.BETA
       
     
       weixin-java-common
    diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml
    index 0fa4104a2e..1790105d8f 100644
    --- a/weixin-java-cp/pom.xml
    +++ b/weixin-java-cp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.7.3.BETA
    +    2.7.4.BETA
       
     
       weixin-java-cp
    diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml
    index fc4c3f43c0..60d1194a78 100644
    --- a/weixin-java-miniapp/pom.xml
    +++ b/weixin-java-miniapp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.7.3.BETA
    +    2.7.4.BETA
       
       weixin-java-miniapp
       WeiXin Java Tools - MiniApp
    diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml
    index 5030f42b1e..d65bceef9f 100644
    --- a/weixin-java-mp/pom.xml
    +++ b/weixin-java-mp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.7.3.BETA
    +    2.7.4.BETA
       
       weixin-java-mp
       WeiXin Java Tools - MP
    diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml
    index 0f9e4c8d8b..7e9780f881 100644
    --- a/weixin-java-pay/pom.xml
    +++ b/weixin-java-pay/pom.xml
    @@ -5,7 +5,7 @@
       
         weixin-java-parent
         com.github.binarywang
    -    2.7.3.BETA
    +    2.7.4.BETA
       
       4.0.0
     
    
    From 166e54c3f589018234dc08d09bd3e59244a86549 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Sat, 8 Jul 2017 17:37:33 +0800
    Subject: [PATCH 034/165] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?=
     =?UTF-8?q?=E6=A8=A1=E5=9D=97=E8=B0=83=E6=95=B4=EF=BC=8C=E8=B7=9F=E5=85=B6?=
     =?UTF-8?q?=E4=BB=96=E6=A8=A1=E5=9D=97=E4=BF=9D=E6=8C=81=E7=BB=9F=E4=B8=80?=
     =?UTF-8?q?,=E9=BB=98=E8=AE=A4=E4=BD=BF=E7=94=A8apache=20httpclient?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     weixin-java-pay/pom.xml                       |   3 +-
     .../wxpay/bean/result/WxPayBaseResult.java    |   4 +-
     .../impl/WxPayServiceAbstractImpl.java        | 466 ++++++++++++++++
     .../impl/WxPayServiceApacheHttpImpl.java      |  66 +++
     .../wxpay/service/impl/WxPayServiceImpl.java  | 515 +-----------------
     .../impl/WxPayServiceJoddHttpImpl.java        |  68 +++
     6 files changed, 610 insertions(+), 512 deletions(-)
     create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
     create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java
     create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java
    
    diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml
    index 7e9780f881..7bb79b229d 100644
    --- a/weixin-java-pay/pom.xml
    +++ b/weixin-java-pay/pom.xml
    @@ -23,10 +23,11 @@
           com.github.binarywang
           qrcode-utils
         
    +
         
           org.jodd
           jodd-http
    -      compile
    +      provided
         
     
         
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java
    index 3f07a58199..802e22b312 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java
    @@ -1,7 +1,7 @@
     package com.github.binarywang.wxpay.bean.result;
     
     import com.github.binarywang.wxpay.exception.WxPayException;
    -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
    +import com.github.binarywang.wxpay.service.impl.WxPayServiceAbstractImpl;
     import com.github.binarywang.wxpay.util.SignUtils;
     import com.google.common.base.Joiner;
     import com.google.common.collect.Maps;
    @@ -307,7 +307,7 @@ protected Integer getXmlValueAsInt(String... path) {
       /**
        * 校验返回结果签名
        */
    -  public void checkResult(WxPayServiceImpl wxPayService) throws WxPayException {
    +  public void checkResult(WxPayServiceAbstractImpl wxPayService) throws WxPayException {
         //校验返回结果签名
         Map map = toMap();
         if (getSign() != null && !SignUtils.checkSign(map, wxPayService.getConfig().getMchKey())) {
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    new file mode 100644
    index 0000000000..aa9291760c
    --- /dev/null
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    @@ -0,0 +1,466 @@
    +package com.github.binarywang.wxpay.service.impl;
    +
    +import com.github.binarywang.utils.qrcode.QrcodeUtils;
    +import com.github.binarywang.wxpay.bean.request.*;
    +import com.github.binarywang.wxpay.bean.result.*;
    +import com.github.binarywang.wxpay.config.WxPayConfig;
    +import com.github.binarywang.wxpay.exception.WxPayException;
    +import com.github.binarywang.wxpay.service.WxPayService;
    +import com.github.binarywang.wxpay.util.SignUtils;
    +import com.google.common.collect.Maps;
    +import org.apache.commons.lang3.StringUtils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.File;
    +import java.util.HashMap;
    +import java.util.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * 
    + *  微信支付接口请求抽象实现类
    + * Created by Binary Wang on 2017-7-8.
    + * 
    + * @author Binary Wang + */ +public abstract class WxPayServiceAbstractImpl implements WxPayService { + private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com"; + protected final Logger log = LoggerFactory.getLogger(this.getClass()); + + protected WxPayConfig config; + + @Override + public WxPayConfig getConfig() { + return this.config; + } + + @Override + public void setConfig(WxPayConfig config) { + this.config = config; + } + + private String getPayBaseUrl() { + if (this.getConfig().useSandbox()) { + return PAY_BASE_URL + "/sandboxnew"; + } + + return PAY_BASE_URL; + } + + /** + * 发送post请求 + * + * @param url 请求地址 + * @param requestStr 请求信息 + * @param useKey 是否使用证书 + * @return 返回请求结果字符串 + */ + protected abstract String post(String url, String requestStr, boolean useKey) throws WxPayException; + + @Override + public WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/secapi/pay/refund"; + String responseContent = this.post(url, request.toXML(), true); + WxPayRefundResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundResult.class); + result.checkResult(this); + return result; + } + + @Override + public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, String outRefundNo, String refundId) + throws WxPayException { + WxPayRefundQueryRequest request = new WxPayRefundQueryRequest(); + request.setOutTradeNo(StringUtils.trimToNull(outTradeNo)); + request.setTransactionId(StringUtils.trimToNull(transactionId)); + request.setOutRefundNo(StringUtils.trimToNull(outRefundNo)); + request.setRefundId(StringUtils.trimToNull(refundId)); + + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/pay/refundquery"; + String responseContent = this.post(url, request.toXML(), false); + WxPayRefundQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundQueryResult.class); + result.composeRefundRecords(); + result.checkResult(this); + return result; + } + + @Override + public WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayException { + try { + log.debug("微信支付回调参数详细:{}", xmlData); + WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData); + log.debug("微信支付回调结果对象:{}", result); + result.checkResult(this); + return result; + } catch (WxPayException e) { + log.error(e.getMessage(), e); + throw e; + } catch (Exception e) { + log.error(e.getMessage(), e); + throw new WxPayException("发生异常," + e.getMessage(), e); + } + } + + @Override + public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/mmpaymkttransfers/sendredpack"; + if (request.getAmtType() != null) { + //裂变红包 + url = this.getPayBaseUrl() + "/mmpaymkttransfers/sendgroupredpack"; + } + + String responseContent = this.post(url, request.toXML(), true); + WxPaySendRedpackResult result = WxPayBaseResult.fromXML(responseContent, WxPaySendRedpackResult.class); + //毋须校验,因为没有返回签名信息 + // this.checkResult(result); + return result; + } + + @Override + public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayException { + WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest(); + request.setMchBillNo(mchBillNo); + request.setBillType("MCHT"); + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo"; + String responseContent = this.post(url, request.toXML(), true); + WxPayRedpackQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRedpackQueryResult.class); + result.checkResult(this); + return result; + } + + @Override + public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) throws WxPayException { + WxPayOrderQueryRequest request = new WxPayOrderQueryRequest(); + request.setOutTradeNo(StringUtils.trimToNull(outTradeNo)); + request.setTransactionId(StringUtils.trimToNull(transactionId)); + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/pay/orderquery"; + String responseContent = this.post(url, request.toXML(), false); + if (StringUtils.isBlank(responseContent)) { + throw new WxPayException("无响应结果"); + } + + WxPayOrderQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderQueryResult.class); + result.composeCoupons(); + result.checkResult(this); + return result; + } + + @Override + public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException { + if (StringUtils.isBlank(outTradeNo)) { + throw new IllegalArgumentException("out_trade_no不能为空"); + } + + WxPayOrderCloseRequest request = new WxPayOrderCloseRequest(); + request.setOutTradeNo(StringUtils.trimToNull(outTradeNo)); + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/pay/closeorder"; + String responseContent = this.post(url, request.toXML(), false); + WxPayOrderCloseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderCloseResult.class); + result.checkResult(this); + + return result; + } + + @Override + public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/pay/unifiedorder"; + String responseContent = this.post(url, request.toXML(), false); + WxPayUnifiedOrderResult result = WxPayBaseResult.fromXML(responseContent, WxPayUnifiedOrderResult.class); + result.checkResult(this); + return result; + } + + @Override + public Map getPayInfo(WxPayUnifiedOrderRequest request) throws WxPayException { + WxPayUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request); + String prepayId = unifiedOrderResult.getPrepayId(); + if (StringUtils.isBlank(prepayId)) { + throw new RuntimeException(String.format("无法获取prepay id,错误代码: '%s',信息:%s。", + unifiedOrderResult.getErrCode(), unifiedOrderResult.getErrCodeDes())); + } + + Map payInfo = new HashMap<>(); + if ("NATIVE".equals(request.getTradeType())) { + payInfo.put("codeUrl", unifiedOrderResult.getCodeURL()); + } else if ("APP".equals(request.getTradeType())) { + // APP支付绑定的是微信开放平台上的账号,APPID为开放平台上绑定APP后发放的参数 + String appId = getConfig().getAppId(); + Map configMap = new HashMap<>(); + // 此map用于参与调起sdk支付的二次签名,格式全小写,timestamp只能是10位,格式固定,切勿修改 + String partnerid = getConfig().getMchId(); + configMap.put("prepayid", prepayId); + configMap.put("partnerid", partnerid); + configMap.put("package", "Sign=WXPay"); + configMap.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000)); + configMap.put("noncestr", String.valueOf(System.currentTimeMillis())); + configMap.put("appid", appId); + // 此map用于客户端与微信服务器交互 + payInfo.put("sign", SignUtils.createSign(configMap, this.getConfig().getMchKey())); + payInfo.put("prepayId", prepayId); + payInfo.put("partnerId", partnerid); + payInfo.put("appId", appId); + payInfo.put("packageValue", "Sign=WXPay"); + payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000)); + payInfo.put("nonceStr", String.valueOf(System.currentTimeMillis())); + } else if ("JSAPI".equals(request.getTradeType())) { + payInfo.put("appId", unifiedOrderResult.getAppid()); + // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 + payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000)); + payInfo.put("nonceStr", String.valueOf(System.currentTimeMillis())); + payInfo.put("package", "prepay_id=" + prepayId); + payInfo.put("signType", "MD5"); + payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey())); + } + return payInfo; + } + + @Override + public WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + String url = this.getPayBaseUrl() + "/mmpaymkttransfers/promotion/transfers"; + + String responseContent = this.post(url, request.toXML(), true); + WxEntPayResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayResult.class); + result.checkResult(this); + return result; + } + + @Override + public WxEntPayQueryResult queryEntPay(String partnerTradeNo) throws WxPayException { + WxEntPayQueryRequest request = new WxEntPayQueryRequest(); + request.setPartnerTradeNo(partnerTradeNo); + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gettransferinfo"; + String responseContent = this.post(url, request.toXML(), true); + WxEntPayQueryResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayQueryResult.class); + result.checkResult(this); + return result; + } + + @Override + public byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength) { + String content = this.createScanPayQrcodeMode1(productId); + return this.createQrcode(content, logoFile, sideLength); + } + + @Override + public String createScanPayQrcodeMode1(String productId) { + //weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX + StringBuilder codeUrl = new StringBuilder("weixin://wxpay/bizpayurl?"); + Map params = Maps.newHashMap(); + params.put("appid", this.getConfig().getAppId()); + params.put("mch_id", this.getConfig().getMchId()); + params.put("product_id", productId); + params.put("time_stamp", String.valueOf(System.currentTimeMillis() / 1000));//这里需要秒,10位数字 + params.put("nonce_str", String.valueOf(System.currentTimeMillis())); + + String sign = SignUtils.createSign(params, this.getConfig().getMchKey()); + params.put("sign", sign); + + + for (String key : params.keySet()) { + codeUrl.append(key + "=" + params.get(key) + "&"); + } + + String content = codeUrl.toString().substring(0, codeUrl.length() - 1); + log.debug("扫码支付模式一生成二维码的URL:{}", content); + return content; + } + + @Override + public byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) { + return this.createQrcode(codeUrl, logoFile, sideLength); + } + + private byte[] createQrcode(String content, File logoFile, Integer sideLength) { + if (sideLength == null || sideLength < 1) { + return QrcodeUtils.createQrcode(content, logoFile); + } + + return QrcodeUtils.createQrcode(content, sideLength, logoFile); + } + + public void report(WxPayReportRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/payitil/report"; + String responseContent = this.post(url, request.toXML(), false); + WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class); + result.checkResult(this); + } + + @Override + public WxPayBillResult downloadBill(String billDate, String billType, String tarType, String deviceInfo) throws WxPayException { + WxPayDownloadBillRequest request = new WxPayDownloadBillRequest(); + request.setBillType(billType); + request.setBillDate(billDate); + request.setTarType(tarType); + request.setDeviceInfo(deviceInfo); + + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/pay/downloadbill"; + String responseContent = this.post(url, request.toXML(), false); + if (responseContent.startsWith("<")) { + WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class); + result.checkResult(this); + return null; + } else { + WxPayBillResult wxPayBillResult = billInformationDeal(responseContent); + return wxPayBillResult; + } + } + + private WxPayBillResult billInformationDeal(String responseContent) { + WxPayBillResult wxPayBillResult = new WxPayBillResult(); + + String listStr = ""; + String objStr = ""; + if (responseContent.contains("总交易单数")) { + listStr = responseContent.substring(0, responseContent.indexOf("总交易单数")); + objStr = responseContent.substring(responseContent.indexOf("总交易单数")); + } + + /* + * 交易时间:2017-04-06 01:00:02 公众账号ID: 商户号: 子商户号:0 设备号:WEB 微信订单号: 商户订单号:2017040519091071873216 用户标识: 交易类型:NATIVE + * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00 + * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60% + */ + + // 参考以上格式进行取值 + + List wxPayBillBaseResultLst = new LinkedList<>(); + String newStr = listStr.replaceAll(",", " "); // 去空格 + String[] tempStr = newStr.split("`"); // 数据分组 + String[] t = tempStr[0].split(" ");// 分组标题 + int j = tempStr.length / t.length; // 计算循环次数 + int k = 1; // 纪录数组下标 + for (int i = 0; i < j; i++) { + WxPayBillBaseResult wxPayBillBaseResult = new WxPayBillBaseResult(); + + wxPayBillBaseResult.setTradeTime(tempStr[k]); + wxPayBillBaseResult.setAppId(tempStr[k + 1]); + wxPayBillBaseResult.setMchId(tempStr[k + 2]); + wxPayBillBaseResult.setSubMchId(tempStr[k + 3]); + wxPayBillBaseResult.setDeviceInfo(tempStr[k + 4]); + wxPayBillBaseResult.setTransationId(tempStr[k + 5]); + wxPayBillBaseResult.setOutTradeNo(tempStr[k + 6]); + wxPayBillBaseResult.setOpenId(tempStr[k + 7]); + wxPayBillBaseResult.setTradeType(tempStr[k + 8]); + wxPayBillBaseResult.setTradeState(tempStr[k + 9]); + wxPayBillBaseResult.setBankType(tempStr[k + 10]); + wxPayBillBaseResult.setFeeType(tempStr[k + 11]); + wxPayBillBaseResult.setTotalFee(tempStr[k + 12]); + wxPayBillBaseResult.setCouponFee(tempStr[k + 13]); + wxPayBillBaseResult.setRefundId(tempStr[k + 14]); + wxPayBillBaseResult.setOutRefundNo(tempStr[k + 15]); + wxPayBillBaseResult.setSettlementRefundFee(tempStr[k + 16]); + wxPayBillBaseResult.setCouponRefundFee(tempStr[k + 17]); + wxPayBillBaseResult.setRefundChannel(tempStr[k + 18]); + wxPayBillBaseResult.setRefundState(tempStr[k + 19]); + wxPayBillBaseResult.setBody(tempStr[k + 20]); + wxPayBillBaseResult.setAttach(tempStr[k + 21]); + wxPayBillBaseResult.setPoundage(tempStr[k + 22]); + wxPayBillBaseResult.setPoundageRate(tempStr[k + 23]); + wxPayBillBaseResultLst.add(wxPayBillBaseResult); + k += t.length; + } + /* + * 总交易单数,总交易额,总退款金额,总代金券或立减优惠退款金额,手续费总金额 `2,`0.02,`0.0,`0.0,`0 + */ + + // 参考以上格式进行取值 + + String totalStr = objStr.replaceAll(",", " "); + String[] totalTempStr = totalStr.split("`"); + wxPayBillResult.setTotalRecord(totalTempStr[1]); + wxPayBillResult.setTotalFee(totalTempStr[2]); + wxPayBillResult.setTotalRefundFee(totalTempStr[3]); + wxPayBillResult.setTotalCouponFee(totalTempStr[4]); + wxPayBillResult.setTotalPoundageFee(totalTempStr[5]); + + return wxPayBillResult; + } + + @Override + public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/pay/micropay"; + String responseContent = this.post(url, request.toXML(), false); + WxPayMicropayResult result = WxPayBaseResult.fromXML(responseContent, WxPayMicropayResult.class); + result.checkResult(this); + return result; + } + + @Override + public WxPayOrderReverseResult reverseOrder(WxPayOrderReverseRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/secapi/pay/reverse"; + String responseContent = this.post(url, request.toXML(), true); + WxPayOrderReverseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderReverseResult.class); + result.checkResult(this); + return result; + } + + @Override + public String shorturl(WxPayShorturlRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/tools/shorturl"; + String responseContent = this.post(url, request.toXML(), false); + WxPayShorturlResult result = WxPayBaseResult.fromXML(responseContent, WxPayShorturlResult.class); + result.checkResult(this); + return result.getShortUrl(); + } + + @Override + public String shorturl(String longUrl) throws WxPayException { + return this.shorturl(new WxPayShorturlRequest(longUrl)); + } + + @Override + public String authcode2Openid(WxPayAuthcode2OpenidRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/tools/authcodetoopenid"; + String responseContent = this.post(url, request.toXML(), false); + WxPayAuthcode2OpenidResult result = WxPayBaseResult.fromXML(responseContent, WxPayAuthcode2OpenidResult.class); + result.checkResult(this); + return result.getOpenid(); + } + + @Override + public String authcode2Openid(String authCode) throws WxPayException { + return this.authcode2Openid(new WxPayAuthcode2OpenidRequest(authCode)); + } + + @Override + public String getSandboxSignKey() throws WxPayException { + WxPayDefaultRequest request = new WxPayDefaultRequest(); + request.checkAndSign(this.getConfig()); + + String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey"; + String responseContent = this.post(url, request.toXML(), false); + WxPaySandboxSignKeyResult result = WxPayBaseResult.fromXML(responseContent, WxPaySandboxSignKeyResult.class); + result.checkResult(this); + return result.getSandboxSignKey(); + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java new file mode 100644 index 0000000000..c5da982c13 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java @@ -0,0 +1,66 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.exception.WxPayException; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.DefaultHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import javax.net.ssl.SSLContext; +import java.nio.charset.StandardCharsets; + +/** + *
    + * 微信支付请求实现类,apache httpclient实现
    + * Created by Binary Wang on 2016/7/28.
    + * 
    + * + * @author binarywang (https://github.com/binarywang) + */ +public class WxPayServiceApacheHttpImpl extends WxPayServiceAbstractImpl { + + @Override + protected String post(String url, String requestStr, boolean useKey) throws WxPayException { + try { + HttpClientBuilder httpClientBuilder = HttpClients.custom(); + if (useKey) { + SSLContext sslContext = this.getConfig().getSslContext(); + if (null == sslContext) { + sslContext = this.getConfig().initSSLContext(); + } + + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, + new String[]{"TLSv1"}, null, new DefaultHostnameVerifier()); + httpClientBuilder.setSSLSocketFactory(sslsf); + } + + HttpPost httpPost = new HttpPost(url); + httpPost.setConfig(RequestConfig.custom() + .setConnectionRequestTimeout(this.getConfig().getHttpConnectionTimeout()) + .setConnectTimeout(this.getConfig().getHttpConnectionTimeout()) + .setSocketTimeout(this.getConfig().getHttpTimeout()) + .build()); + + try (CloseableHttpClient httpclient = httpClientBuilder.build()) { + httpPost.setEntity(new StringEntity(new String(requestStr.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1))); + try (CloseableHttpResponse response = httpclient.execute(httpPost)) { + String result = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); + this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, result); + return result; + } + } finally { + httpPost.releaseConnection(); + } + } catch (Exception e) { + this.log.error("\n【请求地址】:{}\n【请求数据】:{}\n【异常信息】:{}", url, requestStr, e.getMessage()); + throw new WxPayException(e.getMessage(), e); + } + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java index f799a2c974..8e795966f4 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImpl.java @@ -1,515 +1,12 @@ package com.github.binarywang.wxpay.service.impl; -import com.github.binarywang.utils.qrcode.QrcodeUtils; -import com.github.binarywang.wxpay.bean.request.*; -import com.github.binarywang.wxpay.bean.result.*; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.util.SignUtils; -import com.google.common.collect.Maps; -import jodd.http.HttpRequest; -import jodd.http.HttpResponse; -import jodd.http.net.SSLSocketHttpConnectionProvider; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.net.ssl.SSLContext; -import java.io.File; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - /** - * Created by Binary Wang on 2016/7/28. + *
    + * 微信支付接口请求实现类,默认使用Apache HttpClient实现
    + * Created by Binary Wang on 2017-7-8.
    + * 
    * - * @author binarywang (https://github.com/binarywang) + * @author Binary Wang */ -public class WxPayServiceImpl implements WxPayService { - private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com"; - private final Logger log = LoggerFactory.getLogger(this.getClass()); - - private WxPayConfig config; - - @Override - public WxPayConfig getConfig() { - return this.config; - } - - @Override - public void setConfig(WxPayConfig config) { - this.config = config; - } - - private String getPayBaseUrl() { - if (this.getConfig().useSandbox()) { - return PAY_BASE_URL + "/sandboxnew"; - } - - return PAY_BASE_URL; - } - - @Override - public WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayException { - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/secapi/pay/refund"; - String responseContent = this.post(url, request.toXML(), true); - WxPayRefundResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundResult.class); - result.checkResult(this); - return result; - } - - @Override - public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, String outRefundNo, String refundId) - throws WxPayException { - WxPayRefundQueryRequest request = new WxPayRefundQueryRequest(); - request.setOutTradeNo(StringUtils.trimToNull(outTradeNo)); - request.setTransactionId(StringUtils.trimToNull(transactionId)); - request.setOutRefundNo(StringUtils.trimToNull(outRefundNo)); - request.setRefundId(StringUtils.trimToNull(refundId)); - - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/pay/refundquery"; - String responseContent = this.post(url, request.toXML(), false); - WxPayRefundQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundQueryResult.class); - result.composeRefundRecords(); - result.checkResult(this); - return result; - } - - @Override - public WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayException { - try { - log.debug("微信支付回调参数详细:{}", xmlData); - WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData); - log.debug("微信支付回调结果对象:{}", result); - result.checkResult(this); - return result; - } catch (WxPayException e) { - log.error(e.getMessage(), e); - throw e; - } catch (Exception e) { - log.error(e.getMessage(), e); - throw new WxPayException("发生异常," + e.getMessage(), e); - } - } - - @Override - public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throws WxPayException { - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/mmpaymkttransfers/sendredpack"; - if (request.getAmtType() != null) { - //裂变红包 - url = this.getPayBaseUrl() + "/mmpaymkttransfers/sendgroupredpack"; - } - - String responseContent = this.post(url, request.toXML(), true); - WxPaySendRedpackResult result = WxPayBaseResult.fromXML(responseContent, WxPaySendRedpackResult.class); - //毋须校验,因为没有返回签名信息 - // this.checkResult(result); - return result; - } - - @Override - public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayException { - WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest(); - request.setMchBillNo(mchBillNo); - request.setBillType("MCHT"); - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo"; - String responseContent = this.post(url, request.toXML(), true); - WxPayRedpackQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRedpackQueryResult.class); - result.checkResult(this); - return result; - } - - @Override - public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) throws WxPayException { - WxPayOrderQueryRequest request = new WxPayOrderQueryRequest(); - request.setOutTradeNo(StringUtils.trimToNull(outTradeNo)); - request.setTransactionId(StringUtils.trimToNull(transactionId)); - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/pay/orderquery"; - String responseContent = this.post(url, request.toXML(), false); - if (StringUtils.isBlank(responseContent)) { - throw new WxPayException("无响应结果"); - } - - WxPayOrderQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderQueryResult.class); - result.composeCoupons(); - result.checkResult(this); - return result; - } - - @Override - public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException { - if (StringUtils.isBlank(outTradeNo)) { - throw new IllegalArgumentException("out_trade_no不能为空"); - } - - WxPayOrderCloseRequest request = new WxPayOrderCloseRequest(); - request.setOutTradeNo(StringUtils.trimToNull(outTradeNo)); - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/pay/closeorder"; - String responseContent = this.post(url, request.toXML(), false); - WxPayOrderCloseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderCloseResult.class); - result.checkResult(this); - - return result; - } - - @Override - public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) throws WxPayException { - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/pay/unifiedorder"; - String responseContent = this.post(url, request.toXML(), false); - WxPayUnifiedOrderResult result = WxPayBaseResult.fromXML(responseContent, WxPayUnifiedOrderResult.class); - result.checkResult(this); - return result; - } - - @Override - public Map getPayInfo(WxPayUnifiedOrderRequest request) throws WxPayException { - WxPayUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request); - String prepayId = unifiedOrderResult.getPrepayId(); - if (StringUtils.isBlank(prepayId)) { - throw new RuntimeException(String.format("无法获取prepay id,错误代码: '%s',信息:%s。", - unifiedOrderResult.getErrCode(), unifiedOrderResult.getErrCodeDes())); - } - - Map payInfo = new HashMap<>(); - if ("NATIVE".equals(request.getTradeType())) { - payInfo.put("codeUrl", unifiedOrderResult.getCodeURL()); - } else if ("APP".equals(request.getTradeType())) { - // APP支付绑定的是微信开放平台上的账号,APPID为开放平台上绑定APP后发放的参数 - String appId = getConfig().getAppId(); - Map configMap = new HashMap<>(); - // 此map用于参与调起sdk支付的二次签名,格式全小写,timestamp只能是10位,格式固定,切勿修改 - String partnerid = getConfig().getMchId(); - configMap.put("prepayid", prepayId); - configMap.put("partnerid", partnerid); - configMap.put("package", "Sign=WXPay"); - configMap.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000)); - configMap.put("noncestr", String.valueOf(System.currentTimeMillis())); - configMap.put("appid", appId); - // 此map用于客户端与微信服务器交互 - payInfo.put("sign", SignUtils.createSign(configMap, this.getConfig().getMchKey())); - payInfo.put("prepayId", prepayId); - payInfo.put("partnerId", partnerid); - payInfo.put("appId", appId); - payInfo.put("packageValue", "Sign=WXPay"); - payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000)); - payInfo.put("nonceStr", String.valueOf(System.currentTimeMillis())); - } else if ("JSAPI".equals(request.getTradeType())) { - payInfo.put("appId", unifiedOrderResult.getAppid()); - // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 - payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000)); - payInfo.put("nonceStr", String.valueOf(System.currentTimeMillis())); - payInfo.put("package", "prepay_id=" + prepayId); - payInfo.put("signType", "MD5"); - payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey())); - } - return payInfo; - } - - @Override - public WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException { - request.checkAndSign(this.getConfig()); - String url = this.getPayBaseUrl() + "/mmpaymkttransfers/promotion/transfers"; - - String responseContent = this.post(url, request.toXML(), true); - WxEntPayResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayResult.class); - result.checkResult(this); - return result; - } - - @Override - public WxEntPayQueryResult queryEntPay(String partnerTradeNo) throws WxPayException { - WxEntPayQueryRequest request = new WxEntPayQueryRequest(); - request.setPartnerTradeNo(partnerTradeNo); - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gettransferinfo"; - String responseContent = this.post(url, request.toXML(), true); - WxEntPayQueryResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayQueryResult.class); - result.checkResult(this); - return result; - } - - @Override - public byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength) { - String content = this.createScanPayQrcodeMode1(productId); - return this.createQrcode(content, logoFile, sideLength); - } - - @Override - public String createScanPayQrcodeMode1(String productId) { - //weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX - StringBuilder codeUrl = new StringBuilder("weixin://wxpay/bizpayurl?"); - Map params = Maps.newHashMap(); - params.put("appid", this.getConfig().getAppId()); - params.put("mch_id", this.getConfig().getMchId()); - params.put("product_id", productId); - params.put("time_stamp", String.valueOf(System.currentTimeMillis() / 1000));//这里需要秒,10位数字 - params.put("nonce_str", String.valueOf(System.currentTimeMillis())); - - String sign = SignUtils.createSign(params, this.getConfig().getMchKey()); - params.put("sign", sign); - - - for (String key : params.keySet()) { - codeUrl.append(key + "=" + params.get(key) + "&"); - } - - String content = codeUrl.toString().substring(0, codeUrl.length() - 1); - log.debug("扫码支付模式一生成二维码的URL:{}", content); - return content; - } - - @Override - public byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) { - return this.createQrcode(codeUrl, logoFile, sideLength); - } - - private byte[] createQrcode(String content, File logoFile, Integer sideLength) { - if (sideLength == null || sideLength < 1) { - return QrcodeUtils.createQrcode(content, logoFile); - } - - return QrcodeUtils.createQrcode(content, sideLength, logoFile); - } - - public void report(WxPayReportRequest request) throws WxPayException { - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/payitil/report"; - String responseContent = this.post(url, request.toXML(), false); - WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class); - result.checkResult(this); - } - - @Override - public WxPayBillResult downloadBill(String billDate, String billType, String tarType, String deviceInfo) throws WxPayException { - WxPayDownloadBillRequest request = new WxPayDownloadBillRequest(); - request.setBillType(billType); - request.setBillDate(billDate); - request.setTarType(tarType); - request.setDeviceInfo(deviceInfo); - - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/pay/downloadbill"; - String responseContent = this.post(url, request.toXML(), false); - if (responseContent.startsWith("<")) { - WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class); - result.checkResult(this); - return null; - } else { - WxPayBillResult wxPayBillResult = billInformationDeal(responseContent); - return wxPayBillResult; - } - } - - private WxPayBillResult billInformationDeal(String responseContent) { - WxPayBillResult wxPayBillResult = new WxPayBillResult(); - - String listStr = ""; - String objStr = ""; - if (responseContent.contains("总交易单数")) { - listStr = responseContent.substring(0, responseContent.indexOf("总交易单数")); - objStr = responseContent.substring(responseContent.indexOf("总交易单数")); - } - - /* - * 交易时间:2017-04-06 01:00:02 公众账号ID: 商户号: 子商户号:0 设备号:WEB 微信订单号: 商户订单号:2017040519091071873216 用户标识: 交易类型:NATIVE - * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00 - * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60% - */ - - // 参考以上格式进行取值 - - List wxPayBillBaseResultLst = new LinkedList<>(); - String newStr = listStr.replaceAll(",", " "); // 去空格 - String[] tempStr = newStr.split("`"); // 数据分组 - String[] t = tempStr[0].split(" ");// 分组标题 - int j = tempStr.length / t.length; // 计算循环次数 - int k = 1; // 纪录数组下标 - for (int i = 0; i < j; i++) { - WxPayBillBaseResult wxPayBillBaseResult = new WxPayBillBaseResult(); - - wxPayBillBaseResult.setTradeTime(tempStr[k]); - wxPayBillBaseResult.setAppId(tempStr[k + 1]); - wxPayBillBaseResult.setMchId(tempStr[k + 2]); - wxPayBillBaseResult.setSubMchId(tempStr[k + 3]); - wxPayBillBaseResult.setDeviceInfo(tempStr[k + 4]); - wxPayBillBaseResult.setTransationId(tempStr[k + 5]); - wxPayBillBaseResult.setOutTradeNo(tempStr[k + 6]); - wxPayBillBaseResult.setOpenId(tempStr[k + 7]); - wxPayBillBaseResult.setTradeType(tempStr[k + 8]); - wxPayBillBaseResult.setTradeState(tempStr[k + 9]); - wxPayBillBaseResult.setBankType(tempStr[k + 10]); - wxPayBillBaseResult.setFeeType(tempStr[k + 11]); - wxPayBillBaseResult.setTotalFee(tempStr[k + 12]); - wxPayBillBaseResult.setCouponFee(tempStr[k + 13]); - wxPayBillBaseResult.setRefundId(tempStr[k + 14]); - wxPayBillBaseResult.setOutRefundNo(tempStr[k + 15]); - wxPayBillBaseResult.setSettlementRefundFee(tempStr[k + 16]); - wxPayBillBaseResult.setCouponRefundFee(tempStr[k + 17]); - wxPayBillBaseResult.setRefundChannel(tempStr[k + 18]); - wxPayBillBaseResult.setRefundState(tempStr[k + 19]); - wxPayBillBaseResult.setBody(tempStr[k + 20]); - wxPayBillBaseResult.setAttach(tempStr[k + 21]); - wxPayBillBaseResult.setPoundage(tempStr[k + 22]); - wxPayBillBaseResult.setPoundageRate(tempStr[k + 23]); - wxPayBillBaseResultLst.add(wxPayBillBaseResult); - k += t.length; - } - /* - * 总交易单数,总交易额,总退款金额,总代金券或立减优惠退款金额,手续费总金额 `2,`0.02,`0.0,`0.0,`0 - */ - - // 参考以上格式进行取值 - - String totalStr = objStr.replaceAll(",", " "); - String[] totalTempStr = totalStr.split("`"); - wxPayBillResult.setTotalRecord(totalTempStr[1]); - wxPayBillResult.setTotalFee(totalTempStr[2]); - wxPayBillResult.setTotalRefundFee(totalTempStr[3]); - wxPayBillResult.setTotalCouponFee(totalTempStr[4]); - wxPayBillResult.setTotalPoundageFee(totalTempStr[5]); - - return wxPayBillResult; - } - - @Override - public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxPayException { - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/pay/micropay"; - String responseContent = this.post(url, request.toXML(), false); - WxPayMicropayResult result = WxPayBaseResult.fromXML(responseContent, WxPayMicropayResult.class); - result.checkResult(this); - return result; - } - - @Override - public WxPayOrderReverseResult reverseOrder(WxPayOrderReverseRequest request) throws WxPayException { - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/secapi/pay/reverse"; - String responseContent = this.post(url, request.toXML(), true); - WxPayOrderReverseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderReverseResult.class); - result.checkResult(this); - return result; - } - - @Override - public String shorturl(WxPayShorturlRequest request) throws WxPayException { - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/tools/shorturl"; - String responseContent = this.post(url, request.toXML(), false); - WxPayShorturlResult result = WxPayBaseResult.fromXML(responseContent, WxPayShorturlResult.class); - result.checkResult(this); - return result.getShortUrl(); - } - - @Override - public String shorturl(String longUrl) throws WxPayException { - return this.shorturl(new WxPayShorturlRequest(longUrl)); - } - - @Override - public String authcode2Openid(WxPayAuthcode2OpenidRequest request) throws WxPayException { - request.checkAndSign(this.getConfig()); - - String url = this.getPayBaseUrl() + "/tools/authcodetoopenid"; - String responseContent = this.post(url, request.toXML(), false); - WxPayAuthcode2OpenidResult result = WxPayBaseResult.fromXML(responseContent, WxPayAuthcode2OpenidResult.class); - result.checkResult(this); - return result.getOpenid(); - } - - @Override - public String authcode2Openid(String authCode) throws WxPayException { - return this.authcode2Openid(new WxPayAuthcode2OpenidRequest(authCode)); - } - - @Override - public String getSandboxSignKey() throws WxPayException { - WxPayDefaultRequest request = new WxPayDefaultRequest(); - request.checkAndSign(this.getConfig()); - - String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey"; - String responseContent = this.post(url, request.toXML(), false); - WxPaySandboxSignKeyResult result = WxPayBaseResult.fromXML(responseContent, WxPaySandboxSignKeyResult.class); - result.checkResult(this); - return result.getSandboxSignKey(); - } - - /** - * 发送post请求 - * - * @param url 请求地址 - * @param requestStr 请求信息 - * @param useKey 是否使用证书 - * @return 返回请求结果字符串 - */ - private String post(String url, String requestStr, boolean useKey) throws WxPayException { - try { - HttpRequest request = HttpRequest - .post(url) - .timeout(this.config.getHttpTimeout()) - .connectionTimeout(this.config.getHttpConnectionTimeout()) - .bodyText(requestStr); - - if (useKey) { - SSLContext sslContext = this.getConfig().getSslContext(); - if (null == sslContext) { - sslContext = this.getConfig().initSSLContext(); - } - request.withConnectionProvider(new SSLSocketHttpConnectionProvider(sslContext)); - } - - String responseString = this.getResponseString(request.send()); - - this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, responseString); - return responseString; - } catch (Exception e) { - this.log.error("\n【请求地址】:{}\n【请求数据】:{}\n【异常信息】:{}", url, requestStr, e.getMessage()); - throw new WxPayException(e.getMessage(), e); - } - } - - private String getResponseString(HttpResponse response) throws WxPayException { - try { - this.log.debug("【微信服务器响应头信息】:\n{}", response.toString(false)); - } catch (NullPointerException e) { - throw new WxPayException("response.toString() 居然抛出空指针异常了", e); - } - - String responseString = response.bodyText(); - - if (StringUtils.isBlank(responseString)) { - throw new WxPayException("响应信息为空"); - } - - if (StringUtils.isBlank(response.charset())) { - responseString = new String(responseString.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); - } - - return responseString; - } - - +public class WxPayServiceImpl extends WxPayServiceApacheHttpImpl { } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java new file mode 100644 index 0000000000..29008e26bd --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java @@ -0,0 +1,68 @@ +package com.github.binarywang.wxpay.service.impl; + +import com.github.binarywang.wxpay.exception.WxPayException; +import jodd.http.HttpRequest; +import jodd.http.HttpResponse; +import jodd.http.net.SSLSocketHttpConnectionProvider; +import org.apache.commons.lang3.StringUtils; + +import javax.net.ssl.SSLContext; +import java.nio.charset.StandardCharsets; + +/** + * 微信支付请求实现类,jodd-http实现 + * Created by Binary Wang on 2016/7/28. + * + * @author binarywang (https://github.com/binarywang) + */ +public class WxPayServiceJoddHttpImpl extends WxPayServiceAbstractImpl { + + @Override + protected String post(String url, String requestStr, boolean useKey) throws WxPayException { + try { + HttpRequest request = HttpRequest + .post(url) + .timeout(this.config.getHttpTimeout()) + .connectionTimeout(this.config.getHttpConnectionTimeout()) + .bodyText(requestStr); + + if (useKey) { + SSLContext sslContext = this.getConfig().getSslContext(); + if (null == sslContext) { + sslContext = this.getConfig().initSSLContext(); + } + request.withConnectionProvider(new SSLSocketHttpConnectionProvider(sslContext)); + } + + String responseString = this.getResponseString(request.send()); + + this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, responseString); + return responseString; + } catch (Exception e) { + this.log.error("\n【请求地址】:{}\n【请求数据】:{}\n【异常信息】:{}", url, requestStr, e.getMessage()); + throw new WxPayException(e.getMessage(), e); + } + } + + private String getResponseString(HttpResponse response) throws WxPayException { + try { + this.log.debug("【微信服务器响应头信息】:\n{}", response.toString(false)); + } catch (NullPointerException e) { + throw new WxPayException("response.toString() 居然抛出空指针异常了", e); + } + + String responseString = response.bodyText(); + + if (StringUtils.isBlank(responseString)) { + throw new WxPayException("响应信息为空"); + } + + if (StringUtils.isBlank(response.charset())) { + responseString = new String(responseString.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + } + + return responseString; + } + + +} From 57f3755a843eda7ece90e75f05611cdc74709b14 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 8 Jul 2017 19:22:26 +0800 Subject: [PATCH 035/165] =?UTF-8?q?#68=20=E5=AE=9E=E7=8E=B0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=85=AC=E4=BC=97=E5=8F=B7=E7=9A=84=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E8=A7=84=E5=88=99=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/json/WxBooleanTypeAdapter.java | 47 +++ .../common/util/json/WxDateTypeAdapter.java | 43 +++ .../me/chanjar/weixin/mp/api/WxMpService.java | 30 +- .../mp/api/impl/AbstractWxMpServiceImpl.java | 5 + .../bean/result/WxMpCurrentAutoReplyInfo.java | 359 ++++++++++++++++++ .../mp/api/impl/WxMpServiceImplTest.java | 12 + .../result/WxMpCurrentAutoReplyInfoTest.java | 157 ++++++++ 7 files changed, 647 insertions(+), 6 deletions(-) create mode 100644 weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxBooleanTypeAdapter.java create mode 100644 weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxDateTypeAdapter.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java create mode 100644 weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxBooleanTypeAdapter.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxBooleanTypeAdapter.java new file mode 100644 index 0000000000..3fbbef4a43 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxBooleanTypeAdapter.java @@ -0,0 +1,47 @@ +package me.chanjar.weixin.common.util.json; + +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; +import org.apache.commons.lang3.BooleanUtils; + +import java.io.IOException; + +/** + *
    + * Gson 布尔类型类型转换器
    + * Created by Binary Wang on 2017-7-8.
    + * 
    + * + * @author Binary Wang + */ +public class WxBooleanTypeAdapter extends TypeAdapter { + @Override + public void write(JsonWriter out, Boolean value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(value); + } + } + + @Override + public Boolean read(JsonReader in) throws IOException { + JsonToken peek = in.peek(); + switch (peek) { + case BOOLEAN: + return in.nextBoolean(); + case NULL: + in.nextNull(); + return null; + case NUMBER: + return BooleanUtils.toBoolean(in.nextInt()); + case STRING: + return BooleanUtils.toBoolean(in.nextString()); + default: + throw new JsonParseException("Expected BOOLEAN or NUMBER but was " + peek); + } + } +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxDateTypeAdapter.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxDateTypeAdapter.java new file mode 100644 index 0000000000..fd54cf3f43 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxDateTypeAdapter.java @@ -0,0 +1,43 @@ +package me.chanjar.weixin.common.util.json; + +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.Date; + +/** + *
    + * Gson 日期类型转换器
    + * Created by Binary Wang on 2017-7-8.
    + * 
    + * + * @author Binary Wang + */ +public class WxDateTypeAdapter extends TypeAdapter { + @Override + public void write(JsonWriter out, Date value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(value.getTime() / 1000); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + JsonToken peek = in.peek(); + switch (peek) { + case NULL: + in.nextNull(); + return null; + case NUMBER: + return new Date(in.nextInt() * 1000); + default: + throw new JsonParseException("Expected NUMBER but was " + peek); + } + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java index 7199d4e05c..0cff2c1cfd 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java @@ -77,6 +77,11 @@ public interface WxMpService { */ String CONNECT_OAUTH2_AUTHORIZE_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s#wechat_redirect"; + /** + * 获取公众号的自动回复规则 + */ + String GET_CURRENT_AUTOREPLY_INFO_URL = "https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info"; + /** *
        * 验证消息的确来自微信服务器
    @@ -273,6 +278,24 @@ public interface WxMpService {
        */
       String[] getCallbackIP() throws WxErrorException;
     
    +  /**
    +   * 
    +   * 获取公众号的自动回复规则
    +   * http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751299&token=&lang=zh_CN
    +   * 开发者可以通过该接口,获取公众号当前使用的自动回复规则,包括关注后自动回复、消息自动回复(60分钟内触发一次)、关键词自动回复。
    +   * 请注意:
    +   * 1、第三方平台开发者可以通过本接口,在旗下公众号将业务授权给你后,立即通过本接口检测公众号的自动回复配置,并通过接口再次给公众号设置好自动回复规则,以提升公众号运营者的业务体验。
    +   * 2、本接口仅能获取公众号在公众平台官网的自动回复功能中设置的自动回复规则,若公众号自行开发实现自动回复,或通过第三方平台开发者来实现,则无法获取。
    +   * 3、认证/未认证的服务号/订阅号,以及接口测试号,均拥有该接口权限。
    +   * 4、从第三方平台的公众号登录授权机制上来说,该接口从属于消息与菜单权限集。
    +   * 5、本接口中返回的图片/语音/视频为临时素材(临时素材每次获取都不同,3天内有效,通过素材管理-获取临时素材接口来获取这些素材),本接口返回的图文消息为永久素材素材(通过素材管理-获取永久素材接口来获取这些素材)。
    +   * 接口调用请求说明
    +   * http请求方式: GET(请使用https协议)
    +   * https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info?access_token=ACCESS_TOKEN
    +   * 
    + */ + WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException; + /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求 */ @@ -292,15 +315,10 @@ public interface WxMpService { */ T execute(RequestExecutor executor, String uri, E data) throws WxErrorException; - /** - * 获取代理对象 - */ - //HttpHost getRequestHttpProxy(); - /** *
        * 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试
    -   * 默认:1000ms
    +   * @param retrySleepMillis 默认:1000ms
        * 
    */ void setRetrySleepMillis(int retrySleepMillis); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java index d3075aa11d..ed93d4936f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java @@ -231,6 +231,11 @@ public String[] getCallbackIP() throws WxErrorException { return ipArray; } + @Override + public WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException { + return WxMpCurrentAutoReplyInfo.fromJson(this.get(GET_CURRENT_AUTOREPLY_INFO_URL, null)); + } + @Override public String get(String url, String queryParam) throws WxErrorException { return execute(SimpleGetRequestExecutor.create(this), url, queryParam); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java new file mode 100644 index 0000000000..6738b8bc4a --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java @@ -0,0 +1,359 @@ +package me.chanjar.weixin.mp.bean.result; + +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import me.chanjar.weixin.common.util.ToStringUtils; +import me.chanjar.weixin.common.util.json.WxBooleanTypeAdapter; +import me.chanjar.weixin.common.util.json.WxDateTypeAdapter; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + +import java.util.Date; +import java.util.List; + +/** + *
    + * 公众号的自动回复规则
    + * Created by Binary Wang on 2017-7-8.
    + * @author Binary Wang
    + * 
    + */ +public class WxMpCurrentAutoReplyInfo { + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + + public static WxMpCurrentAutoReplyInfo fromJson(String json) { + return WxMpGsonBuilder.create().fromJson(json, WxMpCurrentAutoReplyInfo.class); + } + + @SerializedName("is_add_friend_reply_open") + @JsonAdapter(WxBooleanTypeAdapter.class) + private Boolean isAddFriendReplyOpen; + + @SerializedName("is_autoreply_open") + @JsonAdapter(WxBooleanTypeAdapter.class) + private Boolean isAutoReplyOpen; + + @SerializedName("add_friend_autoreply_info") + private AutoReplyInfo addFriendAutoReplyInfo; + + @SerializedName("message_default_autoreply_info") + private AutoReplyInfo messageDefaultAutoReplyInfo; + + @SerializedName("keyword_autoreply_info") + private KeywordAutoReplyInfo keywordAutoReplyInfo; + + public Boolean getAddFriendReplyOpen() { + return this.isAddFriendReplyOpen; + } + + public void setAddFriendReplyOpen(Boolean addFriendReplyOpen) { + isAddFriendReplyOpen = addFriendReplyOpen; + } + + public Boolean getAutoReplyOpen() { + return this.isAutoReplyOpen; + } + + public void setAutoReplyOpen(Boolean autoReplyOpen) { + isAutoReplyOpen = autoReplyOpen; + } + + public AutoReplyInfo getAddFriendAutoReplyInfo() { + return this.addFriendAutoReplyInfo; + } + + public void setAddFriendAutoReplyInfo(AutoReplyInfo addFriendAutoReplyInfo) { + this.addFriendAutoReplyInfo = addFriendAutoReplyInfo; + } + + public AutoReplyInfo getMessageDefaultAutoReplyInfo() { + return this.messageDefaultAutoReplyInfo; + } + + public void setMessageDefaultAutoReplyInfo(AutoReplyInfo messageDefaultAutoReplyInfo) { + this.messageDefaultAutoReplyInfo = messageDefaultAutoReplyInfo; + } + + public KeywordAutoReplyInfo getKeywordAutoReplyInfo() { + return this.keywordAutoReplyInfo; + } + + public void setKeywordAutoReplyInfo(KeywordAutoReplyInfo keywordAutoReplyInfo) { + this.keywordAutoReplyInfo = keywordAutoReplyInfo; + } + + public static class AutoReplyRule { + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + + @SerializedName("rule_name") + private String ruleName; + + @SerializedName("create_time") + @JsonAdapter(WxDateTypeAdapter.class) + private Date createTime; + + @SerializedName("reply_mode") + private String replyMode; + + @SerializedName("keyword_list_info") + private List keywordListInfo; + + @SerializedName("reply_list_info") + private List replyListInfo; + + public String getRuleName() { + return this.ruleName; + } + + public void setRuleName(String ruleName) { + this.ruleName = ruleName; + } + + public Date getCreateTime() { + return this.createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getReplyMode() { + return this.replyMode; + } + + public void setReplyMode(String replyMode) { + this.replyMode = replyMode; + } + + public List getKeywordListInfo() { + return this.keywordListInfo; + } + + public void setKeywordListInfo(List keywordListInfo) { + this.keywordListInfo = keywordListInfo; + } + + public List getReplyListInfo() { + return this.replyListInfo; + } + + public void setReplyListInfo(List replyListInfo) { + this.replyListInfo = replyListInfo; + } + } + + public static class ReplyInfo { + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + + private String type; + private String content; + + @SerializedName("news_info") + private NewsInfo newsInfo; + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public NewsInfo getNewsInfo() { + return this.newsInfo; + } + + public void setNewsInfo(NewsInfo newsInfo) { + this.newsInfo = newsInfo; + } + } + + public static class NewsInfo { + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + + private List list; + + public List getList() { + return this.list; + } + + public void setList(List list) { + this.list = list; + } + } + + public static class NewsItem { + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + + @SerializedName("cover_url") + private String coverUrl; + private String author; + @SerializedName("content_url") + private String contentUrl; + private String digest; + @SerializedName("show_cover") + @JsonAdapter(WxBooleanTypeAdapter.class) + private Boolean showCover; + @SerializedName("source_url") + private String sourceUrl; + private String title; + + public String getCoverUrl() { + return this.coverUrl; + } + + public void setCoverUrl(String coverUrl) { + this.coverUrl = coverUrl; + } + + public String getAuthor() { + return this.author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public String getContentUrl() { + return this.contentUrl; + } + + public void setContentUrl(String contentUrl) { + this.contentUrl = contentUrl; + } + + public String getDigest() { + return this.digest; + } + + public void setDigest(String digest) { + this.digest = digest; + } + + public Boolean getShowCover() { + return this.showCover; + } + + public void setShowCover(Boolean showCover) { + this.showCover = showCover; + } + + public String getSourceUrl() { + return this.sourceUrl; + } + + public void setSourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + } + + public static class KeywordInfo { + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + + private String type; + @SerializedName("match_mode") + private String matchMode; + private String content; + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMatchMode() { + return this.matchMode; + } + + public void setMatchMode(String matchMode) { + this.matchMode = matchMode; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + } + + public static class KeywordAutoReplyInfo { + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + + private List list; + + public List getList() { + return this.list; + } + + public void setList(List list) { + this.list = list; + } + } + + public static class AutoReplyInfo { + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + + private String type; + private String content; + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + } + +} diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java index d5bf621287..c3f9f69d7b 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java @@ -2,12 +2,16 @@ import com.google.inject.Inject; import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.test.TestConfigStorage; +import me.chanjar.weixin.mp.bean.result.WxMpCurrentAutoReplyInfo; import org.testng.*; import org.testng.annotations.*; +import static org.testng.Assert.*; + @Test @Guice(modules = ApiTestModule.class) public class WxMpServiceImplTest { @@ -15,6 +19,14 @@ public class WxMpServiceImplTest { @Inject private WxMpService wxService; + @Test + public void testGetCurrentAutoReplyInfo() throws WxErrorException { + WxMpCurrentAutoReplyInfo autoReplyInfo = this.wxService.getCurrentAutoReplyInfo(); + + assertNotNull(autoReplyInfo); + System.out.println(autoReplyInfo); + } + @Test public void testCheckSignature() { Assert.fail("Not yet implemented"); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java new file mode 100644 index 0000000000..da2cddff40 --- /dev/null +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java @@ -0,0 +1,157 @@ +package me.chanjar.weixin.mp.bean.result; + +import org.testng.annotations.*; + +import static org.testng.Assert.*; + +/** + *
    + * Created by Binary Wang on 2017-7-8.
    + * @author Binary Wang
    + * 
    + */ +public class WxMpCurrentAutoReplyInfoTest { + @Test + public void testFromJson() throws Exception { + String json = "{ \n" + + " \"is_add_friend_reply_open\": 1, \n" + + " \"is_autoreply_open\": 1, \n" + + " \"add_friend_autoreply_info\": { \n" + + " \"type\": \"text\", \n" + + " \"content\": \"Thanks for your attention!\"\n" + + " }, \n" + + " \"message_default_autoreply_info\": { \n" + + " \"type\": \"text\", \n" + + " \"content\": \"Hello, this is autoreply!\"\n" + + " }, \n" + + " \"keyword_autoreply_info\": { \n" + + " \"list\": [ \n" + + " { \n" + + " \"rule_name\": \"autoreply-news\", \n" + + " \"create_time\": 1423028166, \n" + + " \"reply_mode\": \"reply_all\", \n" + + " \"keyword_list_info\": [ \n" + + " { \n" + + " \"type\": \"text\", \n" + + " \"match_mode\": \"contain\", \n" + + " \"content\": \"news测试\"//此处content即为关键词内容\n" + + " }\n" + + " ], \n" + + " \"reply_list_info\": [ \n" + + " { \n" + + " \"type\": \"news\", \n" + + " \"news_info\": { \n" + + " \"list\": [ \n" + + " { \n" + + " \"title\": \"it's news\", \n" + + " \"author\": \"jim\", \n" + + " \"digest\": \"it's digest\", \n" + + " \"show_cover\": 1, \"cover_url\": \"http://mmbiz.qpic.cn/mmbiz/GE7et87vE9vicuCibqXsX9GPPLuEtBfXfKbE8sWdt2DDcL0dMfQWJWTVn1N8DxI0gcRmrtqBOuwQH\n" + + " euPKmFLK0ZQ/0\", \n" + + " \"content_url\": \"http://mp.weixin.qq.com/s?__biz=MjM5ODUwNTM3Ng==&mid=203929886&idx=1&sn=628f964cf0c6d84c026881b6959aea8b#rd\", \n" + + " \"source_url\": \"http://www.url.com\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " }, \n" + + " { \n" + + " \"type\": \"news\",\n" + + " \"content\":\"KQb_w_Tiz-nSdVLoTV35Psmty8hGBulGhEdbb9SKs-o\", \n" + + " \"news_info\": { \n" + + " \"list\": [ \n" + + " { \n" + + " \"title\": \"MULTI_NEWS\", \n" + + " \"author\": \"JIMZHENG\", \n" + + " \"digest\": \"text\", \n" + + " \"show_cover\": 0, \n" + + " \"cover_url\": \"http://mmbiz.qpic.cn/mmbiz/GE7et87vE9vicuCibqXsX9GPPLuEtBfXfK0HKuBIa1A1cypS0uY1wickv70iaY1gf3I1DTszuJoS3lAVLv\n" + + "hTcm9sDA/0\", \n" + + " \"content_url\": \"http://mp.weixin.qq.com/s?__biz=MjM5ODUwNTM3Ng==&mid=204013432&idx=1&sn=80ce6d9abcb832237bf86c87e50fda15#rd\", \n" + + " \"source_url\": \"\"\n" + + " },\n" + + " { \n" + + " \"title\": \"MULTI_NEWS4\", \n" + + " \"author\": \"JIMZHENG\", \n" + + " \"digest\": \"MULTI_NEWSMULTI_NEWSMULTI_NEWSMULTI_NEWSMULTI_NEWSMULT\", \n" + + " \"show_cover\": 1, \n" + + "\"cover_url\": \"http://mmbiz.qpic.cn/mmbiz/GE7et87vE9vicuCibqXsX9GPPLuEtBfXfKbE8sWdt2DDcL0dMfQWJWTVn1N8DxI0gcRmrtqBOuwQ\n" + + "HeuPKmFLK0ZQ/0\", \n" + + " \"content_url\": \"http://mp.weixin.qq.com/s?__biz=MjM5ODUwNTM3Ng==&mid=204013432&idx=5&sn=b4ef73a915e7c2265e437096582774af#rd\", \n" + + " \"source_url\": \"\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " }\n" + + " ]\n" + + " }, \n" + + " { \n" + + " \"rule_name\": \"autoreply-voice\", \n" + + " \"create_time\": 1423027971, \n" + + " \"reply_mode\": \"random_one\", \n" + + " \"keyword_list_info\": [ \n" + + " { \n" + + " \"type\": \"text\", \n" + + " \"match_mode\": \"contain\", \n" + + " \"content\": \"voice测试\"\n" + + " }\n" + + " ], \n" + + " \"reply_list_info\": [ \n" + + " { \n" + + " \"type\": \"voice\", \n" + + " \"content\": \"NESsxgHEvAcg3egJTtYj4uG1PTL6iPhratdWKDLAXYErhN6oEEfMdVyblWtBY5vp\"\n" + + " }\n" + + " ]\n" + + " }, \n" + + " { \n" + + " \"rule_name\": \"autoreply-text\", \n" + + " \"create_time\": 1423027926, \n" + + " \"reply_mode\": \"random_one\", \n" + + " \"keyword_list_info\": [ \n" + + " { \n" + + " \"type\": \"text\", \n" + + " \"match_mode\": \"contain\", \n" + + " \"content\": \"text测试\"\n" + + " }\n" + + " ], \n" + + " \"reply_list_info\": [ \n" + + " { \n" + + " \"type\": \"text\", \n" + + " \"content\": \"hello!text!\"\n" + + " }\n" + + " ]\n" + + " }, \n" + + " { \n" + + " \"rule_name\": \"autoreply-video\", \n" + + " \"create_time\": 1423027801, \n" + + " \"reply_mode\": \"random_one\", \n" + + " \"keyword_list_info\": [ \n" + + " { \n" + + " \"type\": \"text\", \n" + + " \"match_mode\": \"equal\", \n" + + " \"content\": \"video测试\"\n" + + " }\n" + + " ], \n" + + " \"reply_list_info\": [ \n" + + " { \n" + + " \"type\": \"video\", \n" + + "\"content\": \"http://61.182.133.153/vweixinp.tc.qq.com/1007_114bcede9a2244eeb5ab7f76d951df5f.f10.mp4?vkey=7183E5C952B16C3AB1991BA8138673DE1037CB82A29801A504B64A77F691BF9DF7AD054A9B7FE683&sha=0&save=1\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " }\n" + + "}"; + + WxMpCurrentAutoReplyInfo autoReplyInfo = WxMpCurrentAutoReplyInfo.fromJson(json); + + assertNotNull(autoReplyInfo); + assertTrue(autoReplyInfo.getAddFriendReplyOpen()); + assertTrue(autoReplyInfo.getAutoReplyOpen()); + assertNotNull(autoReplyInfo.getAddFriendAutoReplyInfo()); + assertNotNull(autoReplyInfo.getMessageDefaultAutoReplyInfo()); + assertTrue(autoReplyInfo.getKeywordAutoReplyInfo().getList().size() > 0); + + System.out.println(autoReplyInfo); + } + +} From f76f9f5a8e781ffbb6310ea26105b71543e9f527 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 11 Jul 2017 17:48:13 +0800 Subject: [PATCH 036/165] =?UTF-8?q?#272=20=E7=BB=9F=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E5=8D=95=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0H5=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=BF=85=E9=A1=BB=E7=9A=84=E5=8F=82=E6=95=B0scene=5Fi?= =?UTF-8?q?nfo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/WxPayUnifiedOrderRequest.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index 342a3eb2d2..fdfcea3e22 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -280,6 +280,26 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { @XStreamAlias("sub_openid") private String subOpenid; + /** + *
    +   * 字段名:场景信息
    +   * 变量名:scene_info
    +   * 是否必填:否,对H5支付来说是必填
    +   * 类型:String(256)
    +   * 示例值:{
    +   * "store_id": "SZT10000",
    +   * "store_name":"腾讯大厦腾大餐厅"
    +   * }
    +   * 描述:该字段用于统一下单时上报场景信息,目前支持上报实际门店信息。
    +   * {
    +   * "store_id": "", //门店唯一标识,选填,String(32)
    +   * "store_name":"”//门店名称,选填,String(64)
    +   * }
    +   * 
    + */ + @XStreamAlias("scene_info") + private String sceneInfo; + public WxPayUnifiedOrderRequest() { } @@ -307,6 +327,7 @@ private WxPayUnifiedOrderRequest(Builder builder) { setLimitPay(builder.limitPay); setOpenid(builder.openid); setSubOpenid(builder.subOpenid); + setSceneInfo(builder.sceneInfo); } public static Builder newBuilder() { @@ -459,6 +480,14 @@ public void setSubOpenid(String subOpenid) { this.subOpenid = subOpenid; } + public String getSceneInfo() { + return this.sceneInfo; + } + + public void setSceneInfo(String sceneInfo) { + this.sceneInfo = sceneInfo; + } + @Override protected void checkConstraints() { // if (!ArrayUtils.contains(TRADE_TYPES, this.getTradeType())) { @@ -512,6 +541,7 @@ public static final class Builder { private String limitPay; private String openid; private String subOpenid; + private String sceneInfo; private Builder() { } @@ -631,6 +661,11 @@ public Builder subOpenid(String subOpenid) { return this; } + public Builder sceneInfo(String sceneInfo) { + this.sceneInfo = sceneInfo; + return this; + } + public WxPayUnifiedOrderRequest build() { return new WxPayUnifiedOrderRequest(this); } From fae294099362453eded559177659031ac36ad91a Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 11 Jul 2017 17:59:27 +0800 Subject: [PATCH 037/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.7.5.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 5f1d901d4b..3b6ab1509b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.7.4.BETA + 2.7.5.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 3800522ceb..a2f1195b9a 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.4.BETA + 2.7.5.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 1790105d8f..b63055ebc2 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.4.BETA + 2.7.5.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 60d1194a78..b3e0e88e15 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.4.BETA + 2.7.5.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index d65bceef9f..bd95d24728 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.4.BETA + 2.7.5.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 7bb79b229d..7c695abc3e 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.7.4.BETA + 2.7.5.BETA 4.0.0 From 55c71a995e4423939906c7a73ae19878ccebce4f Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 14 Jul 2017 10:32:16 +0800 Subject: [PATCH 038/165] update travis settings --- .travis.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1c533f9765..484475232b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,17 @@ language: java -sudo: false -install: true -addons: - sonarcloud: - token: - secure: "834110c7191f97ecb226970c46dcaff8e681da5a" +#sudo: false +#install: true +#addons: +# sonarcloud: +# token: +# secure: "834110c7191f97ecb226970c46dcaff8e681da5a" jdk: - oraclejdk8 -#script: "mvn clean package -Dmaven.test.skip=true" +script: "mvn clean package -Dmaven.test.skip=true" -script: - - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar +#script: +# - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar branches: only: @@ -20,7 +20,7 @@ branches: cache: directories: - '$HOME/.m2/repository' - - '$HOME/.sonar/cache' +# - '$HOME/.sonar/cache' notifications: email: From 687093f755b3ec4a006e5db85e6cd4dc4bd8e7aa Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 15 Jul 2017 13:55:05 +0800 Subject: [PATCH 039/165] =?UTF-8?q?#279=20=E7=BB=9F=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E5=8D=95=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?WxPayUnifiedOrderRequest=E5=A2=9E=E5=8A=A0fingerprint=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/WxPayUnifiedOrderRequest.java | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index fdfcea3e22..7c927425de 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -299,6 +299,16 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { */ @XStreamAlias("scene_info") private String sceneInfo; + /** + *
    +   * 字段名:浏览器指纹
    +   * 变量名:fingerprint
    +   * 是否必填:否
    +   * 详细参考 https://pay.weixin.qq.com/wiki/doc/api/H5.php?chapter=15_7&index=6
    +   * 
    + */ + @XStreamAlias("fingerprint") + private String fingerprint; public WxPayUnifiedOrderRequest() { } @@ -328,6 +338,7 @@ private WxPayUnifiedOrderRequest(Builder builder) { setOpenid(builder.openid); setSubOpenid(builder.subOpenid); setSceneInfo(builder.sceneInfo); + fingerprint = builder.fingerprint; } public static Builder newBuilder() { @@ -518,14 +529,14 @@ public void checkAndSign(WxPayConfig config) throws WxPayException { } public static final class Builder { - private String deviceInfo; private String appid; - private String body; private String mchId; private String subAppId; private String subMchId; private String nonceStr; private String sign; + private String deviceInfo; + private String body; private String detail; private String attach; private String outTradeNo; @@ -542,25 +553,16 @@ public static final class Builder { private String openid; private String subOpenid; private String sceneInfo; + private String fingerprint; private Builder() { } - public Builder deviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - return this; - } - public Builder appid(String appid) { this.appid = appid; return this; } - public Builder body(String body) { - this.body = body; - return this; - } - public Builder mchId(String mchId) { this.mchId = mchId; return this; @@ -586,6 +588,16 @@ public Builder sign(String sign) { return this; } + public Builder deviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + return this; + } + + public Builder body(String body) { + this.body = body; + return this; + } + public Builder detail(String detail) { this.detail = detail; return this; @@ -666,6 +678,11 @@ public Builder sceneInfo(String sceneInfo) { return this; } + public Builder fingerprint(String fingerprint) { + this.fingerprint = fingerprint; + return this; + } + public WxPayUnifiedOrderRequest build() { return new WxPayUnifiedOrderRequest(this); } From 3a2efdd343c4f22e44b8d8e2456c59f22db861c5 Mon Sep 17 00:00:00 2001 From: mgcnrx11 Date: Sat, 15 Jul 2017 16:22:36 +0800 Subject: [PATCH 040/165] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E5=8D=A1=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=20(#280)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 新增会员卡相关接口 1. 激活会员卡接口 2. 拉取会员信息接口 --- .../weixin/mp/api/WxMpMemberCardService.java | 38 +++++ .../me/chanjar/weixin/mp/api/WxMpService.java | 7 + .../mp/api/impl/AbstractWxMpServiceImpl.java | 6 + .../api/impl/WxMpMemberCardServiceImpl.java | 78 ++++++++++ .../bean/membercard/MemberCardUserInfo.java | 27 ++++ .../weixin/mp/bean/membercard/NameValues.java | 36 +++++ .../WxMpMemberCardActivatedMessage.java | 144 ++++++++++++++++++ .../WxMpMemberCardUserInfoResult.java | 137 +++++++++++++++++ .../weixin/mp/util/json/WxMpGsonBuilder.java | 2 + ...MpMemberCardUserInfoResultGsonAdapter.java | 72 +++++++++ 10 files changed, 547 insertions(+) create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImpl.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java new file mode 100644 index 0000000000..89b9fd74ea --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java @@ -0,0 +1,38 @@ +package me.chanjar.weixin.mp.api; + +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardActivatedMessage; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult; + +/** + * 会员卡相关接口 + * + * @author YuJian(mgcnrx11@gmail.com) + * @version 2017/7/8 + */ +public interface WxMpMemberCardService { + + /** + * 得到WxMpService + */ + WxMpService getWxMpService(); + + /** + * 会员卡激活接口 + * + * @param activatedMessage 激活所需参数 + * @return 调用返回的JSON字符串。 + * @throws WxErrorException 接口调用失败抛出的异常 + */ + String activateMemberCard(WxMpMemberCardActivatedMessage activatedMessage) throws WxErrorException; + + /** + * 拉取会员信息接口 + * + * @param cardId 会员卡的CardId,微信分配 + * @param code 领取会员的会员卡Code + * @return 会员信息的结果对象 + * @throws WxErrorException 接口调用失败抛出的异常 + */ + WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code) throws WxErrorException; +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java index 0cff2c1cfd..e4da721c8e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java @@ -434,6 +434,13 @@ public interface WxMpService { */ WxMpShakeService getShakeService(); + /** + * 返回会员卡相关接口方法的实现类对象,以方便调用其各个接口 + * + * @return WxMpMemberCardService + */ + WxMpMemberCardService getMemberCardService(); + /** * 初始化http请求对象 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java index ed93d4936f..cc965026c4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java @@ -42,6 +42,7 @@ public abstract class AbstractWxMpServiceImpl implements WxMpService, Requ private WxMpTemplateMsgService templateMsgService = new WxMpTemplateMsgServiceImpl(this); private WxMpDeviceService deviceService = new WxMpDeviceServiceImpl(this); private WxMpShakeService shakeService = new WxMpShakeServiceImpl(this); + private WxMpMemberCardService memberCardService = new WxMpMemberCardServiceImpl(this); private int retrySleepMillis = 1000; private int maxRetryTimes = 5; @@ -406,6 +407,11 @@ public WxMpShakeService getShakeService() { return this.shakeService; } + @Override + public WxMpMemberCardService getMemberCardService() { + return this.memberCardService; + } + @Override public RequestHttp getRequestHttp() { return this; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImpl.java new file mode 100644 index 0000000000..24c70ebe9f --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImpl.java @@ -0,0 +1,78 @@ +package me.chanjar.weixin.mp.api.impl; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpMemberCardService; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardActivatedMessage; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 会员卡相关接口的实现类 + * + * @author YuJian(mgcnrx11@gmail.com) + * @version 2017/7/8 + */ +public class WxMpMemberCardServiceImpl implements WxMpMemberCardService { + + private final Logger log = LoggerFactory.getLogger(WxMpMemberCardServiceImpl.class); + + private static final String MEMBER_CARD_ACTIVATE = "https://api.weixin.qq.com/card/membercard/activate"; + private static final String MEMBER_CARD_USER_INFO_GET = "https://api.weixin.qq.com/card/membercard/userinfo/get"; + + private WxMpService wxMpService; + + private static final Gson GSON = new Gson(); + + WxMpMemberCardServiceImpl(WxMpService wxMpService) { + this.wxMpService = wxMpService; + } + + /** + * 得到WxMpService + */ + @Override + public WxMpService getWxMpService() { + return this.wxMpService; + } + + /** + * 会员卡激活接口 + * + * @param activatedMessage 激活所需参数 + * @return 调用返回的JSON字符串。 + * @throws WxErrorException 接口调用失败抛出的异常 + */ + @Override + public String activateMemberCard(WxMpMemberCardActivatedMessage activatedMessage) throws WxErrorException { + return this.wxMpService.post(MEMBER_CARD_ACTIVATE, GSON.toJson(activatedMessage)); + } + + /** + * 拉取会员信息接口 + * + * @param cardId 会员卡的CardId,微信分配 + * @param code 领取会员的会员卡Code + * @return 会员信息的结果对象 + * @throws WxErrorException 接口调用失败抛出的异常 + */ + @Override + public WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code) throws WxErrorException { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("card_id", cardId); + jsonObject.addProperty("code",code); + + String responseContent = this.getWxMpService().post(MEMBER_CARD_USER_INFO_GET, jsonObject.toString()); + JsonElement tmpJsonElement = new JsonParser().parse(responseContent); + return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement, + new TypeToken() { + }.getType()); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java new file mode 100644 index 0000000000..336008b085 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java @@ -0,0 +1,27 @@ +package me.chanjar.weixin.mp.bean.membercard; + +/** + * Created by YuJian on 2017/7/11. + */ +public class MemberCardUserInfo { + + private NameValues[] commonFieldList; + + private NameValues[] customFieldList; + + public NameValues[] getCommonFieldList() { + return commonFieldList; + } + + public void setCommonFieldList(NameValues[] commonFieldList) { + this.commonFieldList = commonFieldList; + } + + public NameValues[] getCustomFieldList() { + return customFieldList; + } + + public void setCustomFieldList(NameValues[] customFieldList) { + this.customFieldList = customFieldList; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java new file mode 100644 index 0000000000..ae30d7a9a4 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.mp.bean.membercard; + +/** + * Created by YuJian on 2017/7/11. + */ +public class NameValues { + private String name; + + private String value; + + private String[] valueList; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String[] getValueList() { + return valueList; + } + + public void setValueList(String[] valueList) { + this.valueList = valueList; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java new file mode 100644 index 0000000000..8040224a09 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java @@ -0,0 +1,144 @@ +package me.chanjar.weixin.mp.bean.membercard; + +import com.google.gson.annotations.SerializedName; + +/** + * 会员卡激活接口的参数 + * + * @author YuJian(mgcnrx11@hotmail.com) + * @version 2017/7/8 + */ +public class WxMpMemberCardActivatedMessage { + + // 会员卡编号,由开发者填入,作为序列号显示在用户的卡包里。可与Code码保持等值。 + @SerializedName("membership_number") + private String membershipNumber; + // 领取会员卡用户获得的code + private String code; + // 卡券ID,自定义code卡券必填 + @SerializedName("card_id") + private String cardId; + // 商家自定义会员卡背景图,须先调用上传图片接口将背景图上传至CDN,否则报错。卡面设计请遵循微信会员卡自定义背景设计规范 + @SerializedName("background_pic_url") + private String backgroundPicUrl; + // 激活后的有效起始时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。 + @SerializedName("activate_begin_time") + private Integer activateBeginTime; + // 激活后的有效截至时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。 + @SerializedName("activate_end_time") + private Integer activateEndTime; + // 初始积分,不填为0。 + @SerializedName("init_bonus") + private Integer initBonus; + // 积分同步说明。 + @SerializedName("init_bonus_record") + private String initBonusRecord; + // 初始余额,不填为0。 + @SerializedName("init_balance") + private Integer initBalance; + // 创建时字段custom_field1定义类型的初始值,限制为4个汉字,12字节。 + @SerializedName("init_custom_field_value1") + private String initCustomFieldValue1; + // 创建时字段custom_field2定义类型的初始值,限制为4个汉字,12字节。 + @SerializedName("init_custom_field_value2") + private String initCustomFieldValue2; + // 创建时字段custom_field3定义类型的初始值,限制为4个汉字,12字节。 + @SerializedName("init_custom_field_value3") + private String initCustomFieldValue3; + + public String getMembershipNumber() { + return membershipNumber; + } + + public void setMembershipNumber(String membershipNumber) { + this.membershipNumber = membershipNumber; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getCardId() { + return cardId; + } + + public void setCardId(String cardId) { + this.cardId = cardId; + } + + public String getBackgroundPicUrl() { + return backgroundPicUrl; + } + + public void setBackgroundPicUrl(String backgroundPicUrl) { + this.backgroundPicUrl = backgroundPicUrl; + } + + public Integer getActivateBeginTime() { + return activateBeginTime; + } + + public void setActivateBeginTime(Integer activateBeginTime) { + this.activateBeginTime = activateBeginTime; + } + + public Integer getActivateEndTime() { + return activateEndTime; + } + + public void setActivateEndTime(Integer activateEndTime) { + this.activateEndTime = activateEndTime; + } + + public Integer getInitBonus() { + return initBonus; + } + + public void setInitBonus(Integer initBonus) { + this.initBonus = initBonus; + } + + public String getInitBonusRecord() { + return initBonusRecord; + } + + public void setInitBonusRecord(String initBonusRecord) { + this.initBonusRecord = initBonusRecord; + } + + public Integer getInitBalance() { + return initBalance; + } + + public void setInitBalance(Integer initBalance) { + this.initBalance = initBalance; + } + + public String getInitCustomFieldValue1() { + return initCustomFieldValue1; + } + + public void setInitCustomFieldValue1(String initCustomFieldValue1) { + this.initCustomFieldValue1 = initCustomFieldValue1; + } + + public String getInitCustomFieldValue2() { + return initCustomFieldValue2; + } + + public void setInitCustomFieldValue2(String initCustomFieldValue2) { + this.initCustomFieldValue2 = initCustomFieldValue2; + } + + public String getInitCustomFieldValue3() { + return initCustomFieldValue3; + } + + public void setInitCustomFieldValue3(String initCustomFieldValue3) { + this.initCustomFieldValue3 = initCustomFieldValue3; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java new file mode 100644 index 0000000000..b3691da6dd --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java @@ -0,0 +1,137 @@ +package me.chanjar.weixin.mp.bean.membercard; + +import java.io.Serializable; + +/** + * 拉取会员信息返回的结果 + * + * 字段格式参考https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283 6.2.1小节的步骤5 + * + * @author YuJian + * @version 2017/7/9 + */ +public class WxMpMemberCardUserInfoResult implements Serializable { + + private static final long serialVersionUID = 9084777967442098311L; + + private String errorCode; + + private String errorMsg; + + private String openId; + + private String nickname; + + private String membershipNumber; + + private Integer bonus; + + private String sex; + + private MemberCardUserInfo userInfo; + + private String userCardStatus; + + private Boolean hasActive; + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public String getOpenId() { + return openId; + } + + public void setOpenId(String openId) { + this.openId = openId; + } + + public String getNickname() { + return nickname; + } + + public void setNickname(String nickname) { + this.nickname = nickname; + } + + public String getMembershipNumber() { + return membershipNumber; + } + + public void setMembershipNumber(String membershipNumber) { + this.membershipNumber = membershipNumber; + } + + public Integer getBonus() { + return bonus; + } + + public void setBonus(Integer bonus) { + this.bonus = bonus; + } + + public String getSex() { + return sex; + } + + public void setSex(String sex) { + this.sex = sex; + } + + public MemberCardUserInfo getUserInfo() { + return userInfo; + } + + public void setUserInfo(MemberCardUserInfo userInfo) { + this.userInfo = userInfo; + } + + public String getUserCardStatus() { + return userCardStatus; + } + + public void setUserCardStatus(String userCardStatus) { + this.userCardStatus = userCardStatus; + } + + public Boolean getHasActive() { + return hasActive; + } + + public void setHasActive(Boolean hasActive) { + this.hasActive = hasActive; + } + + @Override + public String toString() { + return "WxMpMemberCardUserInfoResult{" + + "errorCode='" + errorCode + '\'' + + ", errorMsg='" + errorMsg + '\'' + + ", openId='" + openId + '\'' + + ", nickname='" + nickname + '\'' + + ", membershipNumber='" + membershipNumber + '\'' + + ", bonus=" + bonus + + ", sex='" + sex + '\'' + + ", userInfo=" + userInfo + + ", userCardStatus='" + userCardStatus + '\'' + + ", hasActive=" + hasActive + + '}'; + } +} + diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java index 286778ad4b..8fca5a6a88 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java @@ -6,6 +6,7 @@ import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult; import me.chanjar.weixin.mp.bean.material.*; import me.chanjar.weixin.mp.bean.result.*; import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; @@ -49,6 +50,7 @@ public class WxMpGsonBuilder { INSTANCE.registerTypeAdapter(WxMediaImgUploadResult.class, new WxMediaImgUploadResultGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpTemplateIndustry.class, new WxMpIndustryGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpUserBlacklistGetResult.class, new WxUserBlacklistGetResultGsonAdapter()); + INSTANCE.registerTypeAdapter(WxMpMemberCardUserInfoResult.class, new WxMpMemberCardUserInfoResultGsonAdapter()); } public static Gson create() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java new file mode 100644 index 0000000000..021ea60226 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java @@ -0,0 +1,72 @@ +package me.chanjar.weixin.mp.util.json; + +import com.google.gson.*; +import me.chanjar.weixin.common.util.json.GsonHelper; +import me.chanjar.weixin.mp.bean.membercard.MemberCardUserInfo; +import me.chanjar.weixin.mp.bean.membercard.NameValues; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult; + +import java.lang.reflect.Type; + +/** + * Created by YuJian on 2017/7/11. + * + * @author YuJian + * @version 2017/7/11 + */ +public class WxMpMemberCardUserInfoResultGsonAdapter implements JsonDeserializer { + + @Override + public WxMpMemberCardUserInfoResult deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { + WxMpMemberCardUserInfoResult result = new WxMpMemberCardUserInfoResult(); + + JsonObject jsonObject = jsonElement.getAsJsonObject(); + + result.setOpenId(GsonHelper.getString(jsonObject, "openid")); + result.setErrorCode(GsonHelper.getString(jsonObject, "errcode")); + result.setErrorMsg(GsonHelper.getString(jsonObject, "errmsg")); + result.setNickname(GsonHelper.getString(jsonObject, "nickname")); + result.setMembershipNumber(GsonHelper.getString(jsonObject, "membership_number")); + result.setBonus(GsonHelper.getInteger(jsonObject, "bonus")); + result.setSex(GsonHelper.getString(jsonObject, "sex")); + result.setUserCardStatus(GsonHelper.getString(jsonObject, "user_card_status")); + result.setHasActive(GsonHelper.getBoolean(jsonObject, "has_active")); + + JsonObject userInfoJsonObject = jsonObject.getAsJsonObject("user_info"); + MemberCardUserInfo cardUserInfo = new MemberCardUserInfo(); + + JsonArray commonFieldListObj = userInfoJsonObject.getAsJsonArray("common_field_list"); + NameValues[] commonFieldListValues = new NameValues[commonFieldListObj.size()]; + for (int i = 0; i < commonFieldListObj.size(); i++) { + JsonObject commonField = commonFieldListObj.get(i).getAsJsonObject(); + NameValues commonNameValues = new NameValues(); + commonNameValues.setName(GsonHelper.getString(commonField, "name")); + commonNameValues.setValue(GsonHelper.getString(commonField, "value")); + commonFieldListValues[i] = commonNameValues; + } + cardUserInfo.setCommonFieldList(commonFieldListValues); + + JsonArray customFieldListObj = userInfoJsonObject.getAsJsonArray("custom_field_list"); + NameValues[] customFieldListValues = new NameValues[customFieldListObj.size()]; + for (int i = 0; i < customFieldListObj.size(); i++) { + JsonObject customField = customFieldListObj.get(i).getAsJsonObject(); + NameValues customNameValues = new NameValues(); + customNameValues.setName(GsonHelper.getString(customField, "name")); + customNameValues.setValue(GsonHelper.getString(customField, "value")); + + JsonArray valueListArray = customField.getAsJsonArray("value_list"); + String[] valueList = new String[valueListArray.size()]; + for (int j = 0; j < valueListArray.size(); j++) { + JsonObject valueListObj = valueListArray.getAsJsonObject(); + valueList[i] = valueListObj.getAsString(); + } + customNameValues.setValueList(valueList); + customFieldListValues[i] = customNameValues; + } + cardUserInfo.setCustomFieldList(customFieldListValues); + + result.setUserInfo(cardUserInfo); + + return result; + } +} From c8c51a9ceecf7574c68aa31e4ee2d5b87b5a5f26 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 15 Jul 2017 17:13:00 +0800 Subject: [PATCH 041/165] =?UTF-8?q?#178=20=E5=AE=9E=E7=8E=B0=E5=8F=91?= =?UTF-8?q?=E9=80=81=E4=BB=A3=E9=87=91=E5=88=B8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/coupon/WxPayCouponSendRequest.java | 311 ++++++++++++++++++ .../bean/coupon/WxPayCouponSendResult.java | 204 ++++++++++++ .../wxpay/bean/request/WxPayBaseRequest.java | 79 ++--- .../wxpay/service/WxPayService.java | 12 + .../impl/WxPayServiceAbstractImpl.java | 13 + ...java => WxPayServiceAbstractImplTest.java} | 14 +- 6 files changed, 589 insertions(+), 44 deletions(-) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java rename weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/{WxPayServiceImplTest.java => WxPayServiceAbstractImplTest.java} (94%) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java new file mode 100644 index 0000000000..9a98fd64a2 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java @@ -0,0 +1,311 @@ +package com.github.binarywang.wxpay.bean.coupon; + +import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import me.chanjar.weixin.common.annotation.Required; + +/** + *
    + * 发送代金券请求对象类
    + * Created by Binary Wang on 2017-7-15.
    + * 
    + * + * @author Binary Wang + */ +@XStreamAlias("xml") +public class WxPayCouponSendRequest extends WxPayBaseRequest { + /** + *
    +   * 字段名:代金券批次id
    +   * 变量名:coupon_stock_id
    +   * 是否必填:是
    +   * 示例值:1757
    +   * 类型:String
    +   * 说明:代金券批次id
    +   * 
    + */ + @Required + @XStreamAlias("coupon_stock_id") + private String couponStockId; + + /** + *
    +   * 字段名:openid记录数
    +   * 变量名:openid_count
    +   * 是否必填:是
    +   * 示例值:1
    +   * 类型:int
    +   * 说明:openid记录数(目前支持num=1)
    +   * 
    + */ + @Required + @XStreamAlias("openid_count") + private Integer openidCount; + + /** + *
    +   * 字段名:商户单据号
    +   * 变量名:partner_trade_no
    +   * 是否必填:是
    +   * 示例值:1000009820141203515766
    +   * 类型:String
    +   * 说明:商户此次发放凭据号(格式:商户id+日期+流水号),商户侧需保持唯一性
    +   * 
    + */ + @Required + @XStreamAlias("partner_trade_no") + private String partnerTradeNo; + + /** + *
    +   * 字段名:用户openid
    +   * 变量名:openid
    +   * 是否必填:是
    +   * 示例值:onqOjjrXT-776SpHnfexGm1_P7iE
    +   * 类型:String
    +   * 说明:Openid信息,用户在appid下的openid。
    +   * 
    + */ + @Required + @XStreamAlias("openid") + private String openid; + + /** + *
    +   * 字段名:操作员
    +   * 变量名:op_user_id
    +   * 是否必填:否
    +   * 示例值:10000098
    +   * 类型:String(32)
    +   * 说明:操作员帐号, 默认为商户号,可在商户平台配置操作员对应的api权限
    +   * 
    + */ + @XStreamAlias("op_user_id") + private String opUserId; + + /** + *
    +   * 字段名:设备号
    +   * 变量名:device_info
    +   * 是否必填:否
    +   * 示例值:
    +   * 类型:String(32)
    +   * 说明:微信支付分配的终端设备号
    +   * 
    + */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + *
    +   * 字段名:协议版本
    +   * 变量名:version
    +   * 是否必填:否
    +   * 示例值:1.0
    +   * 类型:String(32)
    +   * 说明:默认1.0
    +   * 
    + */ + @XStreamAlias("version") + private String version; + + /** + *
    +   * 字段名:协议类型
    +   * 变量名:type
    +   * 是否必填:否
    +   * 示例值:XML
    +   * 类型:String(32)
    +   * 说明:XML【目前仅支持默认XML】
    +   * 
    + */ + @XStreamAlias("type") + private String type; + + public WxPayCouponSendRequest() { + } + + private WxPayCouponSendRequest(Builder builder) { + setAppid(builder.appid); + setMchId(builder.mchId); + setSubAppId(builder.subAppId); + setSubMchId(builder.subMchId); + setNonceStr(builder.nonceStr); + setSign(builder.sign); + setCouponStockId(builder.couponStockId); + setOpenidCount(builder.openidCount); + setPartnerTradeNo(builder.partnerTradeNo); + setOpenid(builder.openid); + setOpUserId(builder.opUserId); + setDeviceInfo(builder.deviceInfo); + setVersion(builder.version); + setType(builder.type); + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getCouponStockId() { + return this.couponStockId; + } + + public void setCouponStockId(String couponStockId) { + this.couponStockId = couponStockId; + } + + public Integer getOpenidCount() { + return this.openidCount; + } + + public void setOpenidCount(Integer openidCount) { + this.openidCount = openidCount; + } + + public String getPartnerTradeNo() { + return this.partnerTradeNo; + } + + public void setPartnerTradeNo(String partnerTradeNo) { + this.partnerTradeNo = partnerTradeNo; + } + + public String getOpenid() { + return this.openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + + public String getOpUserId() { + return this.opUserId; + } + + public void setOpUserId(String opUserId) { + this.opUserId = opUserId; + } + + public String getDeviceInfo() { + return this.deviceInfo; + } + + public void setDeviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + } + + public String getVersion() { + return this.version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + protected void checkConstraints() { + //do nothing + } + + public static final class Builder { + private String appid; + private String mchId; + private String subAppId; + private String subMchId; + private String nonceStr; + private String sign; + private String couponStockId; + private Integer openidCount; + private String partnerTradeNo; + private String openid; + private String opUserId; + private String deviceInfo; + private String version; + private String type; + + private Builder() { + } + + public Builder appid(String appid) { + this.appid = appid; + return this; + } + + public Builder mchId(String mchId) { + this.mchId = mchId; + return this; + } + + public Builder subAppId(String subAppId) { + this.subAppId = subAppId; + return this; + } + + public Builder subMchId(String subMchId) { + this.subMchId = subMchId; + return this; + } + + public Builder nonceStr(String nonceStr) { + this.nonceStr = nonceStr; + return this; + } + + public Builder sign(String sign) { + this.sign = sign; + return this; + } + + public Builder couponStockId(String couponStockId) { + this.couponStockId = couponStockId; + return this; + } + + public Builder openidCount(Integer openidCount) { + this.openidCount = openidCount; + return this; + } + + public Builder partnerTradeNo(String partnerTradeNo) { + this.partnerTradeNo = partnerTradeNo; + return this; + } + + public Builder openid(String openid) { + this.openid = openid; + return this; + } + + public Builder opUserId(String opUserId) { + this.opUserId = opUserId; + return this; + } + + public Builder deviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + return this; + } + + public Builder version(String version) { + this.version = version; + return this; + } + + public Builder type(String type) { + this.type = type; + return this; + } + + public WxPayCouponSendRequest build() { + return new WxPayCouponSendRequest(this); + } + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java new file mode 100644 index 0000000000..1c562adae2 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java @@ -0,0 +1,204 @@ +package com.github.binarywang.wxpay.bean.coupon; + +import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; +import com.thoughtworks.xstream.annotations.XStreamAlias; + +/** + *
    + * 发送代金券响应结果类
    + * Created by Binary Wang on 2017-7-15.
    + * 
    + * + * @author Binary Wang + */ +@XStreamAlias("xml") +public class WxPayCouponSendResult extends WxPayBaseResult { + /** + *
    +   * 字段名:设备号
    +   * 变量名:device_info
    +   * 是否必填:否
    +   * 示例值:123456sb
    +   * 类型:String(32)
    +   * 描述:微信支付分配的终端设备号,
    +   * 
    + */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + *
    +   * 字段名:代金券批次id
    +   * 变量名:coupon_stock_id
    +   * 是否必填:是
    +   * 示例值:1757
    +   * 类型:String
    +   * 描述:用户在商户appid下的唯一标识
    +   * 
    + */ + @XStreamAlias("coupon_stock_id") + private String couponStockId; + + /** + *
    +   * 字段名:返回记录数
    +   * 变量名:resp_count
    +   * 是否必填:是
    +   * 示例值:1
    +   * 类型:Int
    +   * 描述:返回记录数
    +   * 
    + */ + @XStreamAlias("resp_count") + private Integer respCount; + + /** + *
    +   * 字段名:成功记录数
    +   * 变量名:success_count
    +   * 是否必填:是
    +   * 示例值:1或者0
    +   * 类型:Int
    +   * 描述:成功记录数
    +   * 
    + */ + @XStreamAlias("success_count") + private Integer successCount; + + /** + *
    +   * 字段名:失败记录数
    +   * 变量名:failed_count
    +   * 是否必填:是
    +   * 示例值:1或者0
    +   * 类型:Int
    +   * 描述:失败记录数
    +   * 
    + */ + @XStreamAlias("failed_count") + private Integer failedCount; + + /** + *
    +   * 字段名:用户标识
    +   * 变量名:openid
    +   * 是否必填:是
    +   * 示例值:onqOjjrXT-776SpHnfexGm1_P7iE
    +   * 类型:String
    +   * 描述:用户在商户appid下的唯一标识
    +   * 
    + */ + @XStreamAlias("openid") + private String openid; + + /** + *
    +   * 字段名:返回码
    +   * 变量名:ret_code
    +   * 是否必填:是
    +   * 示例值:SUCCESS或者FAILED
    +   * 类型:String
    +   * 描述:返回码,SUCCESS/FAILED
    +   * 
    + */ + @XStreamAlias("ret_code") + private String retCode; + + /** + *
    +   * 字段名:代金券id
    +   * 变量名:coupon_id
    +   * 是否必填:是
    +   * 示例值:1870
    +   * 类型:String
    +   * 描述:对一个用户成功发放代金券则返回代金券id,即ret_code为SUCCESS的时候;如果ret_code为FAILED则填写空串""
    +   * 
    + */ + @XStreamAlias("coupon_id") + private String couponId; + + /** + *
    +   * 字段名:返回信息
    +   * 变量名:ret_msg
    +   * 是否必填:是
    +   * 示例值:失败描述信息,例如:“用户已达领用上限”
    +   * 类型:String
    +   * 描述:返回信息,当返回码是FAILED的时候填写,否则填空串“”
    +   * 
    + */ + @XStreamAlias("ret_msg") + private String retMsg; + + public String getDeviceInfo() { + return this.deviceInfo; + } + + public void setDeviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + } + + public String getCouponStockId() { + return this.couponStockId; + } + + public void setCouponStockId(String couponStockId) { + this.couponStockId = couponStockId; + } + + public Integer getRespCount() { + return this.respCount; + } + + public void setRespCount(Integer respCount) { + this.respCount = respCount; + } + + public Integer getSuccessCount() { + return this.successCount; + } + + public void setSuccessCount(Integer successCount) { + this.successCount = successCount; + } + + public Integer getFailedCount() { + return this.failedCount; + } + + public void setFailedCount(Integer failedCount) { + this.failedCount = failedCount; + } + + public String getOpenid() { + return this.openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + + public String getRetCode() { + return this.retCode; + } + + public void setRetCode(String retCode) { + this.retCode = retCode; + } + + public String getCouponId() { + return this.couponId; + } + + public void setCouponId(String couponId) { + this.couponId = couponId; + } + + public String getRetMsg() { + return this.retMsg; + } + + public void setRetMsg(String retMsg) { + this.retMsg = retMsg; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java index 0d4fc08b9d..b0c2e85d5c 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java @@ -17,13 +17,6 @@ *
      * Created by Binary Wang on 2016-10-24.
      *  微信支付请求对象共用的参数存放类
    - * 注释中各行每个字段描述对应如下:
    - * 
  • 字段名 - *
  • 变量名 - *
  • 是否必填 - *
  • 类型 - *
  • 示例值 - *
  • 描述 *
  • * * @author binarywang(Binary Wang) @@ -31,72 +24,72 @@ public abstract class WxPayBaseRequest { /** *
    -   * 公众账号ID
    -   * appid
    -   * 是
    -   * String(32)
    -   * wxd678efh567hg6787
    -   * 微信分配的公众账号ID(企业号corpid即为此appId)
    +   * 字段名:公众账号ID
    +   * 变量名:appid
    +   * 是否必填:是
    +   * 类型:String(32)
    +   * 示例值:wxd678efh567hg6787
    +   * 描述:微信分配的公众账号ID(企业号corpid即为此appId)
        * 
    */ @XStreamAlias("appid") protected String appid; /** *
    -   * 商户号
    -   * mch_id
    -   * 是
    -   * String(32)
    -   * 1230000109
    -   * 微信支付分配的商户号
    +   * 字段名:商户号
    +   * 变量名:mch_id
    +   * 是否必填:是
    +   * 类型:String(32)
    +   * 示例值:1230000109
    +   * 描述:微信支付分配的商户号
        * 
    */ @XStreamAlias("mch_id") protected String mchId; /** *
    -   * 服务商模式下的子商户公众账号ID
    -   * sub_appid
    -   * 是
    -   * String(32)
    -   * wxd678efh567hg6787
    -   * 微信分配的子商户公众账号ID
    +   * 字段名:服务商模式下的子商户公众账号ID
    +   * 变量名:sub_appid
    +   * 是否必填:是
    +   * 类型:String(32)
    +   * 示例值:wxd678efh567hg6787
    +   * 描述:微信分配的子商户公众账号ID
        * 
    */ @XStreamAlias("sub_appid") protected String subAppId; /** *
    -   * 服务商模式下的子商户号
    -   * sub_mch_id
    -   * 是
    -   * String(32)
    -   * 1230000109
    -   * 微信支付分配的子商户号,开发者模式下必填
    +   * 字段名:服务商模式下的子商户号
    +   * 变量名:sub_mch_id
    +   * 是否必填:是
    +   * 类型:String(32)
    +   * 示例值:1230000109
    +   * 描述:微信支付分配的子商户号,开发者模式下必填
        * 
    */ @XStreamAlias("sub_mch_id") protected String subMchId; /** *
    -   * 随机字符串
    -   * nonce_str
    -   * 是
    -   * String(32)
    -   * 5K8264ILTKCH16CQ2502SI8ZNMTM67VS
    -   * 随机字符串,不长于32位。推荐随机数生成算法
    +   * 字段名:随机字符串
    +   * 变量名:nonce_str
    +   * 是否必填:是
    +   * 类型:String(32)
    +   * 示例值:5K8264ILTKCH16CQ2502SI8ZNMTM67VS
    +   * 描述:随机字符串,不长于32位。推荐随机数生成算法
        * 
    */ @XStreamAlias("nonce_str") protected String nonceStr; /** *
    -   * 签名
    -   * sign
    -   * 是
    -   * String(32)
    -   * C380BEC2BFD727A4B6845133519F3AD6
    -   * 签名,详见签名生成算法
    +   * 字段名:签名
    +   * 变量名:sign
    +   * 是否必填:是
    +   * 类型:String(32)
    +   * 示例值:C380BEC2BFD727A4B6845133519F3AD6
    +   * 描述:签名,详见签名生成算法
        * 
    */ @XStreamAlias("sign") diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java index 03640eb067..f2106c7260 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java @@ -1,5 +1,7 @@ package com.github.binarywang.wxpay.service; +import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest; +import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.config.WxPayConfig; @@ -339,4 +341,14 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri *
    */ String getSandboxSignKey() throws WxPayException; + + /** + *
    +   * 发放代金券
    +   * 接口请求链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/send_coupon
    +   * 是否需要证书:请求需要双向证书。
    +   * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_3
    +   * 
    + */ + WxPayCouponSendResult sendCoupon(WxPayCouponSendRequest request) throws WxPayException; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index aa9291760c..b1c31b8676 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -1,6 +1,8 @@ package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.utils.qrcode.QrcodeUtils; +import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest; +import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.config.WxPayConfig; @@ -463,4 +465,15 @@ public String getSandboxSignKey() throws WxPayException { result.checkResult(this); return result.getSandboxSignKey(); } + + @Override + public WxPayCouponSendResult sendCoupon(WxPayCouponSendRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/mmpaymkttransfers/send_coupon"; + String responseContent = this.post(url, request.toXML(), true); + WxPayCouponSendResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponSendResult.class); + result.checkResult(this); + return result; + } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java similarity index 94% rename from weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImplTest.java rename to weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index 1cba44c59b..cc6ab5a0b5 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -1,6 +1,8 @@ package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.utils.qrcode.QrcodeUtils; +import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest; +import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.exception.WxPayException; @@ -26,7 +28,7 @@ */ @Test @Guice(modules = ApiTestModule.class) -public class WxPayServiceImplTest { +public class WxPayServiceAbstractImplTest { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Inject @@ -271,4 +273,14 @@ public void testGetSandboxSignKey() throws Exception { this.logger.info(signKey); } + @Test + public void testSendCoupon() throws Exception { + WxPayCouponSendResult result = this.payService.sendCoupon(WxPayCouponSendRequest.newBuilder() + .couponStockId("123") + .openid("122") + .partnerTradeNo("1212") + .openidCount(1) + .build()); + this.logger.info(result.toString()); + } } From 22287a482da1ddf20307f474cc385928a87d7be6 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 15 Jul 2017 18:05:00 +0800 Subject: [PATCH 042/165] =?UTF-8?q?#281=20=E6=B6=88=E6=81=AF=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E5=99=A8=E5=A2=9E=E5=8A=A0=E5=AF=B9EventKey=E6=AD=A3?= =?UTF-8?q?=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F=E5=8C=B9=E9=85=8D=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cp/message/WxCpMessageRouterRule.java | 25 +++++++++++++------ .../weixin/mp/api/WxMpMessageRouterRule.java | 25 +++++++++++++------ .../weixin/mp/api/WxMpMessageRouterTest.java | 1 + 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouterRule.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouterRule.java index 5f41f61783..b5912404ce 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouterRule.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouterRule.java @@ -6,6 +6,7 @@ import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpXmlMessage; import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage; +import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.HashMap; @@ -27,6 +28,8 @@ public class WxCpMessageRouterRule { private String eventKey; + private String eventKeyRegex; + private String content; private String rContent; @@ -95,6 +98,14 @@ public WxCpMessageRouterRule eventKey(String eventKey) { return this; } + /** + * 如果eventKey匹配该正则表达式 + */ + public WxCpMessageRouterRule eventKeyRegex(String regex) { + this.eventKeyRegex = regex; + return this; + } + /** * 如果content等于某值 * @@ -207,17 +218,17 @@ protected boolean test(WxCpXmlMessage wxMessage) { && (this.agentId == null || this.agentId.equals(wxMessage.getAgentId())) && - (this.msgType == null || this.msgType.equals(wxMessage.getMsgType())) + (this.msgType == null || this.msgType.equalsIgnoreCase(wxMessage.getMsgType())) + && + (this.event == null || this.event.equalsIgnoreCase(wxMessage.getEvent())) && - (this.event == null || this.event.equals(wxMessage.getEvent())) + (this.eventKey == null || this.eventKey.equalsIgnoreCase(wxMessage.getEventKey())) && - (this.eventKey == null || this.eventKey.equals(wxMessage.getEventKey())) + (this.eventKeyRegex == null || Pattern.matches(this.eventKeyRegex, StringUtils.trimToEmpty(wxMessage.getEventKey()))) && - (this.content == null || this.content - .equals(wxMessage.getContent() == null ? null : wxMessage.getContent().trim())) + (this.content == null || this.content.equals(StringUtils.trimToNull(wxMessage.getContent()))) && - (this.rContent == null || Pattern - .matches(this.rContent, wxMessage.getContent() == null ? "" : wxMessage.getContent().trim())) + (this.rContent == null || Pattern.matches(this.rContent, StringUtils.trimToEmpty(wxMessage.getContent()))) && (this.matcher == null || this.matcher.match(wxMessage)) ; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouterRule.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouterRule.java index e44406f4b1..50e30af6b7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouterRule.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouterRule.java @@ -5,6 +5,7 @@ import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.HashMap; @@ -26,6 +27,8 @@ public class WxMpMessageRouterRule { private String eventKey; + private String eventKeyRegex; + private String content; private String rContent; @@ -74,6 +77,14 @@ public WxMpMessageRouterRule eventKey(String eventKey) { return this; } + /** + * 如果eventKey匹配该正则表达式 + */ + public WxMpMessageRouterRule eventKeyRegex(String regex) { + this.eventKeyRegex = regex; + return this; + } + /** * 如果content等于某值 */ @@ -170,17 +181,17 @@ protected boolean test(WxMpXmlMessage wxMessage) { return (this.fromUser == null || this.fromUser.equals(wxMessage.getFromUser())) && - (this.msgType == null || this.msgType.toLowerCase().equals((wxMessage.getMsgType() == null ? null : wxMessage.getMsgType().toLowerCase()))) + (this.msgType == null || this.msgType.equalsIgnoreCase(wxMessage.getMsgType())) + && + (this.event == null || this.event.equalsIgnoreCase(wxMessage.getEvent())) && - (this.event == null || this.event.toLowerCase().equals((wxMessage.getEvent() == null ? null : wxMessage.getEvent().toLowerCase()))) + (this.eventKey == null || this.eventKey.equalsIgnoreCase(wxMessage.getEventKey())) && - (this.eventKey == null || this.eventKey.toLowerCase().equals((wxMessage.getEventKey() == null ? null : wxMessage.getEventKey().toLowerCase()))) + (this.eventKeyRegex == null || Pattern.matches(this.eventKeyRegex, StringUtils.trimToEmpty(wxMessage.getEventKey()))) && - (this.content == null || this.content - .equals(wxMessage.getContent() == null ? null : wxMessage.getContent().trim())) + (this.content == null || this.content.equals(StringUtils.trimToNull(wxMessage.getContent()))) && - (this.rContent == null || Pattern - .matches(this.rContent, wxMessage.getContent() == null ? "" : wxMessage.getContent().trim())) + (this.rContent == null || Pattern.matches(this.rContent, StringUtils.trimToEmpty(wxMessage.getContent()))) && (this.matcher == null || this.matcher.match(wxMessage)) ; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMessageRouterTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMessageRouterTest.java index 4360440f04..35d13ee1e9 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMessageRouterTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMessageRouterTest.java @@ -39,6 +39,7 @@ public void prepare(boolean async, StringBuffer sb, WxMpMessageRouter router) { .rule().async(async).msgType(WxConsts.XML_MSG_TEXT).handler(new WxEchoMpMessageHandler(sb, WxConsts.XML_MSG_TEXT)).end() .rule().async(async).event(WxConsts.EVT_CLICK).handler(new WxEchoMpMessageHandler(sb, WxConsts.EVT_CLICK)).end() .rule().async(async).eventKey("KEY_1").handler(new WxEchoMpMessageHandler(sb, "KEY_1")).end() + .rule().async(async).eventKeyRegex("KEY_1*").handler(new WxEchoMpMessageHandler(sb, "KEY_123")).end() .rule().async(async).content("CONTENT_1").handler(new WxEchoMpMessageHandler(sb, "CONTENT_1")).end() .rule().async(async).rContent(".*bc.*").handler(new WxEchoMpMessageHandler(sb, "abcd")).end() .rule().async(async).matcher(new WxMpMessageMatcher() { From 9368177d0058b5030b5003767b9f437041e78d29 Mon Sep 17 00:00:00 2001 From: mgcnrx11 Date: Sat, 15 Jul 2017 18:53:23 +0800 Subject: [PATCH 043/165] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E5=8D=A1=E7=AE=A1=E7=90=86=E6=9C=8D=E5=8A=A1=E7=9A=84`?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BC=9A=E5=91=98=E4=BF=A1=E6=81=AF`?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=9A=84=E5=AE=9E=E7=8E=B0=20(#283)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复UserInfo反序列化的bug,补充其单元测试 * 增加`更新会员信息`接口的实现 * 增加会员卡相关接口的测试类 包含下述方法: 1. 会员卡激活接口 2. 会员信息获取接口 3. 更新会员信息接口 --- .../weixin/mp/api/WxMpMemberCardService.java | 15 ++ .../api/impl/WxMpMemberCardServiceImpl.java | 26 +++ .../mp/bean/membercard/NotifyOptional.java | 73 ++++++++ .../WxMpMemberCardUpdateMessage.java | 156 ++++++++++++++++++ .../WxMpMemberCardUpdateResult.java | 82 +++++++++ .../WxMpMemberCardUserInfoResult.java | 6 + .../weixin/mp/util/json/WxMpGsonBuilder.java | 2 + ...WxMpMemberCardUpdateResultGsonAdapter.java | 37 +++++ ...MpMemberCardUserInfoResultGsonAdapter.java | 7 +- .../impl/WxMpMemberCardServiceImplTest.java | 61 +++++++ .../WxMpMemberCardUpdateResultTest.java | 33 ++++ .../WxMpMemberCardUserInfoResultTest.java | 80 +++++++++ 12 files changed, 574 insertions(+), 4 deletions(-) create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUpdateResultGsonAdapter.java create mode 100644 weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImplTest.java create mode 100644 weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResultTest.java create mode 100644 weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResultTest.java diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java index 89b9fd74ea..7cebb8c858 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java @@ -2,6 +2,8 @@ import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardActivatedMessage; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateMessage; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateResult; import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult; /** @@ -35,4 +37,17 @@ public interface WxMpMemberCardService { * @throws WxErrorException 接口调用失败抛出的异常 */ WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code) throws WxErrorException; + + /** + * 当会员持卡消费后,支持开发者调用该接口更新会员信息。会员卡交易后的每次信息变更需通过该接口通知微信,便于后续消息通知及其他扩展功能。 + * + * 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。同时传入add_bonus和bonus时 + * add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。 + * 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。 + * + * @param updateUserMessage 更新会员信息所需字段消息 + * @return 调用返回的JSON字符串。 + * @throws WxErrorException 接口调用失败抛出的异常 + */ + WxMpMemberCardUpdateResult updateUserMemberCard(WxMpMemberCardUpdateMessage updateUserMessage) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImpl.java index 24c70ebe9f..b3a43a765a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImpl.java @@ -9,6 +9,8 @@ import me.chanjar.weixin.mp.api.WxMpMemberCardService; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardActivatedMessage; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateMessage; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateResult; import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import org.slf4j.Logger; @@ -26,6 +28,7 @@ public class WxMpMemberCardServiceImpl implements WxMpMemberCardService { private static final String MEMBER_CARD_ACTIVATE = "https://api.weixin.qq.com/card/membercard/activate"; private static final String MEMBER_CARD_USER_INFO_GET = "https://api.weixin.qq.com/card/membercard/userinfo/get"; + private static final String MEMBER_CARD_UPDATE_USER = "https://api.weixin.qq.com/card/membercard/updateuser"; private WxMpService wxMpService; @@ -75,4 +78,27 @@ public WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code) thro new TypeToken() { }.getType()); } + + /** + * 当会员持卡消费后,支持开发者调用该接口更新会员信息。会员卡交易后的每次信息变更需通过该接口通知微信,便于后续消息通知及其他扩展功能。 + * + * 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。同时传入add_bonus和bonus时 + * add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。 + * 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。 + * + * @param updateUserMessage 更新会员信息所需字段消息 + * @return 调用返回的JSON字符串。 + * @throws WxErrorException 接口调用失败抛出的异常 + */ + @Override + public WxMpMemberCardUpdateResult updateUserMemberCard(WxMpMemberCardUpdateMessage updateUserMessage) + throws WxErrorException { + + String responseContent = this.getWxMpService().post(MEMBER_CARD_UPDATE_USER, GSON.toJson(updateUserMessage)); + + JsonElement tmpJsonElement = new JsonParser().parse(responseContent); + return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement, + new TypeToken() { + }.getType()); + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java new file mode 100644 index 0000000000..a8adae8ac7 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java @@ -0,0 +1,73 @@ +package me.chanjar.weixin.mp.bean.membercard; + +import com.google.gson.annotations.SerializedName; + +/** + * 控制原生消息结构体,包含各字段的消息控制字段。 + * + * 用于 `7 更新会员信息` 的接口参数调用 + * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283 + * + * @author YuJian(mgcnrx11@gmail.com) + * @version 2017/7/15 + */ +public class NotifyOptional { + + // 积分变动时是否触发系统模板消息,默认为true + @SerializedName("is_notify_bonus") + private Boolean isNotifyBonus; + + // 余额变动时是否触发系统模板消息,默认为true + @SerializedName("is_notify_balance") + private Boolean isNotifyBalance; + + // 自定义group1变动时是否触发系统模板消息,默认为false。(2、3同理) + @SerializedName("is_notify_custom_field1") + private Boolean isNotifyCustomField1; + + @SerializedName("is_notify_custom_field2") + private Boolean isNotifyCustomField2; + + @SerializedName("is_notify_custom_field3") + private Boolean isNotifyCustomField3; + + public Boolean getNotifyBonus() { + return isNotifyBonus; + } + + public void setNotifyBonus(Boolean notifyBonus) { + isNotifyBonus = notifyBonus; + } + + public Boolean getNotifyBalance() { + return isNotifyBalance; + } + + public void setNotifyBalance(Boolean notifyBalance) { + isNotifyBalance = notifyBalance; + } + + public Boolean getNotifyCustomField1() { + return isNotifyCustomField1; + } + + public void setNotifyCustomField1(Boolean notifyCustomField1) { + isNotifyCustomField1 = notifyCustomField1; + } + + public Boolean getNotifyCustomField2() { + return isNotifyCustomField2; + } + + public void setNotifyCustomField2(Boolean notifyCustomField2) { + isNotifyCustomField2 = notifyCustomField2; + } + + public Boolean getNotifyCustomField3() { + return isNotifyCustomField3; + } + + public void setNotifyCustomField3(Boolean notifyCustomField3) { + isNotifyCustomField3 = notifyCustomField3; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java new file mode 100644 index 0000000000..f4d410185d --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java @@ -0,0 +1,156 @@ +package me.chanjar.weixin.mp.bean.membercard; + +import com.google.gson.annotations.SerializedName; + +/** + * 更新会员信息所需字段消息。 + * + * 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。同时传入add_bonus和bonus时 + * add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。 + * 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。 + * + * @author YuJian(mgcnrx11@gmail.com) + * @version 2017/7/15 + */ +public class WxMpMemberCardUpdateMessage { + + // 领取会员卡用户获得的code + private String code; + // 卡券ID,自定义code卡券必填 + @SerializedName("card_id") + private String cardId; + // 支持商家激活时针对单个会员卡分配自定义的会员卡背景 + @SerializedName("background_pic_url") + private String backgroundPicUrl; + // 需要设置的积分全量值,传入的数值会直接显示 + private Integer bonus; + // 本次积分变动值,传负数代表减少 + @SerializedName("add_bonus") + private Integer addBounus; + // 商家自定义积分消耗记录,不超过14个汉字 + @SerializedName("record_bonus") + private String recordBonus; + // 需要设置的余额全量值,传入的数值会直接显示在卡面 + private Integer balance; + // 本次余额变动值,传负数代表减少 + @SerializedName("add_balance") + private Integer addBalance; + // 商家自定义金额消耗记录,不超过14个汉字。 + @SerializedName("record_balance") + private String recordBalance; + + // 创建时字段custom_field定义类型的最新数值,限制为4个汉字,12字节。 + @SerializedName("custom_field_value1") + private String customFieldValue1; + @SerializedName("custom_field_value2") + private String customFieldValue2; + @SerializedName("custom_field_value3") + private String customFieldValue3; + + @SerializedName("notify_optional") + private NotifyOptional notifyOptional; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getCardId() { + return cardId; + } + + public void setCardId(String cardId) { + this.cardId = cardId; + } + + public String getBackgroundPicUrl() { + return backgroundPicUrl; + } + + public void setBackgroundPicUrl(String backgroundPicUrl) { + this.backgroundPicUrl = backgroundPicUrl; + } + + public Integer getBonus() { + return bonus; + } + + public void setBonus(Integer bonus) { + this.bonus = bonus; + } + + public Integer getAddBounus() { + return addBounus; + } + + public void setAddBounus(Integer addBounus) { + this.addBounus = addBounus; + } + + public String getRecordBonus() { + return recordBonus; + } + + public void setRecordBonus(String recordBonus) { + this.recordBonus = recordBonus; + } + + public Integer getBalance() { + return balance; + } + + public void setBalance(Integer balance) { + this.balance = balance; + } + + public Integer getAddBalance() { + return addBalance; + } + + public void setAddBalance(Integer addBalance) { + this.addBalance = addBalance; + } + + public String getRecordBalance() { + return recordBalance; + } + + public void setRecordBalance(String recordBalance) { + this.recordBalance = recordBalance; + } + + public String getCustomFieldValue1() { + return customFieldValue1; + } + + public void setCustomFieldValue1(String customFieldValue1) { + this.customFieldValue1 = customFieldValue1; + } + + public String getCustomFieldValue2() { + return customFieldValue2; + } + + public void setCustomFieldValue2(String customFieldValue2) { + this.customFieldValue2 = customFieldValue2; + } + + public String getCustomFieldValue3() { + return customFieldValue3; + } + + public void setCustomFieldValue3(String customFieldValue3) { + this.customFieldValue3 = customFieldValue3; + } + + public NotifyOptional getNotifyOptional() { + return notifyOptional; + } + + public void setNotifyOptional(NotifyOptional notifyOptional) { + this.notifyOptional = notifyOptional; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java new file mode 100644 index 0000000000..e615cb0721 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java @@ -0,0 +1,82 @@ +package me.chanjar.weixin.mp.bean.membercard; + +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + +import java.io.Serializable; + +/** + * 用于 `7 更新会员信息` 的接口调用后的返回结果 + * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283 + * + * @author YuJian(mgcnrx11@gmail.com) + * @version 2017/7/15 + */ +public class WxMpMemberCardUpdateResult implements Serializable { + + private static final long serialVersionUID = 9084886191442098311L; + + private String errorCode; + + private String errorMsg; + + private String openId; + + private Integer resultBonus; + + private Integer resultBalance; + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public String getOpenId() { + return openId; + } + + public void setOpenId(String openId) { + this.openId = openId; + } + + public Integer getResultBonus() { + return resultBonus; + } + + public void setResultBonus(Integer resultBonus) { + this.resultBonus = resultBonus; + } + + public Integer getResultBalance() { + return resultBalance; + } + + public void setResultBalance(Integer resultBalance) { + this.resultBalance = resultBalance; + } + + @Override + public String toString() { + return "WxMpMemberCardUpdateResult{" + + "errorCode='" + errorCode + '\'' + + ", errorMsg='" + errorMsg + '\'' + + ", openId='" + openId + '\'' + + ", resultBonus=" + resultBonus + + ", resultBalance=" + resultBalance + + '}'; + } + + public static WxMpMemberCardUpdateResult fromJson(String json) { + return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpMemberCardUpdateResult.class); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java index b3691da6dd..1ddb57d34b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java @@ -1,5 +1,7 @@ package me.chanjar.weixin.mp.bean.membercard; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + import java.io.Serializable; /** @@ -133,5 +135,9 @@ public String toString() { ", hasActive=" + hasActive + '}'; } + + public static WxMpMemberCardUserInfoResult fromJson(String json) { + return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpMemberCardUserInfoResult.class); + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java index 8fca5a6a88..124845ed6b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java @@ -6,6 +6,7 @@ import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateResult; import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult; import me.chanjar.weixin.mp.bean.material.*; import me.chanjar.weixin.mp.bean.result.*; @@ -51,6 +52,7 @@ public class WxMpGsonBuilder { INSTANCE.registerTypeAdapter(WxMpTemplateIndustry.class, new WxMpIndustryGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpUserBlacklistGetResult.class, new WxUserBlacklistGetResultGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpMemberCardUserInfoResult.class, new WxMpMemberCardUserInfoResultGsonAdapter()); + INSTANCE.registerTypeAdapter(WxMpMemberCardUpdateResult.class, new WxMpMemberCardUpdateResultGsonAdapter()); } public static Gson create() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUpdateResultGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUpdateResultGsonAdapter.java new file mode 100644 index 0000000000..dc068db1e8 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUpdateResultGsonAdapter.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.mp.util.json; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import me.chanjar.weixin.common.util.json.GsonHelper; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateResult; + +import java.lang.reflect.Type; + +/** + * Json to WxMpMemberCardUpdateResult 的转换适配器 + * + * @author YuJian + * @version 2017/7/15 + */ +public class WxMpMemberCardUpdateResultGsonAdapter implements JsonDeserializer { + + @Override + public WxMpMemberCardUpdateResult deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext + jsonDeserializationContext) throws JsonParseException { + + WxMpMemberCardUpdateResult result = new WxMpMemberCardUpdateResult(); + + JsonObject jsonObject = jsonElement.getAsJsonObject(); + + result.setOpenId(GsonHelper.getString(jsonObject, "openid")); + result.setErrorCode(GsonHelper.getString(jsonObject, "errcode")); + result.setErrorMsg(GsonHelper.getString(jsonObject, "errmsg")); + result.setResultBalance(GsonHelper.getInteger(jsonObject, "result_balance")); + result.setResultBonus(GsonHelper.getInteger(jsonObject, "result_bonus")); + + return result; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java index 021ea60226..5a97ee7496 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMemberCardUserInfoResultGsonAdapter.java @@ -9,9 +9,9 @@ import java.lang.reflect.Type; /** - * Created by YuJian on 2017/7/11. + * Json to WxMpMemberCardUserInfoResult 的转换适配器 * - * @author YuJian + * @author YuJian(mgcnrx11@gmail.com) * @version 2017/7/11 */ public class WxMpMemberCardUserInfoResultGsonAdapter implements JsonDeserializer { @@ -57,8 +57,7 @@ public WxMpMemberCardUserInfoResult deserialize(JsonElement jsonElement, Type ty JsonArray valueListArray = customField.getAsJsonArray("value_list"); String[] valueList = new String[valueListArray.size()]; for (int j = 0; j < valueListArray.size(); j++) { - JsonObject valueListObj = valueListArray.getAsJsonObject(); - valueList[i] = valueListObj.getAsString(); + valueList[j] = valueListArray.get(j).getAsString(); } customNameValues.setValueList(valueList); customFieldListValues[i] = customNameValues; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImplTest.java new file mode 100644 index 0000000000..67eb5817cc --- /dev/null +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImplTest.java @@ -0,0 +1,61 @@ +package me.chanjar.weixin.mp.api.impl; + +import com.google.inject.Inject; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.api.test.ApiTestModule; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardActivatedMessage; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateMessage; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateResult; +import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import static org.testng.AssertJUnit.assertNotNull; + +/** + * 会员卡相关接口的测试类。 + * 数据均为测试数据,由于直接与调用微信的接口,需要填写真实数据进行测试才能通过。 + */ +@Test +@Guice(modules = ApiTestModule.class) +public class WxMpMemberCardServiceImplTest { + + @Inject + protected WxMpService wxService; + private String cardId = "abc"; + private String code = "123"; + private String openId = "xyz"; + + @Test + public void testActivateMemberCard() throws Exception { + WxMpMemberCardActivatedMessage activatedMessage = new WxMpMemberCardActivatedMessage(); + activatedMessage.setMembershipNumber(openId); + activatedMessage.setCode(code); + activatedMessage.setCardId(cardId); + activatedMessage.setInitBonus(2000); + activatedMessage.setInitBonusRecord("测试激活送积分"); + String response = this.wxService.getMemberCardService().activateMemberCard(activatedMessage); + assertNotNull(response); + System.out.println(response); + } + + @Test + public void testGetUserInfo() throws Exception { + WxMpMemberCardUserInfoResult result = this.wxService.getMemberCardService().getUserInfo(cardId, code); + assertNotNull(result); + System.out.println(result); + } + + @Test + public void testUpdateUserMemberCard() throws Exception { + WxMpMemberCardUpdateMessage updateMessage = new WxMpMemberCardUpdateMessage(); + updateMessage.setAddBounus(100); + updateMessage.setBonus(1000); + updateMessage.setCardId(cardId); + updateMessage.setCode(code); + WxMpMemberCardUpdateResult result = this.wxService.getMemberCardService().updateUserMemberCard(updateMessage); + assertNotNull(result); + System.out.println(result); + } + +} diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResultTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResultTest.java new file mode 100644 index 0000000000..f7860e7c85 --- /dev/null +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResultTest.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.mp.bean.membercard; + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +/** + * + * @author YuJian + * @version 2017/7/15 + */ +public class WxMpMemberCardUpdateResultTest { + + @Test + public void testFromJson() throws Exception { + String json = "{\n" + + " \"errcode\": 0,\n" + + " \"errmsg\": \"ok\",\n" + + " \"result_bonus\": 100,\n" + + " \"result_balance\": 200,\n" + + " \"openid\": \"oFS7Fjl0WsZ9AMZqrI80nbIq8xrA\"\n" + + "}"; + + WxMpMemberCardUpdateResult result = WxMpMemberCardUpdateResult.fromJson(json); + + assertNotNull(result); + assertTrue(result.getErrorCode().equalsIgnoreCase("0")); + + System.out.println(result); + } +} diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResultTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResultTest.java new file mode 100644 index 0000000000..da8ff3da36 --- /dev/null +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResultTest.java @@ -0,0 +1,80 @@ +package me.chanjar.weixin.mp.bean.membercard; + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +/** + * + * @author YuJian + * @version 2017/7/15 + */ +public class WxMpMemberCardUserInfoResultTest { + + @Test + public void testFromJson() throws Exception { + String json = "{\n" + + " \"errcode\": 0,\n" + + " \"errmsg\": \"ok\",\n" + + " \"openid\": \"obLatjjwDolFj******wNqRXw\",\n" + + " \"nickname\": \"*******\",\n" + + " \"membership_number\": \"658*****445\",\n" + + " \"bonus\": 995,\n" + + " \"sex\": \"MALE\",\n" + + " \"user_info\": {\n" + + " \"common_field_list\": [\n" + + " {\n" + + " \"name\": \"USER_FORM_INFO_FLAG_MOBILE\",\n" + + " \"value\": \"15*****518\"\n" + + " },\n" + + " {\n" + + " \"name\": \"USER_FORM_INFO_FLAG_NAME\",\n" + + " \"value\": \"HK\"\n" + + " },\n" + + " {\n" + + " \"name\": \"USER_FORM_INFO_FLAG_EDUCATION_BACKGROUND\",\n" + + " \"value\": \"研究生\"\n" + + " }\n" + + " ],\n" + + " \"custom_field_list\": [\n" + + " {\n" + + " \"name\": \"兴趣\",\n" + + " \"value\": \"钢琴\",\n" + + " \"value_list\": []\n" + + " },\n" + + " {\n" + + " \"name\": \"喜好\",\n" + + " \"value\": \"郭敬明\",\n" + + " \"value_list\": []\n" + + " },\n" + + " {\n" + + " \"name\": \"职业\",\n" + + " \"value\": \"\",\n" + + " \"value_list\": [\n" + + " \"赛车手\",\n" + + " \"旅行家\"\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"user_card_status\": \"NORMAL\",\n" + + " \"has_active\": false\n" + + "}"; + + + WxMpMemberCardUserInfoResult userInfoResult = WxMpMemberCardUserInfoResult.fromJson(json); + + assertNotNull(userInfoResult); + assertFalse(userInfoResult.getHasActive()); + assertTrue(userInfoResult.getSex().equalsIgnoreCase("MALE")); + assertNotNull(userInfoResult.getUserInfo()); + assertNotNull(userInfoResult.getUserInfo().getCommonFieldList()); + assertNotNull(userInfoResult.getUserInfo().getCustomFieldList()); + assertTrue(userInfoResult.getUserInfo().getCommonFieldList().length == 3); + assertTrue(userInfoResult.getUserInfo().getCustomFieldList()[2].getValueList()[0].equalsIgnoreCase("赛车手")); + + System.out.println(userInfoResult); + } +} From 9f669dff8285942c8b0b3221a3d9ce839a0a4f6a Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 15 Jul 2017 19:16:52 +0800 Subject: [PATCH 044/165] =?UTF-8?q?#178=20=E5=AE=9E=E7=8E=B0=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=BB=A3=E9=87=91=E5=88=B8=E6=89=B9=E6=AC=A1=E5=92=8C?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coupon/WxPayCouponInfoQueryRequest.java | 280 ++++++++++++++ .../coupon/WxPayCouponInfoQueryResult.java | 351 ++++++++++++++++++ .../coupon/WxPayCouponStockQueryRequest.java | 221 +++++++++++ .../coupon/WxPayCouponStockQueryResult.java | 288 ++++++++++++++ .../wxpay/service/WxPayService.java | 21 +- .../impl/WxPayServiceAbstractImpl.java | 25 +- .../impl/WxPayServiceAbstractImplTest.java | 21 +- 7 files changed, 1201 insertions(+), 6 deletions(-) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java new file mode 100644 index 0000000000..3d83d0a6c6 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java @@ -0,0 +1,280 @@ +package com.github.binarywang.wxpay.bean.coupon; + +import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import me.chanjar.weixin.common.annotation.Required; + +/** + *
    + * 查询代金券信息请求对象类
    + * Created by Binary Wang on 2017-7-15.
    + * 
    + * + * @author Binary Wang + */ +@XStreamAlias("xml") +public class WxPayCouponInfoQueryRequest extends WxPayBaseRequest { + /** + *
    +   * 字段名:代金券id
    +   * 变量名:coupon_id
    +   * 是否必填:是
    +   * 示例值:1757
    +   * 类型:String
    +   * 说明:代金券id
    +   * 
    + */ + @Required + @XStreamAlias("coupon_id") + private String couponId; + + /** + *
    +   * 字段名:代金券批次号
    +   * 变量名:stock_id
    +   * 是否必填:是
    +   * 示例值:58818
    +   * 类型:String
    +   * 说明:代金劵对应的批次号
    +   * 
    + */ + @Required + @XStreamAlias("stock_id") + private String stockId; + + /** + *
    +   * 字段名:用户openid
    +   * 变量名:openid
    +   * 是否必填:是
    +   * 示例值:onqOjjrXT-776SpHnfexGm1_P7iE
    +   * 类型:String
    +   * 说明:Openid信息,用户在appid下的openid。
    +   * 
    + */ + @Required + @XStreamAlias("openid") + private String openid; + + /** + *
    +   * 字段名:操作员
    +   * 变量名:op_user_id
    +   * 是否必填:否
    +   * 示例值:10000098
    +   * 类型:String(32)
    +   * 说明:操作员帐号, 默认为商户号,可在商户平台配置操作员对应的api权限
    +   * 
    + */ + @XStreamAlias("op_user_id") + private String opUserId; + + /** + *
    +   * 字段名:设备号
    +   * 变量名:device_info
    +   * 是否必填:否
    +   * 示例值:
    +   * 类型:String(32)
    +   * 说明:微信支付分配的终端设备号
    +   * 
    + */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + *
    +   * 字段名:协议版本
    +   * 变量名:version
    +   * 是否必填:否
    +   * 示例值:1.0
    +   * 类型:String(32)
    +   * 说明:默认1.0
    +   * 
    + */ + @XStreamAlias("version") + private String version; + + /** + *
    +   * 字段名:协议类型
    +   * 变量名:type
    +   * 是否必填:否
    +   * 示例值:XML
    +   * 类型:String(32)
    +   * 说明:XML【目前仅支持默认XML】
    +   * 
    + */ + @XStreamAlias("type") + private String type; + + private WxPayCouponInfoQueryRequest(Builder builder) { + setAppid(builder.appid); + setMchId(builder.mchId); + setSubAppId(builder.subAppId); + setSubMchId(builder.subMchId); + setNonceStr(builder.nonceStr); + setSign(builder.sign); + setCouponId(builder.couponId); + setStockId(builder.stockId); + setOpenid(builder.openid); + setOpUserId(builder.opUserId); + setDeviceInfo(builder.deviceInfo); + setVersion(builder.version); + setType(builder.type); + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getCouponId() { + return this.couponId; + } + + public void setCouponId(String couponId) { + this.couponId = couponId; + } + + public String getStockId() { + return this.stockId; + } + + public void setStockId(String stockId) { + this.stockId = stockId; + } + + public String getOpenid() { + return this.openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + + public String getOpUserId() { + return this.opUserId; + } + + public void setOpUserId(String opUserId) { + this.opUserId = opUserId; + } + + public String getDeviceInfo() { + return this.deviceInfo; + } + + public void setDeviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + } + + public String getVersion() { + return this.version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + protected void checkConstraints() { + //do nothing + } + + + public static final class Builder { + private String appid; + private String mchId; + private String subAppId; + private String subMchId; + private String nonceStr; + private String sign; + private String couponId; + private String stockId; + private String openid; + private String opUserId; + private String deviceInfo; + private String version; + private String type; + + private Builder() { + } + + public Builder appid(String appid) { + this.appid = appid; + return this; + } + + public Builder mchId(String mchId) { + this.mchId = mchId; + return this; + } + + public Builder subAppId(String subAppId) { + this.subAppId = subAppId; + return this; + } + + public Builder subMchId(String subMchId) { + this.subMchId = subMchId; + return this; + } + + public Builder nonceStr(String nonceStr) { + this.nonceStr = nonceStr; + return this; + } + + public Builder sign(String sign) { + this.sign = sign; + return this; + } + + public Builder couponId(String couponId) { + this.couponId = couponId; + return this; + } + + public Builder stockId(String stockId) { + this.stockId = stockId; + return this; + } + + public Builder openid(String openid) { + this.openid = openid; + return this; + } + + public Builder opUserId(String opUserId) { + this.opUserId = opUserId; + return this; + } + + public Builder deviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + return this; + } + + public Builder version(String version) { + this.version = version; + return this; + } + + public Builder type(String type) { + this.type = type; + return this; + } + + public WxPayCouponInfoQueryRequest build() { + return new WxPayCouponInfoQueryRequest(this); + } + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java new file mode 100644 index 0000000000..bec1c9e10a --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java @@ -0,0 +1,351 @@ +package com.github.binarywang.wxpay.bean.coupon; + +import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; +import com.thoughtworks.xstream.annotations.XStreamAlias; + +/** + *
    + * 查询代金券信息响应结果类
    + * Created by Binary Wang on 2017-7-15.
    + * 
    + * + * @author Binary Wang + */ +@XStreamAlias("xml") +public class WxPayCouponInfoQueryResult extends WxPayBaseResult { + /** + *
    +   * 字段名:设备号
    +   * 变量名:device_info
    +   * 是否必填:否
    +   * 示例值:123456sb
    +   * 类型:String(32)
    +   * 说明:微信支付分配的终端设备号,
    +   * 
    + */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + *
    +   * 字段名:批次ID
    +   * 变量名:coupon_stock_id
    +   * 是否必填:是
    +   * 示例值:1567
    +   * 类型:String
    +   * 说明:代金券批次Id
    +   * 
    + */ + @XStreamAlias("coupon_stock_id") + private String couponStockId; + + /** + *
    +   * 字段名:代金券id
    +   * 变量名:coupon_id
    +   * 是否必填:是
    +   * 示例值:4242
    +   * 类型:String
    +   * 说明:代金券id
    +   * 
    + */ + @XStreamAlias("coupon_id") + private String couponId; + + /** + *
    +   * 字段名:代金券面额
    +   * 变量名:coupon_value
    +   * 是否必填:是
    +   * 示例值:4
    +   * 类型:Unsinged int
    +   * 说明:代金券面值,单位是分
    +   * 
    + */ + @XStreamAlias("coupon_value") + private Integer couponValue; + + /** + *
    +   * 字段名:代金券使用门槛
    +   * 变量名:coupon_mininum
    +   * 是否必填:是
    +   * 示例值:10
    +   * 类型:Unsinged int
    +   * 说明:代金券使用最低限额,单位是分
    +   * 
    + */ + @XStreamAlias("coupon_mininum") + private Integer couponMininum; + + /** + *
    +   * 字段名:代金券名称
    +   * 变量名:coupon_name
    +   * 是否必填:是
    +   * 示例值:测试代金券
    +   * 类型:String
    +   * 说明:代金券名称
    +   * 
    + */ + @XStreamAlias("coupon_name") + private String couponName; + + /** + *
    +   * 字段名:代金券状态
    +   * 变量名:coupon_state
    +   * 是否必填:是
    +   * 示例值:SENDED
    +   * 类型:int
    +   * 说明:代金券状态:SENDED-可用,USED-已实扣,EXPIRED-已过期
    +   * 
    + */ + @XStreamAlias("coupon_state") + private Integer couponState; + + /** + *
    +   * 字段名:代金券描述
    +   * 变量名:coupon_desc
    +   * 是否必填:是
    +   * 示例值:微信支付-代金券
    +   * 类型:String
    +   * 说明:代金券描述
    +   * 
    + */ + @XStreamAlias("coupon_desc") + private String couponDesc; + + /** + *
    +   * 字段名:实际优惠金额
    +   * 变量名:coupon_use_value
    +   * 是否必填:是
    +   * 示例值:0
    +   * 类型:Unsinged int
    +   * 说明:代金券实际使用金额
    +   * 
    + */ + @XStreamAlias("coupon_use_value") + private Integer couponUseValue; + + /** + *
    +   * 字段名:优惠剩余可用额
    +   * 变量名:coupon_remain_value
    +   * 是否必填:是
    +   * 示例值:4
    +   * 类型:Unsinged int
    +   * 说明:代金券剩余金额:部分使用情况下,可能会存在券剩余金额
    +   * 
    + */ + @XStreamAlias("coupon_remain_value") + private Integer couponRemainValue; + + /** + *
    +   * 字段名:生效开始时间
    +   * 变量名:begin_time
    +   * 是否必填:是
    +   * 示例值:1943787483
    +   * 类型:String
    +   * 说明:格式为时间戳
    +   * 
    + */ + @XStreamAlias("begin_time") + private String beginTime; + + /** + *
    +   * 字段名:生效结束时间
    +   * 变量名:end_time
    +   * 是否必填:是
    +   * 示例值:1943787484
    +   * 类型:String
    +   * 说明:格式为时间戳
    +   * 
    + */ + @XStreamAlias("end_time") + private String endTime; + + /** + *
    +   * 字段名:发放时间
    +   * 变量名:send_time
    +   * 是否必填:是
    +   * 示例值:1943787420
    +   * 类型:String
    +   * 说明:格式为时间戳
    +   * 
    + */ + @XStreamAlias("send_time") + private String sendTime; + + /** + *
    +   * 字段名:消耗方商户id
    +   * 变量名:consumer_mch_id
    +   * 是否必填:否
    +   * 示例值:10000098
    +   * 类型:String
    +   * 说明:代金券使用后,消耗方商户id
    +   * 
    + */ + @XStreamAlias("consumer_mch_id") + private String consumerMchId; + + /** + *
    +   * 字段名:发放来源
    +   * 变量名:send_source
    +   * 是否必填:是
    +   * 示例值:FULL_SEND
    +   * 类型:String
    +   * 说明:代金券发放来源:FULL_SEND-满送 NORMAL-普通发放场景
    +   * 
    + */ + @XStreamAlias("send_source") + private String sendSource; + + /** + *
    +   * 字段名:是否允许部分使用
    +   * 变量名:is_partial_use
    +   * 是否必填:否
    +   * 示例值:1
    +   * 类型:String
    +   * 说明:该代金券是否允许部分使用标识:1-表示支持部分使用
    +   * 
    + */ + @XStreamAlias("is_partial_use") + private String isPartialUse; + + public String getDeviceInfo() { + return this.deviceInfo; + } + + public void setDeviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + } + + public String getCouponStockId() { + return this.couponStockId; + } + + public void setCouponStockId(String couponStockId) { + this.couponStockId = couponStockId; + } + + public String getCouponId() { + return this.couponId; + } + + public void setCouponId(String couponId) { + this.couponId = couponId; + } + + public Integer getCouponValue() { + return this.couponValue; + } + + public void setCouponValue(Integer couponValue) { + this.couponValue = couponValue; + } + + public Integer getCouponMininum() { + return this.couponMininum; + } + + public void setCouponMininum(Integer couponMininum) { + this.couponMininum = couponMininum; + } + + public String getCouponName() { + return this.couponName; + } + + public void setCouponName(String couponName) { + this.couponName = couponName; + } + + public Integer getCouponState() { + return this.couponState; + } + + public void setCouponState(Integer couponState) { + this.couponState = couponState; + } + + public String getCouponDesc() { + return this.couponDesc; + } + + public void setCouponDesc(String couponDesc) { + this.couponDesc = couponDesc; + } + + public Integer getCouponUseValue() { + return this.couponUseValue; + } + + public void setCouponUseValue(Integer couponUseValue) { + this.couponUseValue = couponUseValue; + } + + public Integer getCouponRemainValue() { + return this.couponRemainValue; + } + + public void setCouponRemainValue(Integer couponRemainValue) { + this.couponRemainValue = couponRemainValue; + } + + public String getBeginTime() { + return this.beginTime; + } + + public void setBeginTime(String beginTime) { + this.beginTime = beginTime; + } + + public String getEndTime() { + return this.endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getSendTime() { + return this.sendTime; + } + + public void setSendTime(String sendTime) { + this.sendTime = sendTime; + } + + public String getConsumerMchId() { + return this.consumerMchId; + } + + public void setConsumerMchId(String consumerMchId) { + this.consumerMchId = consumerMchId; + } + + public String getSendSource() { + return this.sendSource; + } + + public void setSendSource(String sendSource) { + this.sendSource = sendSource; + } + + public String getIsPartialUse() { + return this.isPartialUse; + } + + public void setIsPartialUse(String isPartialUse) { + this.isPartialUse = isPartialUse; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java new file mode 100644 index 0000000000..24cec5523c --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java @@ -0,0 +1,221 @@ +package com.github.binarywang.wxpay.bean.coupon; + +import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import me.chanjar.weixin.common.annotation.Required; + +/** + *
    + * 查询代金券批次请求对象类
    + * Created by Binary Wang on 2017-7-15.
    + * 
    + * + * @author Binary Wang + */ +@XStreamAlias("xml") +public class WxPayCouponStockQueryRequest extends WxPayBaseRequest { + /** + *
    +   * 字段名:代金券批次id
    +   * 变量名:coupon_stock_id
    +   * 是否必填:是
    +   * 示例值:1757
    +   * 类型:String
    +   * 说明:代金券批次id
    +   * 
    + */ + @Required + @XStreamAlias("coupon_stock_id") + private String couponStockId; + + /** + *
    +   * 字段名:操作员
    +   * 变量名:op_user_id
    +   * 是否必填:否
    +   * 示例值:10000098
    +   * 类型:String(32)
    +   * 说明:操作员帐号, 默认为商户号,可在商户平台配置操作员对应的api权限
    +   * 
    + */ + @XStreamAlias("op_user_id") + private String opUserId; + + /** + *
    +   * 字段名:设备号
    +   * 变量名:device_info
    +   * 是否必填:否
    +   * 示例值:
    +   * 类型:String(32)
    +   * 说明:微信支付分配的终端设备号
    +   * 
    + */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + *
    +   * 字段名:协议版本
    +   * 变量名:version
    +   * 是否必填:否
    +   * 示例值:1.0
    +   * 类型:String(32)
    +   * 说明:默认1.0
    +   * 
    + */ + @XStreamAlias("version") + private String version; + + /** + *
    +   * 字段名:协议类型
    +   * 变量名:type
    +   * 是否必填:否
    +   * 示例值:XML
    +   * 类型:String(32)
    +   * 说明:XML【目前仅支持默认XML】
    +   * 
    + */ + @XStreamAlias("type") + private String type; + + private WxPayCouponStockQueryRequest(Builder builder) { + setAppid(builder.appid); + setMchId(builder.mchId); + setSubAppId(builder.subAppId); + setSubMchId(builder.subMchId); + setNonceStr(builder.nonceStr); + setSign(builder.sign); + setCouponStockId(builder.couponStockId); + setOpUserId(builder.opUserId); + setDeviceInfo(builder.deviceInfo); + setVersion(builder.version); + setType(builder.type); + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getCouponStockId() { + return this.couponStockId; + } + + public void setCouponStockId(String couponStockId) { + this.couponStockId = couponStockId; + } + + public String getOpUserId() { + return this.opUserId; + } + + public void setOpUserId(String opUserId) { + this.opUserId = opUserId; + } + + public String getDeviceInfo() { + return this.deviceInfo; + } + + public void setDeviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + } + + public String getVersion() { + return this.version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + protected void checkConstraints() { + //do nothing + } + + public static final class Builder { + private String appid; + private String mchId; + private String subAppId; + private String subMchId; + private String nonceStr; + private String sign; + private String couponStockId; + private String opUserId; + private String deviceInfo; + private String version; + private String type; + + private Builder() { + } + + public Builder appid(String appid) { + this.appid = appid; + return this; + } + + public Builder mchId(String mchId) { + this.mchId = mchId; + return this; + } + + public Builder subAppId(String subAppId) { + this.subAppId = subAppId; + return this; + } + + public Builder subMchId(String subMchId) { + this.subMchId = subMchId; + return this; + } + + public Builder nonceStr(String nonceStr) { + this.nonceStr = nonceStr; + return this; + } + + public Builder sign(String sign) { + this.sign = sign; + return this; + } + + public Builder couponStockId(String couponStockId) { + this.couponStockId = couponStockId; + return this; + } + + public Builder opUserId(String opUserId) { + this.opUserId = opUserId; + return this; + } + + public Builder deviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + return this; + } + + public Builder version(String version) { + this.version = version; + return this; + } + + public Builder type(String type) { + this.type = type; + return this; + } + + public WxPayCouponStockQueryRequest build() { + return new WxPayCouponStockQueryRequest(this); + } + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java new file mode 100644 index 0000000000..065c3f606d --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java @@ -0,0 +1,288 @@ +package com.github.binarywang.wxpay.bean.coupon; + +import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; +import com.thoughtworks.xstream.annotations.XStreamAlias; + +/** + *
    + * 查询代金券批次响应结果类
    + * Created by Binary Wang on 2017-7-15.
    + * 
    + * + * @author Binary Wang + */ +@XStreamAlias("xml") +public class WxPayCouponStockQueryResult extends WxPayBaseResult { + /** + *
    +   * 字段名:设备号
    +   * 变量名:device_info
    +   * 是否必填:否
    +   * 示例值:123456sb
    +   * 类型:String(32)
    +   * 说明:微信支付分配的终端设备号
    +   * 
    + */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + *
    +   * 字段名:代金券批次ID
    +   * 变量名:coupon_stock_id
    +   * 是否必填:是
    +   * 示例值:1757
    +   * 类型:String
    +   * 说明:代金券批次Id
    +   * 
    + */ + @XStreamAlias("coupon_stock_id") + private String couponStockId; + + /** + *
    +   * 字段名:代金券名称
    +   * 变量名:coupon_name
    +   * 是否必填:否
    +   * 示例值:测试代金券
    +   * 类型:String
    +   * 说明:代金券名称
    +   * 
    + */ + @XStreamAlias("coupon_name") + private String couponName; + + /** + *
    +   * 字段名:代金券面额
    +   * 变量名:coupon_value
    +   * 是否必填:是
    +   * 示例值:5
    +   * 类型:Unsinged int
    +   * 说明:代金券面值,单位是分
    +   * 
    + */ + @XStreamAlias("coupon_value") + private Integer couponValue; + + /** + *
    +   * 字段名:代金券使用最低限额
    +   * 变量名:coupon_mininumn
    +   * 是否必填:否
    +   * 示例值:10
    +   * 类型:Unsinged int
    +   * 说明:代金券使用最低限额,单位是分
    +   * 
    + */ + @XStreamAlias("coupon_mininumn") + private Integer couponMininumn; + + /** + *
    +   * 字段名:代金券批次状态
    +   * 变量名:coupon_stock_status
    +   * 是否必填:是
    +   * 示例值:4
    +   * 类型:int
    +   * 说明:批次状态: 1-未激活;2-审批中;4-已激活;8-已作废;16-中止发放;
    +   * 
    + */ + @XStreamAlias("coupon_stock_status") + private Integer couponStockStatus; + + /** + *
    +   * 字段名:代金券数量
    +   * 变量名:coupon_total
    +   * 是否必填:是
    +   * 示例值:100
    +   * 类型:Unsigned int
    +   * 说明:代金券数量
    +   * 
    + */ + @XStreamAlias("coupon_total") + private Integer couponTotal; + + /** + *
    +   * 字段名:代金券最大领取数量
    +   * 变量名:max_quota
    +   * 是否必填:否
    +   * 示例值:1
    +   * 类型:Unsigned int
    +   * 说明:代金券每个人最多能领取的数量, 如果为0,则表示没有限制
    +   * 
    + */ + @XStreamAlias("max_quota") + private Integer maxQuota; + + /** + *
    +   * 字段名:代金券已经发送的数量
    +   * 变量名:is_send_num
    +   * 是否必填:否
    +   * 示例值:0
    +   * 类型:Unsigned int
    +   * 说明:代金券已经发送的数量
    +   * 
    + */ + @XStreamAlias("is_send_num") + private Integer isSendNum; + + /** + *
    +   * 字段名:生效开始时间
    +   * 变量名:begin_time
    +   * 是否必填:是
    +   * 示例值:1943787483
    +   * 类型:String
    +   * 说明:格式为时间戳
    +   * 
    + */ + @XStreamAlias("begin_time") + private String beginTime; + + /** + *
    +   * 字段名:生效结束时间
    +   * 变量名:end_time
    +   * 是否必填:是
    +   * 示例值:1943787490
    +   * 类型:String
    +   * 说明:格式为时间戳
    +   * 
    + */ + @XStreamAlias("end_time") + private String endTime; + + /** + *
    +   * 字段名:创建时间
    +   * 变量名:create_time
    +   * 是否必填:是
    +   * 示例值:1943787420
    +   * 类型:String
    +   * 说明:格式为时间戳
    +   * 
    + */ + @XStreamAlias("create_time") + private String createTime; + + /** + *
    +   * 字段名:代金券预算额度
    +   * 变量名:coupon_budget
    +   * 是否必填:否
    +   * 示例值:500
    +   * 类型:Unsigned int
    +   * 说明:代金券预算额度
    +   * 
    + */ + @XStreamAlias("coupon_budget") + private Integer couponBudget; + + public String getDeviceInfo() { + return this.deviceInfo; + } + + public void setDeviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + } + + public String getCouponStockId() { + return this.couponStockId; + } + + public void setCouponStockId(String couponStockId) { + this.couponStockId = couponStockId; + } + + public String getCouponName() { + return this.couponName; + } + + public void setCouponName(String couponName) { + this.couponName = couponName; + } + + public Integer getCouponValue() { + return this.couponValue; + } + + public void setCouponValue(Integer couponValue) { + this.couponValue = couponValue; + } + + public Integer getCouponMininumn() { + return this.couponMininumn; + } + + public void setCouponMininumn(Integer couponMininumn) { + this.couponMininumn = couponMininumn; + } + + public Integer getCouponStockStatus() { + return this.couponStockStatus; + } + + public void setCouponStockStatus(Integer couponStockStatus) { + this.couponStockStatus = couponStockStatus; + } + + public Integer getCouponTotal() { + return this.couponTotal; + } + + public void setCouponTotal(Integer couponTotal) { + this.couponTotal = couponTotal; + } + + public Integer getMaxQuota() { + return this.maxQuota; + } + + public void setMaxQuota(Integer maxQuota) { + this.maxQuota = maxQuota; + } + + public Integer getIsSendNum() { + return this.isSendNum; + } + + public void setIsSendNum(Integer isSendNum) { + this.isSendNum = isSendNum; + } + + public String getBeginTime() { + return this.beginTime; + } + + public void setBeginTime(String beginTime) { + this.beginTime = beginTime; + } + + public String getEndTime() { + return this.endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getCreateTime() { + return this.createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public Integer getCouponBudget() { + return this.couponBudget; + } + + public void setCouponBudget(Integer couponBudget) { + this.couponBudget = couponBudget; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java index f2106c7260..2eef29b85a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java @@ -1,7 +1,6 @@ package com.github.binarywang.wxpay.service; -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest; -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult; +import com.github.binarywang.wxpay.bean.coupon.*; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.config.WxPayConfig; @@ -351,4 +350,22 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri *
    */ WxPayCouponSendResult sendCoupon(WxPayCouponSendRequest request) throws WxPayException; + + /** + *
    +   * 查询代金券批次
    +   * 接口请求链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/query_coupon_stock
    +   * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_4
    +   * 
    + */ + WxPayCouponStockQueryResult queryCouponStock(WxPayCouponStockQueryRequest request) throws WxPayException; + + /** + *
    +   * 查询代金券信息
    +   * 接口请求链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/querycouponsinfo
    +   * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_5
    +   * 
    + */ + WxPayCouponInfoQueryResult queryCouponInfo(WxPayCouponInfoQueryRequest request) throws WxPayException; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index b1c31b8676..8eef35043c 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -1,8 +1,7 @@ package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.utils.qrcode.QrcodeUtils; -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest; -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult; +import com.github.binarywang.wxpay.bean.coupon.*; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.config.WxPayConfig; @@ -476,4 +475,26 @@ public WxPayCouponSendResult sendCoupon(WxPayCouponSendRequest request) throws W result.checkResult(this); return result; } + + @Override + public WxPayCouponStockQueryResult queryCouponStock(WxPayCouponStockQueryRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/mmpaymkttransfers/query_coupon_stock"; + String responseContent = this.post(url, request.toXML(), false); + WxPayCouponStockQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponStockQueryResult.class); + result.checkResult(this); + return result; + } + + @Override + public WxPayCouponInfoQueryResult queryCouponInfo(WxPayCouponInfoQueryRequest request) throws WxPayException { + request.checkAndSign(this.getConfig()); + + String url = this.getPayBaseUrl() + "/mmpaymkttransfers/querycouponsinfo"; + String responseContent = this.post(url, request.toXML(), false); + WxPayCouponInfoQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponInfoQueryResult.class); + result.checkResult(this); + return result; + } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index cc6ab5a0b5..bbf444d901 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -1,8 +1,7 @@ package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.utils.qrcode.QrcodeUtils; -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest; -import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult; +import com.github.binarywang.wxpay.bean.coupon.*; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.exception.WxPayException; @@ -283,4 +282,22 @@ public void testSendCoupon() throws Exception { .build()); this.logger.info(result.toString()); } + + @Test + public void testQueryCouponStock() throws Exception { + WxPayCouponStockQueryResult result = this.payService.queryCouponStock(WxPayCouponStockQueryRequest.newBuilder() + .couponStockId("123") + .build()); + this.logger.info(result.toString()); + } + + @Test + public void testQueryCouponInfo() throws Exception { + WxPayCouponInfoQueryResult result = this.payService.queryCouponInfo(WxPayCouponInfoQueryRequest.newBuilder() + .openid("onqOjjrXT-776SpHnfexGm1_P7iE") + .couponId("11") + .stockId("1121") + .build()); + this.logger.info(result.toString()); + } } From 66c7ae374ddc52fba7af10e08be2bd6e8e0bad05 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 15 Jul 2017 19:23:32 +0800 Subject: [PATCH 045/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.7.6.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 3b6ab1509b..0b78452d55 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.7.5.BETA + 2.7.6.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index a2f1195b9a..9299fa1ce7 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.5.BETA + 2.7.6.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index b63055ebc2..6732165602 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.5.BETA + 2.7.6.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index b3e0e88e15..181b505cd3 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.5.BETA + 2.7.6.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index bd95d24728..16648606b2 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.5.BETA + 2.7.6.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 7c695abc3e..4783621af5 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.7.5.BETA + 2.7.6.BETA 4.0.0 From 2b7dd7a7bf19d1e92de74df09d3e6716ca03f1aa Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 20 Jul 2017 21:12:07 +0800 Subject: [PATCH 046/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=B6=E7=9A=84=E4=B9=B1=E7=A0=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../http/apache/ApacheMaterialUploadRequestExecutor.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialUploadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialUploadRequestExecutor.java index 474fcb9936..445ff2736e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialUploadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialUploadRequestExecutor.java @@ -8,6 +8,7 @@ import me.chanjar.weixin.mp.bean.material.WxMpMaterial; import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; import me.chanjar.weixin.mp.util.http.MaterialUploadRequestExecutor; +import org.apache.http.Consts; import org.apache.http.HttpHost; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; @@ -15,6 +16,7 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.CloseableHttpClient; import java.io.File; @@ -53,7 +55,8 @@ public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material) throw .setMode(HttpMultipartMode.RFC6532); Map form = material.getForm(); if (material.getForm() != null) { - multipartEntityBuilder.addTextBody("description", WxGsonBuilder.create().toJson(form)); + multipartEntityBuilder.addPart("description", + new StringBody(WxGsonBuilder.create().toJson(form), ContentType.create("text/plain", Consts.UTF_8))); } httpPost.setEntity(multipartEntityBuilder.build()); From 1886c6b751bd1cb4e2b9faa9ccc9dd6cc53b6bd0 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 20 Jul 2017 21:21:54 +0800 Subject: [PATCH 047/165] =?UTF-8?q?#284=20=E6=8F=90=E5=8F=96=E5=85=B1?= =?UTF-8?q?=E5=90=8C=E4=BB=A3=E7=A0=81=E5=BF=AB=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=AD=BE=E5=90=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WxPayServiceAbstractImpl.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index 8eef35043c..7c57e5edeb 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -24,6 +24,7 @@ * 微信支付接口请求抽象实现类 * Created by Binary Wang on 2017-7-8. *
    + * * @author Binary Wang */ public abstract class WxPayServiceAbstractImpl implements WxPayService { @@ -196,6 +197,8 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W } Map payInfo = new HashMap<>(); + String timestamp = String.valueOf(System.currentTimeMillis() / 1000); + String nonceStr = String.valueOf(System.currentTimeMillis()); if ("NATIVE".equals(request.getTradeType())) { payInfo.put("codeUrl", unifiedOrderResult.getCodeURL()); } else if ("APP".equals(request.getTradeType())) { @@ -207,8 +210,8 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W configMap.put("prepayid", prepayId); configMap.put("partnerid", partnerid); configMap.put("package", "Sign=WXPay"); - configMap.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000)); - configMap.put("noncestr", String.valueOf(System.currentTimeMillis())); + configMap.put("timestamp", timestamp); + configMap.put("noncestr", nonceStr); configMap.put("appid", appId); // 此map用于客户端与微信服务器交互 payInfo.put("sign", SignUtils.createSign(configMap, this.getConfig().getMchKey())); @@ -216,17 +219,18 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W payInfo.put("partnerId", partnerid); payInfo.put("appId", appId); payInfo.put("packageValue", "Sign=WXPay"); - payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000)); - payInfo.put("nonceStr", String.valueOf(System.currentTimeMillis())); + payInfo.put("timeStamp", timestamp); + payInfo.put("nonceStr", nonceStr); } else if ("JSAPI".equals(request.getTradeType())) { payInfo.put("appId", unifiedOrderResult.getAppid()); // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 - payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000)); - payInfo.put("nonceStr", String.valueOf(System.currentTimeMillis())); + payInfo.put("timeStamp", timestamp); + payInfo.put("nonceStr", nonceStr); payInfo.put("package", "prepay_id=" + prepayId); payInfo.put("signType", "MD5"); payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey())); } + return payInfo; } From b9c9b844c88850cbb128daef5995a489f8ef0b80 Mon Sep 17 00:00:00 2001 From: lwxian Date: Fri, 21 Jul 2017 10:24:45 +0800 Subject: [PATCH 048/165] =?UTF-8?q?#287=20=E4=BF=AE=E5=A4=8D=E5=AF=B9?= =?UTF-8?q?=E5=B8=90=E5=8D=95=E4=B8=8B=E8=BD=BDbug=EF=BC=8C=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=9A=84=E5=AF=B9=E8=B1=A1=E6=B2=A1=E6=9C=89=E5=AF=B9?= =?UTF-8?q?=E5=B8=90=E5=8D=95=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同时修复返回对账单的所有属性的值最后多余的空格; --- .../impl/WxPayServiceAbstractImpl.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index 7c57e5edeb..9a75b46973 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -359,33 +359,34 @@ private WxPayBillResult billInformationDeal(String responseContent) { for (int i = 0; i < j; i++) { WxPayBillBaseResult wxPayBillBaseResult = new WxPayBillBaseResult(); - wxPayBillBaseResult.setTradeTime(tempStr[k]); - wxPayBillBaseResult.setAppId(tempStr[k + 1]); - wxPayBillBaseResult.setMchId(tempStr[k + 2]); - wxPayBillBaseResult.setSubMchId(tempStr[k + 3]); - wxPayBillBaseResult.setDeviceInfo(tempStr[k + 4]); - wxPayBillBaseResult.setTransationId(tempStr[k + 5]); - wxPayBillBaseResult.setOutTradeNo(tempStr[k + 6]); - wxPayBillBaseResult.setOpenId(tempStr[k + 7]); - wxPayBillBaseResult.setTradeType(tempStr[k + 8]); - wxPayBillBaseResult.setTradeState(tempStr[k + 9]); - wxPayBillBaseResult.setBankType(tempStr[k + 10]); - wxPayBillBaseResult.setFeeType(tempStr[k + 11]); - wxPayBillBaseResult.setTotalFee(tempStr[k + 12]); - wxPayBillBaseResult.setCouponFee(tempStr[k + 13]); - wxPayBillBaseResult.setRefundId(tempStr[k + 14]); - wxPayBillBaseResult.setOutRefundNo(tempStr[k + 15]); - wxPayBillBaseResult.setSettlementRefundFee(tempStr[k + 16]); - wxPayBillBaseResult.setCouponRefundFee(tempStr[k + 17]); - wxPayBillBaseResult.setRefundChannel(tempStr[k + 18]); - wxPayBillBaseResult.setRefundState(tempStr[k + 19]); - wxPayBillBaseResult.setBody(tempStr[k + 20]); - wxPayBillBaseResult.setAttach(tempStr[k + 21]); - wxPayBillBaseResult.setPoundage(tempStr[k + 22]); - wxPayBillBaseResult.setPoundageRate(tempStr[k + 23]); + wxPayBillBaseResult.setTradeTime(tempStr[k].trim()); + wxPayBillBaseResult.setAppId(tempStr[k + 1].trim()); + wxPayBillBaseResult.setMchId(tempStr[k + 2].trim()); + wxPayBillBaseResult.setSubMchId(tempStr[k + 3].trim()); + wxPayBillBaseResult.setDeviceInfo(tempStr[k + 4].trim()); + wxPayBillBaseResult.setTransationId(tempStr[k + 5].trim()); + wxPayBillBaseResult.setOutTradeNo(tempStr[k + 6].trim()); + wxPayBillBaseResult.setOpenId(tempStr[k + 7].trim()); + wxPayBillBaseResult.setTradeType(tempStr[k + 8].trim()); + wxPayBillBaseResult.setTradeState(tempStr[k + 9].trim()); + wxPayBillBaseResult.setBankType(tempStr[k + 10].trim()); + wxPayBillBaseResult.setFeeType(tempStr[k + 11].trim()); + wxPayBillBaseResult.setTotalFee(tempStr[k + 12].trim()); + wxPayBillBaseResult.setCouponFee(tempStr[k + 13].trim()); + wxPayBillBaseResult.setRefundId(tempStr[k + 14].trim()); + wxPayBillBaseResult.setOutRefundNo(tempStr[k + 15].trim()); + wxPayBillBaseResult.setSettlementRefundFee(tempStr[k + 16].trim()); + wxPayBillBaseResult.setCouponRefundFee(tempStr[k + 17].trim()); + wxPayBillBaseResult.setRefundChannel(tempStr[k + 18].trim()); + wxPayBillBaseResult.setRefundState(tempStr[k + 19].trim()); + wxPayBillBaseResult.setBody(tempStr[k + 20].trim()); + wxPayBillBaseResult.setAttach(tempStr[k + 21].trim()); + wxPayBillBaseResult.setPoundage(tempStr[k + 22].trim()); + wxPayBillBaseResult.setPoundageRate(tempStr[k + 23].trim()); wxPayBillBaseResultLst.add(wxPayBillBaseResult); k += t.length; } + wxPayBillResult.setWxPayBillBaseResultLst(wxPayBillBaseResultLst); /* * 总交易单数,总交易额,总退款金额,总代金券或立减优惠退款金额,手续费总金额 `2,`0.02,`0.0,`0.0,`0 */ From 30b5a9aa8f6ffd7b97ce9018d8682fd4e0d3668f Mon Sep 17 00:00:00 2001 From: Hyseen Date: Wed, 26 Jul 2017 14:34:57 +0800 Subject: [PATCH 049/165] =?UTF-8?q?#289=20=E5=A2=9E=E5=8A=A0=E4=B8=B4?= =?UTF-8?q?=E6=97=B6=E4=BA=8C=E7=BB=B4=E7=A0=81=E7=9A=84=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E5=80=BC=E6=94=AF=E6=8C=81=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 更新接口:临时二维码的场景值支持字符串 * 新增临时二维码的场景值为字符串的单元测试 --- .../weixin/mp/api/WxMpQrcodeService.java | 12 +++++++ .../mp/api/impl/WxMpQrcodeServiceImpl.java | 33 +++++++++++++++++++ .../api/impl/WxMpQrcodeServiceImplTest.java | 16 +++++++++ 3 files changed, 61 insertions(+) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpQrcodeService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpQrcodeService.java index e2e17eb359..37ed7dcd12 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpQrcodeService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpQrcodeService.java @@ -26,6 +26,18 @@ public interface WxMpQrcodeService { */ WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds) throws WxErrorException; + + /** + *
    +   * 换取临时二维码ticket
    +   * 详情请见: 生成带参数的二维码
    +   * 
    + * + * @param sceneStr 场景值ID(字符串形式的ID),字符串类型,长度限制为1到64 + * @param expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。 + */ + WxMpQrCodeTicket qrCodeCreateTmpTicket(String sceneStr, Integer expireSeconds) throws WxErrorException; + /** *
        * 换取永久二维码ticket
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java
    index 817a0b68f2..5f6c3ad54f 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java
    @@ -7,6 +7,7 @@
     import me.chanjar.weixin.mp.api.WxMpService;
     import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
     import me.chanjar.weixin.mp.util.http.QrCodeRequestExecutor;
    +import org.apache.commons.lang3.StringUtils;
     
     import java.io.File;
     import java.io.UnsupportedEncodingException;
    @@ -54,6 +55,38 @@ public WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds
         return WxMpQrCodeTicket.fromJson(responseContent);
       }
     
    +
    +  @Override
    +  public WxMpQrCodeTicket qrCodeCreateTmpTicket(String sceneStr, Integer expireSeconds) throws WxErrorException {
    +    if (StringUtils.isBlank(sceneStr)) {
    +      throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("临时二维码场景值不能为空!").build());
    +    }
    +
    +    //expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。
    +    if (expireSeconds != null && expireSeconds > 2592000) {
    +      throw new WxErrorException(WxError.newBuilder().setErrorCode(-1)
    +        .setErrorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build());
    +    }
    +
    +    if (expireSeconds == null) {
    +      expireSeconds = 30;
    +    }
    +
    +    String url = API_URL_PREFIX + "/create";
    +    JsonObject json = new JsonObject();
    +    json.addProperty("action_name", "QR_STR_SCENE");
    +    json.addProperty("expire_seconds", expireSeconds);
    +
    +    JsonObject actionInfo = new JsonObject();
    +    JsonObject scene = new JsonObject();
    +    scene.addProperty("scene_str", sceneStr);
    +    actionInfo.add("scene", scene);
    +    json.add("action_info", actionInfo);
    +    String responseContent = this.wxMpService.post(url, json.toString());
    +    return WxMpQrCodeTicket.fromJson(responseContent);
    +  }
    +
    +
       @Override
       public WxMpQrCodeTicket qrCodeCreateLastTicket(int sceneId) throws WxErrorException {
         if (sceneId < 1 || sceneId > 100000) {
    diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java
    index c61e38339c..216eec77f0 100644
    --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java
    +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java
    @@ -5,6 +5,7 @@
     import me.chanjar.weixin.mp.api.WxMpService;
     import me.chanjar.weixin.mp.api.test.ApiTestModule;
     import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
    +import org.apache.commons.lang3.RandomStringUtils;
     import org.testng.*;
     import org.testng.annotations.*;
     
    @@ -26,6 +27,11 @@ public Object[][] sceneIds() {
         return new Object[][]{{-1}, {0}, {1}, {200000}};
       }
     
    +  @DataProvider
    +  public Object[][] sceneStrs() {
    +    return new Object[][]{{null}, {""}, {"test"}, {RandomStringUtils.randomAlphanumeric(100)}};
    +  }
    +
       @Test(dataProvider = "sceneIds")
       public void testQrCodeCreateTmpTicket(int sceneId) throws WxErrorException {
         WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateTmpTicket(sceneId, null);
    @@ -35,6 +41,16 @@ public void testQrCodeCreateTmpTicket(int sceneId) throws WxErrorException {
         System.out.println(ticket);
       }
     
    +
    +  @Test(dataProvider = "sceneStrs")
    +  public void testQrCodeCreateTmpTicketWithSceneStr(String sceneStr) throws WxErrorException {
    +    WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateTmpTicket(sceneStr, null);
    +    Assert.assertNotNull(ticket.getUrl());
    +    Assert.assertNotNull(ticket.getTicket());
    +    Assert.assertTrue(ticket.getExpire_seconds() != -1);
    +    System.out.println(ticket);
    +  }
    +
       @Test(dataProvider = "sceneIds")
       public void testQrCodeCreateLastTicket(int sceneId) throws WxErrorException {
         WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateLastTicket(sceneId);
    
    From 087f0371b8deda7b054b1b70cdeecb180bbaff51 Mon Sep 17 00:00:00 2001
    From: forfuns 
    Date: Thu, 27 Jul 2017 17:24:48 +0800
    Subject: [PATCH 050/165] =?UTF-8?q?#292=20=E5=A2=9E=E5=8A=A0=E5=B0=8F?=
     =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=A0=81=E6=94=AF=E6=8C=81?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    * 更新小程序二维码(小程序码)接口
    修复小程序模板推送读取错误字段导致的NullPoint
    
    * 更新小程序二维码(小程序码)接口
    修复小程序模板推送读取错误字段导致的NullPoint
    
    * 更正WxMaMsgService接口逻辑
    
    * 使用IDEA对miniapp做了批量格式化
    ---
     .../weixin/common/util/fs/FileUtils.java      |  2 +-
     .../wx/miniapp/api/WxMaQrcodeService.java     | 83 +++++++++++++++++++
     .../api/impl/WxMaQrcodeServiceImpl.java       | 47 +++++++++++
     .../bean/WxMaJscode2SessionResult.java        | 15 +++-
     .../wx/miniapp/bean/WxMaQrcode.java           |  2 +-
     .../wx/miniapp/bean/WxMaQrcodeWrapper.java    | 16 ++++
     .../wx/miniapp/bean/WxMaWxcode.java           | 64 ++++++++++++++
     .../wx/miniapp/bean/WxMaWxcodeLimit.java      | 68 +++++++++++++++
     .../wx/miniapp/builder/ImageBuilder.java      |  2 +-
     .../message/WxMaMessageInterceptor.java       |  2 +-
     .../util/http/QrCodeRequestExecutor.java      |  6 +-
     .../util/json/WxMaKefuMessageGsonAdapter.java |  1 -
     .../api/impl/WxMaMsgServiceImplTest.java      |  3 +-
     .../api/impl/WxMaQrcodeServiceImplTest.java   | 12 +++
     .../wx/miniapp/bean/WxMaMessageTest.java      |  1 -
     .../wx/miniapp/demo/WxMaDemoServer.java       |  4 +-
     16 files changed, 314 insertions(+), 14 deletions(-)
     create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcodeWrapper.java
     create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java
     create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java
    
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java
    index df031b3371..37ee5ebe4b 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java
    @@ -24,7 +24,7 @@ public static File createTmpFile(InputStream inputStream, String name, String ex
           tmpFile = File.createTempFile(name, '.' + ext, tmpDirFile);
         }
     
    -    tmpFile.deleteOnExit();
    +//    tmpFile.deleteOnExit();
     
         try (FileOutputStream fos = new FileOutputStream(tmpFile)) {
           int read = 0;
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java
    index 822f5de8a4..c2222bc93e 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java
    @@ -7,6 +7,9 @@
     /**
      * 
      * 二维码相关操作接口
    + *
    + * 接口A(createWxCode)加上接口C(createQrcode),总共生成的码数量限制为100,000,请谨慎调用。
    + *
      * 文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html
      * 
    * @@ -15,6 +18,7 @@ public interface WxMaQrcodeService { /** + * 接口C *
        * 获取小程序页面二维码
        * 适用于需要的码数量较少的业务场景
    @@ -27,4 +31,83 @@ public interface WxMaQrcodeService {
        * @param width 默认430 二维码的宽度
        */
       File createQrcode(String path, int width) throws WxErrorException;
    +
    +  File createQrcode(String path) throws WxErrorException;
    +
    +  /**
    +   * 接口A
    +   * 获取小程序码
    +   *
    +   * @param path      不能为空,最大长度 128 字节
    +   * @param width     默认430 二维码的宽度
    +   * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
    +   * @param lineColor auth_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
    +   * @return
    +   * @throws WxErrorException
    +   */
    +  File createWxCode(String path, int width, boolean autoColor, LineColor lineColor) throws WxErrorException;
    +
    +  File createWxCode(String path, int width) throws WxErrorException;
    +
    +  File createWxCode(String path) throws WxErrorException;
    +
    +  /**
    +   * 接口B
    +   * 获取小程序码(永久有效、数量暂无限制)
    +   * 

    + * 通过该接口生成的小程序码,永久有效,数量暂无限制。 + * 用户扫描该码进入小程序后,将统一打开首页,开发者需在对应页面根据获取的码中 scene 字段的值,再做处理逻辑。 + * 使用如下代码可以获取到二维码中的 scene 字段的值。 + * 调试阶段可以使用开发工具的条件编译自定义参数 scene=xxxx 进行模拟,开发工具模拟时的 scene 的参数值需要进行 urlencode + * + * @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) + * @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面 + * @param width 默认false 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 + * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 + * @param lineColor auth_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} + * @return + * @throws WxErrorException + */ + File createWxCodeLimit(String scene, String page, int width, boolean autoColor, LineColor lineColor) throws WxErrorException; + + File createWxCodeLimit(String scene, String page) throws WxErrorException; + + /** + * lineColor 包装类 + * 用于描述二维码(小程序码)颜色(RGB参数值),详情请查看文档 + */ + public static class LineColor { + + private String r = "0", g = "0", b = "0"; + + public LineColor(String r, String g, String b) { + this.r = r; + this.g = g; + this.b = b; + } + + public String getR() { + return r; + } + + public void setR(String r) { + this.r = r; + } + + public String getG() { + return g; + } + + public void setG(String g) { + this.g = g; + } + + public String getB() { + return b; + } + + public void setB(String b) { + this.b = b; + } + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java index f0fc36af16..fd58855b3d 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java @@ -3,6 +3,8 @@ import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaQrcode; +import cn.binarywang.wx.miniapp.bean.WxMaWxcode; +import cn.binarywang.wx.miniapp.bean.WxMaWxcodeLimit; import cn.binarywang.wx.miniapp.util.http.QrCodeRequestExecutor; import me.chanjar.weixin.common.exception.WxErrorException; @@ -25,4 +27,49 @@ public File createQrcode(String path, int width) throws WxErrorException { url, new WxMaQrcode(path, width)); } + @Override + public File createQrcode(String path) throws WxErrorException { + return this.createQrcode(path, 430); + } + + @Override + public File createWxCode(String path, int width, boolean autoColor, LineColor lineColor) throws WxErrorException { + String url = "https://api.weixin.qq.com/wxa/getwxacode"; + WxMaWxcode wxMaWxcode = new WxMaWxcode(); + wxMaWxcode.setPath(path); + wxMaWxcode.setWidth(width); + wxMaWxcode.setAutoColor(autoColor); + wxMaWxcode.setLineColor(lineColor); + return this.wxMaService.execute(new QrCodeRequestExecutor(this.wxMaService.getRequestHttp()), + url, wxMaWxcode); + } + + @Override + public File createWxCode(String path, int width) throws WxErrorException { + return this.createWxCode(path, width, true, null); + } + + @Override + public File createWxCode(String path) throws WxErrorException { + return this.createWxCode(path, 430, true, null); + } + + @Override + public File createWxCodeLimit(String scene, String page, int width, boolean autoColor, LineColor lineColor) throws WxErrorException { + String url = "http://api.weixin.qq.com/wxa/getwxacodeunlimit"; + WxMaWxcodeLimit wxMaWxcodeLimit = new WxMaWxcodeLimit(); + wxMaWxcodeLimit.setScene(scene); + wxMaWxcodeLimit.setPage(page); + wxMaWxcodeLimit.setWidth(width); + wxMaWxcodeLimit.setAutoColor(autoColor); + wxMaWxcodeLimit.setLineColor(lineColor); + return this.wxMaService.execute(new QrCodeRequestExecutor(this.wxMaService.getRequestHttp()), + url, wxMaWxcodeLimit); + } + + @Override + public File createWxCodeLimit(String scene, String page) throws WxErrorException { + return this.createWxCodeLimit(scene, page, 430, true, null); + } + } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java index 4b9cc93d6b..471e6c46ec 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java @@ -18,6 +18,13 @@ public class WxMaJscode2SessionResult { @SerializedName("openid") private String openid; + @SerializedName("unionid") + private String unionid; + + public static WxMaJscode2SessionResult fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, WxMaJscode2SessionResult.class); + } + public String getSessionKey() { return sessionKey; } @@ -42,8 +49,12 @@ public void setOpenid(String openid) { this.openid = openid; } - public static WxMaJscode2SessionResult fromJson(String json) { - return WxMaGsonBuilder.create().fromJson(json, WxMaJscode2SessionResult.class); + public String getUnionid() { + return unionid; + } + + public void setUnionid(String unionid) { + this.unionid = unionid; } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java index 83050f0619..a047d7c8b1 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java @@ -7,7 +7,7 @@ /** * @author Binary Wang */ -public class WxMaQrcode implements Serializable { +public class WxMaQrcode extends WxMaQrcodeWrapper implements Serializable { private static final long serialVersionUID = 5777119669111011584L; private String path; private int width = 430; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcodeWrapper.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcodeWrapper.java new file mode 100644 index 0000000000..37c5c5db88 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcodeWrapper.java @@ -0,0 +1,16 @@ +package cn.binarywang.wx.miniapp.bean; + +import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; + +/** + * 微信二维码(小程序码)包装器 + * Created by Element on 2017/7/27. + */ +public abstract class WxMaQrcodeWrapper { + + @Override + public String toString() { + return WxMaGsonBuilder.create().toJson(this); + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java new file mode 100644 index 0000000000..9ea674ed98 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java @@ -0,0 +1,64 @@ +package cn.binarywang.wx.miniapp.bean; + +import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; +import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +/** + * Created by Element on 2017/7/27. + */ +public class WxMaWxcode extends WxMaQrcodeWrapper implements Serializable { + + private static final long serialVersionUID = 1287399621649210322L; + private String path; + private int width = 430; + + @SerializedName("auto_color") + private boolean autoColor = true; + + @SerializedName("line_color") + private WxMaQrcodeService.LineColor lineColor = new WxMaQrcodeService.LineColor("0", "0", "0"); + + public static WxMaWxcode fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, WxMaWxcode.class); + } + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width = width; + } + + public boolean isAutoColor() { + return autoColor; + } + + public void setAutoColor(boolean autoColor) { + this.autoColor = autoColor; + } + + public WxMaQrcodeService.LineColor getLineColor() { + return lineColor; + } + + public void setLineColor(WxMaQrcodeService.LineColor lineColor) { + this.lineColor = lineColor; + } + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java new file mode 100644 index 0000000000..7619fe46f2 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java @@ -0,0 +1,68 @@ +package cn.binarywang.wx.miniapp.bean; + +import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; +import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +/** + * Created by Element on 2017/7/27. + */ +public class WxMaWxcodeLimit extends WxMaQrcodeWrapper implements Serializable { + private static final long serialVersionUID = 4782193774524960401L; + private String scene; + private String page; + + private int width = 430; + + @SerializedName("auto_color") + private boolean autoColor = true; + + @SerializedName("line_color") + private WxMaQrcodeService.LineColor lineColor = new WxMaQrcodeService.LineColor("0", "0", "0"); + + public static WxMaWxcodeLimit fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, WxMaWxcodeLimit.class); + } + + public String getPage() { + return page; + } + + public void setPage(String page) { + this.page = page; + } + + public String getScene() { + return scene; + } + + public void setScene(String scene) { + this.scene = scene; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width = width; + } + + public boolean isAutoColor() { + return autoColor; + } + + public void setAutoColor(boolean autoColor) { + this.autoColor = autoColor; + } + + public WxMaQrcodeService.LineColor getLineColor() { + return lineColor; + } + + public void setLineColor(WxMaQrcodeService.LineColor lineColor) { + this.lineColor = lineColor; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java index 219e3fd43b..a903e97c43 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java @@ -10,7 +10,7 @@ public final class ImageBuilder extends BaseBuilder { private String mediaId; public ImageBuilder() { - this.msgType = WxMaConstants.KefuMsgType.IMAGE; + this.msgType = WxMaConstants.KefuMsgType.IMAGE; } public ImageBuilder mediaId(String media_id) { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageInterceptor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageInterceptor.java index 1b220a0baa..3443862fe1 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageInterceptor.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageInterceptor.java @@ -17,7 +17,7 @@ public interface WxMaMessageInterceptor { /** * 拦截微信消息 * - * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 + * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 * @return true代表OK,false代表不OK */ boolean intercept(WxMaMessage wxMessage, diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java index 7883ffda9b..dc482dff25 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java @@ -1,6 +1,6 @@ package cn.binarywang.wx.miniapp.util.http; -import cn.binarywang.wx.miniapp.bean.WxMaQrcode; +import cn.binarywang.wx.miniapp.bean.WxMaQrcodeWrapper; import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; @@ -25,7 +25,7 @@ /** * @author Binary Wang */ -public class QrCodeRequestExecutor implements RequestExecutor { +public class QrCodeRequestExecutor implements RequestExecutor { protected RequestHttp requestHttp; public QrCodeRequestExecutor(RequestHttp requestHttp) { @@ -33,7 +33,7 @@ public QrCodeRequestExecutor(RequestHttp requestHttp) { } @Override - public File execute(String uri, WxMaQrcode ticket) throws WxErrorException, IOException { + public File execute(String uri, WxMaQrcodeWrapper ticket) throws WxErrorException, IOException { HttpPost httpPost = new HttpPost(uri); if (requestHttp.getRequestHttpProxy() != null) { httpPost diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/json/WxMaKefuMessageGsonAdapter.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/json/WxMaKefuMessageGsonAdapter.java index 33c46d63cd..829469f872 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/json/WxMaKefuMessageGsonAdapter.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/json/WxMaKefuMessageGsonAdapter.java @@ -14,7 +14,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import org.apache.commons.lang3.StringUtils; import java.lang.reflect.Type; diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java index 9604a25691..37e3608bff 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java @@ -9,7 +9,8 @@ import com.google.inject.Inject; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.exception.WxErrorException; -import org.testng.annotations.*; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; import java.text.SimpleDateFormat; import java.util.Date; diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImplTest.java index 48dad9362a..eba65f7c34 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImplTest.java @@ -23,4 +23,16 @@ public void testCreateQrCode() throws Exception { System.out.println(qrCode); } + @Test + public void testCreateWxCode() throws Exception { + final File wxCode = this.wxService.getQrcodeService().createWxCode("111", 122); + System.out.println(wxCode); + } + + @Test + public void testCreateWxCodeLimit() throws Exception { + final File wxCode = this.wxService.getQrcodeService().createWxCodeLimit("111", null); + System.out.println(wxCode); + } + } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java index 881091a1df..cdf989a6af 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java @@ -1,6 +1,5 @@ package cn.binarywang.wx.miniapp.bean; -import cn.binarywang.wx.miniapp.bean.WxMaMessage; import me.chanjar.weixin.common.api.WxConsts; import org.testng.annotations.Test; diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java index fe986c8e71..f6dcbae27b 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java @@ -2,8 +2,8 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; -import cn.binarywang.wx.miniapp.bean.WxMaMessage; import cn.binarywang.wx.miniapp.bean.WxMaKefuMessage; +import cn.binarywang.wx.miniapp.bean.WxMaMessage; import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; import cn.binarywang.wx.miniapp.config.WxMaConfig; import cn.binarywang.wx.miniapp.constant.WxMaConstants; @@ -69,7 +69,7 @@ public void handle(WxMaMessage wxMessage, Map context, } } }; - + private static final WxMaMessageHandler qrcodeHandler = new WxMaMessageHandler() { @Override public void handle(WxMaMessage wxMessage, Map context, From 945516515cf8ce9357daded93415d490767d3ec0 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 27 Jul 2017 17:19:19 +0800 Subject: [PATCH 051/165] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E4=BC=81=E4=B8=9A=E4=BB=98=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/bean/request/WxEntPayRequest.java | 258 +++++++++++++----- .../impl/WxPayServiceAbstractImplTest.java | 10 +- 2 files changed, 200 insertions(+), 68 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java index fd43fb1aaa..7897ad02da 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java @@ -1,18 +1,12 @@ package com.github.binarywang.wxpay.bean.request; import com.thoughtworks.xstream.annotations.XStreamAlias; +import me.chanjar.weixin.common.annotation.Required; import me.chanjar.weixin.common.util.ToStringUtils; /** *

      * 企业付款请求对象
    - * 注释中各行每个字段描述对应如下:
    - * 
  • 字段名 - *
  • 变量名 - *
  • 是否必填 - *
  • 类型 - *
  • 示例值 - *
  • 描述 *
  • * Created by Binary Wang on 2016/10/02. * @@ -22,12 +16,12 @@ public class WxEntPayRequest extends WxPayBaseRequest { /** *
    -   * 公众账号appid
    -   * mch_appid
    -   * 是
    -   * wx8888888888888888
    -   * String
    -   * 微信分配的公众账号ID(企业号corpid即为此appId)
    +   * 字段名:公众账号appid
    +   * 变量名:mch_appid
    +   * 是否必填:是
    +   * 示例值:wx8888888888888888
    +   * 类型:String
    +   * 描述:微信分配的公众账号ID(企业号corpid即为此appId)
        * 
    */ @XStreamAlias("mch_appid") @@ -35,12 +29,12 @@ public class WxEntPayRequest extends WxPayBaseRequest { /** *
    -   *  商户号
    -   *  mchid
    -   *  是
    -   *  1900000109
    -   *  String(32)
    -   *  微信支付分配的商户号
    +   * 字段名:商户号
    +   * 变量名:mchid
    +   * 是否必填:是
    +   * 示例值:1900000109
    +   * 类型:String(32)
    +   * 描述:微信支付分配的商户号
        * 
    */ @XStreamAlias("mchid") @@ -48,12 +42,12 @@ public class WxEntPayRequest extends WxPayBaseRequest { /** *
    -   * 设备号
    -   * device_info
    -   * 否
    -   * 13467007045764
    -   * String(32)
    -   * 微信支付分配的终端设备号
    +   * 字段名:设备号
    +   * 变量名:device_info
    +   * 是否必填:否
    +   * 示例值:13467007045764
    +   * 类型:String(32)
    +   * 描述:微信支付分配的终端设备号
        * 
    */ @XStreamAlias("device_info") @@ -61,53 +55,56 @@ public class WxEntPayRequest extends WxPayBaseRequest { /** *
    -   * 商户订单号
    -   * partner_trade_no
    -   * 是
    -   * 10000098201411111234567890
    -   * String
    -   * 商户订单号
    +   * 字段名:商户订单号
    +   * 变量名:partner_trade_no
    +   * 是否必填:是
    +   * 示例值:10000098201411111234567890
    +   * 类型:String
    +   * 描述:商户订单号
        * 
    */ + @Required @XStreamAlias("partner_trade_no") private String partnerTradeNo; /** *
    -   * 需保持唯一性 用户openid
    -   * openid
    -   * 是
    -   * oxTWIuGaIt6gTKsQRLau2M0yL16E
    -   * String
    -   * 商户appid下,某用户的openid
    +   * 字段名:需保持唯一性 用户openid
    +   * 变量名:openid
    +   * 是否必填:是
    +   * 示例值:oxTWIuGaIt6gTKsQRLau2M0yL16E
    +   * 类型:String
    +   * 描述:商户appid下,某用户的openid
        * 
    */ + @Required @XStreamAlias("openid") private String openid; /** *
    -   * 校验用户姓名选项
    -   * check_name
    -   * 是
    -   * OPTION_CHECK
    -   * String
    -   * NO_CHECK:不校验真实姓名 
    +   * 字段名:校验用户姓名选项
    +   * 变量名:check_name
    +   * 是否必填:是
    +   * 示例值:OPTION_CHECK
    +   * 类型:String
    +   * 描述:NO_CHECK:不校验真实姓名 
        * FORCE_CHECK:强校验真实姓名(未实名认证的用户会校验失败,无法转账) 
        * OPTION_CHECK:针对已实名认证的用户才校验真实姓名(未实名认证用户不校验,可以转账成功)
        * 
    */ + @Required @XStreamAlias("check_name") private String checkName; /** *
    -   * 收款用户姓名
    -   * re_user_name
    -   * 可选
    -   * 马花花
    -   * String
    -   * 收款用户真实姓名。
    +   * 字段名:收款用户姓名
    +   * 变量名:re_user_name
    +   * 是否必填:可选
    +   * 示例值:马花花
    +   * 类型:String
    +   * 描述:收款用户真实姓名。
        * 如果check_name设置为FORCE_CHECK或OPTION_CHECK,  则必填用户真实姓名
        * 
    */ @@ -116,43 +113,71 @@ public class WxEntPayRequest extends WxPayBaseRequest { /** *
    -   * 金额
    -   * amount
    -   * 是
    -   * 10099
    -   * int
    -   * 企业付款金额, 单位为分
    +   * 字段名:金额
    +   * 变量名:amount
    +   * 是否必填:是
    +   * 示例值:10099
    +   * 类型:int
    +   * 描述:企业付款金额, 单位为分
        * 
    */ + @Required @XStreamAlias("amount") private Integer amount; /** *
    -   * 企业付款描述信息
    -   * desc
    -   * 是
    -   * 理赔
    -   * String
    -   * 企业付款操作说明信息。必填。
    +   * 字段名:企业付款描述信息
    +   * 变量名:desc
    +   * 是否必填:是
    +   * 示例值:理赔
    +   * 类型:String
    +   * 描述:企业付款操作说明信息。必填。
        * 
    */ + @Required @XStreamAlias("desc") private String description; /** *
    -   * Ip地址
    -   * spbill_create_ip
    -   * 是
    -   * 192.168.0.1
    -   * String(32)
    -   * 调用接口的机器Ip地址
    +   * 字段名:Ip地址
    +   * 变量名:spbill_create_ip
    +   * 是否必填:是
    +   * 示例值:192.168.0.1
    +   * 类型:String(32)
    +   * 描述:调用接口的机器Ip地址
        * 
    */ + @Required @XStreamAlias("spbill_create_ip") private String spbillCreateIp; + public WxEntPayRequest() { + } + + private WxEntPayRequest(Builder builder) { + setAppid(builder.appid); + setMchId(builder.mchId); + setSubAppId(builder.subAppId); + setSubMchId(builder.subMchId); + setNonceStr(builder.nonceStr); + setSign(builder.sign); + mchAppid = builder.mchAppid; + setMchId(builder.mchId); + setDeviceInfo(builder.deviceInfo); + setPartnerTradeNo(builder.partnerTradeNo); + setOpenid(builder.openid); + setCheckName(builder.checkName); + setReUserName(builder.reUserName); + setAmount(builder.amount); + setDescription(builder.description); + setSpbillCreateIp(builder.spbillCreateIp); + } + + public static Builder newBuilder() { + return new Builder(); + } @Override protected void checkConstraints() { @@ -248,4 +273,103 @@ public String toString() { return ToStringUtils.toSimpleString(this); } + public static final class Builder { + private String appid; + private String mchId; + private String deviceInfo; + private String partnerTradeNo; + private String openid; + private String checkName; + private String reUserName; + private Integer amount; + private String description; + private String spbillCreateIp; + private String subAppId; + private String subMchId; + private String nonceStr; + private String sign; + private String mchAppid; + + private Builder() { + } + + public Builder appid(String appid) { + this.appid = appid; + return this; + } + + public Builder mchId(String mchId) { + this.mchId = mchId; + return this; + } + + public Builder deviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + return this; + } + + public Builder partnerTradeNo(String partnerTradeNo) { + this.partnerTradeNo = partnerTradeNo; + return this; + } + + public Builder openid(String openid) { + this.openid = openid; + return this; + } + + public Builder checkName(String checkName) { + this.checkName = checkName; + return this; + } + + public Builder reUserName(String reUserName) { + this.reUserName = reUserName; + return this; + } + + public Builder amount(Integer amount) { + this.amount = amount; + return this; + } + + public Builder description(String description) { + this.description = description; + return this; + } + + public Builder spbillCreateIp(String spbillCreateIp) { + this.spbillCreateIp = spbillCreateIp; + return this; + } + + public WxEntPayRequest build() { + return new WxEntPayRequest(this); + } + + public Builder subAppId(String subAppId) { + this.subAppId = subAppId; + return this; + } + + public Builder subMchId(String subMchId) { + this.subMchId = subMchId; + return this; + } + + public Builder nonceStr(String nonceStr) { + this.nonceStr = nonceStr; + return this; + } + + public Builder sign(String sign) { + this.sign = sign; + return this; + } + + public Builder mchAppid(String mchAppid) { + this.mchAppid = mchAppid; + return this; + } + } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index bbf444d901..9b57d77b1c 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -170,7 +170,15 @@ public void testCloseOrder() throws WxPayException { */ @Test public void testEntPay() throws WxPayException { - WxEntPayRequest request = new WxEntPayRequest(); + WxEntPayRequest request = WxEntPayRequest.newBuilder() + .partnerTradeNo("Eb6Aep7uVTdbkJqrP4") + .openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4") + .amount(1) + .spbillCreateIp("10.10.10.10") + .checkName("NO_CHECK") + .description("描述信息") + .build(); + this.logger.info(this.payService.entPay(request).toString()); } From 0a06c4d1a13c39fc83903e83d1647362f280c2ca Mon Sep 17 00:00:00 2001 From: dylanleung <0095103cn@gmail.com> Date: Sun, 30 Jul 2017 22:39:20 -0500 Subject: [PATCH 052/165] =?UTF-8?q?#293=20=E9=87=8D=E6=9E=84OkHttp?= =?UTF-8?q?=E7=9A=84=E5=AE=9E=E7=8E=B0=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E4=BF=AE=E5=A4=8DJSApi=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update travis settings * feat(okhttp): 修改okhttp底层调用方法 直接用OkHttpClient代替connect.使客户端单一化.Okhttp 自动管理连接池优化 * feat(log,jsApi): 添加log debug 标记明确下调用底层效果,修复jsAPI Lock 为null 问题 添加log debug 标记明确下调用底层效果,修复jsAPI Lock 为null 问题 #293 --- .../OkHttpMediaDownloadRequestExecutor.java | 33 ++++------- .../OkHttpMediaUploadRequestExecutor.java | 23 ++------ .../OkHttpSimpleGetRequestExecutor.java | 25 ++------ .../OkHttpSimplePostRequestExecutor.java | 27 ++------- .../cp/api/impl/WxCpServiceOkHttpImpl.java | 50 ++++++++-------- .../mp/api/impl/AbstractWxMpServiceImpl.java | 3 +- .../mp/api/impl/WxMpServiceOkHttpImpl.java | 52 ++++++++-------- .../OkhttpMaterialDeleteRequestExecutor.java | 23 ++------ ...OkhttpMaterialNewsInfoRequestExecutor.java | 20 +------ .../OkhttpMaterialUploadRequestExecutor.java | 27 ++++----- ...khttpMaterialVideoInfoRequestExecutor.java | 24 +++----- ...lVoiceAndImageDownloadRequestExecutor.java | 59 ++++++------------- .../OkhttpMediaImgUploadRequestExecutor.java | 25 +++----- .../okhttp/OkhttpQrCodeRequestExecutor.java | 33 ++++------- .../weixin/mp/api/WxMpBaseAPITest.java | 6 ++ .../chanjar/weixin/mp/api/WxMpJsAPITest.java | 6 +- .../weixin/mp/api/test/ApiTestModule.java | 3 +- 17 files changed, 159 insertions(+), 280 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java index 97f8cb02c5..e5346c2a26 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java @@ -6,7 +6,11 @@ import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; import okhttp3.*; +import okio.BufferedSink; +import okio.Okio; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; import java.io.File; @@ -18,7 +22,8 @@ /** * Created by ecoolper on 2017/5/5. */ -public class OkHttpMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor { +public class OkHttpMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); public OkHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { @@ -27,6 +32,7 @@ public OkHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFi @Override public File execute(String uri, String queryParam) throws WxErrorException, IOException { + logger.debug("OkHttpMediaDownloadRequestExecutor is running"); if (queryParam != null) { if (uri.indexOf('?') == -1) { uri += '?'; @@ -34,23 +40,8 @@ public File execute(String uri, String queryParam) throws WxErrorException, IOEx uri += uri.endsWith("?") ? queryParam : '&' + queryParam; } - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); - //设置代理 - if (requestHttp.getRequestHttpProxy() != null) { - clientBuilder.proxy(requestHttp.getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(requestHttp.getRequestHttpProxy().getProxyUsername(), requestHttp.getRequestHttpProxy().getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); //得到httpClient - OkHttpClient client = clientBuilder.build(); + OkHttpClient client = requestHttp.getRequestHttpClient(); Request request = new Request.Builder().url(uri).get().build(); @@ -66,10 +57,12 @@ public Request authenticate(Route route, Response response) throws IOException { if (StringUtils.isBlank(fileName)) { return null; } - - InputStream inputStream = new ByteArrayInputStream(response.body().bytes()); String[] nameAndExt = fileName.split("\\."); - return FileUtils.createTmpFile(inputStream, nameAndExt[0], nameAndExt[1], super.tmpDirFile); + File file = File.createTempFile(nameAndExt[0], nameAndExt[1], super.tmpDirFile); + try (BufferedSink sink = Okio.buffer(Okio.sink(file))) { + sink.writeAll(response.body().source()); + } + return file; } private String getFileName(Response response) throws WxErrorException { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java index 91b36d7da6..9edeee89be 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaUploadRequestExecutor.java @@ -6,6 +6,8 @@ import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -13,7 +15,8 @@ /** * Created by ecoolper on 2017/5/5. */ -public class OkHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor { +public class OkHttpMediaUploadRequestExecutor extends MediaUploadRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); public OkHttpMediaUploadRequestExecutor(RequestHttp requestHttp) { super(requestHttp); @@ -21,23 +24,9 @@ public OkHttpMediaUploadRequestExecutor(RequestHttp requestHttp) { @Override public WxMediaUploadResult execute(String uri, File file) throws WxErrorException, IOException { - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); - //设置代理 - if (requestHttp.getRequestHttpProxy() != null) { - clientBuilder.proxy(requestHttp.getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(requestHttp.getRequestHttpProxy().getProxyUsername(), requestHttp.getRequestHttpProxy().getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); + logger.debug("OkHttpMediaUploadRequestExecutor is running"); //得到httpClient - OkHttpClient client = clientBuilder.build(); + OkHttpClient client = requestHttp.getRequestHttpClient(); RequestBody body = new MultipartBody.Builder() .setType(MediaType.parse("multipart/form-data")) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimpleGetRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimpleGetRequestExecutor.java index bbb5d43754..e468c609c8 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimpleGetRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimpleGetRequestExecutor.java @@ -5,13 +5,16 @@ import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; /** * Created by ecoolper on 2017/5/4. */ -public class OkHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor { +public class OkHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); public OkHttpSimpleGetRequestExecutor(RequestHttp requestHttp) { super(requestHttp); @@ -19,6 +22,7 @@ public OkHttpSimpleGetRequestExecutor(RequestHttp requestHttp) { @Override public String execute(String uri, String queryParam) throws WxErrorException, IOException { + logger.debug("OkHttpSimpleGetRequestExecutor is running"); if (queryParam != null) { if (uri.indexOf('?') == -1) { uri += '?'; @@ -26,26 +30,9 @@ public String execute(String uri, String queryParam) throws WxErrorException, IO uri += uri.endsWith("?") ? queryParam : '&' + queryParam; } - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); - //设置代理 - if (requestHttp.getRequestHttpProxy() != null) { - clientBuilder.proxy(requestHttp.getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(requestHttp.getRequestHttpProxy().getProxyUsername(), requestHttp.getRequestHttpProxy().getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); //得到httpClient - OkHttpClient client = clientBuilder.build(); - + OkHttpClient client = requestHttp.getRequestHttpClient(); Request request = new Request.Builder().url(uri).build(); - Response response = client.newCall(request).execute(); String responseContent = response.body().string(); WxError error = WxError.fromJson(responseContent); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java index 9d153117c5..bc54d7b4cd 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpSimplePostRequestExecutor.java @@ -5,13 +5,16 @@ import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; /** * Created by ecoolper on 2017/5/4. */ -public class OkHttpSimplePostRequestExecutor extends SimplePostRequestExecutor { +public class OkHttpSimplePostRequestExecutor extends SimplePostRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); public OkHttpSimplePostRequestExecutor(RequestHttp requestHttp) { super(requestHttp); @@ -19,27 +22,9 @@ public OkHttpSimplePostRequestExecutor(RequestHttp requestHttp) { @Override public String execute(String uri, String postEntity) throws WxErrorException, IOException { - ConnectionPool pool = requestHttp.getRequestHttpClient(); - final OkHttpProxyInfo proxyInfo = requestHttp.getRequestHttpProxy(); - - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(pool); - //设置代理 - if (proxyInfo != null) { - clientBuilder.proxy(proxyInfo.getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(proxyInfo.getProxyUsername(), proxyInfo.getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); + logger.debug("OkHttpSimplePostRequestExecutor running"); //得到httpClient - OkHttpClient client = clientBuilder.build(); - + OkHttpClient client = requestHttp.getRequestHttpClient(); MediaType mediaType = MediaType.parse("text/plain; charset=utf-8"); RequestBody body = RequestBody.create(mediaType, postEntity); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java index 4dd66d9d86..2b8ae0c4af 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java @@ -7,16 +7,20 @@ import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; -public class WxCpServiceOkHttpImpl extends AbstractWxCpServiceImpl { - protected ConnectionPool httpClient; +public class WxCpServiceOkHttpImpl extends AbstractWxCpServiceImpl { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + protected OkHttpClient httpClient; protected OkHttpProxyInfo httpProxy; @Override - public ConnectionPool getRequestHttpClient() { + public OkHttpClient getRequestHttpClient() { return httpClient; } @@ -32,6 +36,7 @@ public HttpType getRequestType() { @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { + logger.debug("WxCpServiceOkHttpImpl is running"); if (forceRefresh) { this.configStorage.expireAccessToken(); } @@ -41,24 +46,8 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?" + "&corpid=" + this.configStorage.getCorpId() + "&corpsecret=" + this.configStorage.getCorpSecret(); - - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(httpClient); - //设置代理 - if (httpProxy != null) { - clientBuilder.proxy(getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); //得到httpClient - OkHttpClient client = clientBuilder.build(); + OkHttpClient client = getRequestHttpClient(); //请求的request Request request = new Request.Builder().url(url).get().build(); Response response = null; @@ -88,13 +77,24 @@ public Request authenticate(Route route, Response response) throws IOException { @Override public void initHttp() { - WxCpConfigStorage configStorage = this.configStorage; + logger.debug("WxCpServiceOkHttpImpl initHttp"); + OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); + //设置代理 + if (httpProxy != null) { + clientBuilder.proxy(getRequestHttpProxy().getProxy()); - if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { - httpProxy = new OkHttpProxyInfo(OkHttpProxyInfo.ProxyType.SOCKS5, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); + //设置授权 + clientBuilder.authenticator(new Authenticator() { + @Override + public Request authenticate(Route route, Response response) throws IOException { + String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword()); + return response.request().newBuilder() + .header("Authorization", credential) + .build(); + } + }); } - - httpClient = new ConnectionPool(); + httpClient = clientBuilder.build(); } @Override diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java index cc965026c4..25eeeadce4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java @@ -66,10 +66,9 @@ public String getJsapiTicket() throws WxErrorException { @Override public String getJsapiTicket(boolean forceRefresh) throws WxErrorException { - Lock lock = this.getWxMpConfigStorage().getJsapiTicketLock(); + Lock lock = this.getWxMpConfigStorage().getAccessTokenLock(); try { lock.lock(); - if (forceRefresh) { this.getWxMpConfigStorage().expireJsapiTicket(); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java index 81fb848909..dbb957b84c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java @@ -8,16 +8,21 @@ import me.chanjar.weixin.mp.api.WxMpConfigStorage; import me.chanjar.weixin.mp.api.WxMpService; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.locks.Lock; -public class WxMpServiceOkHttpImpl extends AbstractWxMpServiceImpl { - private ConnectionPool httpClient; +public class WxMpServiceOkHttpImpl extends AbstractWxMpServiceImpl { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private OkHttpClient httpClient; private OkHttpProxyInfo httpProxy; @Override - public ConnectionPool getRequestHttpClient() { + public OkHttpClient getRequestHttpClient() { return httpClient; } @@ -33,6 +38,7 @@ public HttpType getRequestType() { @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { + logger.debug("WxMpServiceOkHttpImpl is running"); Lock lock = this.getWxMpConfigStorage().getAccessTokenLock(); try { lock.lock(); @@ -45,26 +51,8 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { String url = String.format(WxMpService.GET_ACCESS_TOKEN_URL, this.getWxMpConfigStorage().getAppId(), this.getWxMpConfigStorage().getSecret()); - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(httpClient); - //设置代理 - if (httpProxy != null) { - clientBuilder.proxy(getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); - //得到httpClient - OkHttpClient client = clientBuilder.build(); - Request request = new Request.Builder().url(url).get().build(); - Response response = client.newCall(request).execute(); + Response response = getRequestHttpClient().newCall(request).execute(); String resultContent = response.body().string(); WxError error = WxError.fromJson(resultContent); if (error.getErrorCode() != 0) { @@ -84,13 +72,29 @@ public Request authenticate(Route route, Response response) throws IOException { @Override public void initHttp() { + logger.debug("WxMpServiceOkHttpImpl initHttp"); WxMpConfigStorage configStorage = this.getWxMpConfigStorage(); if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { - httpProxy = new OkHttpProxyInfo(OkHttpProxyInfo.ProxyType.SOCKS5, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); + httpProxy = OkHttpProxyInfo.socks5Proxy(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); } + OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); + //设置代理 + if (httpProxy != null) { + clientBuilder.proxy(getRequestHttpProxy().getProxy()); - httpClient = new ConnectionPool(); + //设置授权 + clientBuilder.authenticator(new Authenticator() { + @Override + public Request authenticate(Route route, Response response) throws IOException { + String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword()); + return response.request().newBuilder() + .header("Authorization", credential) + .build(); + } + }); + } + httpClient = clientBuilder.build(); } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialDeleteRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialDeleteRequestExecutor.java index 61d4d18b37..40ac27465e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialDeleteRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialDeleteRequestExecutor.java @@ -6,13 +6,16 @@ import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.mp.util.http.MaterialDeleteRequestExecutor; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; /** * Created by ecoolper on 2017/5/5. */ -public class OkhttpMaterialDeleteRequestExecutor extends MaterialDeleteRequestExecutor { +public class OkhttpMaterialDeleteRequestExecutor extends MaterialDeleteRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); public OkhttpMaterialDeleteRequestExecutor(RequestHttp requestHttp) { @@ -21,23 +24,9 @@ public OkhttpMaterialDeleteRequestExecutor(RequestHttp requestHttp) { @Override public Boolean execute(String uri, String materialId) throws WxErrorException, IOException { - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); - //设置代理 - if (requestHttp.getRequestHttpProxy() != null) { - clientBuilder.proxy(requestHttp.getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(requestHttp.getRequestHttpProxy().getProxyUsername(), requestHttp.getRequestHttpProxy().getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); + logger.debug("OkhttpMaterialDeleteRequestExecutor is running"); //得到httpClient - OkHttpClient client = clientBuilder.build(); + OkHttpClient client = requestHttp.getRequestHttpClient(); RequestBody requestBody = new FormBody.Builder().add("media_id", materialId).build(); Request request = new Request.Builder().url(uri).post(requestBody).build(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java index a0a1c05231..3f46ab7880 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java @@ -16,7 +16,7 @@ /** * Created by ecoolper on 2017/5/5. */ -public class OkhttpMaterialNewsInfoRequestExecutor extends MaterialNewsInfoRequestExecutor { +public class OkhttpMaterialNewsInfoRequestExecutor extends MaterialNewsInfoRequestExecutor { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public OkhttpMaterialNewsInfoRequestExecutor(RequestHttp requestHttp) { super(requestHttp); @@ -24,23 +24,9 @@ public OkhttpMaterialNewsInfoRequestExecutor(RequestHttp requestHttp) { @Override public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorException, IOException { - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); - //设置代理 - if (requestHttp.getRequestHttpProxy() != null) { - clientBuilder.proxy(requestHttp.getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(requestHttp.getRequestHttpProxy().getProxyUsername(), requestHttp.getRequestHttpProxy().getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); + //得到httpClient - OkHttpClient client = clientBuilder.build(); + OkHttpClient client = requestHttp.getRequestHttpClient(); RequestBody requestBody = new FormBody.Builder().add("media_id", materialId).build(); Request request = new Request.Builder().url(uri).post(requestBody).build(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java index 3770aa1b67..ef4bcbb299 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java @@ -9,6 +9,8 @@ import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; import me.chanjar.weixin.mp.util.http.MaterialUploadRequestExecutor; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.FileNotFoundException; @@ -18,13 +20,16 @@ /** * Created by ecoolper on 2017/5/5. */ -public class OkhttpMaterialUploadRequestExecutor extends MaterialUploadRequestExecutor { +public class OkhttpMaterialUploadRequestExecutor extends MaterialUploadRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + public OkhttpMaterialUploadRequestExecutor(RequestHttp requestHttp) { super(requestHttp); } @Override public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material) throws WxErrorException, IOException { + logger.debug("OkhttpMaterialUploadRequestExecutor is running"); if (material == null) { throw new WxErrorException(WxError.newBuilder().setErrorMsg("非法请求,material参数为空").build()); } @@ -33,21 +38,9 @@ public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material) throw throw new FileNotFoundException(); } - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); - //设置代理 - if (requestHttp.getRequestHttpProxy() != null) { - clientBuilder.proxy(requestHttp.getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(requestHttp.getRequestHttpProxy().getProxyUsername(), requestHttp.getRequestHttpProxy().getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); + //得到httpClient + + OkHttpClient client = requestHttp.getRequestHttpClient(); MultipartBody.Builder bodyBuilder = new MultipartBody.Builder() .setType(MediaType.parse("multipart/form-data")) @@ -60,7 +53,7 @@ public Request authenticate(Route route, Response response) throws IOException { } Request request = new Request.Builder().url(uri).post(bodyBuilder.build()).build(); - Response response = clientBuilder.build().newCall(request).execute(); + Response response = client.newCall(request).execute(); String responseContent = response.body().string(); WxError error = WxError.fromJson(responseContent); if (error.getErrorCode() != 0) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVideoInfoRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVideoInfoRequestExecutor.java index 90c775bac6..79dd12be53 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVideoInfoRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVideoInfoRequestExecutor.java @@ -7,36 +7,26 @@ import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult; import me.chanjar.weixin.mp.util.http.MaterialVideoInfoRequestExecutor; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; /** * Created by ecoolper on 2017/5/5. */ -public class OkhttpMaterialVideoInfoRequestExecutor extends MaterialVideoInfoRequestExecutor { +public class OkhttpMaterialVideoInfoRequestExecutor extends MaterialVideoInfoRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + public OkhttpMaterialVideoInfoRequestExecutor(RequestHttp requestHttp) { super(requestHttp); } @Override public WxMpMaterialVideoInfoResult execute(String uri, String materialId) throws WxErrorException, IOException { - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); - //设置代理 - if (requestHttp.getRequestHttpProxy() != null) { - clientBuilder.proxy(requestHttp.getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(requestHttp.getRequestHttpProxy().getProxyUsername(), requestHttp.getRequestHttpProxy().getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); + logger.debug("OkhttpMaterialVideoInfoRequestExecutor is running"); //得到httpClient - OkHttpClient client = clientBuilder.build(); + OkHttpClient client = requestHttp.getRequestHttpClient(); RequestBody requestBody = new FormBody.Builder().add("media_id", materialId).build(); Request request = new Request.Builder().url(uri).post(requestBody).build(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVoiceAndImageDownloadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVoiceAndImageDownloadRequestExecutor.java index 1d0a5f7f65..8c48139183 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVoiceAndImageDownloadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialVoiceAndImageDownloadRequestExecutor.java @@ -7,62 +7,39 @@ import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.mp.util.http.MaterialVoiceAndImageDownloadRequestExecutor; import okhttp3.*; +import okio.BufferedSink; +import okio.Okio; import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; +import java.io.*; /** * Created by ecoolper on 2017/5/5. */ -public class OkhttpMaterialVoiceAndImageDownloadRequestExecutor extends MaterialVoiceAndImageDownloadRequestExecutor { +public class OkhttpMaterialVoiceAndImageDownloadRequestExecutor extends MaterialVoiceAndImageDownloadRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + public OkhttpMaterialVoiceAndImageDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { super(requestHttp, tmpDirFile); } @Override public InputStream execute(String uri, String materialId) throws WxErrorException, IOException { - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); - //设置代理 - if (requestHttp.getRequestHttpProxy() != null) { - clientBuilder.proxy(requestHttp.getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(requestHttp.getRequestHttpProxy().getProxyUsername(), requestHttp.getRequestHttpProxy().getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); - //得到httpClient - OkHttpClient client = clientBuilder.build(); - + logger.debug("OkhttpMaterialVoiceAndImageDownloadRequestExecutor is running"); + OkHttpClient client = requestHttp.getRequestHttpClient(); RequestBody requestBody = new FormBody.Builder().add("media_id", materialId).build(); Request request = new Request.Builder().url(uri).get().post(requestBody).build(); Response response = client.newCall(request).execute(); - - try (InputStream inputStream = new ByteArrayInputStream(response.body().bytes())) { - - // 下载媒体文件出错 - byte[] responseContent = IOUtils.toByteArray(inputStream); - String responseContentString = new String(responseContent, StandardCharsets.UTF_8); - if (responseContentString.length() < 100) { - try { - WxError wxError = WxGsonBuilder.create().fromJson(responseContentString, WxError.class); - if (wxError.getErrorCode() != 0) { - throw new WxErrorException(wxError); - } - } catch (com.google.gson.JsonSyntaxException ex) { - return new ByteArrayInputStream(responseContent); - } - } - return new ByteArrayInputStream(responseContent); + String contentTypeHeader = response.header("Content-Type"); + if ("text/plain".equals(contentTypeHeader)) { + String responseContent = response.body().string(); + throw new WxErrorException(WxError.fromJson(responseContent)); + } + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); BufferedSink sink = Okio.buffer(Okio.sink(outputStream))) { + sink.writeAll(response.body().source()); + return new ByteArrayInputStream(outputStream.toByteArray()); } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMediaImgUploadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMediaImgUploadRequestExecutor.java index 3b10f63bcf..f8e5859287 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMediaImgUploadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMediaImgUploadRequestExecutor.java @@ -7,6 +7,8 @@ import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult; import me.chanjar.weixin.mp.util.http.MediaImgUploadRequestExecutor; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -14,7 +16,8 @@ /** * Created by ecoolper on 2017/5/5. */ -public class OkhttpMediaImgUploadRequestExecutor extends MediaImgUploadRequestExecutor { +public class OkhttpMediaImgUploadRequestExecutor extends MediaImgUploadRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); public OkhttpMediaImgUploadRequestExecutor(RequestHttp requestHttp) { super(requestHttp); @@ -22,21 +25,9 @@ public OkhttpMediaImgUploadRequestExecutor(RequestHttp requestHttp) { @Override public WxMediaImgUploadResult execute(String uri, File file) throws WxErrorException, IOException { - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); - //设置代理 - if (requestHttp.getRequestHttpProxy() != null) { - clientBuilder.proxy(requestHttp.getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(requestHttp.getRequestHttpProxy().getProxyUsername(), requestHttp.getRequestHttpProxy().getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); + logger.debug("OkhttpMediaImgUploadRequestExecutor is running"); + //得到httpClient + OkHttpClient client = requestHttp.getRequestHttpClient(); RequestBody body = new MultipartBody.Builder() .setType(MediaType.parse("multipart/form-data")) @@ -46,7 +37,7 @@ public Request authenticate(Route route, Response response) throws IOException { .build(); Request request = new Request.Builder().url(uri).post(body).build(); - Response response = clientBuilder.build().newCall(request).execute(); + Response response = client.newCall(request).execute(); String responseContent = response.body().string(); WxError error = WxError.fromJson(responseContent); if (error.getErrorCode() != 0) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java index f401b021cc..2f9bcc7437 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java @@ -9,6 +9,10 @@ import me.chanjar.weixin.mp.util.http.QrCodeRequestExecutor; import okhttp3.*; +import okio.BufferedSink; +import okio.Okio; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; import java.io.File; @@ -19,31 +23,18 @@ /** * Created by ecoolper on 2017/5/5. */ -public class OkhttpQrCodeRequestExecutor extends QrCodeRequestExecutor { +public class OkhttpQrCodeRequestExecutor extends QrCodeRequestExecutor { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + public OkhttpQrCodeRequestExecutor(RequestHttp requestHttp) { super(requestHttp); } @Override public File execute(String uri, WxMpQrCodeTicket data) throws WxErrorException, IOException { - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder().connectionPool(requestHttp.getRequestHttpClient()); - //设置代理 - if (requestHttp.getRequestHttpProxy() != null) { - clientBuilder.proxy(requestHttp.getRequestHttpProxy().getProxy()); - } - //设置授权 - clientBuilder.authenticator(new Authenticator() { - @Override - public Request authenticate(Route route, Response response) throws IOException { - String credential = Credentials.basic(requestHttp.getRequestHttpProxy().getProxyUsername(), requestHttp.getRequestHttpProxy().getProxyPassword()); - return response.request().newBuilder() - .header("Authorization", credential) - .build(); - } - }); + logger.debug("OkhttpQrCodeRequestExecutor is running"); //得到httpClient - OkHttpClient client = clientBuilder.build(); - + OkHttpClient client = requestHttp.getRequestHttpClient(); Request request = new Request.Builder().url(uri).get().build(); Response response = client.newCall(request).execute(); String contentTypeHeader = response.header("Content-Type"); @@ -51,8 +42,10 @@ public Request authenticate(Route route, Response response) throws IOException { String responseContent = response.body().string(); throw new WxErrorException(WxError.fromJson(responseContent)); } - try (InputStream inputStream = new ByteArrayInputStream(response.body().bytes())) { - return FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), "jpg"); + File temp = File.createTempFile(UUID.randomUUID().toString(), ".png"); + try (BufferedSink sink = Okio.buffer(Okio.sink(temp))) { + sink.writeAll(response.body().source()); } + return temp; } } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBaseAPITest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBaseAPITest.java index c8b616fa96..7fb10716f0 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBaseAPITest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBaseAPITest.java @@ -29,4 +29,10 @@ public void testRefreshAccessToken() throws WxErrorException { Assert.assertTrue(StringUtils.isNotBlank(after)); } + public void testJsapiTicket() throws WxErrorException { + String jsapiTicket = this.wxService.getJsapiTicket(false); + System.out.println(jsapiTicket); + Assert.assertNotNull(jsapiTicket); + } + } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpJsAPITest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpJsAPITest.java index 9fd3227893..e6be87302d 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpJsAPITest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpJsAPITest.java @@ -20,11 +20,7 @@ public class WxMpJsAPITest { protected WxMpService wxService; - public void testJsapiTicket() throws WxErrorException { - String jsapiTicket = this.wxService.getJsapiTicket(false); - System.out.println(jsapiTicket); - Assert.assertNotNull(jsapiTicket); - } + public void test() { long timestamp = 1419835025l; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java index 036c534adc..2a9421a499 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java @@ -7,6 +7,7 @@ import me.chanjar.weixin.mp.api.WxMpConfigStorage; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.impl.WxMpServiceApacheHttpClientImpl; +import me.chanjar.weixin.mp.api.impl.WxMpServiceOkHttpImpl; import java.io.IOException; import java.io.InputStream; @@ -19,7 +20,7 @@ public void configure(Binder binder) { try (InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml")) { TestConfigStorage config = this.fromXml(TestConfigStorage.class, is1); config.setAccessTokenLock(new ReentrantLock()); - WxMpService wxService = new WxMpServiceApacheHttpClientImpl(); + WxMpService wxService = new WxMpServiceOkHttpImpl(); wxService.setWxMpConfigStorage(config); binder.bind(WxMpService.class).toInstance(wxService); From 70d90c8b9bd57709245d6ef785c6c213edbee0e4 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 31 Jul 2017 17:42:17 +0800 Subject: [PATCH 053/165] =?UTF-8?q?=E9=9D=9E=E6=B3=95=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8=E7=BB=9F=E4=B8=80=E4=BD=BF=E7=94=A8?= =?UTF-8?q?WxPayException?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binarywang/wxpay/bean/request/WxPayBaseRequest.java | 2 +- .../wxpay/bean/request/WxPayDownloadBillRequest.java | 7 ++++--- .../wxpay/bean/request/WxPayOrderQueryRequest.java | 5 +++-- .../wxpay/bean/request/WxPayOrderReverseRequest.java | 5 +++-- .../wxpay/bean/request/WxPayRefundQueryRequest.java | 5 +++-- .../binarywang/wxpay/bean/request/WxPayRefundRequest.java | 6 +++--- .../wxpay/bean/request/WxPayUnifiedOrderRequest.java | 8 ++++---- .../binarywang/wxpay/bean/result/WxPayBaseResult.java | 7 +++---- .../com/github/binarywang/wxpay/config/WxPayConfig.java | 4 ++-- .../wxpay/service/impl/WxPayServiceAbstractImpl.java | 2 +- .../wxpay/service/impl/WxPayServiceAbstractImplTest.java | 2 +- 11 files changed, 28 insertions(+), 25 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java index b0c2e85d5c..cc0490d22e 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java @@ -122,7 +122,7 @@ protected void checkFields() throws WxPayException { /** * 检查约束情况 */ - protected abstract void checkConstraints(); + protected abstract void checkConstraints() throws WxPayException; public String getAppid() { return this.appid; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java index ed02060f83..2838284c80 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.bean.request; +import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; import me.chanjar.weixin.common.annotation.Required; import org.apache.commons.lang3.ArrayUtils; @@ -128,13 +129,13 @@ public void setTarType(String tarType) { } @Override - protected void checkConstraints() { + protected void checkConstraints() throws WxPayException { if (StringUtils.isNotBlank(this.getTarType()) && !"GZIP".equals(this.getTarType())) { - throw new IllegalArgumentException("tar_type值如果存在,只能为GZIP"); + throw new WxPayException("tar_type值如果存在,只能为GZIP"); } if (!ArrayUtils.contains(BILL_TYPE, this.getBillType())) { - throw new IllegalArgumentException(String.format("bill_tpye目前必须为%s其中之一,实际值:%s", + throw new WxPayException(String.format("bill_tpye目前必须为%s其中之一,实际值:%s", Arrays.toString(BILL_TYPE), this.getBillType())); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java index 499727995e..e7767da607 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.bean.request; +import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; import org.apache.commons.lang3.StringUtils; @@ -64,10 +65,10 @@ public void setOutTradeNo(String outTradeNo) { } @Override - protected void checkConstraints() { + protected void checkConstraints() throws WxPayException { if ((StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)) || (StringUtils.isNotBlank(transactionId) && StringUtils.isNotBlank(outTradeNo))) { - throw new IllegalArgumentException("transaction_id 和 out_trade_no 不能同时存在或同时为空,必须二选一"); + throw new WxPayException("transaction_id 和 out_trade_no 不能同时存在或同时为空,必须二选一"); } } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java index 6aef2aa0fa..075295238e 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.bean.request; +import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; import org.apache.commons.lang3.StringUtils; @@ -91,9 +92,9 @@ public void setSignType(String signType) { } @Override - protected void checkConstraints() { + protected void checkConstraints() throws WxPayException { if (StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)) { - throw new IllegalArgumentException("transaction_id 和 out_trade_no不能同时为空!"); + throw new WxPayException("transaction_id 和 out_trade_no不能同时为空!"); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java index 1efa23db7a..00545f004c 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.bean.request; +import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; import org.apache.commons.lang3.StringUtils; @@ -135,12 +136,12 @@ public void setRefundId(String refundId) { } @Override - protected void checkConstraints() { + protected void checkConstraints() throws WxPayException { if ((StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo) && StringUtils.isBlank(outRefundNo) && StringUtils.isBlank(refundId)) || (StringUtils.isNotBlank(transactionId) && StringUtils.isNotBlank(outTradeNo) && StringUtils.isNotBlank(outRefundNo) && StringUtils.isNotBlank(refundId))) { - throw new IllegalArgumentException("transaction_id,out_trade_no,out_refund_no,refund_id 必须四选一"); + throw new WxPayException("transaction_id,out_trade_no,out_refund_no,refund_id 必须四选一"); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java index 7fae6fa0f5..66808738ca 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java @@ -271,16 +271,16 @@ public void checkAndSign(WxPayConfig config) throws WxPayException { } @Override - protected void checkConstraints() { + protected void checkConstraints() throws WxPayException { if (StringUtils.isNotBlank(this.getRefundAccount())) { if (!ArrayUtils.contains(REFUND_ACCOUNT, this.getRefundAccount())) { - throw new IllegalArgumentException(String.format("refund_account目前必须为%s其中之一,实际值:%s", + throw new WxPayException(String.format("refund_account目前必须为%s其中之一,实际值:%s", Arrays.toString(REFUND_ACCOUNT), this.getRefundAccount())); } } if (StringUtils.isBlank(this.getOutTradeNo()) && StringUtils.isBlank(this.getTransactionId())) { - throw new IllegalArgumentException("transaction_id 和 out_trade_no 不能同时为空,必须提供一个"); + throw new WxPayException("transaction_id 和 out_trade_no 不能同时为空,必须提供一个"); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index 7c927425de..8061556cc7 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -500,18 +500,18 @@ public void setSceneInfo(String sceneInfo) { } @Override - protected void checkConstraints() { + protected void checkConstraints() throws WxPayException { // if (!ArrayUtils.contains(TRADE_TYPES, this.getTradeType())) { -// throw new IllegalArgumentException(String.format("trade_type目前必须为%s其中之一,实际值:%s", +// throw new WxPayException(String.format("trade_type目前必须为%s其中之一,实际值:%s", // Arrays.toString(TRADE_TYPES), this.getTradeType())); // } if ("JSAPI".equals(this.getTradeType()) && this.getOpenid() == null) { - throw new IllegalArgumentException("当 trade_type是'JSAPI'时未指定openid"); + throw new WxPayException("当 trade_type是'JSAPI'时未指定openid"); } if ("NATIVE".equals(this.getTradeType()) && this.getProductId() == null) { - throw new IllegalArgumentException("当 trade_type是'NATIVE'时未指定product_id"); + throw new WxPayException("当 trade_type是'NATIVE'时未指定product_id"); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java index 802e22b312..d4b96dc408 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java @@ -316,8 +316,8 @@ public void checkResult(WxPayServiceAbstractImpl wxPayService) throws WxPayExcep } //校验结果是否成功 - if (!"SUCCESS".equalsIgnoreCase(getReturnCode()) - || !"SUCCESS".equalsIgnoreCase(getResultCode())) { + if (!StringUtils.equalsAny(StringUtils.trimToEmpty(getReturnCode()).toUpperCase(), "SUCCESS", "") + || !StringUtils.equalsAny(StringUtils.trimToEmpty(getResultCode()).toUpperCase(), "SUCCESS", "")) { StringBuilder errorMsg = new StringBuilder(); if (getReturnCode() != null) { errorMsg.append("返回代码:").append(getReturnCode()); @@ -335,8 +335,7 @@ public void checkResult(WxPayServiceAbstractImpl wxPayService) throws WxPayExcep errorMsg.append(",错误详情:").append(getErrCodeDes()); } - this.getLogger().error("\n结果业务代码异常,返回結果:{},\n{}", - map, errorMsg.toString()); + this.getLogger().error("\n结果业务代码异常,返回結果:{},\n{}", map, errorMsg.toString()); throw WxPayException.from(this); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java index aeab939a06..b51f28e94a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java @@ -160,11 +160,11 @@ public void setUseSandboxEnv(boolean useSandboxEnv) { public SSLContext initSSLContext() throws WxPayException { if (StringUtils.isBlank(mchId)) { - throw new IllegalArgumentException("请确保商户号mchId已设置"); + throw new WxPayException("请确保商户号mchId已设置"); } if (StringUtils.isBlank(this.keyPath)) { - throw new IllegalArgumentException("请确保证书文件地址keyPath已配置"); + throw new WxPayException("请确保证书文件地址keyPath已配置"); } InputStream inputStream; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index 9a75b46973..616f860988 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -161,7 +161,7 @@ public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) @Override public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException { if (StringUtils.isBlank(outTradeNo)) { - throw new IllegalArgumentException("out_trade_no不能为空"); + throw new WxPayException("out_trade_no不能为空"); } WxPayOrderCloseRequest request = new WxPayOrderCloseRequest(); diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index 9b57d77b1c..7ac35a6061 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -139,7 +139,7 @@ public void testUnifiedOrder() throws WxPayException { .unifiedOrder(WxPayUnifiedOrderRequest.newBuilder() .body("我去") .totalFee(1) - .spbillCreateIp("111111") + .spbillCreateIp("11.1.11.1") .notifyURL("111111") .tradeType("JSAPI") .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()) From 2d9d392889bcf6f63d105ecd41ad785c72a3620d Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 31 Jul 2017 17:44:48 +0800 Subject: [PATCH 054/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.7.7.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 0b78452d55..8bd9de49e5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.7.6.BETA + 2.7.7.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 9299fa1ce7..f93c89abb8 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.6.BETA + 2.7.7.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 6732165602..6e0a3e27b2 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.6.BETA + 2.7.7.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 181b505cd3..bc75c8f7f9 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.6.BETA + 2.7.7.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 16648606b2..18de637004 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.6.BETA + 2.7.7.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 4783621af5..0a65663c6b 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.7.6.BETA + 2.7.7.BETA 4.0.0 From 5a2b3b61a44c0805b5471172874e8bb9a9da86f5 Mon Sep 17 00:00:00 2001 From: dylanleung <0095103cn@gmail.com> Date: Mon, 31 Jul 2017 05:18:15 -0500 Subject: [PATCH 055/165] =?UTF-8?q?#295=20=E4=BF=AE=E5=A4=8D=E4=B8=B4?= =?UTF-8?q?=E6=97=B6=E6=96=87=E4=BB=B6=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update travis settings * feat(okhttp): 修改okhttp底层调用方法 直接用OkHttpClient代替connect.使客户端单一化.Okhttp 自动管理连接池优化 * feat(log,jsApi): 添加log debug 标记明确下调用底层效果,修复jsAPI Lock 为null 问题 添加log debug 标记明确下调用底层效果,修复jsAPI Lock 为null 问题 #293 * fix(File): 修复文件关闭 修复文件关闭 * Update OkHttpMediaDownloadRequestExecutor.java --- .../main/java/me/chanjar/weixin/common/util/fs/FileUtils.java | 2 +- .../util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java | 1 + .../weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java index 37ee5ebe4b..df031b3371 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java @@ -24,7 +24,7 @@ public static File createTmpFile(InputStream inputStream, String name, String ex tmpFile = File.createTempFile(name, '.' + ext, tmpDirFile); } -// tmpFile.deleteOnExit(); + tmpFile.deleteOnExit(); try (FileOutputStream fos = new FileOutputStream(tmpFile)) { int read = 0; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java index e5346c2a26..246ce4dcc0 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java @@ -62,6 +62,7 @@ public File execute(String uri, String queryParam) throws WxErrorException, IOEx try (BufferedSink sink = Okio.buffer(Okio.sink(file))) { sink.writeAll(response.body().source()); } + file.deleteOnExit(); return file; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java index 2f9bcc7437..6feb137925 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java @@ -46,6 +46,8 @@ public File execute(String uri, WxMpQrCodeTicket data) throws WxErrorException, try (BufferedSink sink = Okio.buffer(Okio.sink(temp))) { sink.writeAll(response.body().source()); } + temp.deleteOnExit(); + return temp; } } From afcd62c065d1e2c9418b73bc8f9ebc49a6df1876 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 1 Aug 2017 12:03:38 +0800 Subject: [PATCH 056/165] =?UTF-8?q?#297=20WxMpMenu=E7=B1=BB=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AE=9E=E7=8E=B0=E5=BA=8F=E5=88=97=E5=8C=96=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java index 366ca2f1ba..3c154726fa 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java @@ -6,6 +6,7 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.json.WxGsonBuilder; +import java.io.Serializable; import java.util.List; /** @@ -15,7 +16,10 @@ * @author binarywang(Binary Wang) *
    */ -public class WxMpMenu { +public class WxMpMenu implements Serializable{ + + private static final long serialVersionUID = -5794350513426702252L; + @SerializedName("menu") private WxMpConditionalMenu menu; From 289405f8453bf0b57769b851f9692b2c888053e8 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 1 Aug 2017 13:00:46 +0800 Subject: [PATCH 057/165] =?UTF-8?q?#298=20WxMpMenu=E7=9A=84=E5=86=85?= =?UTF-8?q?=E9=83=A8=E7=B1=BBWxMpConditionalMenu=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=BA=8F=E5=88=97=E5=8C=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java index 3c154726fa..6c7d3e8650 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java @@ -55,7 +55,10 @@ public String toJson() { return WxGsonBuilder.create().toJson(this); } - public static class WxMpConditionalMenu { + public static class WxMpConditionalMenu implements Serializable { + + private static final long serialVersionUID = -2279946921755382289L; + @SerializedName("button") private List buttons; @SerializedName("matchrule") From 9e32f00e6b9e98c78e4989394443a19da6b4d298 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 8 Aug 2017 10:39:02 +0800 Subject: [PATCH 058/165] =?UTF-8?q?#302=20WxMpXmlOutNewsMessage=E7=B1=BB?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=86=85=E9=83=A8=E7=B1=BB=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=BA=8F=E5=88=97=E5=8C=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/bean/message/WxMpXmlOutNewsMessage.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java index 1d4fb0c767..8865a39358 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java @@ -5,6 +5,7 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -39,7 +40,9 @@ public List getArticles() { @XStreamAlias("item") - public static class Item { + public static class Item implements Serializable { + + private static final long serialVersionUID = -4971456355028904754L; @XStreamAlias("Title") @XStreamConverter(value = XStreamCDataConverter.class) From 6ce585f2460f01c42b2ec2f8161004f1a4f4128f Mon Sep 17 00:00:00 2001 From: kakotor Date: Thu, 10 Aug 2017 12:25:10 +0800 Subject: [PATCH 059/165] =?UTF-8?q?DefaultApacheHttpClientBuilder=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8D=95=E4=BE=8B=E6=A8=A1=E5=BC=8F=20(#310)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DefaultApacheHttpClientBuilder.java | 23 +++++-- .../DefaultApacheHttpClientBuilderTest.java | 64 +++++++++++++++++++ 2 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 weixin-java-common/src/test/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilderTest.java diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilder.java index b328ede9af..19c79bdcf2 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilder.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilder.java @@ -68,13 +68,16 @@ public boolean retryRequest(IOException exception, int executionCount, HttpConte * 闲置连接监控线程 */ private IdleConnectionMonitorThread idleConnectionMonitorThread; - private HttpClientBuilder httpClientBuilder; + /** + * 持有client对象,仅初始化一次,避免多service实例的时候造成重复初始化的问题 + */ + private CloseableHttpClient closeableHttpClient; private DefaultApacheHttpClientBuilder() { } public static DefaultApacheHttpClientBuilder get() { - return new DefaultApacheHttpClientBuilder(); + return DefaultApacheHttpClientBuilder.SingletonHolder.INSTANCE; } @Override @@ -219,7 +222,7 @@ private synchronized void prepare() { this.idleConnectionMonitorThread.setDaemon(true); this.idleConnectionMonitorThread.start(); - this.httpClientBuilder = HttpClients.custom() + HttpClientBuilder httpClientBuilder = HttpClients.custom() .setConnectionManager(connectionManager) .setConnectionManagerShared(true) .setSSLSocketFactory(this.buildSSLConnectionSocketFactory()) @@ -240,12 +243,13 @@ private synchronized void prepare() { new AuthScope(this.httpProxyHost, this.httpProxyPort), new UsernamePasswordCredentials(this.httpProxyUsername, this.httpProxyPassword)); - this.httpClientBuilder.setDefaultCredentialsProvider(provider); + httpClientBuilder.setDefaultCredentialsProvider(provider); } if (StringUtils.isNotBlank(this.userAgent)) { - this.httpClientBuilder.setUserAgent(this.userAgent); + httpClientBuilder.setUserAgent(this.userAgent); } + this.closeableHttpClient = httpClientBuilder.build(); prepared.set(true); } @@ -277,7 +281,14 @@ public CloseableHttpClient build() { if (!prepared.get()) { prepare(); } - return this.httpClientBuilder.build(); + return this.closeableHttpClient; + } + + /** + * DefaultApacheHttpClientBuilder 改为单例模式,并持有唯一的CloseableHttpClient(仅首次调用创建) + */ + private static class SingletonHolder { + private static final DefaultApacheHttpClientBuilder INSTANCE = new DefaultApacheHttpClientBuilder(); } public static class IdleConnectionMonitorThread extends Thread { diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilderTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilderTest.java new file mode 100644 index 0000000000..24a45eea09 --- /dev/null +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/http/apache/DefaultApacheHttpClientBuilderTest.java @@ -0,0 +1,64 @@ +package me.chanjar.weixin.common.util.http.apache; + +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class DefaultApacheHttpClientBuilderTest { + @Test + public void testBuild() throws Exception { + DefaultApacheHttpClientBuilder builder1 = DefaultApacheHttpClientBuilder.get(); + DefaultApacheHttpClientBuilder builder2 = DefaultApacheHttpClientBuilder.get(); + Assert.assertSame(builder1, builder2, "DefaultApacheHttpClientBuilder为单例,获取到的对象应该相同"); + List threadList = new ArrayList<>(10); + for (int i = 0; i < 10; i++) { + TestThread thread = new TestThread(); + thread.start(); + threadList.add(thread); + } + for (TestThread testThread : threadList) { + testThread.join(); + Assert.assertNotEquals(-1,testThread.getRespState(),"请求响应code不应为-1"); + } + + for (int i = 1; i < threadList.size(); i++) { + TestThread thread1 = threadList.get(i - 1); + TestThread thread2 = threadList.get(i); + Assert.assertSame( + thread1.getClient(), + thread2.getClient(), + "DefaultApacheHttpClientBuilder为单例,并持有了相同的HttpClient" + ); + } + } + + + public static class TestThread extends Thread { + private CloseableHttpClient client; + private int respState = -1; + + @Override + public void run() { + client = DefaultApacheHttpClientBuilder.get().build(); + HttpGet httpGet = new HttpGet("http://www.sina.com.cn/"); + try (CloseableHttpResponse resp = client.execute(httpGet)){ + respState = resp.getStatusLine().getStatusCode(); + } catch (IOException ignored) { + } + } + + public CloseableHttpClient getClient() { + return client; + } + + public int getRespState() { + return respState; + } + } +} From 69ebad5e70a0284be05fd1f2350ce7a1af9684c5 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 11 Aug 2017 11:59:38 +0800 Subject: [PATCH 060/165] =?UTF-8?q?#300=20=E4=BF=AE=E5=A4=8D=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=A4=9A=E5=AA=92=E4=BD=93=E6=96=87=E4=BB=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=90=8E=E7=BC=80=E5=90=8D=E6=97=B6=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/http/HttpResponseProxy.java | 88 +++++++++++++++++++ .../ApacheMediaDownloadRequestExecutor.java | 25 ++---- .../JoddHttpMediaDownloadRequestExecutor.java | 25 ++---- .../OkHttpMediaDownloadRequestExecutor.java | 33 ++----- 4 files changed, 107 insertions(+), 64 deletions(-) create mode 100644 weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java new file mode 100644 index 0000000000..a75aa963e0 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java @@ -0,0 +1,88 @@ +package me.chanjar.weixin.common.util.http; + +import jodd.http.HttpResponse; +import me.chanjar.weixin.common.bean.result.WxError; +import me.chanjar.weixin.common.exception.WxErrorException; +import okhttp3.Response; +import org.apache.http.Header; +import org.apache.http.client.methods.CloseableHttpResponse; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + *
    + * 三种http框架的response代理类,方便提取公共方法
    + * Created by Binary Wang on 2017-8-3.
    + * 
    + * + * @author Binary Wang + */ +public class HttpResponseProxy { + private CloseableHttpResponse apacheHttpResponse; + private HttpResponse joddHttpResponse; + private Response okHttpResponse; + + public HttpResponseProxy(CloseableHttpResponse apacheHttpResponse) { + this.apacheHttpResponse = apacheHttpResponse; + } + + public HttpResponseProxy(HttpResponse joddHttpResponse) { + this.joddHttpResponse = joddHttpResponse; + } + + public HttpResponseProxy(Response okHttpResponse) { + this.okHttpResponse = okHttpResponse; + } + + public String getFileName() throws WxErrorException { + //由于对象只能由一个构造方法实现,因此三个response对象必定且只有一个不为空 + if (this.apacheHttpResponse != null) { + return this.getFileName(this.apacheHttpResponse); + } + + if (this.joddHttpResponse != null) { + return this.getFileName(this.joddHttpResponse); + } + + if (this.okHttpResponse != null) { + return this.getFileName(this.okHttpResponse); + } + + //cannot happen + return null; + } + + private String getFileName(CloseableHttpResponse response) throws WxErrorException { + Header[] contentDispositionHeader = response.getHeaders("Content-disposition"); + if (contentDispositionHeader == null || contentDispositionHeader.length == 0) { + throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build()); + } + + return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue()); + } + + private String getFileName(HttpResponse response) throws WxErrorException { + String content = response.header("Content-disposition"); + return this.extractFileNameFromContentString(content); + } + + private String getFileName(Response response) throws WxErrorException { + String content = response.header("Content-disposition"); + return this.extractFileNameFromContentString(content); + } + + private String extractFileNameFromContentString(String content) throws WxErrorException { + if (content == null || content.length() == 0) { + throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build()); + } + + Pattern p = Pattern.compile(".*filename=\"(.*)\""); + Matcher m = p.matcher(content); + if (m.matches()) { + return m.group(1); + } + throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build()); + } + +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java index 6a928648e5..0a5a504873 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java @@ -3,8 +3,10 @@ import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; +import me.chanjar.weixin.common.util.http.HttpResponseProxy; import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.Header; import org.apache.http.HttpHost; @@ -17,15 +19,12 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * Created by ecoolper on 2017/5/5. */ public class ApacheMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor { - public ApacheMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { super(requestHttp, tmpDirFile); } @@ -57,31 +56,17 @@ public File execute(String uri, String queryParam) throws WxErrorException, IOEx } } - String fileName = getFileName(response); + String fileName = new HttpResponseProxy(response).getFileName(); if (StringUtils.isBlank(fileName)) { return null; } - String[] nameAndExt = fileName.split("\\."); - return FileUtils.createTmpFile(inputStream, nameAndExt[0], nameAndExt[1], super.tmpDirFile); + return FileUtils.createTmpFile(inputStream, FilenameUtils.getBaseName(fileName), FilenameUtils.getExtension(fileName), + super.tmpDirFile); } finally { httpGet.releaseConnection(); } } - private String getFileName(CloseableHttpResponse response) throws WxErrorException { - Header[] contentDispositionHeader = response.getHeaders("Content-disposition"); - if (contentDispositionHeader == null || contentDispositionHeader.length == 0) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build()); - } - - Pattern p = Pattern.compile(".*filename=\"(.*)\""); - Matcher m = p.matcher(contentDispositionHeader[0].getValue()); - if (m.matches()) { - return m.group(1); - } - throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build()); - } - } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java index edbee76678..bbd8bec47c 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java @@ -5,27 +5,25 @@ import jodd.http.HttpResponse; import jodd.http.ProxyInfo; import jodd.util.StringPool; - import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; +import me.chanjar.weixin.common.util.http.HttpResponseProxy; import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * Created by ecoolper on 2017/5/5. */ public class JoddHttpMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor { - public JoddHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { super(requestHttp, tmpDirFile); } @@ -54,28 +52,15 @@ public File execute(String uri, String queryParam) throws WxErrorException, IOEx throw new WxErrorException(WxError.fromJson(response.bodyText())); } - String fileName = getFileName(response); + String fileName = new HttpResponseProxy(response).getFileName(); if (StringUtils.isBlank(fileName)) { return null; } InputStream inputStream = new ByteArrayInputStream(response.bodyBytes()); - String[] nameAndExt = fileName.split("\\."); - return FileUtils.createTmpFile(inputStream, nameAndExt[0], nameAndExt[1], super.tmpDirFile); + return FileUtils.createTmpFile(inputStream, FilenameUtils.getBaseName(fileName), FilenameUtils.getExtension(fileName), + super.tmpDirFile); } - private String getFileName(HttpResponse response) throws WxErrorException { - String content = response.header("Content-disposition"); - if (content == null || content.length() == 0) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build()); - } - - Pattern p = Pattern.compile(".*filename=\"(.*)\""); - Matcher m = p.matcher(content); - if (m.matches()) { - return m.group(1); - } - throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build()); - } } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java index 246ce4dcc0..0923527b71 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java @@ -2,22 +2,21 @@ import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.common.util.fs.FileUtils; +import me.chanjar.weixin.common.util.http.HttpResponseProxy; import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; -import okhttp3.*; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; import okio.BufferedSink; import okio.Okio; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * Created by ecoolper on 2017/5/5. @@ -25,7 +24,6 @@ public class OkHttpMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor { private final Logger logger = LoggerFactory.getLogger(this.getClass()); - public OkHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { super(requestHttp, tmpDirFile); } @@ -53,12 +51,13 @@ public File execute(String uri, String queryParam) throws WxErrorException, IOEx throw new WxErrorException(WxError.fromJson(response.body().string())); } - String fileName = getFileName(response); + String fileName = new HttpResponseProxy(response).getFileName(); if (StringUtils.isBlank(fileName)) { return null; } - String[] nameAndExt = fileName.split("\\."); - File file = File.createTempFile(nameAndExt[0], nameAndExt[1], super.tmpDirFile); + + File file = File.createTempFile(FilenameUtils.getBaseName(fileName), FilenameUtils.getExtension(fileName), + super.tmpDirFile); try (BufferedSink sink = Okio.buffer(Okio.sink(file))) { sink.writeAll(response.body().source()); } @@ -66,18 +65,4 @@ public File execute(String uri, String queryParam) throws WxErrorException, IOEx return file; } - private String getFileName(Response response) throws WxErrorException { - String content = response.header("Content-disposition"); - if (content == null || content.length() == 0) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build()); - } - - Pattern p = Pattern.compile(".*filename=\"(.*)\""); - Matcher m = p.matcher(content); - if (m.matches()) { - return m.group(1); - } - throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build()); - } - } From 67dad47be7622f9c275c8410ee5e82b0dd02e681 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 14 Aug 2017 15:02:49 +0800 Subject: [PATCH 061/165] =?UTF-8?q?#305=20=E4=BF=AE=E5=A4=8D=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=8F=98=E6=80=81=E7=9A=84=E6=8B=8D=E7=85=A7=E6=88=96?= =?UTF-8?q?=E5=8F=91=E5=9B=BE=E4=BA=8B=E4=BB=B6=E7=9A=84=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/bean/WxCpXmlMessage.java | 2 + .../weixin/cp/bean/WxCpXmlMessageTest.java | 97 ++++++++----- .../mp/bean/message/WxMpXmlMessage.java | 2 + .../mp/bean/message/WxMpXmlMessageTest.java | 131 +++++++++--------- 4 files changed, 133 insertions(+), 99 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java index 8b7ee5f166..117cf4115b 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java @@ -164,6 +164,8 @@ public class WxCpXmlMessage implements Serializable { private SendLocationInfo sendLocationInfo = new SendLocationInfo(); protected static WxCpXmlMessage fromXml(String xml) { + //修改微信变态的消息内容格式,方便解析 + xml = xml.replace("", ""); return XStreamTransformer.fromXml(WxCpXmlMessage.class, xml); } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java index 74b526160b..87e16d773a 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java @@ -1,8 +1,9 @@ package me.chanjar.weixin.cp.bean; import me.chanjar.weixin.common.api.WxConsts; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.testng.annotations.*; + +import static org.testng.Assert.*; @Test public class WxCpXmlMessageTest { @@ -54,38 +55,66 @@ public void testFromXml() { + "" + ""; WxCpXmlMessage wxMessage = WxCpXmlMessage.fromXml(xml); - Assert.assertEquals(wxMessage.getToUserName(), "toUser"); - Assert.assertEquals(wxMessage.getFromUserName(), "fromUser"); - Assert.assertEquals(wxMessage.getCreateTime(), new Long(1348831860l)); - Assert.assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); - Assert.assertEquals(wxMessage.getContent(), "this is a test"); - Assert.assertEquals(wxMessage.getMsgId(), new Long(1234567890123456l)); - Assert.assertEquals(wxMessage.getPicUrl(), "this is a url"); - Assert.assertEquals(wxMessage.getMediaId(), "media_id"); - Assert.assertEquals(wxMessage.getFormat(), "Format"); - Assert.assertEquals(wxMessage.getThumbMediaId(), "thumb_media_id"); - Assert.assertEquals(wxMessage.getLocationX(), new Double(23.134521d)); - Assert.assertEquals(wxMessage.getLocationY(), new Double(113.358803d)); - Assert.assertEquals(wxMessage.getScale(), new Double(20)); - Assert.assertEquals(wxMessage.getLabel(), "位置信息"); - Assert.assertEquals(wxMessage.getDescription(), "公众平台官网链接"); - Assert.assertEquals(wxMessage.getUrl(), "url"); - Assert.assertEquals(wxMessage.getTitle(), "公众平台官网链接"); - Assert.assertEquals(wxMessage.getEvent(), "subscribe"); - Assert.assertEquals(wxMessage.getEventKey(), "qrscene_123123"); - Assert.assertEquals(wxMessage.getTicket(), "TICKET"); - Assert.assertEquals(wxMessage.getLatitude(), new Double(23.137466)); - Assert.assertEquals(wxMessage.getLongitude(), new Double(113.352425)); - Assert.assertEquals(wxMessage.getPrecision(), new Double(119.385040)); - Assert.assertEquals(wxMessage.getScanCodeInfo().getScanType(), "qrcode"); - Assert.assertEquals(wxMessage.getScanCodeInfo().getScanResult(), "1"); - Assert.assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1l)); - Assert.assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "1b5f7c23b5bf75682a53e7b6d163e185"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationX(), "23"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getScale(), "15"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi"); + assertEquals(wxMessage.getToUserName(), "toUser"); + assertEquals(wxMessage.getFromUserName(), "fromUser"); + assertEquals(wxMessage.getCreateTime(), new Long(1348831860l)); + assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); + assertEquals(wxMessage.getContent(), "this is a test"); + assertEquals(wxMessage.getMsgId(), new Long(1234567890123456l)); + assertEquals(wxMessage.getPicUrl(), "this is a url"); + assertEquals(wxMessage.getMediaId(), "media_id"); + assertEquals(wxMessage.getFormat(), "Format"); + assertEquals(wxMessage.getThumbMediaId(), "thumb_media_id"); + assertEquals(wxMessage.getLocationX(), 23.134521d); + assertEquals(wxMessage.getLocationY(), 113.358803d); + assertEquals(wxMessage.getScale(), 20d); + assertEquals(wxMessage.getLabel(), "位置信息"); + assertEquals(wxMessage.getDescription(), "公众平台官网链接"); + assertEquals(wxMessage.getUrl(), "url"); + assertEquals(wxMessage.getTitle(), "公众平台官网链接"); + assertEquals(wxMessage.getEvent(), "subscribe"); + assertEquals(wxMessage.getEventKey(), "qrscene_123123"); + assertEquals(wxMessage.getTicket(), "TICKET"); + assertEquals(wxMessage.getLatitude(), 23.137466); + assertEquals(wxMessage.getLongitude(), 113.352425); + assertEquals(wxMessage.getPrecision(), 119.385040); + assertEquals(wxMessage.getScanCodeInfo().getScanType(), "qrcode"); + assertEquals(wxMessage.getScanCodeInfo().getScanResult(), "1"); + assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1l)); + assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "1b5f7c23b5bf75682a53e7b6d163e185"); + assertEquals(wxMessage.getSendLocationInfo().getLocationX(), "23"); + assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); + assertEquals(wxMessage.getSendLocationInfo().getScale(), "15"); + assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号"); + assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi"); } + public void testSendPicsInfo() { + String xml = "" + + "" + + "" + + "1502012364" + + "" + + "1000004" + + "" + + "" + + "" + + "" + + "" + + "2" + + "" + + ""; + WxCpXmlMessage wxMessage = WxCpXmlMessage.fromXml(xml.replace("","")); + assertEquals(wxMessage.getToUserName(), "wx45a0972125658be9"); + assertEquals(wxMessage.getFromUserName(), "xiaohe"); + assertEquals(wxMessage.getCreateTime(), new Long(1502012364L)); + assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_EVENT); + assertEquals(wxMessage.getAgentId(), Integer.valueOf(1000004)); + assertEquals(wxMessage.getEvent(), "pic_weixin"); + assertEquals(wxMessage.getEventKey(), "faceSimilarity"); + assertNotNull(wxMessage.getSendPicsInfo()); + assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(2L)); + assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "aef52ae501537e552725c5d7f99c1741"); + assertEquals(wxMessage.getSendPicsInfo().getPicList().get(1).getPicMd5Sum(), "c4564632a4fab91378c39bea6aad6f9e"); + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java index 262399b8f4..730310185c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java @@ -425,6 +425,8 @@ public class WxMpXmlMessage implements Serializable { private Integer deviceStatus; public static WxMpXmlMessage fromXml(String xml) { + //修改微信变态的消息内容格式,方便解析 + xml = xml.replace("", ""); return XStreamTransformer.fromXml(WxMpXmlMessage.class, xml); } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java index bbb8ce83ee..9c2bbf56ac 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java @@ -1,9 +1,10 @@ package me.chanjar.weixin.mp.bean.message; import me.chanjar.weixin.common.api.WxConsts; -import org.testng.*; import org.testng.annotations.*; +import static org.testng.Assert.*; + @Test public class WxMpXmlMessageTest { @@ -54,38 +55,38 @@ public void testFromXml() { + "" + ""; WxMpXmlMessage wxMessage = WxMpXmlMessage.fromXml(xml); - Assert.assertEquals(wxMessage.getToUser(), "toUser"); - Assert.assertEquals(wxMessage.getFromUser(), "fromUser"); - Assert.assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); - Assert.assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); - Assert.assertEquals(wxMessage.getContent(), "this is a test"); - Assert.assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); - Assert.assertEquals(wxMessage.getPicUrl(), "this is a url"); - Assert.assertEquals(wxMessage.getMediaId(), "media_id"); - Assert.assertEquals(wxMessage.getFormat(), "Format"); - Assert.assertEquals(wxMessage.getThumbMediaId(), "thumb_media_id"); - Assert.assertEquals(wxMessage.getLocationX(), 23.134521d); - Assert.assertEquals(wxMessage.getLocationY(), 113.358803d); - Assert.assertEquals(wxMessage.getScale(), 20d); - Assert.assertEquals(wxMessage.getLabel(), "位置信息"); - Assert.assertEquals(wxMessage.getDescription(), "公众平台官网链接"); - Assert.assertEquals(wxMessage.getUrl(), "url"); - Assert.assertEquals(wxMessage.getTitle(), "公众平台官网链接"); - Assert.assertEquals(wxMessage.getEvent(), "subscribe"); - Assert.assertEquals(wxMessage.getEventKey(), "qrscene_123123"); - Assert.assertEquals(wxMessage.getTicket(), "TICKET"); - Assert.assertEquals(wxMessage.getLatitude(), 23.137466); - Assert.assertEquals(wxMessage.getLongitude(), 113.352425); - Assert.assertEquals(wxMessage.getPrecision(), 119.385040); - Assert.assertEquals(wxMessage.getScanCodeInfo().getScanType(), "qrcode"); - Assert.assertEquals(wxMessage.getScanCodeInfo().getScanResult(), "1"); - Assert.assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1L)); - Assert.assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "1b5f7c23b5bf75682a53e7b6d163e185"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationX(), "23"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getScale(), "15"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi"); + assertEquals(wxMessage.getToUser(), "toUser"); + assertEquals(wxMessage.getFromUser(), "fromUser"); + assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); + assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); + assertEquals(wxMessage.getContent(), "this is a test"); + assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); + assertEquals(wxMessage.getPicUrl(), "this is a url"); + assertEquals(wxMessage.getMediaId(), "media_id"); + assertEquals(wxMessage.getFormat(), "Format"); + assertEquals(wxMessage.getThumbMediaId(), "thumb_media_id"); + assertEquals(wxMessage.getLocationX(), 23.134521d); + assertEquals(wxMessage.getLocationY(), 113.358803d); + assertEquals(wxMessage.getScale(), 20d); + assertEquals(wxMessage.getLabel(), "位置信息"); + assertEquals(wxMessage.getDescription(), "公众平台官网链接"); + assertEquals(wxMessage.getUrl(), "url"); + assertEquals(wxMessage.getTitle(), "公众平台官网链接"); + assertEquals(wxMessage.getEvent(), "subscribe"); + assertEquals(wxMessage.getEventKey(), "qrscene_123123"); + assertEquals(wxMessage.getTicket(), "TICKET"); + assertEquals(wxMessage.getLatitude(), 23.137466); + assertEquals(wxMessage.getLongitude(), 113.352425); + assertEquals(wxMessage.getPrecision(), 119.385040); + assertEquals(wxMessage.getScanCodeInfo().getScanType(), "qrcode"); + assertEquals(wxMessage.getScanCodeInfo().getScanResult(), "1"); + assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1L)); + assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "1b5f7c23b5bf75682a53e7b6d163e185"); + assertEquals(wxMessage.getSendLocationInfo().getLocationX(), "23"); + assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); + assertEquals(wxMessage.getSendLocationInfo().getScale(), "15"); + assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号"); + assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi"); } public void testFromXml2() { @@ -135,38 +136,38 @@ public void testFromXml2() { + "" + ""; WxMpXmlMessage wxMessage = WxMpXmlMessage.fromXml(xml); - Assert.assertEquals(wxMessage.getToUser(), "toUser"); - Assert.assertEquals(wxMessage.getFromUser(), "fromUser"); - Assert.assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); - Assert.assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); - Assert.assertEquals(wxMessage.getContent(), "this is a test"); - Assert.assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); - Assert.assertEquals(wxMessage.getPicUrl(), "this is a url"); - Assert.assertEquals(wxMessage.getMediaId(), "media_id"); - Assert.assertEquals(wxMessage.getFormat(), "Format"); - Assert.assertEquals(wxMessage.getThumbMediaId(), "thumb_media_id"); - Assert.assertEquals(wxMessage.getLocationX(), 23.134521d); - Assert.assertEquals(wxMessage.getLocationY(), 113.358803d); - Assert.assertEquals(wxMessage.getScale(), 20d); - Assert.assertEquals(wxMessage.getLabel(), "位置信息"); - Assert.assertEquals(wxMessage.getDescription(), "公众平台官网链接"); - Assert.assertEquals(wxMessage.getUrl(), "url"); - Assert.assertEquals(wxMessage.getTitle(), "公众平台官网链接"); - Assert.assertEquals(wxMessage.getEvent(), "subscribe"); - Assert.assertEquals(wxMessage.getEventKey(), "qrscene_123123"); - Assert.assertEquals(wxMessage.getTicket(), "TICKET"); - Assert.assertEquals(wxMessage.getLatitude(), 23.137466); - Assert.assertEquals(wxMessage.getLongitude(), 113.352425); - Assert.assertEquals(wxMessage.getPrecision(), 119.385040); - Assert.assertEquals(wxMessage.getScanCodeInfo().getScanType(), "qrcode"); - Assert.assertEquals(wxMessage.getScanCodeInfo().getScanResult(), "1"); - Assert.assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1L)); - Assert.assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "1b5f7c23b5bf75682a53e7b6d163e185"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationX(), "23"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getScale(), "15"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号"); - Assert.assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi"); + assertEquals(wxMessage.getToUser(), "toUser"); + assertEquals(wxMessage.getFromUser(), "fromUser"); + assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); + assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); + assertEquals(wxMessage.getContent(), "this is a test"); + assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); + assertEquals(wxMessage.getPicUrl(), "this is a url"); + assertEquals(wxMessage.getMediaId(), "media_id"); + assertEquals(wxMessage.getFormat(), "Format"); + assertEquals(wxMessage.getThumbMediaId(), "thumb_media_id"); + assertEquals(wxMessage.getLocationX(), 23.134521d); + assertEquals(wxMessage.getLocationY(), 113.358803d); + assertEquals(wxMessage.getScale(), 20d); + assertEquals(wxMessage.getLabel(), "位置信息"); + assertEquals(wxMessage.getDescription(), "公众平台官网链接"); + assertEquals(wxMessage.getUrl(), "url"); + assertEquals(wxMessage.getTitle(), "公众平台官网链接"); + assertEquals(wxMessage.getEvent(), "subscribe"); + assertEquals(wxMessage.getEventKey(), "qrscene_123123"); + assertEquals(wxMessage.getTicket(), "TICKET"); + assertEquals(wxMessage.getLatitude(), 23.137466); + assertEquals(wxMessage.getLongitude(), 113.352425); + assertEquals(wxMessage.getPrecision(), 119.385040); + assertEquals(wxMessage.getScanCodeInfo().getScanType(), "qrcode"); + assertEquals(wxMessage.getScanCodeInfo().getScanResult(), "1"); + assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1L)); + assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "1b5f7c23b5bf75682a53e7b6d163e185"); + assertEquals(wxMessage.getSendLocationInfo().getLocationX(), "23"); + assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); + assertEquals(wxMessage.getSendLocationInfo().getScale(), "15"); + assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号"); + assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi"); } } From 1d1c4c74f0f86174516974f799efbb169757db4e Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 14 Aug 2017 15:14:13 +0800 Subject: [PATCH 062/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.7.8.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 8bd9de49e5..fd6312842c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.7.7.BETA + 2.7.8.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index f93c89abb8..bd7bb51cee 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.7.BETA + 2.7.8.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 6e0a3e27b2..330a34b098 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.7.BETA + 2.7.8.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index bc75c8f7f9..11ab7d392e 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.7.BETA + 2.7.8.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 18de637004..d8aa707aee 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.7.BETA + 2.7.8.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 0a65663c6b..74704e6a87 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.7.7.BETA + 2.7.8.BETA 4.0.0 From a8cdb44e6db6276b45e33f74b2a4340ed35699b2 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 14 Aug 2017 15:31:50 +0800 Subject: [PATCH 063/165] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=8D=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E7=9A=84=E7=B1=BB=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...bstractWxCpServiceImpl.java => WxCpServiceAbstractImpl.java} | 2 +- .../weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java | 2 +- .../me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java | 2 +- .../me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java | 2 +- ...bstractWxMpServiceImpl.java => WxMpServiceAbstractImpl.java} | 2 +- .../weixin/mp/api/impl/WxMpServiceApacheHttpClientImpl.java | 2 +- .../me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java | 2 +- .../me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/{AbstractWxCpServiceImpl.java => WxCpServiceAbstractImpl.java} (99%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/{AbstractWxMpServiceImpl.java => WxMpServiceAbstractImpl.java} (99%) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/AbstractWxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java similarity index 99% rename from weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/AbstractWxCpServiceImpl.java rename to weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java index be1b311857..a1f07e68cc 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/AbstractWxCpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java @@ -30,7 +30,7 @@ import java.io.InputStream; import java.util.List; -public abstract class AbstractWxCpServiceImpl implements WxCpService, RequestHttp { +public abstract class WxCpServiceAbstractImpl implements WxCpService, RequestHttp { protected final Logger log = LoggerFactory.getLogger(this.getClass()); private WxCpUserService userService = new WxCpUserServiceImpl(this); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java index d9388f0345..fc6249662b 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java @@ -17,7 +17,7 @@ import java.io.IOException; -public class WxCpServiceApacheHttpClientImpl extends AbstractWxCpServiceImpl { +public class WxCpServiceApacheHttpClientImpl extends WxCpServiceAbstractImpl { protected CloseableHttpClient httpClient; protected HttpHost httpProxy; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java index 3000916fac..5a14eb27fe 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java @@ -7,7 +7,7 @@ import me.chanjar.weixin.common.util.http.HttpType; import me.chanjar.weixin.cp.config.WxCpConfigStorage; -public class WxCpServiceJoddHttpImpl extends AbstractWxCpServiceImpl { +public class WxCpServiceJoddHttpImpl extends WxCpServiceAbstractImpl { protected HttpConnectionProvider httpClient; protected ProxyInfo httpProxy; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java index 2b8ae0c4af..2ad4c72015 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java @@ -12,7 +12,7 @@ import java.io.IOException; -public class WxCpServiceOkHttpImpl extends AbstractWxCpServiceImpl { +public class WxCpServiceOkHttpImpl extends WxCpServiceAbstractImpl { private final Logger logger = LoggerFactory.getLogger(this.getClass()); protected OkHttpClient httpClient; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java similarity index 99% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java index 25eeeadce4..fbf3861e00 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/AbstractWxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java @@ -22,7 +22,7 @@ import java.io.IOException; import java.util.concurrent.locks.Lock; -public abstract class AbstractWxMpServiceImpl implements WxMpService, RequestHttp { +public abstract class WxMpServiceAbstractImpl implements WxMpService, RequestHttp { private static final JsonParser JSON_PARSER = new JsonParser(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceApacheHttpClientImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceApacheHttpClientImpl.java index d929b0974c..ceb0b783e2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceApacheHttpClientImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceApacheHttpClientImpl.java @@ -21,7 +21,7 @@ /** * apache-http方式实现 */ -public class WxMpServiceApacheHttpClientImpl extends AbstractWxMpServiceImpl { +public class WxMpServiceApacheHttpClientImpl extends WxMpServiceAbstractImpl { private CloseableHttpClient httpClient; private HttpHost httpProxy; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java index 5c0fb75300..0551db67c6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java @@ -14,7 +14,7 @@ /** * jodd-http方式实现 */ -public class WxMpServiceJoddHttpImpl extends AbstractWxMpServiceImpl { +public class WxMpServiceJoddHttpImpl extends WxMpServiceAbstractImpl { private HttpConnectionProvider httpClient; private ProxyInfo httpProxy; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java index dbb957b84c..9f2a17add1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java @@ -14,7 +14,7 @@ import java.io.IOException; import java.util.concurrent.locks.Lock; -public class WxMpServiceOkHttpImpl extends AbstractWxMpServiceImpl { +public class WxMpServiceOkHttpImpl extends WxMpServiceAbstractImpl { private final Logger logger = LoggerFactory.getLogger(this.getClass()); From 914042501519616643aad48bf2da09d22059ff30 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 16 Aug 2017 10:20:06 +0800 Subject: [PATCH 064/165] =?UTF-8?q?=E6=B7=BB=E5=8A=A0buttons=E7=9A=84gette?= =?UTF-8?q?r=E5=92=8Csetter=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java index 588e8a9c05..699a41ecfb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java @@ -24,6 +24,14 @@ public String toString() { return ToStringUtils.toSimpleString(this); } + public List getButtons() { + return this.buttons; + } + + public void setButtons(List buttons) { + this.buttons = buttons; + } + public static class WxMpSelfMenuButton { /** *
    
    From af4bb1d85b4a6bd864535575c2fd64e7ad627502 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Wed, 16 Aug 2017 10:20:21 +0800
    Subject: [PATCH 065/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?=
     =?UTF-8?q?=E7=9A=84javadoc?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java  | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java
    index cee28b73ba..4a666eff1b 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java
    @@ -76,7 +76,7 @@ WxTagListUser tagListUser(Long tagId, String nextOpenid)
        * 
        * 批量为用户取消标签
        * 详情请见:用户标签管理
    -   * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN
    +   * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=ACCESS_TOKEN
        * 
    */ boolean batchUntagging(Long tagId, String[] openids) throws WxErrorException; From 92947b344a24785215649b8388b45f71b012df71 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 16 Aug 2017 19:26:21 +0800 Subject: [PATCH 066/165] =?UTF-8?q?=E8=BD=AC=E7=A7=BB=E7=BE=A4=E5=8F=91?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E5=88=B0?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E6=8E=A5=E5=8F=A3=E5=8F=8A=E5=85=B6=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E7=B1=BB=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/WxMpMassMessageService.java | 95 +++++++++++++++++++ .../me/chanjar/weixin/mp/api/WxMpService.java | 83 +--------------- .../api/impl/WxMpMassMessageServiceImpl.java | 58 +++++++++++ .../mp/api/impl/WxMpServiceAbstractImpl.java | 36 ++----- .../WxMpMassMessageServiceImplTest.java} | 63 ++++++------ weixin-java-mp/src/test/resources/testng.xml | 2 +- 6 files changed, 197 insertions(+), 140 deletions(-) create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java rename weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/{WxMpMassMessageAPITest.java => impl/WxMpMassMessageServiceImplTest.java} (80%) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java new file mode 100644 index 0000000000..e4a57de99b --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java @@ -0,0 +1,95 @@ +package me.chanjar.weixin.mp.api; + +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.bean.*; +import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; +import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult; + +/** + *
    + * 群发消息服务类
    + * Created by Binary Wang on 2017-8-16.
    + * 
    + * + * @author Binary Wang + */ +public interface WxMpMassMessageService { + /** + * 上传群发用的图文消息 + */ + String MEDIA_UPLOAD_NEWS_URL = "https://api.weixin.qq.com/cgi-bin/media/uploadnews"; + /** + * 上传群发用的视频 + */ + String MEDIA_UPLOAD_VIDEO_URL = "https://api.weixin.qq.com/cgi-bin/media/uploadvideo"; + /** + * 分组群发消息 + */ + String MESSAGE_MASS_SENDALL_URL = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall"; + /** + * 按openId列表群发消息 + */ + String MESSAGE_MASS_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/mass/send"; + /** + * 群发消息预览接口 + */ + String MESSAGE_MASS_PREVIEW_URL = "https://api.weixin.qq.com/cgi-bin/message/mass/preview"; + + /** + *
    +   * 上传群发用的图文消息,上传后才能群发图文消息
    +   *
    +   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
    +   * 
    + * + * @see #massGroupMessageSend(WxMpMassTagMessage) + * @see #massOpenIdsMessageSend(WxMpMassOpenIdsMessage) + */ + WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException; + + /** + *
    +   * 上传群发用的视频,上传后才能群发视频消息
    +   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
    +   * 
    + * + * @see #massGroupMessageSend(WxMpMassTagMessage) + * @see #massOpenIdsMessageSend(WxMpMassOpenIdsMessage) + */ + WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException; + + /** + *
    +   * 分组群发消息
    +   * 如果发送图文消息,必须先使用 {@link #massNewsUpload(WxMpMassNews)} 获得media_id,然后再发送
    +   * 如果发送视频消息,必须先使用 {@link #massVideoUpload(WxMpMassVideo)} 获得media_id,然后再发送
    +   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
    +   * 
    + */ + WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException; + + /** + *
    +   * 按openId列表群发消息
    +   * 如果发送图文消息,必须先使用 {@link #massNewsUpload(WxMpMassNews)} 获得media_id,然后再发送
    +   * 如果发送视频消息,必须先使用 {@link #massVideoUpload(WxMpMassVideo)} 获得media_id,然后再发送
    +   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
    +   * 
    + */ + WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException; + + /** + *
    +   * 群发消息预览接口
    +   * 开发者可通过该接口发送消息给指定用户,在手机端查看消息的样式和排版。为了满足第三方平台开发者的需求,在保留对openID预览能力的同时,增加了对指定微信号发送预览的能力,但该能力每日调用次数有限制(100次),请勿滥用。
    +   * 接口调用请求说明
    +   *  http请求方式: POST
    +   *  https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=ACCESS_TOKEN
    +   * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
    +   * 
    + * + * @return wxMpMassSendResult + */ + WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception; + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java index e4da721c8e..f684f4e8a4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java @@ -20,26 +20,6 @@ public interface WxMpService { * 获得jsapi_ticket */ String GET_JSAPI_TICKET_URL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi"; - /** - * 上传群发用的图文消息 - */ - String MEDIA_UPLOAD_NEWS_URL = "https://api.weixin.qq.com/cgi-bin/media/uploadnews"; - /** - * 上传群发用的视频 - */ - String MEDIA_UPLOAD_VIDEO_URL = "https://api.weixin.qq.com/cgi-bin/media/uploadvideo"; - /** - * 分组群发消息 - */ - String MESSAGE_MASS_SENDALL_URL = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall"; - /** - * 按openId列表群发消息 - */ - String MESSAGE_MASS_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/mass/send"; - /** - * 群发消息预览接口 - */ - String MESSAGE_MASS_PREVIEW_URL = "https://api.weixin.qq.com/cgi-bin/message/mass/preview"; /** * 长链接转短链接接口 */ @@ -141,63 +121,6 @@ public interface WxMpService { */ WxJsapiSignature createJsapiSignature(String url) throws WxErrorException; - /** - *
    -   * 上传群发用的图文消息,上传后才能群发图文消息
    -   *
    -   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
    -   * 
    - * - * @see #massGroupMessageSend(me.chanjar.weixin.mp.bean.WxMpMassTagMessage) - * @see #massOpenIdsMessageSend(me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage) - */ - WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException; - - /** - *
    -   * 上传群发用的视频,上传后才能群发视频消息
    -   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
    -   * 
    - * - * @see #massGroupMessageSend(me.chanjar.weixin.mp.bean.WxMpMassTagMessage) - * @see #massOpenIdsMessageSend(me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage) - */ - WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException; - - /** - *
    -   * 分组群发消息
    -   * 如果发送图文消息,必须先使用 {@link #massNewsUpload(me.chanjar.weixin.mp.bean.WxMpMassNews)} 获得media_id,然后再发送
    -   * 如果发送视频消息,必须先使用 {@link #massVideoUpload(me.chanjar.weixin.mp.bean.WxMpMassVideo)} 获得media_id,然后再发送
    -   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
    -   * 
    - */ - WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException; - - /** - *
    -   * 按openId列表群发消息
    -   * 如果发送图文消息,必须先使用 {@link #massNewsUpload(me.chanjar.weixin.mp.bean.WxMpMassNews)} 获得media_id,然后再发送
    -   * 如果发送视频消息,必须先使用 {@link #massVideoUpload(me.chanjar.weixin.mp.bean.WxMpMassVideo)} 获得media_id,然后再发送
    -   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
    -   * 
    - */ - WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException; - - /** - *
    -   * 群发消息预览接口
    -   * 开发者可通过该接口发送消息给指定用户,在手机端查看消息的样式和排版。为了满足第三方平台开发者的需求,在保留对openID预览能力的同时,增加了对指定微信号发送预览的能力,但该能力每日调用次数有限制(100次),请勿滥用。
    -   * 接口调用请求说明
    -   *  http请求方式: POST
    -   *  https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=ACCESS_TOKEN
    -   * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140549&token=&lang=zh_CN
    -   * 
    - * - * @return wxMpMassSendResult - */ - WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception; - /** *
        * 长链接转短链接接口
    @@ -451,5 +374,9 @@ public interface WxMpService {
        */
       RequestHttp getRequestHttp();
     
    -
    +  /**
    +   * 返回群发消息相关接口方法的实现类对象,以方便调用其各个接口
    +   * @return WxMpMassMessageService
    +   */
    +  WxMpMassMessageService getMassMessageService();
     }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java
    new file mode 100644
    index 0000000000..015c465c0f
    --- /dev/null
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java
    @@ -0,0 +1,58 @@
    +package me.chanjar.weixin.mp.api.impl;
    +
    +import me.chanjar.weixin.common.exception.WxErrorException;
    +import me.chanjar.weixin.mp.api.WxMpMassMessageService;
    +import me.chanjar.weixin.mp.api.WxMpService;
    +import me.chanjar.weixin.mp.bean.*;
    +import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
    +import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * 
    + * 群发消息服务类
    + * Created by Binary Wang on 2017-8-16.
    + * 
    + * + * @author Binary Wang + */ +public class WxMpMassMessageServiceImpl implements WxMpMassMessageService { + protected final Logger log = LoggerFactory.getLogger(this.getClass()); + private WxMpService wxMpService; + + public WxMpMassMessageServiceImpl(WxMpService wxMpService) { + this.wxMpService = wxMpService; + } + + @Override + public WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException { + String responseContent = this.wxMpService.post(MEDIA_UPLOAD_NEWS_URL, news.toJson()); + return WxMpMassUploadResult.fromJson(responseContent); + } + + @Override + public WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException { + String responseContent = this.wxMpService.post(MEDIA_UPLOAD_VIDEO_URL, video.toJson()); + return WxMpMassUploadResult.fromJson(responseContent); + } + + @Override + public WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException { + String responseContent = this.wxMpService.post(WxMpMassMessageService.MESSAGE_MASS_SENDALL_URL, message.toJson()); + return WxMpMassSendResult.fromJson(responseContent); + } + + @Override + public WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException { + String responseContent = this.wxMpService.post(MESSAGE_MASS_SEND_URL, message.toJson()); + return WxMpMassSendResult.fromJson(responseContent); + } + + @Override + public WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception { + String responseContent = this.wxMpService.post(MESSAGE_MASS_PREVIEW_URL, wxMpMassPreviewMessage.toJson()); + return WxMpMassSendResult.fromJson(responseContent); + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java index fbf3861e00..91dff9babb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java @@ -43,6 +43,7 @@ public abstract class WxMpServiceAbstractImpl implements WxMpService, Requ private WxMpDeviceService deviceService = new WxMpDeviceServiceImpl(this); private WxMpShakeService shakeService = new WxMpShakeServiceImpl(this); private WxMpMemberCardService memberCardService = new WxMpMemberCardServiceImpl(this); + private WxMpMassMessageService massMessageService = new WxMpMassMessageServiceImpl(this); private int retrySleepMillis = 1000; private int maxRetryTimes = 5; @@ -108,36 +109,6 @@ public String getAccessToken() throws WxErrorException { return getAccessToken(false); } - @Override - public WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException { - String responseContent = this.post(WxMpService.MEDIA_UPLOAD_NEWS_URL, news.toJson()); - return WxMpMassUploadResult.fromJson(responseContent); - } - - @Override - public WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException { - String responseContent = this.post(WxMpService.MEDIA_UPLOAD_VIDEO_URL, video.toJson()); - return WxMpMassUploadResult.fromJson(responseContent); - } - - @Override - public WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException { - String responseContent = this.post(WxMpService.MESSAGE_MASS_SENDALL_URL, message.toJson()); - return WxMpMassSendResult.fromJson(responseContent); - } - - @Override - public WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException { - String responseContent = this.post(WxMpService.MESSAGE_MASS_SEND_URL, message.toJson()); - return WxMpMassSendResult.fromJson(responseContent); - } - - @Override - public WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception { - String responseContent = this.post(WxMpService.MESSAGE_MASS_PREVIEW_URL, wxMpMassPreviewMessage.toJson()); - return WxMpMassSendResult.fromJson(responseContent); - } - @Override public String shortUrl(String long_url) throws WxErrorException { JsonObject o = new JsonObject(); @@ -415,4 +386,9 @@ public WxMpMemberCardService getMemberCardService() { public RequestHttp getRequestHttp() { return this; } + + @Override + public WxMpMassMessageService getMassMessageService() { + return this.massMessageService; + } } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMassMessageAPITest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java similarity index 80% rename from weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMassMessageAPITest.java rename to weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java index dd7541ff8c..b896723ab0 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMassMessageAPITest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java @@ -1,9 +1,10 @@ -package me.chanjar.weixin.mp.api; +package me.chanjar.weixin.mp.api.impl; import com.google.inject.Inject; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.api.test.TestConfigStorage; import me.chanjar.weixin.mp.api.test.TestConstants; @@ -13,21 +14,21 @@ import me.chanjar.weixin.mp.bean.WxMpMassVideo; import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult; -import org.testng.*; import org.testng.annotations.*; import java.io.IOException; import java.io.InputStream; +import static org.testng.Assert.*; + /** * 测试群发消息 * * @author chanjarster */ -@Test(groups = "massAPI", dependsOnGroups = {"baseAPI", "mediaAPI", "groupAPI"}) +@Test @Guice(modules = ApiTestModule.class) -public class WxMpMassMessageAPITest { - +public class WxMpMassMessageServiceImplTest { @Inject protected WxMpService wxService; @@ -41,10 +42,10 @@ public void testTextMassOpenIdsMessageSend() throws WxErrorException { massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World"); massMessage.getToUsers().add(configProvider.getOpenid()); - WxMpMassSendResult massResult = this.wxService + WxMpMassSendResult massResult = this.wxService.getMassMessageService() .massOpenIdsMessageSend(massMessage); - Assert.assertNotNull(massResult); - Assert.assertNotNull(massResult.getMsgId()); + assertNotNull(massResult); + assertNotNull(massResult.getMsgId()); } @Test(dataProvider = "massMessages") @@ -57,10 +58,10 @@ public void testMediaMassOpenIdsMessageSend(String massMsgType, String mediaId) massMessage.setMediaId(mediaId); massMessage.getToUsers().add(configProvider.getOpenid()); - WxMpMassSendResult massResult = this.wxService + WxMpMassSendResult massResult = this.wxService.getMassMessageService() .massOpenIdsMessageSend(massMessage); - Assert.assertNotNull(massResult); - Assert.assertNotNull(massResult.getMsgId()); + assertNotNull(massResult); + assertNotNull(massResult.getMsgId()); } @Test @@ -71,10 +72,10 @@ public void testTextMassGroupMessageSend() throws WxErrorException { massMessage .setTagId(this.wxService.getUserTagService().tagGet().get(0).getId()); - WxMpMassSendResult massResult = this.wxService + WxMpMassSendResult massResult = this.wxService.getMassMessageService() .massGroupMessageSend(massMessage); - Assert.assertNotNull(massResult); - Assert.assertNotNull(massResult.getMsgId()); + assertNotNull(massResult); + assertNotNull(massResult.getMsgId()); } @Test(dataProvider = "massMessages") @@ -85,10 +86,10 @@ public void testMediaMassGroupMessageSend(String massMsgType, String mediaId) massMessage.setMediaId(mediaId); massMessage.setTagId(this.wxService.getUserTagService().tagGet().get(0).getId()); - WxMpMassSendResult massResult = this.wxService + WxMpMassSendResult massResult = this.wxService.getMassMessageService() .massGroupMessageSend(massMessage); - Assert.assertNotNull(massResult); - Assert.assertNotNull(massResult.getMsgId()); + assertNotNull(massResult); + assertNotNull(massResult.getMsgId()); } @DataProvider @@ -103,17 +104,17 @@ public Object[][] massMessages() throws WxErrorException, IOException { // 上传视频到媒体库 WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() .mediaUpload(WxConsts.MEDIA_VIDEO, TestConstants.FILE_MP4, inputStream); - Assert.assertNotNull(uploadMediaRes); - Assert.assertNotNull(uploadMediaRes.getMediaId()); + assertNotNull(uploadMediaRes); + assertNotNull(uploadMediaRes.getMediaId()); // 把视频变成可被群发的媒体 WxMpMassVideo video = new WxMpMassVideo(); video.setTitle("测试标题"); video.setDescription("测试描述"); video.setMediaId(uploadMediaRes.getMediaId()); - WxMpMassUploadResult uploadResult = this.wxService.massVideoUpload(video); - Assert.assertNotNull(uploadResult); - Assert.assertNotNull(uploadResult.getMediaId()); + WxMpMassUploadResult uploadResult = this.wxService.getMassMessageService().massVideoUpload(video); + assertNotNull(uploadResult); + assertNotNull(uploadResult.getMediaId()); messages[0] = new Object[]{WxConsts.MASS_MSG_VIDEO, uploadResult.getMediaId()}; } @@ -124,8 +125,8 @@ public Object[][] massMessages() throws WxErrorException, IOException { .getSystemResourceAsStream("mm.jpeg")) { WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() .mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, inputStream); - Assert.assertNotNull(uploadMediaRes); - Assert.assertNotNull(uploadMediaRes.getMediaId()); + assertNotNull(uploadMediaRes); + assertNotNull(uploadMediaRes.getMediaId()); messages[1] = new Object[]{WxConsts.MASS_MSG_IMAGE, uploadMediaRes.getMediaId()}; } @@ -136,8 +137,8 @@ public Object[][] massMessages() throws WxErrorException, IOException { .getSystemResourceAsStream("mm.mp3")) { WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() .mediaUpload(WxConsts.MEDIA_VOICE, TestConstants.FILE_MP3, inputStream); - Assert.assertNotNull(uploadMediaRes); - Assert.assertNotNull(uploadMediaRes.getMediaId()); + assertNotNull(uploadMediaRes); + assertNotNull(uploadMediaRes.getMediaId()); messages[2] = new Object[]{WxConsts.MASS_MSG_VOICE, uploadMediaRes.getMediaId()}; } @@ -149,8 +150,8 @@ public Object[][] massMessages() throws WxErrorException, IOException { // 上传照片到媒体库 WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() .mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, inputStream); - Assert.assertNotNull(uploadMediaRes); - Assert.assertNotNull(uploadMediaRes.getMediaId()); + assertNotNull(uploadMediaRes); + assertNotNull(uploadMediaRes.getMediaId()); // 上传图文消息 WxMpMassNews news = new WxMpMassNews(); @@ -170,10 +171,10 @@ public Object[][] massMessages() throws WxErrorException, IOException { article2.setDigest("摘要2"); news.addArticle(article2); - WxMpMassUploadResult massUploadResult = this.wxService + WxMpMassUploadResult massUploadResult = this.wxService.getMassMessageService() .massNewsUpload(news); - Assert.assertNotNull(massUploadResult); - Assert.assertNotNull(uploadMediaRes.getMediaId()); + assertNotNull(massUploadResult); + assertNotNull(uploadMediaRes.getMediaId()); messages[3] = new Object[]{WxConsts.MASS_MSG_NEWS, massUploadResult.getMediaId()}; } diff --git a/weixin-java-mp/src/test/resources/testng.xml b/weixin-java-mp/src/test/resources/testng.xml index d864635569..ea264e6717 100644 --- a/weixin-java-mp/src/test/resources/testng.xml +++ b/weixin-java-mp/src/test/resources/testng.xml @@ -5,7 +5,7 @@ - + From f0d3a1af73e747e2896b5e792171ff9605d2c7ab Mon Sep 17 00:00:00 2001 From: forfuns Date: Thu, 17 Aug 2017 15:33:45 +0800 Subject: [PATCH 067/165] =?UTF-8?q?#315=20=E4=BF=AE=E6=94=B9messageSend?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E8=87=AA=E5=8A=A8=E4=BB=8EwxCpConfi?= =?UTF-8?q?gStorage=E8=8E=B7=E5=8F=96agentId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/api/impl/WxCpServiceAbstractImpl.java | 4 ++++ .../java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java index a1f07e68cc..43c3415ef1 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java @@ -131,6 +131,10 @@ public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException @Override public WxCpMessageSendResult messageSend(WxCpMessage message) throws WxErrorException { String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send"; + Integer agentId = message.getAgentId(); + if(null == agentId){ + message.setAgentId(this.getWxCpConfigStorage().getAgentId()); + } return WxCpMessageSendResult.fromJson(this.post(url, message.toJson())); } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java index 1e0d40b05b..0cecc01588 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java @@ -20,7 +20,8 @@ public class WxCpMessageAPITest { @Inject - protected WxCpServiceImpl wxService; + protected WxCpService wxService; + private ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage; @BeforeTest @@ -30,7 +31,7 @@ public void setup() { public void testSendMessage() throws WxErrorException { WxCpMessage message = new WxCpMessage(); - message.setAgentId(configStorage.getAgentId()); +// message.setAgentId(configStorage.getAgentId()); message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); message.setToUser(configStorage.getUserId()); message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World"); @@ -43,10 +44,11 @@ public void testSendMessage() throws WxErrorException { System.out.println(messageSendResult.getInvalidTagList()); } + @Test public void testSendMessage1() throws WxErrorException { WxCpMessage message = WxCpMessage .TEXT() - .agentId(configStorage.getAgentId()) +// .agentId(configStorage.getAgentId()) .toUser(configStorage.getUserId()) .content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World") .build(); From bf1ce7ff168f63c60b0988c3879aa201999c8f43 Mon Sep 17 00:00:00 2001 From: forfuns Date: Fri, 18 Aug 2017 11:11:12 +0800 Subject: [PATCH 068/165] =?UTF-8?q?#317=20=E4=BF=AE=E5=A4=8D=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E8=AF=B7=E6=B1=82=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E6=97=B6=E5=AF=B9=E9=94=99=E8=AF=AF=E7=B1=BB=E5=9E=8B=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=EF=BC=88text/plain=20=E6=94=B9=E4=B8=BA=20app/json?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 更新messageSend自动向wxCpConfigStorage里获取agentId * 修复小程序请求二维码时对错误类型检查(text/plain 改为 app/json) * 修复小程序请求二维码时对错误类型检查(text/plain 改为 app/json) --- .../binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java index dc482dff25..3c026f4a18 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java @@ -48,7 +48,7 @@ public File execute(String uri, WxMaQrcodeWrapper ticket) throws WxErrorExceptio InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);) { Header[] contentTypeHeader = response.getHeaders("Content-Type"); if (contentTypeHeader != null && contentTypeHeader.length > 0 - && ContentType.TEXT_PLAIN.getMimeType().equals(contentTypeHeader[0].getValue())) { + && ContentType.APPLICATION_JSON.getMimeType().equals(contentTypeHeader[0].getValue())) { String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); throw new WxErrorException(WxError.fromJson(responseContent)); } From bc80845385db5df847499062007340e921d85e9f Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 22 Aug 2017 23:29:57 +0800 Subject: [PATCH 069/165] =?UTF-8?q?#318=20WxMpService=E5=92=8C=20WxCpServi?= =?UTF-8?q?ce=E4=B8=A4=E4=B8=AA=E6=8E=A5=E5=8F=A3=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=E5=AF=B9=E5=90=84=E4=B8=AA=E5=85=B7=E4=BD=93service=E7=9A=84se?= =?UTF-8?q?tter=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BB=A5=E4=BE=BF=E4=BA=8E?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/cp/api/WxCpService.java | 12 +++ .../cp/api/impl/WxCpServiceAbstractImpl.java | 30 ++++++++ .../me/chanjar/weixin/mp/api/WxMpService.java | 30 ++++++++ .../mp/api/impl/WxMpServiceAbstractImpl.java | 75 +++++++++++++++++++ 4 files changed, 147 insertions(+) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java index 880a92b06e..03df947dc2 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java @@ -458,4 +458,16 @@ WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream i * http请求对象 */ RequestHttp getRequestHttp(); + + void setUserService(WxCpUserService userService); + + void setDepartmentService(WxCpDepartmentService departmentService); + + void setMediaService(WxCpMediaService mediaService); + + void setMenuService(WxCpMenuService menuService); + + void setOauth2Service(WxCpOAuth2Service oauth2Service); + + void setTagService(WxCpTagService tagService); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java index 43c3415ef1..83bc5e13c6 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java @@ -544,4 +544,34 @@ public List departGet() throws WxErrorException { public RequestHttp getRequestHttp() { return this; } + + @Override + public void setUserService(WxCpUserService userService) { + this.userService = userService; + } + + @Override + public void setDepartmentService(WxCpDepartmentService departmentService) { + this.departmentService = departmentService; + } + + @Override + public void setMediaService(WxCpMediaService mediaService) { + this.mediaService = mediaService; + } + + @Override + public void setMenuService(WxCpMenuService menuService) { + this.menuService = menuService; + } + + @Override + public void setOauth2Service(WxCpOAuth2Service oauth2Service) { + this.oauth2Service = oauth2Service; + } + + @Override + public void setTagService(WxCpTagService tagService) { + this.tagService = tagService; + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java index f684f4e8a4..914c902d44 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java @@ -379,4 +379,34 @@ public interface WxMpService { * @return WxMpMassMessageService */ WxMpMassMessageService getMassMessageService(); + + void setKefuService(WxMpKefuService kefuService); + + void setMaterialService(WxMpMaterialService materialService); + + void setMenuService(WxMpMenuService menuService); + + void setUserService(WxMpUserService userService); + + void setTagService(WxMpUserTagService tagService); + + void setQrCodeService(WxMpQrcodeService qrCodeService); + + void setCardService(WxMpCardService cardService); + + void setStoreService(WxMpStoreService storeService); + + void setDataCubeService(WxMpDataCubeService dataCubeService); + + void setBlackListService(WxMpUserBlacklistService blackListService); + + void setTemplateMsgService(WxMpTemplateMsgService templateMsgService); + + void setDeviceService(WxMpDeviceService deviceService); + + void setShakeService(WxMpShakeService shakeService); + + void setMemberCardService(WxMpMemberCardService memberCardService); + + void setMassMessageService(WxMpMassMessageService massMessageService); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java index 91dff9babb..e4482d5aa7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java @@ -391,4 +391,79 @@ public RequestHttp getRequestHttp() { public WxMpMassMessageService getMassMessageService() { return this.massMessageService; } + + @Override + public void setKefuService(WxMpKefuService kefuService) { + this.kefuService = kefuService; + } + + @Override + public void setMaterialService(WxMpMaterialService materialService) { + this.materialService = materialService; + } + + @Override + public void setMenuService(WxMpMenuService menuService) { + this.menuService = menuService; + } + + @Override + public void setUserService(WxMpUserService userService) { + this.userService = userService; + } + + @Override + public void setTagService(WxMpUserTagService tagService) { + this.tagService = tagService; + } + + @Override + public void setQrCodeService(WxMpQrcodeService qrCodeService) { + this.qrCodeService = qrCodeService; + } + + @Override + public void setCardService(WxMpCardService cardService) { + this.cardService = cardService; + } + + @Override + public void setStoreService(WxMpStoreService storeService) { + this.storeService = storeService; + } + + @Override + public void setDataCubeService(WxMpDataCubeService dataCubeService) { + this.dataCubeService = dataCubeService; + } + + @Override + public void setBlackListService(WxMpUserBlacklistService blackListService) { + this.blackListService = blackListService; + } + + @Override + public void setTemplateMsgService(WxMpTemplateMsgService templateMsgService) { + this.templateMsgService = templateMsgService; + } + + @Override + public void setDeviceService(WxMpDeviceService deviceService) { + this.deviceService = deviceService; + } + + @Override + public void setShakeService(WxMpShakeService shakeService) { + this.shakeService = shakeService; + } + + @Override + public void setMemberCardService(WxMpMemberCardService memberCardService) { + this.memberCardService = memberCardService; + } + + @Override + public void setMassMessageService(WxMpMassMessageService massMessageService) { + this.massMessageService = massMessageService; + } } From 3bc9dbd7958debc4f7f497c74142ecef3a3deac3 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 22 Aug 2017 23:43:21 +0800 Subject: [PATCH 070/165] =?UTF-8?q?#312=20=E6=B7=BB=E5=8A=A0=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=BE=A4=E5=8F=91=20=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/WxMpMassMessageService.java | 24 +++++++++++++++++++ .../api/impl/WxMpMassMessageServiceImpl.java | 9 +++++++ .../impl/WxMpMassMessageServiceImplTest.java | 5 ++++ 3 files changed, 38 insertions(+) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java index e4a57de99b..6d1f025728 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java @@ -34,6 +34,10 @@ public interface WxMpMassMessageService { * 群发消息预览接口 */ String MESSAGE_MASS_PREVIEW_URL = "https://api.weixin.qq.com/cgi-bin/message/mass/preview"; + /** + * 删除群发接口 + */ + String MESSAGE_MASS_DELETE_URL = "https://api.weixin.qq.com/cgi-bin/message/mass/delete"; /** *
    @@ -92,4 +96,24 @@ public interface WxMpMassMessageService {
        */
       WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception;
     
    +  /**
    +   * 
    +   * 删除群发
    +   * 群发之后,随时可以通过该接口删除群发。
    +   * 请注意:
    +   * 1、只有已经发送成功的消息才能删除
    +   * 2、删除消息是将消息的图文详情页失效,已经收到的用户,还是能在其本地看到消息卡片。
    +   * 3、删除群发消息只能删除图文消息和视频消息,其他类型的消息一经发送,无法删除。
    +   * 4、如果多次群发发送的是一个图文消息,那么删除其中一次群发,就会删除掉这个图文消息也,导致所有群发都失效
    +   * 接口调用请求说明:
    +   *  http请求方式: POST
    +   *  https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=ACCESS_TOKEN
    +   * 详情请见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1481187827_i0l21
    +   * 
    + * + * @param msgId 发送出去的消息ID + * @param articleIndex 要删除的文章在图文消息中的位置,第一篇编号为1,该字段不填或填0会删除全部文章 + */ + void delete(Integer msgId, Integer articleIndex) throws Exception; + } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java index 015c465c0f..c54fcc768c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.api.impl; +import com.google.gson.JsonObject; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.WxMpMassMessageService; import me.chanjar.weixin.mp.api.WxMpService; @@ -55,4 +56,12 @@ public WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPrev return WxMpMassSendResult.fromJson(responseContent); } + @Override + public void delete(Integer msgId, Integer articleIndex) throws Exception { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("msg_id", msgId); + jsonObject.addProperty("article_idx", articleIndex); + this.wxMpService.post(MESSAGE_MASS_DELETE_URL, jsonObject.toString()); + } + } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java index b896723ab0..3b6c048981 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java @@ -181,4 +181,9 @@ public Object[][] massMessages() throws WxErrorException, IOException { return messages; } + @Test + public void testMassDelete() throws Exception { + this.wxService.getMassMessageService().delete(1,2); + } + } From e75ef7f3ceece81587fe2705201582bde59b0979 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 23 Aug 2017 00:02:16 +0800 Subject: [PATCH 071/165] =?UTF-8?q?#307=20=E5=BE=AE=E4=BF=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E6=A8=A1=E5=9D=97=E4=B8=AD=E5=A2=9E=E5=8A=A0http=20pr?= =?UTF-8?q?oxy=E8=AE=BE=E7=BD=AE=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binarywang/wxpay/config/WxPayConfig.java | 36 +++++++++++++++++++ .../impl/WxPayServiceApacheHttpImpl.java | 16 +++++++++ 2 files changed, 52 insertions(+) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java index b51f28e94a..d512cbe78e 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java @@ -39,6 +39,10 @@ public class WxPayConfig { private SSLContext sslContext; private String keyPath; private boolean useSandboxEnv = false; + private String httpProxyHost; + private Integer httpProxyPort; + private String httpProxyUsername; + private String httpProxyPassword; public String getKeyPath() { return keyPath; @@ -227,4 +231,36 @@ public int getHttpTimeout() { public void setHttpTimeout(int httpTimeout) { this.httpTimeout = httpTimeout; } + + public String getHttpProxyHost() { + return httpProxyHost; + } + + public void setHttpProxyHost(String httpProxyHost) { + this.httpProxyHost = httpProxyHost; + } + + public Integer getHttpProxyPort() { + return httpProxyPort; + } + + public void setHttpProxyPort(Integer httpProxyPort) { + this.httpProxyPort = httpProxyPort; + } + + public String getHttpProxyUsername() { + return httpProxyUsername; + } + + public void setHttpProxyUsername(String httpProxyUsername) { + this.httpProxyUsername = httpProxyUsername; + } + + public String getHttpProxyPassword() { + return httpProxyPassword; + } + + public void setHttpProxyPassword(String httpProxyPassword) { + this.httpProxyPassword = httpProxyPassword; + } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java index c5da982c13..09c414f437 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java @@ -1,12 +1,17 @@ package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.exception.WxPayException; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.DefaultHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; @@ -41,12 +46,23 @@ protected String post(String url, String requestStr, boolean useKey) throws WxPa } HttpPost httpPost = new HttpPost(url); + httpPost.setConfig(RequestConfig.custom() .setConnectionRequestTimeout(this.getConfig().getHttpConnectionTimeout()) .setConnectTimeout(this.getConfig().getHttpConnectionTimeout()) .setSocketTimeout(this.getConfig().getHttpTimeout()) .build()); + if (StringUtils.isNotBlank(this.config.getHttpProxyHost()) + && StringUtils.isNotBlank(this.config.getHttpProxyUsername())) { + // 使用代理服务器 需要用户认证的代理服务器 + CredentialsProvider provider = new BasicCredentialsProvider(); + provider.setCredentials( + new AuthScope(this.config.getHttpProxyHost(), this.config.getHttpProxyPort()), + new UsernamePasswordCredentials(this.config.getHttpProxyUsername(), this.config.getHttpProxyPassword())); + httpClientBuilder.setDefaultCredentialsProvider(provider); + } + try (CloseableHttpClient httpclient = httpClientBuilder.build()) { httpPost.setEntity(new StringEntity(new String(requestStr.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1))); try (CloseableHttpResponse response = httpclient.execute(httpPost)) { From ccebf2d06525f10609fd9f9d5f2ebecd1a0223c5 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 23 Aug 2017 21:35:23 +0800 Subject: [PATCH 072/165] =?UTF-8?q?#307=20=E5=BE=AE=E4=BF=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E6=A8=A1=E5=9D=97=E4=B8=AD=E5=A2=9E=E5=8A=A0http=20pr?= =?UTF-8?q?oxy=E8=AE=BE=E7=BD=AE=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WxPayServiceApacheHttpImpl.java | 2 +- .../service/impl/WxPayServiceJoddHttpImpl.java | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java index 09c414f437..14ef7c120a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java @@ -54,7 +54,7 @@ protected String post(String url, String requestStr, boolean useKey) throws WxPa .build()); if (StringUtils.isNotBlank(this.config.getHttpProxyHost()) - && StringUtils.isNotBlank(this.config.getHttpProxyUsername())) { + && this.config.getHttpProxyPort() > 0) { // 使用代理服务器 需要用户认证的代理服务器 CredentialsProvider provider = new BasicCredentialsProvider(); provider.setCredentials( diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java index 29008e26bd..7e7d31d91a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java @@ -1,9 +1,13 @@ package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.exception.WxPayException; +import jodd.http.HttpConnectionProvider; import jodd.http.HttpRequest; import jodd.http.HttpResponse; +import jodd.http.ProxyInfo; +import jodd.http.ProxyInfo.ProxyType; import jodd.http.net.SSLSocketHttpConnectionProvider; +import jodd.http.net.SocketHttpConnectionProvider; import org.apache.commons.lang3.StringUtils; import javax.net.ssl.SSLContext; @@ -31,7 +35,19 @@ protected String post(String url, String requestStr, boolean useKey) throws WxPa if (null == sslContext) { sslContext = this.getConfig().initSSLContext(); } - request.withConnectionProvider(new SSLSocketHttpConnectionProvider(sslContext)); + final SSLSocketHttpConnectionProvider provider = new SSLSocketHttpConnectionProvider(sslContext); + request.withConnectionProvider(provider); + } + + if (StringUtils.isNotBlank(this.config.getHttpProxyHost()) && this.config.getHttpProxyPort() > 0) { + ProxyInfo httpProxy = new ProxyInfo(ProxyType.HTTP, this.config.getHttpProxyHost(), this.config.getHttpProxyPort(), + this.config.getHttpProxyUsername(), this.config.getHttpProxyPassword()); + HttpConnectionProvider provider = request.connectionProvider(); + if (null == provider) { + provider = new SocketHttpConnectionProvider(); + } + provider.useProxy(httpProxy); + request.withConnectionProvider(provider); } String responseString = this.getResponseString(request.send()); From f5221c064c4da1bfe54d20b0a95009b901737dc0 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 23 Aug 2017 21:54:28 +0800 Subject: [PATCH 073/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.7.9.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 ++-- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index fd6312842c..a10e3adc99 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.7.8.BETA + 2.7.9.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM @@ -288,7 +288,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.7-SNAPSHOT + 1.6 sign-artifacts diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index bd7bb51cee..1b3be7dac3 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.8.BETA + 2.7.9.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 330a34b098..f035d15b7a 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.8.BETA + 2.7.9.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 11ab7d392e..3c4a36751d 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.8.BETA + 2.7.9.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index d8aa707aee..9f658a8fbf 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.8.BETA + 2.7.9.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 74704e6a87..a1f01be6e9 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.7.8.BETA + 2.7.9.BETA 4.0.0 From e7f507baa356be816d544347ff11f80b183dfbbb Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 24 Aug 2017 11:23:21 +0800 Subject: [PATCH 074/165] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=8A=BD=E5=8F=96=E9=83=A8=E5=88=86=E5=B8=B8?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/WxPayDownloadBillRequest.java | 12 +-- .../wxpay/constant/WxPayConstants.java | 87 +++++++++++++++++++ .../impl/WxPayServiceAbstractImpl.java | 37 ++++---- .../impl/WxPayServiceAbstractImplTest.java | 86 +++++++++--------- 4 files changed, 157 insertions(+), 65 deletions(-) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java index 2838284c80..33e410cdd8 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.bean.request; +import com.github.binarywang.wxpay.constant.WxPayConstants.BillType; import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; import me.chanjar.weixin.common.annotation.Required; @@ -17,7 +18,8 @@ */ @XStreamAlias("xml") public class WxPayDownloadBillRequest extends WxPayBaseRequest { - private static final String[] BILL_TYPE = new String[]{"ALL", "REFUND", "SUCCESS"}; + private static final String[] BILL_TYPES = new String[]{BillType.ALL, BillType.SUCCESS, BillType.REFUND, BillType.RECHARGE_REFUND}; + private static final String TAR_TYPE_GZIP = "GZIP"; /** *
    @@ -130,13 +132,13 @@ public void setTarType(String tarType) {
     
       @Override
       protected void checkConstraints() throws WxPayException {
    -    if (StringUtils.isNotBlank(this.getTarType()) && !"GZIP".equals(this.getTarType())) {
    +    if (StringUtils.isNotBlank(this.getTarType()) && !TAR_TYPE_GZIP.equals(this.getTarType())) {
           throw new WxPayException("tar_type值如果存在,只能为GZIP");
         }
     
    -    if (!ArrayUtils.contains(BILL_TYPE, this.getBillType())) {
    -      throw new WxPayException(String.format("bill_tpye目前必须为%s其中之一,实际值:%s",
    -        Arrays.toString(BILL_TYPE), this.getBillType()));
    +    if (!ArrayUtils.contains(BILL_TYPES, this.getBillType())) {
    +      throw new WxPayException(String.format("bill_type目前必须为%s其中之一,实际值:%s",
    +        Arrays.toString(BILL_TYPES), this.getBillType()));
         }
       }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
    new file mode 100644
    index 0000000000..dc8ce23b8e
    --- /dev/null
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
    @@ -0,0 +1,87 @@
    +package com.github.binarywang.wxpay.constant;
    +
    +/**
    + * 
    + * 微信支付常量类
    + * Created by Binary Wang on 2017-8-24.
    + * 
    + * + * @author Binary Wang + */ +public class WxPayConstants { + /** + * 校验用户姓名选项,企业付款时使用 + */ + public static class CheckNameOption { + /** + * 不校验真实姓名 + */ + public static final String NO_CHECK = "NO_CHECK"; + + /** + * 强校验真实姓名 + */ + public static final String FORCE_CHECK = "FORCE_CHECK"; + } + + /** + * 订单类型 + */ + public static class BillType { + /** + * 查询红包时使用:通过商户订单号获取红包信息 + */ + public static final String MCHT = "MCHT"; + + //以下为下载对账单时的账单类型 + /** + * 返回当日所有订单信息,默认值 + */ + public static final String ALL = "ALL"; + /** + * 返回当日成功支付的订单 + */ + public static final String SUCCESS = "SUCCESS"; + /** + * 返回当日退款订单 + */ + public static final String REFUND = "REFUND"; + /** + * 返回当日充值退款订单(相比其他对账单多一栏“返还手续费”) + */ + public static final String RECHARGE_REFUND = "RECHARGE_REFUND"; + } + + /** + * 交易类型 + */ + public static class TradeType { + /** + * 原生扫码支付 + */ + public static final String NATIVE = "NATIVE"; + + /** + * App支付 + */ + public static final String APP = "APP"; + + /** + * 公众号支付 + */ + public static final String JSAPI = "JSAPI"; + + /** + * 刷卡支付,刷卡支付有单独的支付接口,不调用统一下单接口 + */ + public static final String MICROPAY = "MICROPAY"; + } + + /** + * 签名类型 + */ + public static class SignType { + public static final String HMAC_SHA256 = "HMAC-SHA256"; + public static final String MD5 = "MD5"; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index 616f860988..357cad09ff 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -5,6 +5,9 @@ import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.config.WxPayConfig; +import com.github.binarywang.wxpay.constant.WxPayConstants.BillType; +import com.github.binarywang.wxpay.constant.WxPayConstants.SignType; +import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.util.SignUtils; @@ -129,7 +132,7 @@ public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throw public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayException { WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest(); request.setMchBillNo(mchBillNo); - request.setBillType("MCHT"); + request.setBillType(BillType.MCHT); request.checkAndSign(this.getConfig()); String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo"; @@ -199,35 +202,36 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W Map payInfo = new HashMap<>(); String timestamp = String.valueOf(System.currentTimeMillis() / 1000); String nonceStr = String.valueOf(System.currentTimeMillis()); - if ("NATIVE".equals(request.getTradeType())) { + if (TradeType.NATIVE.equals(request.getTradeType())) { payInfo.put("codeUrl", unifiedOrderResult.getCodeURL()); - } else if ("APP".equals(request.getTradeType())) { + } else if (TradeType.APP.equals(request.getTradeType())) { // APP支付绑定的是微信开放平台上的账号,APPID为开放平台上绑定APP后发放的参数 String appId = getConfig().getAppId(); Map configMap = new HashMap<>(); // 此map用于参与调起sdk支付的二次签名,格式全小写,timestamp只能是10位,格式固定,切勿修改 - String partnerid = getConfig().getMchId(); + String partnerId = getConfig().getMchId(); configMap.put("prepayid", prepayId); - configMap.put("partnerid", partnerid); - configMap.put("package", "Sign=WXPay"); + configMap.put("partnerid", partnerId); + String packageValue = "Sign=WXPay"; + configMap.put("package", packageValue); configMap.put("timestamp", timestamp); configMap.put("noncestr", nonceStr); configMap.put("appid", appId); // 此map用于客户端与微信服务器交互 payInfo.put("sign", SignUtils.createSign(configMap, this.getConfig().getMchKey())); payInfo.put("prepayId", prepayId); - payInfo.put("partnerId", partnerid); + payInfo.put("partnerId", partnerId); payInfo.put("appId", appId); - payInfo.put("packageValue", "Sign=WXPay"); + payInfo.put("packageValue", packageValue); payInfo.put("timeStamp", timestamp); payInfo.put("nonceStr", nonceStr); - } else if ("JSAPI".equals(request.getTradeType())) { + } else if (TradeType.JSAPI.equals(request.getTradeType())) { payInfo.put("appId", unifiedOrderResult.getAppid()); // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 payInfo.put("timeStamp", timestamp); payInfo.put("nonceStr", nonceStr); payInfo.put("package", "prepay_id=" + prepayId); - payInfo.put("signType", "MD5"); + payInfo.put("signType", SignType.MD5); payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey())); } @@ -278,7 +282,6 @@ public String createScanPayQrcodeMode1(String productId) { String sign = SignUtils.createSign(params, this.getConfig().getMchKey()); params.put("sign", sign); - for (String key : params.keySet()) { codeUrl.append(key + "=" + params.get(key) + "&"); } @@ -327,8 +330,7 @@ public WxPayBillResult downloadBill(String billDate, String billType, String tar result.checkResult(this); return null; } else { - WxPayBillResult wxPayBillResult = billInformationDeal(responseContent); - return wxPayBillResult; + return billInformationDeal(responseContent); } } @@ -346,10 +348,8 @@ private WxPayBillResult billInformationDeal(String responseContent) { * 交易时间:2017-04-06 01:00:02 公众账号ID: 商户号: 子商户号:0 设备号:WEB 微信订单号: 商户订单号:2017040519091071873216 用户标识: 交易类型:NATIVE * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00 * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60% + * 参考以上格式进行取值 */ - - // 参考以上格式进行取值 - List wxPayBillBaseResultLst = new LinkedList<>(); String newStr = listStr.replaceAll(",", " "); // 去空格 String[] tempStr = newStr.split("`"); // 数据分组 @@ -387,12 +387,11 @@ private WxPayBillResult billInformationDeal(String responseContent) { k += t.length; } wxPayBillResult.setWxPayBillBaseResultLst(wxPayBillBaseResultLst); + /* * 总交易单数,总交易额,总退款金额,总代金券或立减优惠退款金额,手续费总金额 `2,`0.02,`0.0,`0.0,`0 + * 参考以上格式进行取值 */ - - // 参考以上格式进行取值 - String totalStr = objStr.replaceAll(",", " "); String[] totalTempStr = totalStr.split("`"); wxPayBillResult.setTotalRecord(totalTempStr[1]); diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index 7ac35a6061..6d110a0ecd 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -4,6 +4,10 @@ import com.github.binarywang.wxpay.bean.coupon.*; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.constant.WxPayConstants.BillType; +import com.github.binarywang.wxpay.constant.WxPayConstants.SignType; +import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; @@ -33,23 +37,58 @@ public class WxPayServiceAbstractImplTest { @Inject private WxPayService payService; + /** + * Test method for {@link WxPayService#unifiedOrder(WxPayUnifiedOrderRequest)}. + */ + @Test + public void testUnifiedOrder() throws WxPayException { + WxPayUnifiedOrderResult result = this.payService + .unifiedOrder(WxPayUnifiedOrderRequest.newBuilder() + .body("我去") + .totalFee(1) + .spbillCreateIp("11.1.11.1") + .notifyURL("111111") + .tradeType(TradeType.JSAPI) + .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()) + .outTradeNo("1111112") + .build()); + this.logger.info(result.toString()); + } + @Test public void testGetPayInfo() throws Exception { Map payInfo = this.payService.getPayInfo(WxPayUnifiedOrderRequest.newBuilder() .body("我去") .totalFee(1) - .spbillCreateIp("111111") + .spbillCreateIp("1.11.1.11") .notifyURL("111111") - .tradeType("JSAPI") - .outTradeNo("111111") + .tradeType(TradeType.JSAPI) + .outTradeNo("1111113") .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()) .build()); this.logger.info(payInfo.toString()); } + /** + * Test method for {@link WxPayService#queryOrder(String, String)} . + */ + @Test + public void testQueryOrder() throws WxPayException { + this.logger.info(this.payService.queryOrder("11212121", null).toString()); + this.logger.info(this.payService.queryOrder(null, "11111").toString()); + } + + /** + * Test method for {@link WxPayService#closeOrder(String)} . + */ + @Test + public void testCloseOrder() throws WxPayException { + this.logger.info(this.payService.closeOrder("11212121").toString()); + } + @Test public void testDownloadBill() throws Exception { - WxPayBillResult wxPayBillResult = this.payService.downloadBill("20170101", "ALL", "GZIP", "1111111"); + WxPayBillResult wxPayBillResult = this.payService.downloadBill("20170101", BillType.ALL, "GZIP", "1111111"); //前一天没有账单记录返回null assertNotNull(wxPayBillResult); //必填字段为空时,抛出异常 @@ -60,7 +99,7 @@ public void testDownloadBill() throws Exception { public void testReport() throws Exception { WxPayReportRequest request = new WxPayReportRequest(); request.setInterfaceUrl("hahahah"); - request.setSignType("HMAC-SHA256");//貌似接口未校验此字段 + request.setSignType(SignType.HMAC_SHA256);//貌似接口未校验此字段 request.setExecuteTime(1000); request.setReturnCode("aaa"); request.setResultCode("aaa"); @@ -130,41 +169,6 @@ public void testQueryRedpack() throws Exception { this.logger.info(redpackResult.toString()); } - /** - * Test method for {@link WxPayService#unifiedOrder(WxPayUnifiedOrderRequest)}. - */ - @Test - public void testUnifiedOrder() throws WxPayException { - WxPayUnifiedOrderResult result = this.payService - .unifiedOrder(WxPayUnifiedOrderRequest.newBuilder() - .body("我去") - .totalFee(1) - .spbillCreateIp("11.1.11.1") - .notifyURL("111111") - .tradeType("JSAPI") - .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()) - .outTradeNo("111111") - .build()); - this.logger.info(result.toString()); - } - - /** - * Test method for {@link WxPayService#queryOrder(String, String)} . - */ - @Test - public void testQueryOrder() throws WxPayException { - this.logger.info(this.payService.queryOrder("11212121", null).toString()); - this.logger.info(this.payService.queryOrder(null, "11111").toString()); - } - - /** - * Test method for {@link WxPayService#closeOrder(String)} . - */ - @Test - public void testCloseOrder() throws WxPayException { - this.logger.info(this.payService.closeOrder("11212121").toString()); - } - /** * Test method for {@link WxPayService#entPay(WxEntPayRequest)}. */ @@ -175,7 +179,7 @@ public void testEntPay() throws WxPayException { .openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4") .amount(1) .spbillCreateIp("10.10.10.10") - .checkName("NO_CHECK") + .checkName(WxPayConstants.CheckNameOption.NO_CHECK) .description("描述信息") .build(); From 7d5d27527e71d616d0980497d25047a22a3ac735 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 24 Aug 2017 16:29:33 +0800 Subject: [PATCH 075/165] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E6=96=B9=E4=BE=BF=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binarywang/wxpay/config/WxPayConfig.java | 16 ++++++++-------- .../service/impl/WxPayServiceApacheHttpImpl.java | 8 ++++---- .../service/impl/WxPayServiceJoddHttpImpl.java | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java index d512cbe78e..7d8cd5e1e3 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java @@ -163,20 +163,20 @@ public void setUseSandboxEnv(boolean useSandboxEnv) { } public SSLContext initSSLContext() throws WxPayException { - if (StringUtils.isBlank(mchId)) { + if (StringUtils.isBlank(this.getMchId())) { throw new WxPayException("请确保商户号mchId已设置"); } - if (StringUtils.isBlank(this.keyPath)) { + if (StringUtils.isBlank(this.getKeyPath())) { throw new WxPayException("请确保证书文件地址keyPath已配置"); } InputStream inputStream; final String prefix = "classpath:"; - String fileHasProblemMsg = "证书文件【" + this.keyPath + "】有问题,请核实!"; - String fileNotFoundMsg = "证书文件【" + this.keyPath + "】不存在,请核实!"; - if (this.keyPath.startsWith(prefix)) { - String path = StringUtils.removeFirst(this.keyPath, prefix); + String fileHasProblemMsg = "证书文件【" + this.getKeyPath() + "】有问题,请核实!"; + String fileNotFoundMsg = "证书文件【" + this.getKeyPath() + "】不存在,请核实!"; + if (this.getKeyPath().startsWith(prefix)) { + String path = StringUtils.removeFirst(this.getKeyPath(), prefix); if (!path.startsWith("/")) { path = "/" + path; } @@ -186,7 +186,7 @@ public SSLContext initSSLContext() throws WxPayException { } } else { try { - File file = new File(this.keyPath); + File file = new File(this.getKeyPath()); if (!file.exists()) { throw new WxPayException(fileNotFoundMsg); } @@ -199,7 +199,7 @@ public SSLContext initSSLContext() throws WxPayException { try { KeyStore keystore = KeyStore.getInstance("PKCS12"); - char[] partnerId2charArray = mchId.toCharArray(); + char[] partnerId2charArray = this.getMchId().toCharArray(); keystore.load(inputStream, partnerId2charArray); this.sslContext = SSLContexts.custom().loadKeyMaterial(keystore, partnerId2charArray).build(); return this.sslContext; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java index 14ef7c120a..7d8dfcf7c4 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java @@ -53,13 +53,13 @@ protected String post(String url, String requestStr, boolean useKey) throws WxPa .setSocketTimeout(this.getConfig().getHttpTimeout()) .build()); - if (StringUtils.isNotBlank(this.config.getHttpProxyHost()) - && this.config.getHttpProxyPort() > 0) { + if (StringUtils.isNotBlank(this.getConfig().getHttpProxyHost()) + && this.getConfig().getHttpProxyPort() > 0) { // 使用代理服务器 需要用户认证的代理服务器 CredentialsProvider provider = new BasicCredentialsProvider(); provider.setCredentials( - new AuthScope(this.config.getHttpProxyHost(), this.config.getHttpProxyPort()), - new UsernamePasswordCredentials(this.config.getHttpProxyUsername(), this.config.getHttpProxyPassword())); + new AuthScope(this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort()), + new UsernamePasswordCredentials(this.getConfig().getHttpProxyUsername(), this.getConfig().getHttpProxyPassword())); httpClientBuilder.setDefaultCredentialsProvider(provider); } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java index 7e7d31d91a..553d858c04 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java @@ -26,8 +26,8 @@ protected String post(String url, String requestStr, boolean useKey) throws WxPa try { HttpRequest request = HttpRequest .post(url) - .timeout(this.config.getHttpTimeout()) - .connectionTimeout(this.config.getHttpConnectionTimeout()) + .timeout(this.getConfig().getHttpTimeout()) + .connectionTimeout(this.getConfig().getHttpConnectionTimeout()) .bodyText(requestStr); if (useKey) { @@ -39,9 +39,9 @@ protected String post(String url, String requestStr, boolean useKey) throws WxPa request.withConnectionProvider(provider); } - if (StringUtils.isNotBlank(this.config.getHttpProxyHost()) && this.config.getHttpProxyPort() > 0) { - ProxyInfo httpProxy = new ProxyInfo(ProxyType.HTTP, this.config.getHttpProxyHost(), this.config.getHttpProxyPort(), - this.config.getHttpProxyUsername(), this.config.getHttpProxyPassword()); + if (StringUtils.isNotBlank(this.getConfig().getHttpProxyHost()) && this.getConfig().getHttpProxyPort() > 0) { + ProxyInfo httpProxy = new ProxyInfo(ProxyType.HTTP, this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort(), + this.getConfig().getHttpProxyUsername(), this.getConfig().getHttpProxyPassword()); HttpConnectionProvider provider = request.connectionProvider(); if (null == provider) { provider = new SocketHttpConnectionProvider(); From 24fdf009770f16bea26213b202ca202483c93333 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 25 Aug 2017 15:08:30 +0800 Subject: [PATCH 076/165] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E5=BE=AE=E4=BF=A1=E7=9A=84?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=92=8C=E5=93=8D=E5=BA=94=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95getWxApiData()=EF=BC=8C=E6=96=B9?= =?UTF-8?q?=E4=BE=BF=E4=BD=BF=E7=94=A8=E8=80=85=E8=8E=B7=E5=8F=96=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E8=AF=A5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binarywang/wxpay/bean/WxPayApiData.java | 87 +++++++++++++++++++ .../wxpay/service/WxPayService.java | 6 ++ .../impl/WxPayServiceAbstractImpl.java | 13 +++ .../impl/WxPayServiceApacheHttpImpl.java | 9 +- .../impl/WxPayServiceJoddHttpImpl.java | 3 + .../impl/WxPayServiceAbstractImplTest.java | 1 + .../wxpay/testbase/ApiTestModule.java | 9 +- 7 files changed, 123 insertions(+), 5 deletions(-) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayApiData.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayApiData.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayApiData.java new file mode 100644 index 0000000000..ab1dec718c --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayApiData.java @@ -0,0 +1,87 @@ +package com.github.binarywang.wxpay.bean; + +/** + *
    + * 微信支付接口请求数据封装对象
    + * Created by Binary Wang on 2017-8-25.
    + * 
    + * + * @author Binary Wang + */ +public class WxPayApiData { + /** + * 接口请求地址 + */ + private String url; + + /** + * 请求数据 + */ + private String requestData; + + /** + * 响应数据 + */ + private String responseData; + + /** + * 接口请求异常信息 + */ + private String exceptionMsg; + + /** + * @param url 接口请求地址 + * @param requestData 请求数据 + * @param responseData 响应数据 + * @param exceptionMsg 接口请求异常信息 + */ + public WxPayApiData(String url, String requestData, String responseData, String exceptionMsg) { + this.url = url; + this.requestData = requestData; + this.responseData = responseData; + this.exceptionMsg = exceptionMsg; + } + + public String getUrl() { + return this.url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getRequestData() { + return this.requestData; + } + + public void setRequestData(String requestData) { + this.requestData = requestData; + } + + public String getResponseData() { + return this.responseData; + } + + public void setResponseData(String responseData) { + this.responseData = responseData; + } + + public String getExceptionMsg() { + return this.exceptionMsg; + } + + public void setExceptionMsg(String exceptionMsg) { + this.exceptionMsg = exceptionMsg; + } + + @Override + public String toString() { + if (this.exceptionMsg != null) { + return String.format("\n【请求地址】:%s\n【请求数据】:%s\n【异常信息】:%s", + this, url, this.requestData, this.exceptionMsg); + } + + return String.format("\n【请求地址】:%s\n【请求数据】:%s\n【响应数据】:%s", + this.url, this.requestData, this.responseData); + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java index 2eef29b85a..bf599ba175 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.service; +import com.github.binarywang.wxpay.bean.WxPayApiData; import com.github.binarywang.wxpay.bean.coupon.*; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; @@ -368,4 +369,9 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri *
    */ WxPayCouponInfoQueryResult queryCouponInfo(WxPayCouponInfoQueryRequest request) throws WxPayException; + + /** + * 获取微信请求数据,方便接口调用方获取处理 + */ + WxPayApiData getWxApiData(); } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index 357cad09ff..27d4d2dd6f 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -1,6 +1,7 @@ package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.utils.qrcode.QrcodeUtils; +import com.github.binarywang.wxpay.bean.WxPayApiData; import com.github.binarywang.wxpay.bean.coupon.*; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; @@ -33,6 +34,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com"; protected final Logger log = LoggerFactory.getLogger(this.getClass()); + protected static ThreadLocal wxApiData = new ThreadLocal<>(); protected WxPayConfig config; @@ -501,4 +503,15 @@ public WxPayCouponInfoQueryResult queryCouponInfo(WxPayCouponInfoQueryRequest re result.checkResult(this); return result; } + + @Override + public WxPayApiData getWxApiData() { + try { + return wxApiData.get(); + }finally { + //一般来说,接口请求会在一个线程内进行,这种情况下,每个线程get的会是之前所存入的数据, + // 但以防万一有同一线程多次请求的问题,所以每次获取完数据后移除对应数据 + wxApiData.remove(); + } + } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java index 7d8dfcf7c4..1b3284f95f 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.service.impl; +import com.github.binarywang.wxpay.bean.WxPayApiData; import com.github.binarywang.wxpay.exception.WxPayException; import org.apache.commons.lang3.StringUtils; import org.apache.http.auth.AuthScope; @@ -66,15 +67,17 @@ protected String post(String url, String requestStr, boolean useKey) throws WxPa try (CloseableHttpClient httpclient = httpClientBuilder.build()) { httpPost.setEntity(new StringEntity(new String(requestStr.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1))); try (CloseableHttpResponse response = httpclient.execute(httpPost)) { - String result = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); - this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, result); - return result; + String responseString = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); + this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, responseString); + wxApiData.set(new WxPayApiData(url, requestStr, responseString, null)); + return responseString; } } finally { httpPost.releaseConnection(); } } catch (Exception e) { this.log.error("\n【请求地址】:{}\n【请求数据】:{}\n【异常信息】:{}", url, requestStr, e.getMessage()); + wxApiData.set(new WxPayApiData(url, requestStr, null, e.getMessage())); throw new WxPayException(e.getMessage(), e); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java index 553d858c04..bbe024a309 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.service.impl; +import com.github.binarywang.wxpay.bean.WxPayApiData; import com.github.binarywang.wxpay.exception.WxPayException; import jodd.http.HttpConnectionProvider; import jodd.http.HttpRequest; @@ -53,9 +54,11 @@ protected String post(String url, String requestStr, boolean useKey) throws WxPa String responseString = this.getResponseString(request.send()); this.log.info("\n【请求地址】:{}\n【请求数据】:{}\n【响应数据】:{}", url, requestStr, responseString); + wxApiData.set(new WxPayApiData(url, requestStr, responseString, null)); return responseString; } catch (Exception e) { this.log.error("\n【请求地址】:{}\n【请求数据】:{}\n【异常信息】:{}", url, requestStr, e.getMessage()); + wxApiData.set(new WxPayApiData(url, requestStr, null, e.getMessage())); throw new WxPayException(e.getMessage(), e); } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index 6d110a0ecd..de0fe10e2c 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -53,6 +53,7 @@ public void testUnifiedOrder() throws WxPayException { .outTradeNo("1111112") .build()); this.logger.info(result.toString()); + this.logger.warn(this.payService.getWxApiData().toString()); } @Test diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/ApiTestModule.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/ApiTestModule.java index d5a028d1fb..207dc194f5 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/ApiTestModule.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/ApiTestModule.java @@ -12,11 +12,16 @@ import java.io.InputStream; public class ApiTestModule implements Module { + private static final String TEST_CONFIG_XML = "test-config.xml"; @Override public void configure(Binder binder) { - try (InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml")) { - XmlWxPayConfig config = this.fromXml(XmlWxPayConfig.class, is1); + try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) { + if (inputStream == null) { + throw new RuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到"); + } + + XmlWxPayConfig config = this.fromXml(XmlWxPayConfig.class, inputStream); WxPayService wxService = new WxPayServiceImpl(); wxService.setConfig(config); From a15d8d77fb996a88ce6359f12a3554f0877d6090 Mon Sep 17 00:00:00 2001 From: Nick Wong Date: Sat, 26 Aug 2017 20:11:30 +0800 Subject: [PATCH 077/165] =?UTF-8?q?#324:=20=E4=BF=AE=E5=A4=8D=E5=88=86?= =?UTF-8?q?=E5=B8=83=E5=BC=8F=E5=88=B7=E6=96=B0access=5Ftoken=E5=86=B2?= =?UTF-8?q?=E7=AA=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp/api/impl/WxMpServiceApacheHttpClientImpl.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceApacheHttpClientImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceApacheHttpClientImpl.java index ceb0b783e2..dd8aaf6114 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceApacheHttpClientImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceApacheHttpClientImpl.java @@ -65,12 +65,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { Lock lock = this.getWxMpConfigStorage().getAccessTokenLock(); try { lock.lock(); - - if (forceRefresh) { - this.getWxMpConfigStorage().expireAccessToken(); - } - - if (this.getWxMpConfigStorage().isAccessTokenExpired()) { + if (this.getWxMpConfigStorage().isAccessTokenExpired() || forceRefresh) { String url = String.format(WxMpService.GET_ACCESS_TOKEN_URL, this.getWxMpConfigStorage().getAppId(), this.getWxMpConfigStorage().getSecret()); try { From a6b29af33ada984b9b7a856e7a6d0d6fc3f7753f Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 26 Aug 2017 20:16:30 +0800 Subject: [PATCH 078/165] =?UTF-8?q?#324:=20=E4=BF=AE=E5=A4=8D=E5=88=86?= =?UTF-8?q?=E5=B8=83=E5=BC=8F=E5=88=B7=E6=96=B0access=5Ftoken=E5=86=B2?= =?UTF-8?q?=E7=AA=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java | 5 +---- .../chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java | 5 +---- .../chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java | 5 +---- .../cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java | 6 +----- .../chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java | 6 +----- .../chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java | 6 +----- 6 files changed, 6 insertions(+), 27 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java index fc6249662b..af32f5fb5d 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceApacheHttpClientImpl.java @@ -38,10 +38,7 @@ public HttpType getRequestType() { @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { - if (forceRefresh) { - this.configStorage.expireAccessToken(); - } - if (this.configStorage.isAccessTokenExpired()) { + if (this.configStorage.isAccessTokenExpired() || forceRefresh) { synchronized (this.globalAccessTokenRefreshLock) { if (this.configStorage.isAccessTokenExpired()) { String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?" diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java index 5a14eb27fe..3e7c4bc5b8 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceJoddHttpImpl.java @@ -29,10 +29,7 @@ public HttpType getRequestType() { @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { - if (forceRefresh) { - this.configStorage.expireAccessToken(); - } - if (this.configStorage.isAccessTokenExpired()) { + if (this.configStorage.isAccessTokenExpired() || forceRefresh) { synchronized (this.globalAccessTokenRefreshLock) { if (this.configStorage.isAccessTokenExpired()) { String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?" diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java index 2ad4c72015..f8476ff5af 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java @@ -37,10 +37,7 @@ public HttpType getRequestType() { @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { logger.debug("WxCpServiceOkHttpImpl is running"); - if (forceRefresh) { - this.configStorage.expireAccessToken(); - } - if (this.configStorage.isAccessTokenExpired()) { + if (this.configStorage.isAccessTokenExpired() || forceRefresh) { synchronized (this.globalAccessTokenRefreshLock) { if (this.configStorage.isAccessTokenExpired()) { String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?" diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java index 023306634b..106f020e53 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java @@ -87,11 +87,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { try { lock.lock(); - if (forceRefresh) { - this.getWxMaConfig().expireAccessToken(); - } - - if (this.getWxMaConfig().isAccessTokenExpired()) { + if (this.getWxMaConfig().isAccessTokenExpired() || forceRefresh) { String url = String.format(WxMaService.GET_ACCESS_TOKEN_URL, this.getWxMaConfig().getAppid(), this.getWxMaConfig().getSecret()); try { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java index 0551db67c6..f146c365e8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java @@ -51,11 +51,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { try { lock.lock(); - if (forceRefresh) { - this.getWxMpConfigStorage().expireAccessToken(); - } - - if (this.getWxMpConfigStorage().isAccessTokenExpired()) { + if (this.getWxMpConfigStorage().isAccessTokenExpired() || forceRefresh) { String url = String.format(WxMpService.GET_ACCESS_TOKEN_URL, this.getWxMpConfigStorage().getAppId(), this.getWxMpConfigStorage().getSecret()); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java index 9f2a17add1..9066dc8d17 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java @@ -43,11 +43,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { try { lock.lock(); - if (forceRefresh) { - this.getWxMpConfigStorage().expireAccessToken(); - } - - if (this.getWxMpConfigStorage().isAccessTokenExpired()) { + if (this.getWxMpConfigStorage().isAccessTokenExpired() || forceRefresh) { String url = String.format(WxMpService.GET_ACCESS_TOKEN_URL, this.getWxMpConfigStorage().getAppId(), this.getWxMpConfigStorage().getSecret()); From c12c176715a6e83de13f47754a96ef86cd3697e5 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 26 Aug 2017 21:01:28 +0800 Subject: [PATCH 079/165] =?UTF-8?q?#322=20=E4=B8=BAme.chanjar.weixin.mp.be?= =?UTF-8?q?an=E4=B8=8B=E7=9A=84bean=E7=B1=BB=E5=AE=9E=E7=8E=B0Serializable?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=B9=B6=E5=A2=9E=E5=8A=A0serialVer?= =?UTF-8?q?sionUID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/bean/WxMpCard.java | 5 +- .../chanjar/weixin/mp/bean/WxMpMassNews.java | 5 +- .../mp/bean/WxMpMassPreviewMessage.java | 1 + .../weixin/mp/bean/WxMpMassTagMessage.java | 2 +- .../chanjar/weixin/mp/bean/WxMpMassVideo.java | 5 +- .../weixin/mp/bean/WxMpSemanticQuery.java | 5 +- .../weixin/mp/bean/WxMpShakeInfoResult.java | 1 + .../weixin/mp/bean/WxMpShakeQuery.java | 4 +- .../chanjar/weixin/mp/bean/WxMpUserQuery.java | 16 +++--- .../datacube/WxDataCubeArticleResult.java | 3 +- .../bean/datacube/WxDataCubeArticleTotal.java | 3 +- .../WxDataCubeArticleTotalDetail.java | 5 +- .../bean/datacube/WxDataCubeBaseResult.java | 14 +++-- .../datacube/WxDataCubeInterfaceResult.java | 3 +- .../mp/bean/datacube/WxDataCubeMsgResult.java | 3 +- .../bean/datacube/WxDataCubeUserCumulate.java | 1 - .../mp/bean/device/AbstractDeviceBean.java | 6 ++- .../weixin/mp/bean/device/BaseResp.java | 2 + .../weixin/mp/bean/device/RespMsg.java | 2 + .../weixin/mp/bean/device/TransMsgResp.java | 2 + .../weixin/mp/bean/device/WxDevice.java | 6 ++- .../mp/bean/device/WxDeviceAuthorize.java | 2 + .../bean/device/WxDeviceAuthorizeResult.java | 2 + .../weixin/mp/bean/device/WxDeviceBind.java | 2 + .../bean/device/WxDeviceBindDeviceResult.java | 2 + .../mp/bean/device/WxDeviceBindResult.java | 2 + .../weixin/mp/bean/device/WxDeviceMsg.java | 2 + .../mp/bean/device/WxDeviceOpenIdResult.java | 2 + .../mp/bean/device/WxDeviceQrCodeResult.java | 2 + .../mp/bean/kefu/result/WxMpKfList.java | 5 +- .../mp/bean/kefu/result/WxMpKfMsgList.java | 5 +- .../mp/bean/kefu/result/WxMpKfMsgRecord.java | 6 ++- .../mp/bean/kefu/result/WxMpKfOnlineList.java | 5 +- .../mp/bean/kefu/result/WxMpKfSession.java | 6 ++- .../kefu/result/WxMpKfSessionGetResult.java | 6 ++- .../bean/kefu/result/WxMpKfSessionList.java | 5 +- .../result/WxMpKfSessionWaitCaseList.java | 5 +- .../bean/material/WxMediaImgUploadResult.java | 3 -- .../weixin/mp/bean/material/WxMpMaterial.java | 4 +- .../material/WxMpMaterialArticleUpdate.java | 5 +- .../material/WxMpMaterialCountResult.java | 1 + .../WxMpMaterialFileBatchGetResult.java | 1 + .../material/WxMpMaterialVideoInfoResult.java | 5 +- .../bean/membercard/MemberCardUserInfo.java | 5 +- .../weixin/mp/bean/membercard/NameValues.java | 6 ++- .../mp/bean/membercard/NotifyOptional.java | 19 +++++-- .../WxMpMemberCardActivatedMessage.java | 53 ++++++++++++++----- .../WxMpMemberCardUpdateMessage.java | 47 ++++++++++++---- .../WxMpMemberCardUpdateResult.java | 13 ++--- .../WxMpMemberCardUserInfoResult.java | 16 ++---- .../bean/menu/WxMpGetSelfMenuInfoResult.java | 6 ++- .../chanjar/weixin/mp/bean/menu/WxMpMenu.java | 4 +- .../weixin/mp/bean/menu/WxMpSelfMenuInfo.java | 5 +- .../weixin/mp/bean/message/HardWare.java | 6 ++- .../weixin/mp/bean/message/ScanCodeInfo.java | 7 ++- .../mp/bean/message/SendLocationInfo.java | 5 +- .../weixin/mp/bean/message/SendPicsInfo.java | 10 +++- .../mp/bean/message/WxMpXmlMessage.java | 1 - .../bean/message/WxMpXmlOutImageMessage.java | 5 +- .../mp/bean/message/WxMpXmlOutMessage.java | 1 - .../bean/message/WxMpXmlOutMusicMessage.java | 5 +- .../bean/message/WxMpXmlOutNewsMessage.java | 5 +- .../bean/message/WxMpXmlOutTextMessage.java | 5 +- .../WxMpXmlOutTransferKefuMessage.java | 5 +- .../bean/message/WxMpXmlOutVideoMessage.java | 10 ++-- .../bean/message/WxMpXmlOutVoiceMessage.java | 5 +- .../weixin/mp/bean/result/WxMpCardResult.java | 4 -- .../bean/result/WxMpCurrentAutoReplyInfo.java | 33 +++++++++--- .../mp/bean/result/WxMpMassSendResult.java | 1 + .../mp/bean/result/WxMpMassUploadResult.java | 8 ++- .../mp/bean/result/WxMpOAuth2AccessToken.java | 14 +---- .../mp/bean/result/WxMpQrCodeTicket.java | 5 +- .../bean/result/WxMpSemanticQueryResult.java | 5 +- .../weixin/mp/bean/result/WxMpUser.java | 2 +- .../result/WxMpUserBlacklistGetResult.java | 5 +- .../weixin/mp/bean/result/WxMpUserList.java | 4 +- .../mp/bean/store/WxMpStoreBaseInfo.java | 22 ++++++-- .../weixin/mp/bean/store/WxMpStoreInfo.java | 6 ++- .../mp/bean/store/WxMpStoreListResult.java | 9 +++- .../weixin/mp/bean/tag/WxTagListUser.java | 12 +++-- .../chanjar/weixin/mp/bean/tag/WxUserTag.java | 11 ++-- .../weixin/mp/bean/template/WxMpTemplate.java | 9 ++-- .../mp/bean/template/WxMpTemplateData.java | 2 +- .../bean/template/WxMpTemplateIndustry.java | 1 + .../mp/bean/template/WxMpTemplateMessage.java | 4 +- 85 files changed, 369 insertions(+), 204 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java index bc50ce059e..76fc4a6451 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java @@ -3,13 +3,16 @@ import me.chanjar.weixin.common.util.ToStringUtils; +import java.io.Serializable; + /** * 微信卡券 * * @author YuJian * @version 15/11/11 */ -public class WxMpCard { +public class WxMpCard implements Serializable{ + private static final long serialVersionUID = 9214301870017772921L; private String cardId; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java index dc1acd3bd3..bb19f0e79e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java @@ -13,11 +13,8 @@ * @author chanjarster */ public class WxMpMassNews implements Serializable { - - /** - * - */ private static final long serialVersionUID = 565937155013581016L; + private List articles = new ArrayList<>(); public List getArticles() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java index d70ac57071..503bdec43b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java @@ -9,6 +9,7 @@ */ public class WxMpMassPreviewMessage implements Serializable { private static final long serialVersionUID = 9095211638358424020L; + private String toWxUserName; private String toWxUserOpenid; private String msgType; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java index cdf14f79bd..acf9d0f4c1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java @@ -10,8 +10,8 @@ * @author chanjarster */ public class WxMpMassTagMessage implements Serializable { - private static final long serialVersionUID = -6625914040986749286L; + private Long tagId; private String msgType; private String content; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java index 38eef7c8a1..1683be5bdf 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java @@ -10,11 +10,8 @@ * @author chanjarster */ public class WxMpMassVideo implements Serializable { - - /** - * - */ private static final long serialVersionUID = 9153925016061915637L; + private String mediaId; private String title; private String description; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java index f4b1c3da00..8c18a6a9ea 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java @@ -12,11 +12,8 @@ * @author Daniel Qian */ public class WxMpSemanticQuery implements Serializable { - - /** - * - */ private static final long serialVersionUID = 7685873048199870690L; + private String query; private String category; private Float latitude; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java index ac94b457b0..5fb2ab1735 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java @@ -11,6 +11,7 @@ * @author rememberber */ public class WxMpShakeInfoResult implements Serializable { + private static final long serialVersionUID = -1604561297395395468L; private Integer errcode; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java index bb9d326fad..0f4aeadd19 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java @@ -2,6 +2,7 @@ import com.google.gson.Gson; +import java.io.Serializable; import java.util.HashMap; import java.util.Map; @@ -10,7 +11,8 @@ * * @author rememberber */ -public class WxMpShakeQuery { +public class WxMpShakeQuery implements Serializable { + private static final long serialVersionUID = 4316527352035275412L; private String ticket; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java index 800e03e915..243163c28b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java @@ -14,7 +14,9 @@ * * @author LiuJunGuang */ -public class WxMpUserQuery { +public class WxMpUserQuery implements Serializable { + private static final long serialVersionUID = -1344224837373149313L; + private List queryParamList = new ArrayList<>(); public WxMpUserQuery() { @@ -24,7 +26,7 @@ public WxMpUserQuery() { /** * 语言使用默认(zh_CN) * - * @param openids + * @param openids openid列表 */ public WxMpUserQuery(List openids) { super(); @@ -34,7 +36,7 @@ public WxMpUserQuery(List openids) { /** * 添加OpenId列表,语言使用默认(zh_CN) * - * @param openids + * @param openids openid列表 * @return {@link WxMpUserQuery} */ public WxMpUserQuery add(List openids) { @@ -47,7 +49,7 @@ public WxMpUserQuery add(List openids) { /** * 添加一个OpenId * - * @param openid + * @param openid openid * @param lang 国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语 * @return {@link WxMpUserQuery} */ @@ -63,7 +65,7 @@ public WxMpUserQuery add(String openid, String lang) { * 该方法默认lang = zh_CN *
    * - * @param openid + * @param openid openid * @return {@link WxMpUserQuery} */ public WxMpUserQuery add(String openid) { @@ -74,7 +76,7 @@ public WxMpUserQuery add(String openid) { /** * 删除指定的OpenId,语言使用默认(zh_CN) * - * @param openid + * @param openid openid * @return {@link WxMpUserQuery} */ public WxMpUserQuery remove(String openid) { @@ -85,7 +87,7 @@ public WxMpUserQuery remove(String openid) { /** * 删除指定的OpenId * - * @param openid + * @param openid openid * @param lang 国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语 * @return {@link WxMpUserQuery} */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java index fe6627d244..e6518064bb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java @@ -14,8 +14,7 @@ * Created by Binary Wang on 2016/8/24. */ public class WxDataCubeArticleResult extends WxDataCubeBaseResult { - - private static final JsonParser JSON_PARSER = new JsonParser(); + private static final long serialVersionUID = -9222452497954511765L; /** * ref_hour diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java index eee6240f7b..a059c45f3b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java @@ -14,8 +14,7 @@ * Created by Binary Wang on 2016/8/24. */ public class WxDataCubeArticleTotal extends WxDataCubeBaseResult { - - private static final JsonParser JSON_PARSER = new JsonParser(); + private static final long serialVersionUID = -7634365687303052699L; /** * msgid diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java index 27f9b8aa12..86897427d1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java @@ -2,13 +2,16 @@ import com.google.gson.annotations.SerializedName; +import java.io.Serializable; + /** * 获取图文群发总数据接口(getarticletotal)中的详细字段 * * @author binarywang(Binary Wang) * Created by Binary Wang on 2016/8/24. */ -public class WxDataCubeArticleTotalDetail { +public class WxDataCubeArticleTotalDetail implements Serializable{ + private static final long serialVersionUID = -5136169129771430052L; /** * stat_date diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java index 25fbcc62a9..cfc8636143 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java @@ -1,15 +1,23 @@ package me.chanjar.weixin.mp.bean.datacube; +import com.google.gson.JsonParser; import com.google.gson.annotations.SerializedName; import me.chanjar.weixin.common.util.ToStringUtils; +import java.io.Serializable; + /** - * 统计接口的共用属性类 + *
    + *  统计接口的共用属性类
    + *  Created by Binary Wang on 2016/8/25.
    + * 
    * * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016/8/25. */ -public class WxDataCubeBaseResult { +public abstract class WxDataCubeBaseResult implements Serializable { + private static final long serialVersionUID = 8780389911053297600L; + protected static final JsonParser JSON_PARSER = new JsonParser(); + /** * ref_date * 数据的日期,需在begin_date和end_date之间 diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java index 9606c6f98d..fce9fc2018 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java @@ -14,8 +14,7 @@ * Created by Binary Wang on 2016/8/30. */ public class WxDataCubeInterfaceResult extends WxDataCubeBaseResult { - - private static final JsonParser JSON_PARSER = new JsonParser(); + private static final long serialVersionUID = 597734329161281398L; /** * ref_hour diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java index b3592190dc..4800c9c422 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java @@ -14,8 +14,7 @@ * Created by Binary Wang on 2016/8/29. */ public class WxDataCubeMsgResult extends WxDataCubeBaseResult { - - private static final JsonParser JSON_PARSER = new JsonParser(); + private static final long serialVersionUID = 6932121822150573659L; /** * ref_hour diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserCumulate.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserCumulate.java index 32f8d5f5c0..d3237a3b6e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserCumulate.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserCumulate.java @@ -16,7 +16,6 @@ *
    */ public class WxDataCubeUserCumulate implements Serializable { - private static final JsonParser JSON_PARSER = new JsonParser(); private static final long serialVersionUID = -3570981300225093657L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java index 3a327069bc..4aef452270 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java @@ -2,10 +2,14 @@ import me.chanjar.weixin.common.util.json.WxGsonBuilder; +import java.io.Serializable; + /** * Created by keungtung on 14/12/2016. */ -public abstract class AbstractDeviceBean { +public abstract class AbstractDeviceBean implements Serializable{ + private static final long serialVersionUID = 4359729626772515385L; + public String toJson() { return WxGsonBuilder.create().toJson(this); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java index 4b6e52d85c..7d1fd8aa77 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java @@ -6,6 +6,8 @@ * Created by keungtung on 10/12/2016. */ public class BaseResp extends AbstractDeviceBean { + private static final long serialVersionUID = 4252655933699659073L; + @SerializedName("base_info") private BaseInfo baseInfo; @SerializedName("errcode") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java index 1932e1d166..9c62d36f93 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java @@ -7,6 +7,8 @@ */ public class RespMsg extends AbstractDeviceBean { + private static final long serialVersionUID = -4241272701707684136L; + @SerializedName("ret_code") private Integer retCode; @SerializedName("error_info") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java index 31525f6bad..1572da75ac 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java @@ -7,6 +7,8 @@ * Created by keungtung on 14/12/2016. */ public class TransMsgResp extends AbstractDeviceBean { + private static final long serialVersionUID = 5386954916622816491L; + private Integer ret; @SerializedName("ret_info") private String retInfo; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java index c0f95dbf2a..4527d368d2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java @@ -2,10 +2,14 @@ import com.google.gson.annotations.SerializedName; +import java.io.Serializable; + /** * Created by keungtung on 10/12/2016. */ -public class WxDevice { +public class WxDevice implements Serializable { + private static final long serialVersionUID = -3284819760735456195L; + private String id; private String mac; @SerializedName("connect_protocol") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java index 0318754e57..055e41c879 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java @@ -10,6 +10,8 @@ * Created by keungtung on 10/12/2016. */ public class WxDeviceAuthorize extends AbstractDeviceBean { + private static final long serialVersionUID = 8786321356569903887L; + @SerializedName("device_num") private String deviceNum; @SerializedName("op_type") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java index 83ea27c5b2..560f5498bb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java @@ -8,6 +8,8 @@ * Created by keungtung on 10/12/2016. */ public class WxDeviceAuthorizeResult extends AbstractDeviceBean { + private static final long serialVersionUID = 9105294570912249811L; + private List resp; public static WxDeviceAuthorizeResult fromJson(String response) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java index 1acf59628a..4945cfbbf2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java @@ -6,6 +6,8 @@ * Created by keungtung on 10/12/2016. */ public class WxDeviceBind extends AbstractDeviceBean { + private static final long serialVersionUID = 467559769037590880L; + private String ticket; @SerializedName("device_id") private String deviceId; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java index d0ed2dcd60..52c5f45609 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java @@ -9,6 +9,8 @@ * Created by keungtung on 16/12/2016. */ public class WxDeviceBindDeviceResult extends AbstractDeviceBean { + private static final long serialVersionUID = 725870295905935355L; + @SerializedName("resp_msg") private RespMsg respMsg; @SerializedName("openid") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java index 2cbf007835..c26e9c85d1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java @@ -7,6 +7,8 @@ * Created by keungtung on 10/12/2016. */ public class WxDeviceBindResult extends AbstractDeviceBean { + private static final long serialVersionUID = 4687725146279339359L; + @SerializedName("base_resp") private BaseResp baseResp; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java index 680209fd71..182cb27241 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java @@ -7,6 +7,8 @@ * Created by keungtung on 10/12/2016. */ public class WxDeviceMsg extends AbstractDeviceBean { + private static final long serialVersionUID = -5567110858455277963L; + @SerializedName("device_type") private String deviceType; @SerializedName("device_id") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java index 0a23eddd3a..a2ea56c080 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java @@ -9,6 +9,8 @@ * Created by keungtung on 16/12/2016. */ public class WxDeviceOpenIdResult extends AbstractDeviceBean { + private static final long serialVersionUID = 4980885167833836220L; + @SerializedName("errcode") private Integer errCode; @SerializedName("errmsg") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java index ff3028be4f..8d6efac90b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java @@ -7,6 +7,8 @@ * Created by keungtung on 10/12/2016. */ public class WxDeviceQrCodeResult extends AbstractDeviceBean { + private static final long serialVersionUID = -4312858303060918266L; + @SerializedName("deviceid") private String deviceId; @SerializedName("qrticket") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfList.java index b5cef947a9..5cce093dfc 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfList.java @@ -4,12 +4,15 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.List; /** * @author Binary Wang */ -public class WxMpKfList { +public class WxMpKfList implements Serializable { + private static final long serialVersionUID = -8194193505173564894L; + @SerializedName("kf_list") private List kfList; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java index 02d249192f..253652a883 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java @@ -4,12 +4,15 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.List; /** * Created by Binary Wang on 2016/7/15. */ -public class WxMpKfMsgList { +public class WxMpKfMsgList implements Serializable { + private static final long serialVersionUID = 4524296707435188202L; + @SerializedName("recordlist") private List records; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java index c7ada50081..1b32164879 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java @@ -3,10 +3,14 @@ import com.google.gson.annotations.SerializedName; import me.chanjar.weixin.common.util.ToStringUtils; +import java.io.Serializable; + /** * Created by Binary Wang on 2016/7/18. */ -public class WxMpKfMsgRecord { +public class WxMpKfMsgRecord implements Serializable { + private static final long serialVersionUID = -280692188908528688L; + /** * worker 完整客服帐号,格式为:帐号前缀@公众号微信号 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfOnlineList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfOnlineList.java index 1f7545cbfa..6778520c2b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfOnlineList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfOnlineList.java @@ -4,12 +4,15 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.List; /** * @author Binary Wang */ -public class WxMpKfOnlineList { +public class WxMpKfOnlineList implements Serializable { + private static final long serialVersionUID = -6154705288500854617L; + @SerializedName("kf_online_list") private List kfOnlineList; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSession.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSession.java index 500fc7577a..b36edb9f2d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSession.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSession.java @@ -3,10 +3,14 @@ import com.google.gson.annotations.SerializedName; import me.chanjar.weixin.common.util.ToStringUtils; +import java.io.Serializable; + /** * @author Binary Wang */ -public class WxMpKfSession { +public class WxMpKfSession implements Serializable { + private static final long serialVersionUID = 7804332813164994062L; + /** * kf_account 正在接待的客服,为空表示没有人在接待 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionGetResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionGetResult.java index b0177acdfd..d6ed763e9f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionGetResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionGetResult.java @@ -4,10 +4,14 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; + /** * @author Binary Wang */ -public class WxMpKfSessionGetResult { +public class WxMpKfSessionGetResult implements Serializable { + private static final long serialVersionUID = 8474846575200033152L; + /** * kf_account 正在接待的客服,为空表示没有人在接待 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionList.java index dd03668695..f1eb4dd7cb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionList.java @@ -4,12 +4,15 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.List; /** * @author Binary Wang */ -public class WxMpKfSessionList { +public class WxMpKfSessionList implements Serializable { + private static final long serialVersionUID = -7680371346226640206L; + /** * 会话列表 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java index 562113f191..7dd8def8cf 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java @@ -4,12 +4,15 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.List; /** * @author Binary Wang */ -public class WxMpKfSessionWaitCaseList { +public class WxMpKfSessionWaitCaseList implements Serializable { + private static final long serialVersionUID = 2432132626631361922L; + /** * count 未接入会话数量 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMediaImgUploadResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMediaImgUploadResult.java index 387a791ac6..1110a1f16b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMediaImgUploadResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMediaImgUploadResult.java @@ -8,9 +8,6 @@ * @author miller */ public class WxMediaImgUploadResult implements Serializable { - /** - * - */ private static final long serialVersionUID = 1996392453428768829L; private String url; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterial.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterial.java index 8725510a84..e176620f43 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterial.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterial.java @@ -1,10 +1,12 @@ package me.chanjar.weixin.mp.bean.material; import java.io.File; +import java.io.Serializable; import java.util.HashMap; import java.util.Map; -public class WxMpMaterial { +public class WxMpMaterial implements Serializable { + private static final long serialVersionUID = -1651816949780969485L; private String name; private File file; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialArticleUpdate.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialArticleUpdate.java index 371b7e0d30..f2f7aa1201 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialArticleUpdate.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialArticleUpdate.java @@ -5,11 +5,8 @@ import java.io.Serializable; public class WxMpMaterialArticleUpdate implements Serializable { - - /** - * - */ private static final long serialVersionUID = -7611963949517780270L; + private String mediaId; private int index; private WxMpMaterialNews.WxMpMaterialNewsArticle articles; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialCountResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialCountResult.java index 6dd74889ca..4a74b6b64b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialCountResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialCountResult.java @@ -6,6 +6,7 @@ public class WxMpMaterialCountResult implements Serializable { private static final long serialVersionUID = -5568772662085874138L; + private int voiceCount; private int videoCount; private int imageCount; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialFileBatchGetResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialFileBatchGetResult.java index 5df9f4546c..b08a0ce3c4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialFileBatchGetResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialFileBatchGetResult.java @@ -8,6 +8,7 @@ public class WxMpMaterialFileBatchGetResult implements Serializable { private static final long serialVersionUID = -560388368297267884L; + private int totalCount; private int itemCount; private List items; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialVideoInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialVideoInfoResult.java index be5dd3f844..e0558cc888 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialVideoInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialVideoInfoResult.java @@ -5,11 +5,8 @@ import java.io.Serializable; public class WxMpMaterialVideoInfoResult implements Serializable { - - /** - * - */ private static final long serialVersionUID = 1269131745333792202L; + private String title; private String description; private String downUrl; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java index 336008b085..b9c771c487 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java @@ -1,9 +1,12 @@ package me.chanjar.weixin.mp.bean.membercard; +import java.io.Serializable; + /** * Created by YuJian on 2017/7/11. */ -public class MemberCardUserInfo { +public class MemberCardUserInfo implements Serializable { + private static final long serialVersionUID = -4259196162619282129L; private NameValues[] commonFieldList; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java index ae30d7a9a4..a5c62e5e6a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java @@ -1,9 +1,13 @@ package me.chanjar.weixin.mp.bean.membercard; +import java.io.Serializable; + /** * Created by YuJian on 2017/7/11. */ -public class NameValues { +public class NameValues implements Serializable{ + private static final long serialVersionUID = -8529369702944594330L; + private String name; private String value; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java index a8adae8ac7..e44ec4b5ac 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java @@ -2,26 +2,37 @@ import com.google.gson.annotations.SerializedName; +import java.io.Serializable; + /** + *
      * 控制原生消息结构体,包含各字段的消息控制字段。
      *
      * 用于 `7 更新会员信息` 的接口参数调用
      * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283
    + * 
    * * @author YuJian(mgcnrx11@gmail.com) * @version 2017/7/15 */ -public class NotifyOptional { +public class NotifyOptional implements Serializable { + private static final long serialVersionUID = 4488842021504939176L; - // 积分变动时是否触发系统模板消息,默认为true + /** + * 积分变动时是否触发系统模板消息,默认为true + */ @SerializedName("is_notify_bonus") private Boolean isNotifyBonus; - // 余额变动时是否触发系统模板消息,默认为true + /** + * 余额变动时是否触发系统模板消息,默认为true + */ @SerializedName("is_notify_balance") private Boolean isNotifyBalance; - // 自定义group1变动时是否触发系统模板消息,默认为false。(2、3同理) + /** + * 自定义group1变动时是否触发系统模板消息,默认为false。(2、3同理) + */ @SerializedName("is_notify_custom_field1") private Boolean isNotifyCustomField1; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java index 8040224a09..0c782e3c51 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java @@ -2,47 +2,74 @@ import com.google.gson.annotations.SerializedName; +import java.io.Serializable; + /** * 会员卡激活接口的参数 * * @author YuJian(mgcnrx11@hotmail.com) * @version 2017/7/8 */ -public class WxMpMemberCardActivatedMessage { +public class WxMpMemberCardActivatedMessage implements Serializable { + private static final long serialVersionUID = -5972713484594266480L; - // 会员卡编号,由开发者填入,作为序列号显示在用户的卡包里。可与Code码保持等值。 + /** + * 会员卡编号,由开发者填入,作为序列号显示在用户的卡包里。可与Code码保持等值。 + */ @SerializedName("membership_number") private String membershipNumber; - // 领取会员卡用户获得的code + /** + * 领取会员卡用户获得的code + */ private String code; - // 卡券ID,自定义code卡券必填 + /** + * 卡券ID,自定义code卡券必填 + */ @SerializedName("card_id") private String cardId; - // 商家自定义会员卡背景图,须先调用上传图片接口将背景图上传至CDN,否则报错。卡面设计请遵循微信会员卡自定义背景设计规范 + /** + * 商家自定义会员卡背景图,须先调用上传图片接口将背景图上传至CDN,否则报错。卡面设计请遵循微信会员卡自定义背景设计规范 + */ @SerializedName("background_pic_url") private String backgroundPicUrl; - // 激活后的有效起始时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。 + /** + * 激活后的有效起始时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。 + */ @SerializedName("activate_begin_time") private Integer activateBeginTime; - // 激活后的有效截至时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。 + /** + * 激活后的有效截至时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。 + */ @SerializedName("activate_end_time") private Integer activateEndTime; - // 初始积分,不填为0。 + /** + * 初始积分,不填为0。 + */ @SerializedName("init_bonus") private Integer initBonus; - // 积分同步说明。 + /** + * 积分同步说明。 + */ @SerializedName("init_bonus_record") private String initBonusRecord; - // 初始余额,不填为0。 + /** + * 初始余额,不填为0。 + */ @SerializedName("init_balance") private Integer initBalance; - // 创建时字段custom_field1定义类型的初始值,限制为4个汉字,12字节。 + /** + * 创建时字段custom_field1定义类型的初始值,限制为4个汉字,12字节。 + */ @SerializedName("init_custom_field_value1") private String initCustomFieldValue1; - // 创建时字段custom_field2定义类型的初始值,限制为4个汉字,12字节。 + /** + * 创建时字段custom_field2定义类型的初始值,限制为4个汉字,12字节。 + */ @SerializedName("init_custom_field_value2") private String initCustomFieldValue2; - // 创建时字段custom_field3定义类型的初始值,限制为4个汉字,12字节。 + /** + * 创建时字段custom_field3定义类型的初始值,限制为4个汉字,12字节。 + */ @SerializedName("init_custom_field_value3") private String initCustomFieldValue3; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java index f4d410185d..313ba66282 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java @@ -2,44 +2,69 @@ import com.google.gson.annotations.SerializedName; +import java.io.Serializable; + /** + *
      * 更新会员信息所需字段消息。
      *
      * 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。同时传入add_bonus和bonus时
      * add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。
      * 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。
    + * 
    * * @author YuJian(mgcnrx11@gmail.com) * @version 2017/7/15 */ -public class WxMpMemberCardUpdateMessage { +public class WxMpMemberCardUpdateMessage implements Serializable { + private static final long serialVersionUID = 4953923160718911058L; - // 领取会员卡用户获得的code + /** + * 领取会员卡用户获得的code + */ private String code; - // 卡券ID,自定义code卡券必填 + /** + * 卡券ID,自定义code卡券必填 + */ @SerializedName("card_id") private String cardId; - // 支持商家激活时针对单个会员卡分配自定义的会员卡背景 + /** + * 支持商家激活时针对单个会员卡分配自定义的会员卡背景 + */ @SerializedName("background_pic_url") private String backgroundPicUrl; - // 需要设置的积分全量值,传入的数值会直接显示 + /** + * 需要设置的积分全量值,传入的数值会直接显示 + */ private Integer bonus; - // 本次积分变动值,传负数代表减少 + /** + * 本次积分变动值,传负数代表减少 + */ @SerializedName("add_bonus") private Integer addBounus; - // 商家自定义积分消耗记录,不超过14个汉字 + /** + * 商家自定义积分消耗记录,不超过14个汉字 + */ @SerializedName("record_bonus") private String recordBonus; - // 需要设置的余额全量值,传入的数值会直接显示在卡面 + /** + * 需要设置的余额全量值,传入的数值会直接显示在卡面 + */ private Integer balance; - // 本次余额变动值,传负数代表减少 + /** + * 本次余额变动值,传负数代表减少 + */ @SerializedName("add_balance") private Integer addBalance; - // 商家自定义金额消耗记录,不超过14个汉字。 + /** + * 商家自定义金额消耗记录,不超过14个汉字。 + */ @SerializedName("record_balance") private String recordBalance; - // 创建时字段custom_field定义类型的最新数值,限制为4个汉字,12字节。 + /** + * 创建时字段custom_field定义类型的最新数值,限制为4个汉字,12字节。 + */ @SerializedName("custom_field_value1") private String customFieldValue1; @SerializedName("custom_field_value2") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java index e615cb0721..2cbe2efb2f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java @@ -1,17 +1,20 @@ package me.chanjar.weixin.mp.bean.membercard; +import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; /** + *
      * 用于 `7 更新会员信息` 的接口调用后的返回结果
      * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283
    + * 
    * * @author YuJian(mgcnrx11@gmail.com) * @version 2017/7/15 */ -public class WxMpMemberCardUpdateResult implements Serializable { +public class WxMpMemberCardUpdateResult implements Serializable { private static final long serialVersionUID = 9084886191442098311L; @@ -67,13 +70,7 @@ public void setResultBalance(Integer resultBalance) { @Override public String toString() { - return "WxMpMemberCardUpdateResult{" + - "errorCode='" + errorCode + '\'' + - ", errorMsg='" + errorMsg + '\'' + - ", openId='" + openId + '\'' + - ", resultBonus=" + resultBonus + - ", resultBalance=" + resultBalance + - '}'; + return ToStringUtils.toSimpleString(this); } public static WxMpMemberCardUpdateResult fromJson(String json) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java index 1ddb57d34b..82a24cd297 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java @@ -1,13 +1,16 @@ package me.chanjar.weixin.mp.bean.membercard; +import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; /** + *
      * 拉取会员信息返回的结果
      *
      * 字段格式参考https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283  6.2.1小节的步骤5
    + * 
    * * @author YuJian * @version 2017/7/9 @@ -122,18 +125,7 @@ public void setHasActive(Boolean hasActive) { @Override public String toString() { - return "WxMpMemberCardUserInfoResult{" + - "errorCode='" + errorCode + '\'' + - ", errorMsg='" + errorMsg + '\'' + - ", openId='" + openId + '\'' + - ", nickname='" + nickname + '\'' + - ", membershipNumber='" + membershipNumber + '\'' + - ", bonus=" + bonus + - ", sex='" + sex + '\'' + - ", userInfo=" + userInfo + - ", userCardStatus='" + userCardStatus + '\'' + - ", hasActive=" + hasActive + - '}'; + return ToStringUtils.toSimpleString(this); } public static WxMpMemberCardUserInfoResult fromJson(String json) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java index b78d2dc378..295a782696 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java @@ -4,13 +4,17 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.json.WxGsonBuilder; +import java.io.Serializable; + /** *
      * Created by Binary Wang on 2016-11-25.
      * @author binarywang(Binary Wang)
      * 
    */ -public class WxMpGetSelfMenuInfoResult { +public class WxMpGetSelfMenuInfoResult implements Serializable { + private static final long serialVersionUID = -5612495636936835166L; + @SerializedName("selfmenu_info") private WxMpSelfMenuInfo selfMenuInfo; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java index 6c7d3e8650..5e93d7e0d6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java @@ -16,8 +16,7 @@ * @author binarywang(Binary Wang) *
    */ -public class WxMpMenu implements Serializable{ - +public class WxMpMenu implements Serializable { private static final long serialVersionUID = -5794350513426702252L; @SerializedName("menu") @@ -56,7 +55,6 @@ public String toJson() { } public static class WxMpConditionalMenu implements Serializable { - private static final long serialVersionUID = -2279946921755382289L; @SerializedName("button") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java index 699a41ecfb..c278bd4c1a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java @@ -3,6 +3,7 @@ import com.google.gson.annotations.SerializedName; import me.chanjar.weixin.common.util.ToStringUtils; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -12,7 +13,9 @@ * @author binarywang(Binary Wang) *
    */ -public class WxMpSelfMenuInfo { +public class WxMpSelfMenuInfo implements Serializable { + private static final long serialVersionUID = -81203094124202901L; + /** * 菜单按钮 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java index 32dfcd7e2f..1ef3ee6b7c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java @@ -5,6 +5,8 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; +import java.io.Serializable; + /** *
      *  Created by BinaryWang on 2017/5/4.
    @@ -13,7 +15,9 @@
      * @author Binary Wang
      */
     @XStreamAlias("HardWare")
    -public class HardWare {
    +public class HardWare implements Serializable{
    +  private static final long serialVersionUID = -1295785297354896461L;
    +
       /**
        * 消息展示,目前支持myrank(排行榜)
        */
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java
    index ddebffdf61..c5c32cb522 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java
    @@ -5,6 +5,8 @@
     import me.chanjar.weixin.common.util.ToStringUtils;
     import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
     
    +import java.io.Serializable;
    +
     /**
      * 
      *  Created by BinaryWang on 2017/5/4.
    @@ -13,7 +15,9 @@
      * @author Binary Wang
      */
     @XStreamAlias("ScanCodeInfo")
    -public class ScanCodeInfo {
    +public class ScanCodeInfo implements Serializable {
    +  private static final long serialVersionUID = 4745181270645050122L;
    +
       @XStreamAlias("ScanType")
       @XStreamConverter(value = XStreamCDataConverter.class)
       private String scanType;
    @@ -30,7 +34,6 @@ public String toString() {
        * 扫描类型,一般是qrcode
        */
       public String getScanType() {
    -
         return this.scanType;
       }
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java
    index a397ab8193..8ecb3c8bff 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java
    @@ -5,6 +5,8 @@
     import me.chanjar.weixin.common.util.ToStringUtils;
     import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
     
    +import java.io.Serializable;
    +
     /**
      * 
      *  Created by BinaryWang on 2017/5/4.
    @@ -13,7 +15,8 @@
      * @author Binary Wang
      */
     @XStreamAlias("SendLocationInfo")
    -public class SendLocationInfo {
    +public class SendLocationInfo implements Serializable {
    +  private static final long serialVersionUID = 6633214140499161130L;
     
       @XStreamAlias("Location_X")
       @XStreamConverter(value = XStreamCDataConverter.class)
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java
    index 3461355c9a..cf5c374edf 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java
    @@ -5,6 +5,7 @@
     import me.chanjar.weixin.common.util.ToStringUtils;
     import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
     
    +import java.io.Serializable;
     import java.util.ArrayList;
     import java.util.List;
     
    @@ -16,9 +17,12 @@
      * @author Binary Wang
      */
     @XStreamAlias("SendPicsInfo")
    -public class SendPicsInfo {
    +public class SendPicsInfo implements Serializable {
    +  private static final long serialVersionUID = -4572837013294199227L;
    +
       @XStreamAlias("PicList")
       protected final List picList = new ArrayList<>();
    +
       @XStreamAlias("Count")
       private Long count;
     
    @@ -40,7 +44,9 @@ public List getPicList() {
       }
     
       @XStreamAlias("item")
    -  public static class Item {
    +  public static class Item implements Serializable {
    +    private static final long serialVersionUID = 7706235740094081194L;
    +
         @XStreamAlias("PicMd5Sum")
         @XStreamConverter(value = XStreamCDataConverter.class)
         private String picMd5Sum;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java
    index 730310185c..2ea17b9e07 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java
    @@ -25,7 +25,6 @@
      */
     @XStreamAlias("xml")
     public class WxMpXmlMessage implements Serializable {
    -
       private static final long serialVersionUID = -3586245291677274914L;
     
       ///////////////////////
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java
    index f3a0740767..c18508b527 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java
    @@ -7,11 +7,8 @@
     
     @XStreamAlias("xml")
     public class WxMpXmlOutImageMessage extends WxMpXmlOutMessage {
    -
    -  /**
    -   *
    -   */
       private static final long serialVersionUID = -2684778597067990723L;
    +
       @XStreamAlias("Image")
       @XStreamConverter(value = XStreamMediaIdConverter.class)
       private String mediaId;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java
    index ad5d5bd5ca..c84cc665b9 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java
    @@ -12,7 +12,6 @@
     
     @XStreamAlias("xml")
     public abstract class WxMpXmlOutMessage implements Serializable {
    -
       private static final long serialVersionUID = -381382011286216263L;
     
       @XStreamAlias("ToUserName")
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java
    index c9bd003681..2676e69077 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java
    @@ -7,11 +7,8 @@
     
     @XStreamAlias("xml")
     public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage {
    -
    -  /**
    -   *
    -   */
       private static final long serialVersionUID = -4159937804975448945L;
    +
       @XStreamAlias("Music")
       protected final Music music = new Music();
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java
    index 8865a39358..797b042525 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java
    @@ -11,11 +11,8 @@
     
     @XStreamAlias("xml")
     public class WxMpXmlOutNewsMessage extends WxMpXmlOutMessage {
    -
    -  /**
    -   *
    -   */
       private static final long serialVersionUID = -4604402850905714772L;
    +
       @XStreamAlias("Articles")
       protected final List articles = new ArrayList<>();
       @XStreamAlias("ArticleCount")
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java
    index 877ed2605c..7c98c625e7 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java
    @@ -7,11 +7,8 @@
     
     @XStreamAlias("xml")
     public class WxMpXmlOutTextMessage extends WxMpXmlOutMessage {
    -
    -  /**
    -   *
    -   */
       private static final long serialVersionUID = -3972786455288763361L;
    +
       @XStreamAlias("Content")
       @XStreamConverter(value = XStreamCDataConverter.class)
       private String content;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java
    index 1c5f72d6d9..3a3cfc4b4c 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java
    @@ -5,6 +5,8 @@
     import me.chanjar.weixin.common.api.WxConsts;
     import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
     
    +import java.io.Serializable;
    +
     @XStreamAlias("xml")
     public class WxMpXmlOutTransferKefuMessage extends WxMpXmlOutMessage {
       private static final long serialVersionUID = 1850903037285841322L;
    @@ -25,7 +27,8 @@ public void setTransInfo(TransInfo transInfo) {
       }
     
       @XStreamAlias("TransInfo")
    -  public static class TransInfo {
    +  public static class TransInfo implements Serializable {
    +    private static final long serialVersionUID = -6317885617135706056L;
     
         @XStreamAlias("KfAccount")
         @XStreamConverter(value = XStreamCDataConverter.class)
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java
    index adf8849094..346cd5b160 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java
    @@ -5,13 +5,12 @@
     import me.chanjar.weixin.common.api.WxConsts;
     import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
     
    +import java.io.Serializable;
    +
     @XStreamAlias("xml")
     public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage {
    -
    -  /**
    -   *
    -   */
       private static final long serialVersionUID = 1745902309380113978L;
    +
       @XStreamAlias("Video")
       protected final Video video = new Video();
     
    @@ -45,7 +44,8 @@ public void setDescription(String description) {
     
     
       @XStreamAlias("Video")
    -  public static class Video {
    +  public static class Video implements Serializable {
    +    private static final long serialVersionUID = -6445448977569651183L;
     
         @XStreamAlias("MediaId")
         @XStreamConverter(value = XStreamCDataConverter.class)
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java
    index ec354ddfe1..a810e5a0f1 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java
    @@ -7,11 +7,8 @@
     
     @XStreamAlias("xml")
     public class WxMpXmlOutVoiceMessage extends WxMpXmlOutMessage {
    -
    -  /**
    -   *
    -   */
       private static final long serialVersionUID = 240367390249860551L;
    +
       @XStreamAlias("Voice")
       @XStreamConverter(value = XStreamMediaIdConverter.class)
       private String mediaId;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCardResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCardResult.java
    index b39d2fed29..5684557bea 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCardResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCardResult.java
    @@ -12,10 +12,6 @@
      * @version 15/11/11
      */
     public class WxMpCardResult implements Serializable {
    -
    -  /**
    -   *
    -   */
       private static final long serialVersionUID = -7950878428289035637L;
     
       private String errorCode;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java
    index 6738b8bc4a..563dc6aca8 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java
    @@ -7,6 +7,7 @@
     import me.chanjar.weixin.common.util.json.WxDateTypeAdapter;
     import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
     
    +import java.io.Serializable;
     import java.util.Date;
     import java.util.List;
     
    @@ -17,7 +18,9 @@
      * @author Binary Wang
      * 
    */ -public class WxMpCurrentAutoReplyInfo { +public class WxMpCurrentAutoReplyInfo implements Serializable { + private static final long serialVersionUID = 8294705001262751638L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -84,7 +87,9 @@ public void setKeywordAutoReplyInfo(KeywordAutoReplyInfo keywordAutoReplyInfo) { this.keywordAutoReplyInfo = keywordAutoReplyInfo; } - public static class AutoReplyRule { + public static class AutoReplyRule implements Serializable { + private static final long serialVersionUID = -6415971838145909046L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -147,7 +152,9 @@ public void setReplyListInfo(List replyListInfo) { } } - public static class ReplyInfo { + public static class ReplyInfo implements Serializable { + private static final long serialVersionUID = -3429575601599101690L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -184,7 +191,9 @@ public void setNewsInfo(NewsInfo newsInfo) { } } - public static class NewsInfo { + public static class NewsInfo implements Serializable { + private static final long serialVersionUID = 2958827725972593328L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -201,7 +210,9 @@ public void setList(List list) { } } - public static class NewsItem { + public static class NewsItem implements Serializable { + private static final long serialVersionUID = -680356309029767176L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -277,7 +288,9 @@ public void setTitle(String title) { } } - public static class KeywordInfo { + public static class KeywordInfo implements Serializable { + private static final long serialVersionUID = 7720246983986706379L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -313,7 +326,9 @@ public void setContent(String content) { } } - public static class KeywordAutoReplyInfo { + public static class KeywordAutoReplyInfo implements Serializable { + private static final long serialVersionUID = -8789197949404753083L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -330,7 +345,9 @@ public void setList(List list) { } } - public static class AutoReplyInfo { + public static class AutoReplyInfo implements Serializable { + private static final long serialVersionUID = 4993719555937843712L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassSendResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassSendResult.java index 9341fdfbf7..56cfd13d97 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassSendResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassSendResult.java @@ -18,6 +18,7 @@ */ public class WxMpMassSendResult implements Serializable { private static final long serialVersionUID = -4816336807575562818L; + private String errorCode; private String errorMsg; private String msgId; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassUploadResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassUploadResult.java index 9862c43cc7..f8ca889652 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassUploadResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassUploadResult.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.result; +import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -13,11 +14,8 @@ * @author chanjarster */ public class WxMpMassUploadResult implements Serializable { - - /** - * - */ private static final long serialVersionUID = 6568157943644994029L; + private String type; private String mediaId; private long createdAt; @@ -52,7 +50,7 @@ public void setCreatedAt(long createdAt) { @Override public String toString() { - return "WxUploadResult [type=" + this.type + ", media_id=" + this.mediaId + ", created_at=" + this.createdAt + "]"; + return ToStringUtils.toSimpleString(this); } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpOAuth2AccessToken.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpOAuth2AccessToken.java index b485710a9f..3f49397975 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpOAuth2AccessToken.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpOAuth2AccessToken.java @@ -1,14 +1,11 @@ package me.chanjar.weixin.mp.bean.result; +import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; public class WxMpOAuth2AccessToken implements Serializable { - - /** - * - */ private static final long serialVersionUID = -1345910558078620805L; private String accessToken; @@ -77,13 +74,6 @@ public void setUnionId(String unionId) { @Override public String toString() { - return "WxMpOAuth2AccessToken{" + - "accessToken='" + this.accessToken + '\'' + - ", expiresTime=" + this.expiresIn + - ", refreshToken='" + this.refreshToken + '\'' + - ", openId='" + this.openId + '\'' + - ", scope='" + this.scope + '\'' + - ", unionId='" + this.unionId + '\'' + - '}'; + return ToStringUtils.toSimpleString(this); } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpQrCodeTicket.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpQrCodeTicket.java index fc7d071332..7ba6151c3e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpQrCodeTicket.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpQrCodeTicket.java @@ -10,11 +10,8 @@ * @author chanjarster */ public class WxMpQrCodeTicket implements Serializable { - - /** - * - */ private static final long serialVersionUID = 5777119669111011584L; + protected String ticket; protected int expire_seconds = -1; protected String url; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpSemanticQueryResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpSemanticQueryResult.java index 8fd5442c9a..723ea7adc9 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpSemanticQueryResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpSemanticQueryResult.java @@ -12,11 +12,8 @@ * @author Daniel Qian */ public class WxMpSemanticQueryResult implements Serializable { - - /** - * - */ private static final long serialVersionUID = 4811088544804441365L; + private String query; private String type; private String semantic; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java index f2ba9268b6..e9e2bae6c1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java @@ -16,8 +16,8 @@ * @author chanjarster */ public class WxMpUser implements Serializable { - private static final long serialVersionUID = 5788154322646488738L; + private Boolean subscribe; private String openId; private String nickname; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserBlacklistGetResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserBlacklistGetResult.java index 3cfbc00915..5fe0a9448b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserBlacklistGetResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserBlacklistGetResult.java @@ -2,13 +2,16 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; /** * @author miller */ -public class WxMpUserBlacklistGetResult { +public class WxMpUserBlacklistGetResult implements Serializable { + private static final long serialVersionUID = -8780216463588687626L; + protected int total = -1; protected int count = -1; protected List openidList = new ArrayList<>(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserList.java index 2f630e5ba5..6e367aeca1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserList.java @@ -2,6 +2,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -10,7 +11,8 @@ * * @author chanjarster */ -public class WxMpUserList { +public class WxMpUserList implements Serializable { + private static final long serialVersionUID = 1389073042674901032L; protected long total = -1; protected int count = -1; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java index b385fbd0c4..155942a79b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java @@ -7,16 +7,21 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.math.BigDecimal; import java.util.List; /** - * 门店基础信息 + *
    + *  门店基础信息
    + *  Created by Binary Wang on 2016-09-23.
    + * 
    * * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016-09-23. */ -public class WxMpStoreBaseInfo { +public class WxMpStoreBaseInfo implements Serializable { + private static final long serialVersionUID = 829577606838118218L; + /** * sid * 商户自己的id,用于后续审核通过收到poi_id 的通知时,做对应关系。请商户自己保证唯一识别性 @@ -351,12 +356,21 @@ public void setPoiId(String poiId) { this.poiId = poiId; } - public static class WxMpStorePhoto { + public static class WxMpStorePhoto implements Serializable { + private static final long serialVersionUID = -2942447907614186861L; /** * 照片url */ @SerializedName("photo_url") private String photoUrl; + + public String getPhotoUrl() { + return photoUrl; + } + + public void setPhotoUrl(String photoUrl) { + this.photoUrl = photoUrl; + } } public static class WxMpStoreBaseInfoBuilder { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreInfo.java index 8f0b040191..fcbb9aa5ea 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreInfo.java @@ -3,7 +3,11 @@ import com.google.gson.annotations.SerializedName; import me.chanjar.weixin.common.util.ToStringUtils; -public class WxMpStoreInfo { +import java.io.Serializable; + +public class WxMpStoreInfo implements Serializable{ + private static final long serialVersionUID = 7300598931768355461L; + @SerializedName("base_info") private WxMpStoreBaseInfo baseInfo; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java index 3b2c2fc157..6ebb58901f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java @@ -4,15 +4,20 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.List; /** + *
      * 门店列表结果类
    + * Created by Binary Wang on 2016-09-27.
    + * 
    * * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016-09-27. */ -public class WxMpStoreListResult { +public class WxMpStoreListResult implements Serializable { + private static final long serialVersionUID = 5388907559949538663L; + /** * 错误码,0为正常 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java index 952b764c9c..a1bd50660e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java @@ -4,15 +4,19 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.List; /** + *
      * 获取标签下粉丝列表的结果对象
    + * Created by Binary Wang on 2016-09-19.
    + * 
    * * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016-09-19. */ -public class WxTagListUser { +public class WxTagListUser implements Serializable { + private static final long serialVersionUID = -4551768374200676112L; /** * "count":2,这次获取的粉丝数量 @@ -67,7 +71,9 @@ public void setNextOpenid(String nextOpenid) { this.nextOpenid = nextOpenid; } - public static class WxTagListUserData { + public static class WxTagListUserData implements Serializable { + private static final long serialVersionUID = -8584537400336245701L; + /** * openid 列表 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java index 59d2458fbc..a06a1ce40a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java @@ -5,15 +5,20 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.List; /** - * 用户标签对象 + *
    + *  用户标签对象
    + *  Created by Binary Wang on 2016/9/2.
    + * 
    * * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016/9/2. */ -public class WxUserTag { +public class WxUserTag implements Serializable { + private static final long serialVersionUID = -7722428695667031252L; + /** * id 标签id,由微信分配 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java index 38761f3d4e..079210775a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java @@ -6,18 +6,21 @@ import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import java.io.Serializable; import java.util.List; /** *
      * 模板列表信息
      * Created by Binary Wang on 2016-10-17.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author binarywang(Binary Wang) */ -public class WxMpTemplate { - +public class WxMpTemplate implements Serializable { private static final JsonParser JSON_PARSER = new JsonParser(); + private static final long serialVersionUID = -7366474522571199372L; + /** * template_id * 模板ID diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java index 0eb0eaa58d..f9d81e4028 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java @@ -6,8 +6,8 @@ * @author Daniel Qian */ public class WxMpTemplateData implements Serializable { - private static final long serialVersionUID = 6301835292940277870L; + private String name; private String value; private String color; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java index 63576fc2ce..b142c3f70f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java @@ -11,6 +11,7 @@ */ public class WxMpTemplateIndustry implements Serializable { private static final long serialVersionUID = -7700398224795914722L; + private Industry primaryIndustry; private Industry secondIndustry; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java index 70034a63b4..95d619a486 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java @@ -97,7 +97,9 @@ public String toJson() { return WxMpGsonBuilder.INSTANCE.create().toJson(this); } - public static class MiniProgram { + public static class MiniProgram implements Serializable { + private static final long serialVersionUID = -7945254706501974849L; + private String appid; private String pagePath; From 434703327bb7be5cd4d157ff701091b0affe61bd Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 1 Sep 2017 19:18:08 +0800 Subject: [PATCH 080/165] =?UTF-8?q?#319=20=E5=A2=9E=E5=8A=A0=E2=80=9C?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E7=BB=93=E6=9E=9C=E9=80=9A=E7=9F=A5=E2=80=9C?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=96=B9=E6=B3=95=EF=BC=8C=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=B0=83=E6=95=B4=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/crypto/WxCryptUtil.java | 15 +- .../WxPayNotifyResponse.java} | 15 +- .../{ => notify}/WxPayOrderNotifyCoupon.java | 2 +- .../WxPayOrderNotifyResult.java | 5 +- .../bean/notify/WxPayRefundNotifyResult.java | 372 ++++++++++++++++++ .../wxpay/bean/order/WxPayAppOrderResult.java | 145 +++++++ .../wxpay/bean/order/WxPayMpOrderResult.java | 133 +++++++ .../bean/order/WxPayNativeOrderResult.java | 48 +++ .../bean/result/WxPayUnifiedOrderResult.java | 2 +- .../wxpay/constant/WxPayConstants.java | 16 + .../WxPayOrderNotifyResultConverter.java | 4 +- .../wxpay/service/WxPayService.java | 25 +- .../impl/WxPayServiceAbstractImpl.java | 89 ++++- .../WxPayOrderNotifyResultTest.java | 3 +- .../notify/WxPayRefundNotifyResultTest.java | 70 ++++ .../impl/WxPayServiceAbstractImplTest.java | 6 + 16 files changed, 918 insertions(+), 32 deletions(-) rename weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/{WxPayOrderNotifyResponse.java => notify/WxPayNotifyResponse.java} (79%) rename weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/{ => notify}/WxPayOrderNotifyCoupon.java (96%) rename weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/{result => notify}/WxPayOrderNotifyResult.java (98%) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java rename weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/{result => notify}/WxPayOrderNotifyResultTest.java (95%) create mode 100644 weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResultTest.java diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java index e362e64b2f..c91e8ac089 100755 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/WxCryptUtil.java @@ -47,7 +47,6 @@ protected DocumentBuilder initialValue() { protected String appidOrCorpid; public WxCryptUtil() { - super(); } /** @@ -106,7 +105,7 @@ private static int bytesNetworkOrder2Number(byte[] bytesInNetworkOrder) { private static String genRandomStr() { String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; Random random = new Random(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < 16; i++) { int number = random.nextInt(base.length()); sb.append(base.charAt(number)); @@ -148,12 +147,11 @@ public String encrypt(String plainText) { String encryptedXml = encrypt(genRandomStr(), plainText); // 生成安全签名 - String timeStamp = Long.toString(System.currentTimeMillis() / 1000l); + String timeStamp = Long.toString(System.currentTimeMillis() / 1000L); String nonce = genRandomStr(); String signature = SHA1.gen(this.token, timeStamp, nonce, encryptedXml); - String result = generateXml(encryptedXml, signature, timeStamp, nonce); - return result; + return generateXml(encryptedXml, signature, timeStamp, nonce); } /** @@ -194,9 +192,7 @@ protected String encrypt(String randomStr, String plainText) { byte[] encrypted = cipher.doFinal(unencrypted); // 使用BASE64对加密后的字符串进行编码 - String base64Encrypted = base64.encodeToString(encrypted); - - return base64Encrypted; + return base64.encodeToString(encrypted); } catch (Exception e) { throw new RuntimeException(e); } @@ -228,8 +224,7 @@ public String decrypt(String msgSignature, String timeStamp, String nonce, Strin } // 解密 - String result = decrypt(cipherText); - return result; + return decrypt(cipherText); } /** diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayOrderNotifyResponse.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java similarity index 79% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayOrderNotifyResponse.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java index e369293195..e7a7ea9099 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayOrderNotifyResponse.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean; +package com.github.binarywang.wxpay.bean.notify; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.annotations.XStreamAlias; @@ -7,8 +7,11 @@ import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.common.util.xml.XStreamInitializer; +/** + * 微信支付订单和退款的异步通知共用的响应类 + */ @XStreamAlias("xml") -public class WxPayOrderNotifyResponse { +public class WxPayNotifyResponse { @XStreamOmitField private transient static final String FAIL = "FAIL"; @XStreamOmitField @@ -21,25 +24,25 @@ public class WxPayOrderNotifyResponse { @XStreamAlias("return_msg") private String returnMsg; - public WxPayOrderNotifyResponse() { + public WxPayNotifyResponse() { super(); } - public WxPayOrderNotifyResponse(String returnCode, String returnMsg) { + public WxPayNotifyResponse(String returnCode, String returnMsg) { super(); this.returnCode = returnCode; this.returnMsg = returnMsg; } public static String fail(String msg) { - WxPayOrderNotifyResponse response = new WxPayOrderNotifyResponse(FAIL, msg); + WxPayNotifyResponse response = new WxPayNotifyResponse(FAIL, msg); XStream xstream = XStreamInitializer.getInstance(); xstream.autodetectAnnotations(true); return xstream.toXML(response); } public static String success(String msg) { - WxPayOrderNotifyResponse response = new WxPayOrderNotifyResponse(SUCCESS, msg); + WxPayNotifyResponse response = new WxPayNotifyResponse(SUCCESS, msg); XStream xstream = XStreamInitializer.getInstance(); xstream.autodetectAnnotations(true); return xstream.toXML(response); diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayOrderNotifyCoupon.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java similarity index 96% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayOrderNotifyCoupon.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java index c2b4e22e74..cd948dfbac 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayOrderNotifyCoupon.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java @@ -1,4 +1,4 @@ -package com.github.binarywang.wxpay.bean; +package com.github.binarywang.wxpay.bean.notify; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java similarity index 98% rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java index a411cd2c70..54657ac6ae 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java @@ -1,6 +1,6 @@ -package com.github.binarywang.wxpay.bean.result; +package com.github.binarywang.wxpay.bean.notify; -import com.github.binarywang.wxpay.bean.WxPayOrderNotifyCoupon; +import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; import com.github.binarywang.wxpay.converter.WxPayOrderNotifyResultConverter; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.annotations.XStreamAlias; @@ -20,7 +20,6 @@ */ @XStreamAlias("xml") public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializable { - private static final long serialVersionUID = 5389718115223345496L; /** diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java new file mode 100644 index 0000000000..392c10144c --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java @@ -0,0 +1,372 @@ +package com.github.binarywang.wxpay.bean.notify; + +import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import me.chanjar.weixin.common.util.ToStringUtils; +import me.chanjar.weixin.common.util.xml.XStreamInitializer; +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.io.Serializable; +import java.math.BigInteger; +import java.security.MessageDigest; + +/** + *
    + *  退款结果通知对象
    + *  Created by BinaryWang on 2017/8/27.
    + * 
    + * + * @author Binary Wang + */ +@XStreamAlias("xml") +public class WxPayRefundNotifyResult extends WxPayBaseResult implements Serializable { + private static final long serialVersionUID = 4651725860079259186L; + + /** + * 从xml字符串创建bean对象 + * + * @param xmlString xml字符串 + * @param mchKey 商户密钥 + */ + public static WxPayRefundNotifyResult fromXML(String xmlString, String mchKey) throws WxPayException { + WxPayRefundNotifyResult result = WxPayBaseResult.fromXML(xmlString, WxPayRefundNotifyResult.class); + String reqInfoString = result.getReqInfoString(); + try { + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + + final MessageDigest md5 = MessageDigest.getInstance("MD5"); + md5.update(mchKey.getBytes()); + final String keyMd5String = new BigInteger(1, md5.digest()).toString(16).toLowerCase(); + SecretKeySpec key = new SecretKeySpec(keyMd5String.getBytes(), "AES"); + cipher.init(Cipher.DECRYPT_MODE, key); + result.setReqInfo(ReqInfo.fromXML(new String(cipher.doFinal(Base64.decodeBase64(reqInfoString))))); + } catch (Exception e) { + throw new WxPayException("解密退款通知加密信息时出错", e); + } + + return result; + } + + /** + *
    +   * 字段名:加密信息
    +   * 变量名:req_info
    +   * 是否必填:是
    +   * 类型:String(1024)
    +   * 描述:加密信息请用商户证书与商户秘钥进行解密
    +   * 
    + */ + @XStreamAlias("req_info") + private String reqInfoString; + + private ReqInfo reqInfo; + + /** + * 加密信息字段解密后的内容 + */ + @XStreamAlias("root") + public static class ReqInfo { + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + + /** + *
    +     * 字段名:微信订单号
    +     * 变量名:transaction_id
    +     * 是否必填:是
    +     * 类型:String(32)
    +     * 示例值:1217752501201407033233368018
    +     * 描述:微信订单号
    +     * 
    + */ + @XStreamAlias("transaction_id") + private String transactionId; + + /** + *
    +     * 字段名:商户订单号
    +     * 变量名:out_trade_no
    +     * 是否必填:是
    +     * 类型:String(32)
    +     * 示例值:1217752501201407033233368018
    +     * 描述:商户系统内部的订单号
    +     * 
    + */ + @XStreamAlias("out_trade_no") + private String outTradeNo; + + /** + *
    +     * 字段名:微信退款单号
    +     * 变量名:refund_id
    +     * 是否必填:是
    +     * 类型:String(28)
    +     * 示例值:1217752501201407033233368018
    +     * 描述:微信退款单号
    +     * 
    + */ + @XStreamAlias("refund_id") + private String refundId; + + /** + *
    +     * 字段名:商户退款单号
    +     * 变量名:out_refund_no
    +     * 是否必填:是
    +     * 类型:String(64)
    +     * 示例值:1217752501201407033233368018
    +     * 描述:商户退款单号
    +     * 
    + */ + @XStreamAlias("out_refund_no") + private String outRefundNo; + + /** + *
    +     * 字段名:订单金额
    +     * 变量名:total_fee
    +     * 是否必填:是
    +     * 类型:Int
    +     * 示例值:100
    +     * 描述:订单总金额,单位为分,只能为整数,详见支付金额
    +     * 
    + */ + @XStreamAlias("total_fee") + private Integer totalFee; + + /** + *
    +     * 字段名:结订单金额
    +     * 变量名:settlement_total_fee
    +     * 是否必填:否
    +     * 类型:Int
    +     * 示例值:100
    +     * 描述:当该订单有使用非充值券时,返回此字段。应结订单金额=订单金额-非充值代金券金额,应结订单金额<=订单金额。
    +     * 
    + */ + @XStreamAlias("settlement_total_fee") + private Integer settlementTotalFee; + + /** + *
    +     * 字段名:申请退款金额
    +     * 变量名:refund_fee
    +     * 是否必填:是
    +     * 类型:Int
    +     * 示例值:100
    +     * 描述:退款总金额,单位为分
    +     * 
    + */ + @XStreamAlias("refund_fee") + private Integer refundFee; + + /** + *
    +     * 字段名:退款金额
    +     * 变量名:settlement_refund_fee
    +     * 是否必填:是
    +     * 类型:Int
    +     * 示例值:100
    +     * 描述:退款金额=申请退款金额-非充值代金券退款金额,退款金额<=申请退款金额
    +     * 
    + */ + @XStreamAlias("settlement_refund_fee") + private Integer settlementRefundFee; + + /** + *
    +     * 字段名:退款状态
    +     * 变量名:refund_status
    +     * 是否必填:是
    +     * 类型:String(16)
    +     * 示例值:SUCCESS
    +     * 描述:SUCCESS-退款成功,CHANGE-退款异常,REFUNDCLOSE—退款关闭
    +     * 
    + */ + @XStreamAlias("refund_status") + private String refundStatus; + + /** + *
    +     * 字段名:退款成功时间
    +     * 变量名:success_time
    +     * 是否必填:否
    +     * 类型: String(20)
    +     * 示例值:20160725152626
    +     * 描述:-
    +     */
    +    @XStreamAlias("success_time")
    +    private String successTime;
    +
    +    /**
    +     * 
    +     * 字段名:退款入账账户
    +     * 变量名:refund_recv_accout
    +     * 是否必填:是
    +     * 类型:String(64)
    +     * 示例值:招商银行信用卡0403
    +     * 描述:取当前退款单的退款入账方,1)退回银行卡:{银行名称}{卡类型}{卡尾号},2)退回支付用户零钱:支付用户零钱 ,3)退还商户: 商户基本账户,商户结算银行账户,4)退回支付用户零钱通: 支付用户零钱通
    +     * 
    + */ + @XStreamAlias("refund_recv_accout") + private String refundRecvAccout; + + /** + *
    +     * 字段名:退款资金来源
    +     * 变量名:refund_account
    +     * 是否必填:是
    +     * 类型:String(30)
    +     * 示例值:REFUND_SOURCE_RECHARGE_FUNDS
    +     * 描述:REFUND_SOURCE_RECHARGE_FUNDS 可用余额退款/基本账户,REFUND_SOURCE_UNSETTLED_FUNDS 未结算资金退款
    +     * 
    + */ + @XStreamAlias("refund_account") + private String refundAccount; + + /** + *
    +     * 字段名:退款发起来源
    +     * 变量名:refund_request_source
    +     * 是否必填:是
    +     * 类型:String(30)
    +     * 示例值:API
    +     * 描述:API接口,VENDOR_PLATFORM商户平台
    +     * 
    + */ + @XStreamAlias("refund_request_source") + private String refundRequestSource; + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public String getOutTradeNo() { + return outTradeNo; + } + + public void setOutTradeNo(String outTradeNo) { + this.outTradeNo = outTradeNo; + } + + public String getRefundId() { + return refundId; + } + + public void setRefundId(String refundId) { + this.refundId = refundId; + } + + public String getOutRefundNo() { + return outRefundNo; + } + + public void setOutRefundNo(String outRefundNo) { + this.outRefundNo = outRefundNo; + } + + public Integer getTotalFee() { + return totalFee; + } + + public void setTotalFee(Integer totalFee) { + this.totalFee = totalFee; + } + + public Integer getSettlementTotalFee() { + return settlementTotalFee; + } + + public void setSettlementTotalFee(Integer settlementTotalFee) { + this.settlementTotalFee = settlementTotalFee; + } + + public Integer getRefundFee() { + return refundFee; + } + + public void setRefundFee(Integer refundFee) { + this.refundFee = refundFee; + } + + public Integer getSettlementRefundFee() { + return settlementRefundFee; + } + + public void setSettlementRefundFee(Integer settlementRefundFee) { + this.settlementRefundFee = settlementRefundFee; + } + + public String getRefundStatus() { + return refundStatus; + } + + public void setRefundStatus(String refundStatus) { + this.refundStatus = refundStatus; + } + + public String getSuccessTime() { + return successTime; + } + + public void setSuccessTime(String successTime) { + this.successTime = successTime; + } + + public String getRefundRecvAccout() { + return refundRecvAccout; + } + + public void setRefundRecvAccout(String refundRecvAccout) { + this.refundRecvAccout = refundRecvAccout; + } + + public String getRefundAccount() { + return refundAccount; + } + + public void setRefundAccount(String refundAccount) { + this.refundAccount = refundAccount; + } + + public String getRefundRequestSource() { + return refundRequestSource; + } + + public void setRefundRequestSource(String refundRequestSource) { + this.refundRequestSource = refundRequestSource; + } + + public static ReqInfo fromXML(String xmlString) { + XStream xstream = XStreamInitializer.getInstance(); + xstream.processAnnotations(ReqInfo.class); + return (ReqInfo) xstream.fromXML(xmlString); + } + } + + public String getReqInfoString() { + return reqInfoString; + } + + public void setReqInfoString(String reqInfoString) { + this.reqInfoString = reqInfoString; + } + + public ReqInfo getReqInfo() { + return reqInfo; + } + + public void setReqInfo(ReqInfo reqInfo) { + this.reqInfo = reqInfo; + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java new file mode 100644 index 0000000000..6688d602c9 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java @@ -0,0 +1,145 @@ +package com.github.binarywang.wxpay.bean.order; + +/** + *
    + * APP支付调用统一下单接口后的组装所需参数的实现类
    + * 参考 https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_12
    + * Created by Binary Wang on 2017-9-1.
    + * 
    + * + * @author Binary Wang + */ +public class WxPayAppOrderResult { + private String sign; + private String prepayId; + private String partnerId; + private String appId; + private String packageValue; + private String timeStamp; + private String nonceStr; + + public WxPayAppOrderResult() { + } + + private WxPayAppOrderResult(Builder builder) { + setSign(builder.sign); + setPrepayId(builder.prepayId); + setPartnerId(builder.partnerId); + setAppId(builder.appId); + setPackageValue(builder.packageValue); + setTimeStamp(builder.timeStamp); + setNonceStr(builder.nonceStr); + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getSign() { + return this.sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public String getPrepayId() { + return this.prepayId; + } + + public void setPrepayId(String prepayId) { + this.prepayId = prepayId; + } + + public String getPartnerId() { + return this.partnerId; + } + + public void setPartnerId(String partnerId) { + this.partnerId = partnerId; + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getPackageValue() { + return this.packageValue; + } + + public void setPackageValue(String packageValue) { + this.packageValue = packageValue; + } + + public String getTimeStamp() { + return this.timeStamp; + } + + public void setTimeStamp(String timeStamp) { + this.timeStamp = timeStamp; + } + + public String getNonceStr() { + return this.nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public static final class Builder { + private String sign; + private String prepayId; + private String partnerId; + private String appId; + private String packageValue; + private String timeStamp; + private String nonceStr; + + private Builder() { + } + + public Builder sign(String sign) { + this.sign = sign; + return this; + } + + public Builder prepayId(String prepayId) { + this.prepayId = prepayId; + return this; + } + + public Builder partnerId(String partnerId) { + this.partnerId = partnerId; + return this; + } + + public Builder appId(String appId) { + this.appId = appId; + return this; + } + + public Builder packageValue(String packageValue) { + this.packageValue = packageValue; + return this; + } + + public Builder timeStamp(String timeStamp) { + this.timeStamp = timeStamp; + return this; + } + + public Builder nonceStr(String nonceStr) { + this.nonceStr = nonceStr; + return this; + } + + public WxPayAppOrderResult build() { + return new WxPayAppOrderResult(this); + } + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java new file mode 100644 index 0000000000..d1ebdee051 --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java @@ -0,0 +1,133 @@ +package com.github.binarywang.wxpay.bean.order; + +/** + *
    + * 微信公众号支付进行统一下单后组装所需参数的类
    + * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7&index=6
    + * Created by Binary Wang on 2017-9-1.
    + * 
    + * + * @author Binary Wang + */ +public class WxPayMpOrderResult { + private String appId; + private String timeStamp; + private String nonceStr; + /** + * 由于package为java保留关键字,因此改为packageValue + */ + private String packageValue; + private String signType; + private String paySign; + + private WxPayMpOrderResult(Builder builder) { + setAppId(builder.appId); + setTimeStamp(builder.timeStamp); + setNonceStr(builder.nonceStr); + setPackageValue(builder.packageValue); + setSignType(builder.signType); + setPaySign(builder.paySign); + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getAppId() { + return this.appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getTimeStamp() { + return this.timeStamp; + } + + public void setTimeStamp(String timeStamp) { + this.timeStamp = timeStamp; + } + + public String getNonceStr() { + return this.nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getPackageValue() { + return this.packageValue; + } + + public void setPackageValue(String packageValue) { + this.packageValue = packageValue; + } + + public String getSignType() { + return this.signType; + } + + public void setSignType(String signType) { + this.signType = signType; + } + + public String getPaySign() { + return this.paySign; + } + + public void setPaySign(String paySign) { + this.paySign = paySign; + } + + public WxPayMpOrderResult() { + } + + + public static final class Builder { + private String appId; + private String timeStamp; + private String nonceStr; + private String packageValue; + private String signType; + private String paySign; + + private Builder() { + } + + public Builder appId(String appId) { + this.appId = appId; + return this; + } + + public Builder timeStamp(String timeStamp) { + this.timeStamp = timeStamp; + return this; + } + + public Builder nonceStr(String nonceStr) { + this.nonceStr = nonceStr; + return this; + } + + public Builder packageValue(String packageValue) { + this.packageValue = packageValue; + return this; + } + + public Builder signType(String signType) { + this.signType = signType; + return this; + } + + public Builder paySign(String paySign) { + this.paySign = paySign; + return this; + } + + public WxPayMpOrderResult build() { + return new WxPayMpOrderResult(this); + } + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java new file mode 100644 index 0000000000..3eb0e3748a --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java @@ -0,0 +1,48 @@ +package com.github.binarywang.wxpay.bean.order; + +/** + *
    + * 微信扫码支付统一下单后发起支付拼接所需参数实现类
    + * Created by Binary Wang on 2017-9-1.
    + * 
    + * + * @author Binary Wang + */ +public class WxPayNativeOrderResult { + private String codeUrl; + + private WxPayNativeOrderResult(Builder builder) { + setCodeUrl(builder.codeUrl); + } + + public static Builder newBuilder() { + return new Builder(); + } + + public String getCodeUrl() { + return this.codeUrl; + } + + public void setCodeUrl(String codeUrl) { + this.codeUrl = codeUrl; + } + + public WxPayNativeOrderResult() { + } + + public static final class Builder { + private String codeUrl; + + private Builder() { + } + + public Builder codeUrl(String codeUrl) { + this.codeUrl = codeUrl; + return this; + } + + public WxPayNativeOrderResult build() { + return new WxPayNativeOrderResult(this); + } + } +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java index 92c98bda48..d8ab2ab6df 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java @@ -5,7 +5,7 @@ /** *
      * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"返回的结果
    - * 统一下单(详见http://com.github.binarywang.wechat.pay.bean.pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
    + * 统一下单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
      * 
    * * @author chanjarster diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java index dc8ce23b8e..64842b1456 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java @@ -71,6 +71,11 @@ public static class TradeType { */ public static final String JSAPI = "JSAPI"; + /** + * H5支付 + */ + public static final String MWEB = "MWEB"; + /** * 刷卡支付,刷卡支付有单独的支付接口,不调用统一下单接口 */ @@ -84,4 +89,15 @@ public static class SignType { public static final String HMAC_SHA256 = "HMAC-SHA256"; public static final String MD5 = "MD5"; } + + + /** + * 限定支付方式 + */ + public static class LimitPay { + /** + * no_credit--指定不能使用信用卡支付 + */ + public static final String NO_CREDIT = "no_credit"; + } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java index 0e375bd62f..fe35ed2129 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java @@ -1,7 +1,7 @@ package com.github.binarywang.wxpay.converter; -import com.github.binarywang.wxpay.bean.WxPayOrderNotifyCoupon; -import com.github.binarywang.wxpay.bean.result.WxPayOrderNotifyResult; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyCoupon; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; import com.google.common.base.Function; import com.google.common.collect.Maps; import com.thoughtworks.xstream.annotations.XStreamAlias; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java index bf599ba175..0605edfc24 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java @@ -2,6 +2,8 @@ import com.github.binarywang.wxpay.bean.WxPayApiData; import com.github.binarywang.wxpay.bean.coupon.*; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; +import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.config.WxPayConfig; @@ -22,7 +24,7 @@ public interface WxPayService { /** *
    -   * 查询订单(详见https://com.github.binarywang.wechat.pay.bean.pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2)
    +   * 查询订单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2)
        * 该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。
        * 需要调用查询接口的情况:
        * ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
    @@ -54,7 +56,7 @@ public interface WxPayService {
       WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException;
     
       /**
    -   * 统一下单(详见http://com.github.binarywang.wechat.pay.bean.pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
    +   * 统一下单(详见https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_1)
        * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
        * 接口地址:https://api.mch.weixin.qq.com/pay/unifiedorder
        *
    @@ -64,7 +66,7 @@ public interface WxPayService {
     
       /**
        * 该接口调用“统一下单”接口,并拼装发起支付请求需要的参数
    -   * 详见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
    +   * 详见https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_5
        *
        * @param request 请求对象,注意一些参数如appid、mchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置)
        */
    @@ -113,11 +115,24 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri
         throws WxPayException;
     
       /**
    -   * 读取支付结果通知
    -   * 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7
    +   * @deprecated  use WxPayService#parseOrderNotifyResult(String) instead
    +   * @see WxPayService#parseOrderNotifyResult(String)
        */
    +  @Deprecated
       WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayException;
     
    +  /**
    +   * 解析支付结果通知
    +   * 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7
    +   */
    +  WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPayException;
    +
    +  /**
    +   * 解析退款结果通知
    +   * 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_16&index=9
    +   */
    +  WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws WxPayException;
    +
       /**
        * 发送微信红包给个人用户
        * 
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    index 27d4d2dd6f..f0b22d194d 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    @@ -3,6 +3,11 @@
     import com.github.binarywang.utils.qrcode.QrcodeUtils;
     import com.github.binarywang.wxpay.bean.WxPayApiData;
     import com.github.binarywang.wxpay.bean.coupon.*;
    +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
    +import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
    +import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult;
    +import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
    +import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult;
     import com.github.binarywang.wxpay.bean.request.*;
     import com.github.binarywang.wxpay.bean.result.*;
     import com.github.binarywang.wxpay.config.WxPayConfig;
    @@ -97,11 +102,17 @@ public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeN
       }
     
       @Override
    +  @Deprecated
       public WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayException {
    +    return this.parseOrderNotifyResult(xmlData);
    +  }
    +
    +  @Override
    +  public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPayException {
         try {
    -      log.debug("微信支付回调参数详细:{}", xmlData);
    +      log.debug("微信支付异步通知请求参数:{}", xmlData);
           WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData);
    -      log.debug("微信支付回调结果对象:{}", result);
    +      log.debug("微信支付异步通知请求解析后的对象:{}", result);
           result.checkResult(this);
           return result;
         } catch (WxPayException e) {
    @@ -113,6 +124,19 @@ public WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayE
         }
       }
     
    +  @Override
    +  public WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws WxPayException {
    +    try {
    +      log.debug("微信支付退款异步通知参数:{}", xmlData);
    +      WxPayRefundNotifyResult result = WxPayRefundNotifyResult.fromXML(xmlData, this.getConfig().getMchKey());
    +      log.debug("微信支付退款异步通知解析后的对象:{}", result);
    +      return result;
    +    } catch (Exception e) {
    +      log.error(e.getMessage(), e);
    +      throw new WxPayException("发生异常," + e.getMessage(), e);
    +    }
    +  }
    +
       @Override
       public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throws WxPayException {
         request.checkAndSign(this.getConfig());
    @@ -181,6 +205,65 @@ public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException
         return result;
       }
     
    +  public  T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException {
    +    WxPayUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request);
    +    String prepayId = unifiedOrderResult.getPrepayId();
    +    if (StringUtils.isBlank(prepayId)) {
    +      throw new RuntimeException(String.format("无法获取prepay id,错误代码: '%s',信息:%s。",
    +        unifiedOrderResult.getErrCode(), unifiedOrderResult.getErrCodeDes()));
    +    }
    +
    +    String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
    +    String nonceStr = String.valueOf(System.currentTimeMillis());
    +    Object payResult = null;
    +    switch (request.getTradeType()) {
    +      case TradeType.NATIVE: {
    +        payResult = WxPayNativeOrderResult.newBuilder().codeUrl(unifiedOrderResult.getCodeURL())
    +          .build();
    +        break;
    +      }
    +      case TradeType.APP: {
    +        // APP支付绑定的是微信开放平台上的账号,APPID为开放平台上绑定APP后发放的参数
    +        String appId = this.getConfig().getAppId();
    +        Map configMap = new HashMap<>();
    +        // 此map用于参与调起sdk支付的二次签名,格式全小写,timestamp只能是10位,格式固定,切勿修改
    +        String partnerId = getConfig().getMchId();
    +        configMap.put("prepayid", prepayId);
    +        configMap.put("partnerid", partnerId);
    +        String packageValue = "Sign=WXPay";
    +        configMap.put("package", packageValue);
    +        configMap.put("timestamp", timestamp);
    +        configMap.put("noncestr", nonceStr);
    +        configMap.put("appid", appId);
    +
    +        payResult = WxPayAppOrderResult.newBuilder()
    +          .sign(SignUtils.createSign(configMap, this.getConfig().getMchKey()))
    +          .prepayId(prepayId)
    +          .partnerId(partnerId)
    +          .appId(appId)
    +          .packageValue(packageValue)
    +          .timeStamp(timestamp)
    +          .nonceStr(nonceStr)
    +          .build();
    +        break;
    +      }
    +      case TradeType.JSAPI: {
    +        payResult = WxPayMpOrderResult.newBuilder()
    +          .appId(unifiedOrderResult.getAppid())
    +          .timeStamp(timestamp)
    +          .nonceStr(nonceStr)
    +          .packageValue("prepay_id=" + prepayId)
    +          .signType(SignType.MD5)
    +          .build();
    +        ((WxPayMpOrderResult) payResult)
    +          .setPaySign(SignUtils.createSign(payResult, this.getConfig().getMchKey()));
    +        break;
    +      }
    +    }
    +
    +    return (T) payResult;
    +  }
    +
       @Override
       public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) throws WxPayException {
         request.checkAndSign(this.getConfig());
    @@ -508,7 +591,7 @@ public WxPayCouponInfoQueryResult queryCouponInfo(WxPayCouponInfoQueryRequest re
       public WxPayApiData getWxApiData() {
         try {
           return wxApiData.get();
    -    }finally {
    +    } finally {
           //一般来说,接口请求会在一个线程内进行,这种情况下,每个线程get的会是之前所存入的数据,
           // 但以防万一有同一线程多次请求的问题,所以每次获取完数据后移除对应数据
           wxApiData.remove();
    diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResultTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResultTest.java
    similarity index 95%
    rename from weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResultTest.java
    rename to weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResultTest.java
    index 389b374d9e..384de4c983 100644
    --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/result/WxPayOrderNotifyResultTest.java
    +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResultTest.java
    @@ -1,5 +1,6 @@
    -package com.github.binarywang.wxpay.bean.result;
    +package com.github.binarywang.wxpay.bean.notify;
     
    +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
     import org.testng.*;
     import org.testng.annotations.*;
     
    diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResultTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResultTest.java
    new file mode 100644
    index 0000000000..cd1777f836
    --- /dev/null
    +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResultTest.java
    @@ -0,0 +1,70 @@
    +package com.github.binarywang.wxpay.bean.notify;
    +
    +import com.github.binarywang.wxpay.config.WxPayConfig;
    +import com.github.binarywang.wxpay.exception.WxPayException;
    +import com.github.binarywang.wxpay.testbase.ApiTestModule;
    +import org.apache.commons.codec.binary.Base64;
    +import org.testng.annotations.Guice;
    +import org.testng.annotations.Test;
    +
    +import javax.crypto.Cipher;
    +import javax.crypto.spec.SecretKeySpec;
    +import javax.inject.Inject;
    +import java.math.BigInteger;
    +import java.security.MessageDigest;
    +
    +import static org.testng.Assert.assertNotNull;
    +
    +/**
    + * 
    + *  Created by BinaryWang on 2017/8/27.
    + * 
    + * + * @author Binary Wang + */ +@Test +@Guice(modules = ApiTestModule.class) +public class WxPayRefundNotifyResultTest { + @Inject + private WxPayConfig wxPayConfig; + + public void testFromXML() throws WxPayException { + String xmlString = "" + + "SUCCESS" + + "" + + "" + + "" + + ""; + + WxPayRefundNotifyResult refundNotifyResult = WxPayRefundNotifyResult.fromXML(xmlString, this.wxPayConfig.getMchKey()); + + assertNotNull(refundNotifyResult); + System.out.println(refundNotifyResult); + } + + public void encodeReqInfo() throws Exception { + String xml = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + ""; + + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + final MessageDigest md5 = MessageDigest.getInstance("MD5"); + md5.update(this.wxPayConfig.getMchKey().getBytes()); + final String keyMd5String = new BigInteger(1, md5.digest()).toString(16).toLowerCase(); + SecretKeySpec key = new SecretKeySpec(keyMd5String.getBytes(), "AES"); + cipher.init(Cipher.ENCRYPT_MODE, key); + System.out.println(Base64.encodeBase64String(cipher.doFinal(xml.getBytes()))); + } +} diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index de0fe10e2c..8d419be8ac 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -2,6 +2,7 @@ import com.github.binarywang.utils.qrcode.QrcodeUtils; import com.github.binarywang.wxpay.bean.coupon.*; +import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.constant.WxPayConstants; @@ -147,6 +148,11 @@ public void testRefundQuery() throws Exception { this.logger.info(result.toString()); } + @Test + public void testParseRefundNotifyResult() throws Exception { + // 请参考com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResultTest里的单元测试 + } + /** * Test method for {@link WxPayService#sendRedpack(WxPaySendRedpackRequest)} . */ From a5c61268ef9ff6b79677be7c484cf0630132f7c7 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 2 Sep 2017 23:48:33 +0800 Subject: [PATCH 081/165] =?UTF-8?q?#320=20=E5=A2=9E=E5=8A=A0=E2=80=9C?= =?UTF-8?q?=E6=8B=89=E5=8F=96=E8=AE=A2=E5=8D=95=E8=AF=84=E4=BB=B7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E2=80=9C=E6=8E=A5=E5=8F=A3=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/bean/request/WxPayBaseRequest.java | 24 +++- .../request/WxPayQueryCommentRequest.java | 112 ++++++++++++++++++ .../wxpay/constant/WxPayConstants.java | 8 ++ .../wxpay/service/WxPayService.java | 22 +++- .../impl/WxPayServiceAbstractImpl.java | 46 ++++--- .../binarywang/wxpay/util/SignUtils.java | 47 ++++++-- .../impl/WxPayServiceAbstractImplTest.java | 24 +++- .../binarywang/wxpay/util/SignUtilsTest.java | 40 +++++++ 8 files changed, 292 insertions(+), 31 deletions(-) create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java create mode 100644 weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java index cc0490d22e..41a98d0ae4 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java @@ -95,6 +95,19 @@ public abstract class WxPayBaseRequest { @XStreamAlias("sign") protected String sign; + /** + *
    +   * 签名类型
    +   * sign_type
    +   * 否
    +   * String(32)
    +   * HMAC-SHA256
    +   * 签名类型,目前支持HMAC-SHA256和MD5
    +   * 
    + */ + @XStreamAlias("sign_type") + private String signType; + /** * 将单位为元转换为单位为分 * @@ -187,6 +200,14 @@ public void setSubMchId(String subMchId) { this.subMchId = subMchId; } + public String getSignType() { + return signType; + } + + public void setSignType(String signType) { + this.signType = signType; + } + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -230,9 +251,8 @@ public void checkAndSign(WxPayConfig config) throws WxPayException { if (StringUtils.isBlank(getNonceStr())) { this.setNonceStr(String.valueOf(System.currentTimeMillis())); } - //设置签名字段的值 - this.setSign(SignUtils.createSign(this, config.getMchKey())); + this.setSign(SignUtils.createSign(this, config.getMchKey(), this.signType)); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java new file mode 100644 index 0000000000..1bdbf9bf4e --- /dev/null +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java @@ -0,0 +1,112 @@ +package com.github.binarywang.wxpay.bean.request; + +import com.github.binarywang.wxpay.exception.WxPayException; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import me.chanjar.weixin.common.annotation.Required; + +/** + *
    + *  拉取订单评价数据接口的请求参数封装类
    + *  Created by BinaryWang on 2017/9/2.
    + * 
    + * + * @author Binary Wang + */ +@XStreamAlias("xml") +public class WxPayQueryCommentRequest extends WxPayBaseRequest { + /** + *
    +   * 字段名:开始时间
    +   * 变量名:begin_time
    +   * 是否必填:是
    +   * 类型:String(19)
    +   * 示例值:20170724000000
    +   * 描述:按用户评论时间批量拉取的起始时间,格式为yyyyMMddHHmmss
    +   * 
    + */ + @Required + @XStreamAlias("begin_time") + private String beginTime; + + /** + *
    +   * 字段名:结束时间
    +   * 变量名:end_time
    +   * 是否必填:是
    +   * 类型:String(19)
    +   * 示例值:20170725000000
    +   * 描述:按用户评论时间批量拉取的结束时间,格式为yyyyMMddHHmmss
    +   * 
    + */ + @Required + @XStreamAlias("end_time") + private String endTime; + + /** + *
    +   * 字段名:位移
    +   * 变量名:offset
    +   * 是否必填:是
    +   * 类型:uint(64)
    +   * 示例值:0
    +   * 描述:指定从某条记录的下一条开始返回记录。接口调用成功时,会返回本次查询最后一条数据的offset。商户需要翻页时,应该把本次调用返回的offset 作为下次调用的入参。注意offset是评论数据在微信支付后台保存的索引,未必是连续的
    +   * 
    + */ + @Required + @XStreamAlias("offset") + private Integer offset; + + /** + *
    +   * 字段名:条数
    +   * 变量名:limit
    +   * 是否必填:否
    +   * 类型:uint(32)
    +   * 示例值:100
    +   * 描述:一次拉取的条数, 最大值是200,默认是200
    +   * 
    + */ + @XStreamAlias("limit") + private Integer limit; + + /** + * 检查约束情况 + */ + @Override + protected void checkConstraints() throws WxPayException { + + } + + public String getBeginTime() { + return beginTime; + } + + public void setBeginTime(String beginTime) { + this.beginTime = beginTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public Integer getOffset() { + return offset; + } + + public void setOffset(Integer offset) { + this.offset = offset; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + +} diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java index 64842b1456..47f636d0fc 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java @@ -1,5 +1,7 @@ package com.github.binarywang.wxpay.constant; +import java.text.SimpleDateFormat; + /** *
      * 微信支付常量类
    @@ -9,6 +11,12 @@
      * @author Binary Wang
      */
     public class WxPayConstants {
    +
    +  /**
    +   * 拉取订单评价数据接口的参数中日期格式
    +   */
    +  public static final SimpleDateFormat QUERY_COMMENT_DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
    +
       /**
        * 校验用户姓名选项,企业付款时使用
        */
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
    index 0605edfc24..ae058e1478 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
    @@ -10,6 +10,7 @@
     import com.github.binarywang.wxpay.exception.WxPayException;
     
     import java.io.File;
    +import java.util.Date;
     import java.util.Map;
     
     /**
    @@ -115,8 +116,8 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri
         throws WxPayException;
     
       /**
    -   * @deprecated  use WxPayService#parseOrderNotifyResult(String) instead
        * @see WxPayService#parseOrderNotifyResult(String)
    +   * @deprecated use WxPayService#parseOrderNotifyResult(String) instead
        */
       @Deprecated
       WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayException;
    @@ -389,4 +390,23 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri
        * 获取微信请求数据,方便接口调用方获取处理
        */
       WxPayApiData getWxApiData();
    +
    +  /**
    +   * 
    +   * 拉取订单评价数据
    +   * 商户可以通过该接口拉取用户在微信支付交易记录中针对你的支付记录进行的评价内容。商户可结合商户系统逻辑对该内容数据进行存储、分析、展示、客服回访以及其他使用。如商户业务对评价内容有依赖,可主动引导用户进入微信支付交易记录进行评价。
    +   * 注意:
    +   * 1. 该内容所有权为提供内容的微信用户,商户在使用内容的过程中应遵从用户意愿
    +   * 2. 一次最多拉取200条评价数据,可根据时间区间分批次拉取
    +   * 3. 接口只能拉取最近三个月以内的评价数据
    +   * 接口链接:https://api.mch.weixin.qq.com/billcommentsp/batchquerycomment
    +   * 是否需要证书:需要
    +   * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_17&index=10
    +   * 
    + * @param beginDate 开始时间 + * @param endDate 结束时间 + * @param offset 位移 + * @param limit 条数 + */ + String queryComment(Date beginDate, Date endDate, Integer offset, Integer limit) throws WxPayException; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index f0b22d194d..e77d3e1fc8 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -23,10 +23,9 @@ import org.slf4j.LoggerFactory; import java.io.File; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; + +import static com.github.binarywang.wxpay.constant.WxPayConstants.QUERY_COMMENT_DATE_FORMAT; /** *
    @@ -237,7 +236,7 @@ public  T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
             configMap.put("appid", appId);
     
             payResult = WxPayAppOrderResult.newBuilder()
    -          .sign(SignUtils.createSign(configMap, this.getConfig().getMchKey()))
    +          .sign(SignUtils.createSign(configMap, this.getConfig().getMchKey(), null))
               .prepayId(prepayId)
               .partnerId(partnerId)
               .appId(appId)
    @@ -256,7 +255,7 @@ public  T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
               .signType(SignType.MD5)
               .build();
             ((WxPayMpOrderResult) payResult)
    -          .setPaySign(SignUtils.createSign(payResult, this.getConfig().getMchKey()));
    +          .setPaySign(SignUtils.createSign(payResult, this.getConfig().getMchKey(), null));
             break;
           }
         }
    @@ -303,7 +302,7 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W
           configMap.put("noncestr", nonceStr);
           configMap.put("appid", appId);
           // 此map用于客户端与微信服务器交互
    -      payInfo.put("sign", SignUtils.createSign(configMap, this.getConfig().getMchKey()));
    +      payInfo.put("sign", SignUtils.createSign(configMap, this.getConfig().getMchKey(), null));
           payInfo.put("prepayId", prepayId);
           payInfo.put("partnerId", partnerId);
           payInfo.put("appId", appId);
    @@ -317,7 +316,7 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W
           payInfo.put("nonceStr", nonceStr);
           payInfo.put("package", "prepay_id=" + prepayId);
           payInfo.put("signType", SignType.MD5);
    -      payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey()));
    +      payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey(), null));
         }
     
         return payInfo;
    @@ -364,7 +363,7 @@ public String createScanPayQrcodeMode1(String productId) {
         params.put("time_stamp", String.valueOf(System.currentTimeMillis() / 1000));//这里需要秒,10位数字
         params.put("nonce_str", String.valueOf(System.currentTimeMillis()));
     
    -    String sign = SignUtils.createSign(params, this.getConfig().getMchKey());
    +    String sign = SignUtils.createSign(params, this.getConfig().getMchKey(), null);
         params.put("sign", sign);
     
         for (String key : params.keySet()) {
    @@ -411,15 +410,13 @@ public WxPayBillResult downloadBill(String billDate, String billType, String tar
         String url = this.getPayBaseUrl() + "/pay/downloadbill";
         String responseContent = this.post(url, request.toXML(), false);
         if (responseContent.startsWith("<")) {
    -      WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class);
    -      result.checkResult(this);
    -      return null;
    +      throw WxPayException.from(WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class));
         } else {
    -      return billInformationDeal(responseContent);
    +      return this.handleBillInformation(responseContent);
         }
       }
     
    -  private WxPayBillResult billInformationDeal(String responseContent) {
    +  private WxPayBillResult handleBillInformation(String responseContent) {
         WxPayBillResult wxPayBillResult = new WxPayBillResult();
     
         String listStr = "";
    @@ -597,4 +594,25 @@ public WxPayApiData getWxApiData() {
           wxApiData.remove();
         }
       }
    +
    +  @Override
    +  public String queryComment(Date beginDate, Date endDate, Integer offset, Integer limit) throws WxPayException {
    +    WxPayQueryCommentRequest request = new WxPayQueryCommentRequest();
    +    request.setBeginTime(QUERY_COMMENT_DATE_FORMAT.format(beginDate));
    +    request.setEndTime(QUERY_COMMENT_DATE_FORMAT.format(endDate));
    +    request.setOffset(offset);
    +    request.setLimit(limit);
    +    request.setSignType(SignType.HMAC_SHA256);
    +
    +    request.checkAndSign(this.getConfig());
    +
    +    String url = this.getPayBaseUrl() + "/billcommentsp/batchquerycomment";
    +
    +    String responseContent = this.post(url, request.toXML(), true);
    +    if (responseContent.startsWith("<")) {
    +      throw WxPayException.from(WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class));
    +    }
    +
    +    return responseContent;
    +  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java
    index 33e18c49f3..b13175a724 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java
    @@ -1,9 +1,15 @@
     package com.github.binarywang.wxpay.util;
     
    +import com.github.binarywang.wxpay.constant.WxPayConstants.SignType;
     import me.chanjar.weixin.common.util.BeanUtils;
    +import org.apache.commons.codec.binary.Hex;
     import org.apache.commons.codec.digest.DigestUtils;
     import org.apache.commons.lang3.StringUtils;
     
    +import javax.crypto.Mac;
    +import javax.crypto.spec.SecretKeySpec;
    +import java.security.InvalidKeyException;
    +import java.security.NoSuchAlgorithmException;
     import java.util.Map;
     import java.util.SortedMap;
     import java.util.TreeMap;
    @@ -20,22 +26,24 @@ public class SignUtils {
       /**
        * 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
        *
    -   * @param xmlBean Bean需要标记有XML注解
    -   * @param signKey 签名Key
    +   * @param xmlBean  Bean需要标记有XML注解
    +   * @param signKey  签名Key
    +   * @param signType 签名类型,如果为空,则默认为MD5
        * @return 签名字符串
        */
    -  public static String createSign(Object xmlBean, String signKey) {
    -    return createSign(BeanUtils.xmlBean2Map(xmlBean), signKey);
    +  public static String createSign(Object xmlBean, String signKey, String signType) {
    +    return createSign(BeanUtils.xmlBean2Map(xmlBean), signKey, signType);
       }
     
       /**
        * 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
        *
    -   * @param params  参数信息
    -   * @param signKey 签名Key
    +   * @param params   参数信息
    +   * @param signKey  签名Key
    +   * @param signType 签名类型,如果为空,则默认为md5
        * @return 签名字符串
        */
    -  public static String createSign(Map params, String signKey) {
    +  public static String createSign(Map params, String signKey, String signType) {
     //    if (this.getConfig().useSandbox()) {
     //      //使用仿真测试环境
     //      //TODO 目前测试发现,以下两行代码都会出问题,所以暂不建议使用仿真测试环境
    @@ -48,13 +56,32 @@ public static String createSign(Map params, String signKey) {
         StringBuilder toSign = new StringBuilder();
         for (String key : sortedMap.keySet()) {
           String value = params.get(key);
    -      if (StringUtils.isNotEmpty(value) && !"sign".equals(key) && !"key".equals(key)) {
    +      if (StringUtils.isNotEmpty(value)
    +        && !StringUtils.equalsAny(key, "sign", "key", "sign_type")) {
             toSign.append(key).append("=").append(value).append("&");
           }
         }
     
         toSign.append("key=").append(signKey);
    -    return DigestUtils.md5Hex(toSign.toString()).toUpperCase();
    +    if (SignType.HMAC_SHA256.equals(signType)) {
    +      return createHMACSha256Sign(toSign.toString(), signKey);
    +    } else {
    +      return DigestUtils.md5Hex(toSign.toString()).toUpperCase();
    +    }
    +  }
    +
    +  private static String createHMACSha256Sign(String message, String key) {
    +    try {
    +      Mac hmacSHA256 = Mac.getInstance("HmacSHA256");
    +      SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "HmacSHA256");
    +      hmacSHA256.init(secretKeySpec);
    +      byte[] bytes = hmacSHA256.doFinal(message.getBytes());
    +      return Hex.encodeHexString(bytes).toUpperCase();
    +    } catch (NoSuchAlgorithmException | InvalidKeyException e) {
    +      e.printStackTrace();
    +    }
    +
    +    return null;
       }
     
       /**
    @@ -78,7 +105,7 @@ public static boolean checkSign(Object xmlBean, String signKey) {
        * @see #checkSign(Map, String)
        */
       public static boolean checkSign(Map params, String signKey) {
    -    String sign = createSign(params, signKey);
    +    String sign = createSign(params, signKey, null);
         return sign.equals(params.get("sign"));
       }
     }
    diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
    index 8d419be8ac..2fc5354424 100644
    --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
    +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
    @@ -2,7 +2,6 @@
     
     import com.github.binarywang.utils.qrcode.QrcodeUtils;
     import com.github.binarywang.wxpay.bean.coupon.*;
    -import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
     import com.github.binarywang.wxpay.bean.request.*;
     import com.github.binarywang.wxpay.bean.result.*;
     import com.github.binarywang.wxpay.constant.WxPayConstants;
    @@ -16,10 +15,13 @@
     import com.google.inject.Inject;
     import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;
    -import org.testng.annotations.*;
    +import org.testng.annotations.Guice;
    +import org.testng.annotations.Test;
     
     import java.nio.file.Files;
     import java.nio.file.Path;
    +import java.util.Calendar;
    +import java.util.Date;
     import java.util.Map;
     
     import static org.testng.Assert.*;
    @@ -90,7 +92,7 @@ public void testCloseOrder() throws WxPayException {
     
       @Test
       public void testDownloadBill() throws Exception {
    -    WxPayBillResult wxPayBillResult = this.payService.downloadBill("20170101", BillType.ALL, "GZIP", "1111111");
    +    WxPayBillResult wxPayBillResult = this.payService.downloadBill("20170831", BillType.ALL, null, "1111111");
         //前一天没有账单记录返回null
         assertNotNull(wxPayBillResult);
         //必填字段为空时,抛出异常
    @@ -313,10 +315,24 @@ public void testQueryCouponStock() throws Exception {
       @Test
       public void testQueryCouponInfo() throws Exception {
         WxPayCouponInfoQueryResult result = this.payService.queryCouponInfo(WxPayCouponInfoQueryRequest.newBuilder()
    -      .openid("onqOjjrXT-776SpHnfexGm1_P7iE")
    +      .openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4")
           .couponId("11")
           .stockId("1121")
           .build());
         this.logger.info(result.toString());
       }
    +
    +  /**
    +   * 目前调用接口总报“系统繁忙,清稍后再试”,怀疑根本没法使用
    +   */
    +  @Test
    +  public void testQueryComment() throws Exception {
    +    Calendar calendar = Calendar.getInstance();
    +    calendar.add(Calendar.DAY_OF_MONTH, -2);
    +    Date beginDate = calendar.getTime();
    +    calendar.add(Calendar.MONTH, -1);
    +    Date endDate = calendar.getTime();
    +    this.payService.queryComment(beginDate, endDate, 0, null);
    +  }
    +
     }
    diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java
    new file mode 100644
    index 0000000000..23d7088b7b
    --- /dev/null
    +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java
    @@ -0,0 +1,40 @@
    +package com.github.binarywang.wxpay.util;
    +
    +import com.google.common.base.Splitter;
    +import org.testng.annotations.Test;
    +
    +import static com.github.binarywang.wxpay.constant.WxPayConstants.SignType.HMAC_SHA256;
    +import static org.testng.Assert.assertEquals;
    +
    +/**
    + * 
    + * 测试中使用的测试数据参考的是官方文档,地址:
    + * https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_3
    + *  Created by BinaryWang on 2017/9/2.
    + * 
    + * + * @author Binary Wang + */ +public class SignUtilsTest { + @Test + public void testCreateSign() throws Exception { + String signKey = "192006250b4c09247ec02edce69f6a2d"; + String message = "appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_id=10000100&nonce_str=ibuaiVcKdpRxkhJA"; + assertEquals(SignUtils.createSign((Splitter.on("&").withKeyValueSeparator("=").split(message)), signKey, null), + "9A0A8659F005D6984697E2CA0A9CF3B7"); + } + + @Test + public void testCreateSign_HMACSHA256() throws Exception { + String signKey = "192006250b4c09247ec02edce69f6a2d"; + final String message = "appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_id=10000100&nonce_str=ibuaiVcKdpRxkhJA"; + String sign = SignUtils.createSign(Splitter.on("&").withKeyValueSeparator("=").split(message), + signKey, HMAC_SHA256); + assertEquals(sign, "6A9AE1657590FD6257D693A078E1C3E4BB6BA4DC30B23E0EE2496E54170DACD6"); + } + + @Test + public void testCheckSign() throws Exception { + } + +} From a9301efbeaac8633cf4eba4d7acab1266001096c Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 2 Sep 2017 23:57:20 +0800 Subject: [PATCH 082/165] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E4=B8=BA=E6=AD=A3=E5=BC=8F=E7=89=88=E6=9C=AC2.8.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index a10e3adc99..f93c5dd5c6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.7.9.BETA + 2.8.0 pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 1b3be7dac3..68c6130612 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.9.BETA + 2.8.0 weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index f035d15b7a..233a94ecc3 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.9.BETA + 2.8.0 weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 3c4a36751d..3a2614aa59 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.9.BETA + 2.8.0 weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 9f658a8fbf..81ec2c01ab 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.7.9.BETA + 2.8.0 weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index a1f01be6e9..05aa6c5f8f 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.7.9.BETA + 2.8.0 4.0.0 From 3875635a8ab4428b202d951df3f7a5b82ba9c9da Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 11 Sep 2017 11:05:29 +0800 Subject: [PATCH 083/165] =?UTF-8?q?#136=20=E4=BF=AE=E5=A4=8DWxMenuRule?= =?UTF-8?q?=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?tag=5Fid=E4=B8=BA=E7=A9=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/common/bean/menu/WxMenuRule.java | 5 +++++ .../weixin/common/util/json/WxMenuGsonAdapter.java | 1 + .../weixin/mp/api/impl/WxMpMenuServiceImplTest.java | 13 +++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java index e0182c9678..efc42fbb6b 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.common.bean.menu; +import com.google.gson.annotations.SerializedName; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; @@ -7,6 +8,10 @@ public class WxMenuRule implements Serializable { private static final long serialVersionUID = -4587181819499286670L; + /** + * 变态的微信接口,反序列化时这里反人类的使用和序列化时不一样的名字 + */ + @SerializedName(value = "tag_id", alternate = "group_id") private String tagId; private String sex; private String country; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java index c506c1ed75..31c3c0204c 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxMenuGsonAdapter.java @@ -70,6 +70,7 @@ protected JsonObject convertToJson(WxMenuRule menuRule) { return matchRule; } + @Deprecated private WxMenuRule convertToRule(JsonObject json) { WxMenuRule menuRule = new WxMenuRule(); //变态的微信接口,这里居然反人类的使用和序列化时不一样的名字 diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java index 8846809001..922cbb7e08 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java @@ -9,9 +9,10 @@ import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.bean.menu.WxMpGetSelfMenuInfoResult; import me.chanjar.weixin.mp.bean.menu.WxMpMenu; -import org.testng.*; import org.testng.annotations.*; +import static org.testng.Assert.*; + /** * 测试菜单 * @@ -87,6 +88,14 @@ public void testCreateConditionalMenu() throws WxErrorException { System.out.println(this.menuId); } + @Test(dependsOnMethods = {"testCreateConditionalMenu"}) + public void testMenuGet_AfterCreateConditionalMenu() throws WxErrorException { + WxMpMenu wxMenu = this.wxService.getMenuService().menuGet(); + assertNotNull(wxMenu); + System.out.println(wxMenu.toJson()); + assertNotNull(wxMenu.getConditionalMenu().get(0).getRule().getTagId()); + } + @Test(dependsOnMethods = {"testCreateConditionalMenu"}) public void testDeleteConditionalMenu() throws WxErrorException { this.wxService.getMenuService().menuDelete(menuId); @@ -134,7 +143,7 @@ public void testCreateMenu_by_json() throws WxErrorException { @Test(dependsOnMethods = {"testMenuCreate"}) public void testMenuGet() throws WxErrorException { WxMpMenu wxMenu = this.wxService.getMenuService().menuGet(); - Assert.assertNotNull(wxMenu); + assertNotNull(wxMenu); System.out.println(wxMenu.toJson()); } From 0e580a05fffe3eca27ee118c02481c83dd3523fa Mon Sep 17 00:00:00 2001 From: nickwongwong Date: Wed, 13 Sep 2017 17:51:24 +0800 Subject: [PATCH 084/165] =?UTF-8?q?Fix=20issue=20#335:=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84WxMpInRedisConfigStorage,=E6=94=B9=E7=94=A8=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp/api/WxMpInRedisConfigStorage.java | 89 ++++++++++++++----- 1 file changed, 65 insertions(+), 24 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java index d22214dfa1..3254972c26 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java @@ -1,11 +1,12 @@ package me.chanjar.weixin.mp.api; import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; /** * 基于Redis的微信配置provider * - * @author lly835 + * @author nickwong */ @SuppressWarnings("hiding") public class WxMpInRedisConfigStorage extends WxMpInMemoryConfigStorage { @@ -16,75 +17,115 @@ public class WxMpInRedisConfigStorage extends WxMpInMemoryConfigStorage { private final static String CARDAPI_TICKET_KEY = "wechat_cardapi_ticket_"; - protected Jedis jedis; + /** + * 使用连接池保证线程安全 + */ + protected final JedisPool jedisPool; + + private String accessTokenKey; + + private String jsapiTicketKey; + + private String cardapiTicketKey; + + public WxMpInRedisConfigStorage(JedisPool jedisPool) { + this.jedisPool = jedisPool; + } + + /** + * 每个公众号生成独有的存储key + * + * @param appId + */ + @Override + public void setAppId(String appId) { + super.setAppId(appId); + this.accessTokenKey = ACCESS_TOKEN_KEY.concat(appId); + this.jsapiTicketKey = JSAPI_TICKET_KEY.concat(appId); + this.cardapiTicketKey = CARDAPI_TICKET_KEY.concat(appId); + } @Override public String getAccessToken() { - return jedis.get(ACCESS_TOKEN_KEY.concat(appId)); + try (Jedis jedis = this.jedisPool.getResource()) { + return jedis.get(accessTokenKey); + } } @Override public boolean isAccessTokenExpired() { - return jedis.ttl(ACCESS_TOKEN_KEY.concat(appId)) < 2; + try (Jedis jedis = this.jedisPool.getResource()) { + return jedis.ttl(accessTokenKey) < 2; + } } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { - jedis.set(ACCESS_TOKEN_KEY.concat(appId), accessToken); - jedis.expire(ACCESS_TOKEN_KEY.concat(appId), expiresInSeconds - 200); + try (Jedis jedis = this.jedisPool.getResource()) { + jedis.setex(accessTokenKey, expiresInSeconds - 200, accessToken); + } } @Override public void expireAccessToken() { - jedis.expire(ACCESS_TOKEN_KEY.concat(appId), 0); + try (Jedis jedis = this.jedisPool.getResource()) { + jedis.expire(accessTokenKey, 0); + } } @Override public String getJsapiTicket() { - return jedis.get(JSAPI_TICKET_KEY.concat(appId)); + try (Jedis jedis = this.jedisPool.getResource()) { + return jedis.get(jsapiTicketKey); + } } @Override public boolean isJsapiTicketExpired() { - return jedis.ttl(JSAPI_TICKET_KEY.concat(appId)) < 2; + try (Jedis jedis = this.jedisPool.getResource()) { + return jedis.ttl(jsapiTicketKey) < 2; + } } @Override public synchronized void updateJsapiTicket(String jsapiTicket, int expiresInSeconds) { - jedis.set(JSAPI_TICKET_KEY.concat(appId), jsapiTicket); - jedis.expire(JSAPI_TICKET_KEY.concat(appId), expiresInSeconds - 200); + try (Jedis jedis = this.jedisPool.getResource()) { + jedis.setex(jsapiTicketKey, expiresInSeconds - 200, jsapiTicket); + } } @Override public void expireJsapiTicket() { - jedis.expire(JSAPI_TICKET_KEY.concat(appId), 0); + try (Jedis jedis = this.jedisPool.getResource()) { + jedis.expire(jsapiTicketKey, 0); + } } - /** - * 卡券api_ticket - */ @Override public String getCardApiTicket() { - return jedis.get(CARDAPI_TICKET_KEY.concat(appId)); + try (Jedis jedis = this.jedisPool.getResource()) { + return jedis.get(cardapiTicketKey); + } } @Override public boolean isCardApiTicketExpired() { - return jedis.ttl(CARDAPI_TICKET_KEY.concat(appId)) < 2; + try (Jedis jedis = this.jedisPool.getResource()) { + return jedis.ttl(cardapiTicketKey) < 2; + } } @Override public synchronized void updateCardApiTicket(String cardApiTicket, int expiresInSeconds) { - jedis.set(CARDAPI_TICKET_KEY.concat(appId), cardApiTicket); - jedis.expire(CARDAPI_TICKET_KEY.concat(appId), expiresInSeconds - 200); + try (Jedis jedis = this.jedisPool.getResource()) { + jedis.setex(cardapiTicketKey, expiresInSeconds - 200, cardApiTicket); + } } @Override public void expireCardApiTicket() { - jedis.expire(CARDAPI_TICKET_KEY.concat(appId), 0); - } - - public void setJedis(Jedis jedis) { - this.jedis = jedis; + try (Jedis jedis = this.jedisPool.getResource()) { + jedis.expire(cardapiTicketKey, 0); + } } } From d6d3812d9515227be5c36070c173def687abf052 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 18 Sep 2017 11:03:42 +0800 Subject: [PATCH 085/165] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...xMpMaterialFileBatchGetGsonItemAdapter.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialFileBatchGetGsonItemAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialFileBatchGetGsonItemAdapter.java index 7b4bee2e00..7d73ca8343 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialFileBatchGetGsonItemAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialFileBatchGetGsonItemAdapter.java @@ -10,29 +10,29 @@ import com.google.gson.*; import me.chanjar.weixin.common.util.json.GsonHelper; -import me.chanjar.weixin.mp.bean.material.WxMpMaterialFileBatchGetResult; +import me.chanjar.weixin.mp.bean.material.WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem; import java.lang.reflect.Type; import java.util.Date; -public class WxMpMaterialFileBatchGetGsonItemAdapter implements JsonDeserializer { +public class WxMpMaterialFileBatchGetGsonItemAdapter implements JsonDeserializer { @Override - public WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { - WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem wxMaterialFileBatchGetNewsItem = new WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem(); + public WxMaterialFileBatchGetNewsItem deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { + WxMaterialFileBatchGetNewsItem newsItem = new WxMaterialFileBatchGetNewsItem(); JsonObject json = jsonElement.getAsJsonObject(); if (json.get("media_id") != null && !json.get("media_id").isJsonNull()) { - wxMaterialFileBatchGetNewsItem.setMediaId(GsonHelper.getAsString(json.get("media_id"))); + newsItem.setMediaId(GsonHelper.getAsString(json.get("media_id"))); } if (json.get("update_time") != null && !json.get("update_time").isJsonNull()) { - wxMaterialFileBatchGetNewsItem.setUpdateTime(new Date(1000 * GsonHelper.getAsLong(json.get("update_time")))); + newsItem.setUpdateTime(new Date(1000 * GsonHelper.getAsLong(json.get("update_time")))); } if (json.get("name") != null && !json.get("name").isJsonNull()) { - wxMaterialFileBatchGetNewsItem.setName(GsonHelper.getAsString(json.get("name"))); + newsItem.setName(GsonHelper.getAsString(json.get("name"))); } if (json.get("url") != null && !json.get("url").isJsonNull()) { - wxMaterialFileBatchGetNewsItem.setUrl(GsonHelper.getAsString(json.get("url"))); + newsItem.setUrl(GsonHelper.getAsString(json.get("url"))); } - return wxMaterialFileBatchGetNewsItem; + return newsItem; } } From 0b6f4c59153ee1ddd42f47602ff2273fd23fc30a Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 18 Sep 2017 18:30:29 +0800 Subject: [PATCH 086/165] =?UTF-8?q?=E6=B8=85=E7=90=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E8=BF=87=E5=BA=A6=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=AE=B9=E6=98=93=E5=BC=95=E8=B5=B7=E5=86=B2=E7=AA=81=E7=9A=84?= =?UTF-8?q?=E7=B1=BB=E5=BA=93=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/common/bean/result/WxMediaUploadResult.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java index 706de712c7..2c83d85c5f 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java @@ -1,8 +1,7 @@ package me.chanjar.weixin.common.bean.result; +import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.json.WxGsonBuilder; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; import java.io.Serializable; @@ -52,7 +51,7 @@ public void setThumbMediaId(String thumbMediaId) { @Override public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); + return ToStringUtils.toSimpleString(this); } } From 6fde2d10fa774d7d59915d33fcbb05f7399b123b Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 18 Sep 2017 19:05:45 +0800 Subject: [PATCH 087/165] =?UTF-8?q?pay=E6=A8=A1=E5=9D=97=E6=98=BE=E5=BC=8F?= =?UTF-8?q?=E6=8C=87=E5=AE=9Acommons-lang3=EF=BC=8C=E4=BB=A5=E4=BE=BF?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=A1=B9=E7=9B=AE=E5=8F=AF=E8=83=BD=E4=BC=9A?= =?UTF-8?q?=E4=BC=98=E5=85=88=E4=BD=BF=E7=94=A8=E6=89=80=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9A=84=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-pay/pom.xml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f93c5dd5c6..ea329828a8 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,7 @@ org.apache.commons commons-lang3 - 3.5 + 3.6 org.slf4j diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 05aa6c5f8f..43302da782 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -30,6 +30,11 @@ provided + + org.apache.commons + commons-lang3 + + ch.qos.logback logback-classic From 2f0e787a701730bf4dbbbaeae6eff2c4a81cbebc Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 19 Sep 2017 10:17:32 +0800 Subject: [PATCH 088/165] =?UTF-8?q?=E6=B8=85=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/bean/WxCpXmlMessage.java | 44 +------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java index 117cf4115b..bbf9ccca68 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil; @@ -175,12 +176,6 @@ protected static WxCpXmlMessage fromXml(InputStream is) { /** * 从加密字符串转换 - * - * @param encryptedXml - * @param wxCpConfigStorage - * @param timestamp - * @param nonce - * @param msgSignature */ public static WxCpXmlMessage fromEncryptedXml( String encryptedXml, @@ -492,41 +487,7 @@ public void setSendLocationInfo(WxCpXmlMessage.SendLocationInfo sendLocationInfo @Override public String toString() { - return "WxCpXmlMessage{" + - "agentId=" + this.agentId + - ", toUserName='" + this.toUserName + '\'' + - ", fromUserName='" + this.fromUserName + '\'' + - ", createTime=" + this.createTime + - ", msgType='" + this.msgType + '\'' + - ", content='" + this.content + '\'' + - ", msgId=" + this.msgId + - ", picUrl='" + this.picUrl + '\'' + - ", mediaId='" + this.mediaId + '\'' + - ", format='" + this.format + '\'' + - ", thumbMediaId='" + this.thumbMediaId + '\'' + - ", locationX=" + this.locationX + - ", locationY=" + this.locationY + - ", scale=" + this.scale + - ", label='" + this.label + '\'' + - ", title='" + this.title + '\'' + - ", description='" + this.description + '\'' + - ", url='" + this.url + '\'' + - ", event='" + this.event + '\'' + - ", eventKey='" + this.eventKey + '\'' + - ", ticket='" + this.ticket + '\'' + - ", latitude=" + this.latitude + - ", longitude=" + this.longitude + - ", precision=" + this.precision + - ", recognition='" + this.recognition + '\'' + - ", status='" + this.status + '\'' + - ", totalCount=" + this.totalCount + - ", filterCount=" + this.filterCount + - ", sentCount=" + this.sentCount + - ", errorCount=" + this.errorCount + - ", scanCodeInfo=" + this.scanCodeInfo + - ", sendPicsInfo=" + this.sendPicsInfo + - ", sendLocationInfo=" + this.sendLocationInfo + - '}'; + return ToStringUtils.toSimpleString(this); } @XStreamAlias("ScanCodeInfo") @@ -567,7 +528,6 @@ public void setScanResult(String scanResult) { @XStreamAlias("SendPicsInfo") public static class SendPicsInfo { - @XStreamAlias("PicList") protected final List picList = new ArrayList<>(); @XStreamAlias("Count") From cacfaf6a0db00d9e66136bf829ab3706c77dc711 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 19 Sep 2017 10:18:04 +0800 Subject: [PATCH 089/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java index 309c4e0e47..3d1c7ff0cc 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java @@ -231,7 +231,7 @@ public void testMaterialNewsList() throws WxErrorException { assertNotNull(wxMpMaterialNewsBatchGetResult); } - @Test(dependsOnMethods = {"testMaterialNewsList"}) + @Test//(dependsOnMethods = {"testMaterialNewsList"}) public void testMaterialFileList() throws WxErrorException { WxMpMaterialFileBatchGetResult wxMpMaterialVoiceBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MATERIAL_VOICE, 0, 20); WxMpMaterialFileBatchGetResult wxMpMaterialVideoBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MATERIAL_VIDEO, 0, 20); From d2fbb51b680bc98840150e66f18938ca925c15a5 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 19 Sep 2017 10:19:30 +0800 Subject: [PATCH 090/165] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E7=B1=BB=E5=B1=9E=E6=80=A7=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/result/WxPayBillBaseResult.java | 30 ++++++++++++------- .../wxpay/bean/result/WxPayBillResult.java | 11 +++++-- .../impl/WxPayServiceAbstractImpl.java | 2 +- .../impl/WxPayServiceAbstractImplTest.java | 24 +++++++++++---- 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java index e469ff4538..de58536445 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java @@ -1,14 +1,22 @@ package com.github.binarywang.wxpay.bean.result; +import me.chanjar.weixin.common.util.ToStringUtils; + import java.io.Serializable; +/** + * 交易时间:2017-04-06 01:00:02 公众账号ID: 商户号: 子商户号:0 设备号:WEB 微信订单号: 商户订单号:2017040519091071873216 用户标识: 交易类型:NATIVE + * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00 + * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60% + */ public class WxPayBillBaseResult implements Serializable { - /* - * 交易时间:2017-04-06 01:00:02 公众账号ID: 商户号: 子商户号:0 设备号:WEB 微信订单号: 商户订单号:2017040519091071873216 用户标识: 交易类型:NATIVE - * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00 - * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60% - */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 2226245109137435453L; + + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + /** * 交易时间 */ @@ -32,7 +40,7 @@ public class WxPayBillBaseResult implements Serializable { /** * 微信订单号 */ - private String transationId; + private String transactionId; /** * 商户订单号 */ @@ -150,12 +158,12 @@ public void setDeviceInfo(String deviceInfo) { this.deviceInfo = deviceInfo; } - public String getTransationId() { - return transationId; + public String getTransactionId() { + return transactionId; } - public void setTransationId(String transationId) { - this.transationId = transationId; + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; } public String getOutTradeNo() { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java index a7fb25bef2..f699a42ba8 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java @@ -1,14 +1,21 @@ package com.github.binarywang.wxpay.bean.result; +import me.chanjar.weixin.common.util.ToStringUtils; + import java.io.Serializable; import java.util.List; public class WxPayBillResult implements Serializable { + private static final long serialVersionUID = -7687458652694204070L; + + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + /** * 对账返回对象 */ - private static final long serialVersionUID = 1L; - private List wxPayBillBaseResultLst; /** * 总交易单数 diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index e77d3e1fc8..ae855d5b5d 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -446,7 +446,7 @@ private WxPayBillResult handleBillInformation(String responseContent) { wxPayBillBaseResult.setMchId(tempStr[k + 2].trim()); wxPayBillBaseResult.setSubMchId(tempStr[k + 3].trim()); wxPayBillBaseResult.setDeviceInfo(tempStr[k + 4].trim()); - wxPayBillBaseResult.setTransationId(tempStr[k + 5].trim()); + wxPayBillBaseResult.setTransactionId(tempStr[k + 5].trim()); wxPayBillBaseResult.setOutTradeNo(tempStr[k + 6].trim()); wxPayBillBaseResult.setOpenId(tempStr[k + 7].trim()); wxPayBillBaseResult.setTradeType(tempStr[k + 8].trim()); diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index 2fc5354424..afea13d8fd 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -15,8 +15,7 @@ import com.google.inject.Inject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; +import org.testng.annotations.*; import java.nio.file.Files; import java.nio.file.Path; @@ -90,11 +89,24 @@ public void testCloseOrder() throws WxPayException { this.logger.info(this.payService.closeOrder("11212121").toString()); } + @DataProvider + public Object[][] billingData() { + return new Object[][]{ +// {"20170831", BillType.ALL, null, "deviceInfo"}, + {"20170831", BillType.SUCCESS, null, "deviceInfo"} + }; + } + + @Test(dataProvider = "billingData") + public void testDownloadBill(String billDate, String billType, + String tarType, String deviceInfo) throws Exception { + WxPayBillResult billResult = this.payService.downloadBill(billDate, billType, tarType, deviceInfo); + assertNotNull(billResult); + this.logger.info(billResult.toString()); + } + @Test - public void testDownloadBill() throws Exception { - WxPayBillResult wxPayBillResult = this.payService.downloadBill("20170831", BillType.ALL, null, "1111111"); - //前一天没有账单记录返回null - assertNotNull(wxPayBillResult); + public void testDownloadBill_withNoParams() throws Exception { //必填字段为空时,抛出异常 this.payService.downloadBill("", "", "", null); } From 7b20300e8e91a0396f1174c997f90f6825744adf Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 19 Sep 2017 10:41:21 +0800 Subject: [PATCH 091/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.8.1.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index ea329828a8..1f31201d3f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.8.0 + 2.8.1.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 68c6130612..eda5d7c19e 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.0 + 2.8.1.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 233a94ecc3..8e546507c0 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.0 + 2.8.1.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 3a2614aa59..9e96cc0709 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.0 + 2.8.1.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 81ec2c01ab..b4a1608b19 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.0 + 2.8.1.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 43302da782..72714499a7 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.8.0 + 2.8.1.BETA 4.0.0 From 9d27c1513605733e39742eba3a0e896c117421e9 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 21 Sep 2017 14:10:09 +0800 Subject: [PATCH 092/165] =?UTF-8?q?pom=E6=B7=BB=E5=8A=A0lombok=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 ++++++ weixin-java-common/pom.xml | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index 1f31201d3f..fab3357623 100644 --- a/pom.xml +++ b/pom.xml @@ -225,6 +225,12 @@ 2.9.0 provided + + org.projectlombok + lombok + 1.16.18 + compile + diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index eda5d7c19e..cce3b4f9fe 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -74,6 +74,10 @@ com.google.guava guava + + org.projectlombok + lombok + ch.qos.logback From 13ca47c91be279cb8c7002fd823d2819eed7bfba Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 21 Sep 2017 15:07:04 +0800 Subject: [PATCH 093/165] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E5=8C=96=E9=83=A8=E5=88=86javadoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/chanjar/weixin/common/util/BeanUtils.java | 3 ++- .../java/me/chanjar/weixin/common/util/ToStringUtils.java | 3 ++- .../me/chanjar/weixin/common/util/crypto/SHA1Test.java | 2 +- .../me/chanjar/weixin/cp/api/impl/WxCpServiceImpl.java | 3 ++- .../weixin/mp/bean/datacube/WxDataCubeArticleResult.java | 6 +++--- .../weixin/mp/bean/datacube/WxDataCubeArticleTotal.java | 6 +++--- .../mp/bean/datacube/WxDataCubeArticleTotalDetail.java | 7 ++++--- .../weixin/mp/bean/datacube/WxDataCubeBaseResult.java | 2 +- .../weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java | 6 +++--- .../weixin/mp/bean/datacube/WxDataCubeMsgResult.java | 6 +++--- 10 files changed, 24 insertions(+), 20 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java index 630821e954..d74f1d8954 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java @@ -20,8 +20,9 @@ *
      * bean操作的一些工具类
      * Created by Binary Wang on 2016-10-21.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author binarywang(Binary Wang) */ public class BeanUtils { private static Logger log = LoggerFactory.getLogger(BeanUtils.class); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/ToStringUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/ToStringUtils.java index 333e484a8f..a0b069d166 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/ToStringUtils.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/ToStringUtils.java @@ -8,8 +8,9 @@ *
      * 自定义的ToString方法,用于产生去掉空值属性的字符串
      * Created by Binary Wang on 2016-10-27.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ public class ToStringUtils { public static final ToStringStyle THE_STYLE = new SimpleMultiLineToStringStyle(); diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/SHA1Test.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/SHA1Test.java index 323fc7060e..ffdb613128 100644 --- a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/SHA1Test.java +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/crypto/SHA1Test.java @@ -10,7 +10,7 @@ * Created by BinaryWang on 2017/6/10. *
    * - * @author binarywang(Binary Wang) + * @author Binary Wang */ public class SHA1Test { @Test diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceImpl.java index ff8e149c77..a7538c6ead 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceImpl.java @@ -4,8 +4,9 @@ *
      *  默认接口实现类,使用apache httpclient实现
      * Created by Binary Wang on 2017-5-27.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ public class WxCpServiceImpl extends WxCpServiceApacheHttpClientImpl { } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java index e6518064bb..8b14e055a9 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java @@ -1,6 +1,5 @@ package me.chanjar.weixin.mp.bean.datacube; -import com.google.gson.JsonParser; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -9,9 +8,10 @@ /** * 图文分析数据接口返回结果对象 + *

    + * Created by Binary Wang on 2016/8/24. * - * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016/8/24. + * @author Binary Wang */ public class WxDataCubeArticleResult extends WxDataCubeBaseResult { private static final long serialVersionUID = -9222452497954511765L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java index a059c45f3b..7cdddad4de 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java @@ -1,6 +1,5 @@ package me.chanjar.weixin.mp.bean.datacube; -import com.google.gson.JsonParser; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -9,9 +8,10 @@ /** * 图文分析数据接口返回结果对象 + *

    + * Created by Binary Wang on 2016/8/24. * - * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016/8/24. + * @author Binary Wang */ public class WxDataCubeArticleTotal extends WxDataCubeBaseResult { private static final long serialVersionUID = -7634365687303052699L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java index 86897427d1..ebd4b894bf 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java @@ -6,11 +6,12 @@ /** * 获取图文群发总数据接口(getarticletotal)中的详细字段 + *

    + * Created by Binary Wang on 2016/8/24. * - * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016/8/24. + * @author Binary Wang */ -public class WxDataCubeArticleTotalDetail implements Serializable{ +public class WxDataCubeArticleTotalDetail implements Serializable { private static final long serialVersionUID = -5136169129771430052L; /** diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java index cfc8636143..5b613ebbfb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java @@ -12,7 +12,7 @@ * Created by Binary Wang on 2016/8/25. *

    * - * @author binarywang(Binary Wang) + * @author Binary Wang */ public abstract class WxDataCubeBaseResult implements Serializable { private static final long serialVersionUID = 8780389911053297600L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java index fce9fc2018..9ab3adad19 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java @@ -1,6 +1,5 @@ package me.chanjar.weixin.mp.bean.datacube; -import com.google.gson.JsonParser; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -9,9 +8,10 @@ /** * 接口分析数据接口返回结果对象 + *

    + * Created by Binary Wang on 2016/8/30. * - * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016/8/30. + * @author Binary Wang */ public class WxDataCubeInterfaceResult extends WxDataCubeBaseResult { private static final long serialVersionUID = 597734329161281398L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java index 4800c9c422..7b8aa0f162 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java @@ -1,6 +1,5 @@ package me.chanjar.weixin.mp.bean.datacube; -import com.google.gson.JsonParser; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -9,9 +8,10 @@ /** * 消息分析数据接口返回结果对象 + *

    + * Created by Binary Wang on 2016/8/29. * - * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016/8/29. + * @author Binary Wang */ public class WxDataCubeMsgResult extends WxDataCubeBaseResult { private static final long serialVersionUID = 6932121822150573659L; From f86b59438629925d035420a1954c1f0fce499a20 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 21 Sep 2017 15:07:31 +0800 Subject: [PATCH 094/165] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E5=8C=96=E9=83=A8=E5=88=86javadoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/chanjar/weixin/mp/api/WxMpStoreService.java | 5 +++-- .../me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java | 2 +- .../java/me/chanjar/weixin/mp/api/WxMpUserTagService.java | 2 +- .../me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java | 3 ++- .../weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java | 3 ++- .../chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java | 5 +++-- .../weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java | 3 ++- .../main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java | 3 ++- .../me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java | 3 ++- .../me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java | 2 +- .../chanjar/weixin/mp/bean/store/WxMpStoreListResult.java | 2 +- .../java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java | 2 +- .../main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java | 2 +- .../me/chanjar/weixin/mp/bean/template/WxMpTemplate.java | 2 +- .../me/chanjar/weixin/mp/constant/WxMpEventConstants.java | 3 ++- .../weixin/mp/api/impl/WxMpStoreServiceImplTest.java | 7 ++++--- .../weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java | 3 ++- .../weixin/mp/api/impl/WxMpUserTagServiceImplTest.java | 5 +++-- .../weixin/mp/bean/template/WxMpTemplateMessageTest.java | 3 ++- 19 files changed, 36 insertions(+), 24 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java index 2634c3f36c..d996759b00 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java @@ -9,9 +9,10 @@ /** * 门店管理的相关接口代码 + *

    + * Created by Binary Wang on 2016-09-23. * - * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016-09-23. + * @author Binary Wang */ public interface WxMpStoreService { /** diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java index f9203c1644..494813ecae 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java @@ -13,7 +13,7 @@ * http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN * Created by Binary Wang on 2016-10-14. * @author miller.lin - * @author binarywang(Binary Wang) + * @author Binary Wang *

    */ public interface WxMpTemplateMsgService { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java index 4a666eff1b..ce218922c3 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserTagService.java @@ -10,7 +10,7 @@ * 用户标签管理相关接口 * Created by Binary Wang on 2016/9/2. * - * @author binarywang(Binary Wang) + * @author Binary Wang */ public interface WxMpUserTagService { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java index 4d2017dd63..79317f99fc 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java @@ -4,8 +4,9 @@ *
      * 默认接口实现类,使用apache httpclient实现
      * Created by Binary Wang on 2017-5-27.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ public class WxMpServiceImpl extends WxMpServiceApacheHttpClientImpl { } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java index 82ce829cdd..7b73f102d6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java @@ -15,8 +15,9 @@ /** *
      * Created by Binary Wang on 2016-10-14.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { public static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/template"; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java index 99f271065c..e5357b1ed7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java @@ -16,8 +16,9 @@ import java.util.List; /** - * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016/9/2. + * Created by Binary Wang on 2016/9/2. + * + * @author Binary Wang */ public class WxMpUserTagServiceImpl implements WxMpUserTagService { private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/tags"; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java index 295a782696..1202f9ab9b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java @@ -9,8 +9,9 @@ /** *
      * Created by Binary Wang on 2016-11-25.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ public class WxMpGetSelfMenuInfoResult implements Serializable { private static final long serialVersionUID = -5612495636936835166L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java index 5e93d7e0d6..8ab3cc8937 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java @@ -13,8 +13,9 @@ *
      *   公众号专用的菜单类,可能包含个性化菜单
      * Created by Binary Wang on 2017-1-17.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ public class WxMpMenu implements Serializable { private static final long serialVersionUID = -5794350513426702252L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java index c278bd4c1a..f288ab7b7b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java @@ -10,8 +10,9 @@ /** *
      * Created by Binary Wang on 2016-11-25.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ public class WxMpSelfMenuInfo implements Serializable { private static final long serialVersionUID = -81203094124202901L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java index 155942a79b..2c098b5347 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java @@ -17,7 +17,7 @@ * Created by Binary Wang on 2016-09-23. *
    * - * @author binarywang(Binary Wang) + * @author Binary Wang */ public class WxMpStoreBaseInfo implements Serializable { private static final long serialVersionUID = 829577606838118218L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java index 6ebb58901f..3eac16add2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java @@ -13,7 +13,7 @@ * Created by Binary Wang on 2016-09-27. *
    * - * @author binarywang(Binary Wang) + * @author Binary Wang */ public class WxMpStoreListResult implements Serializable { private static final long serialVersionUID = 5388907559949538663L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java index a1bd50660e..14f2f0b296 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java @@ -13,7 +13,7 @@ * Created by Binary Wang on 2016-09-19. *
    * - * @author binarywang(Binary Wang) + * @author Binary Wang */ public class WxTagListUser implements Serializable { private static final long serialVersionUID = -4551768374200676112L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java index a06a1ce40a..d39031cd14 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java @@ -14,7 +14,7 @@ * Created by Binary Wang on 2016/9/2. *
    * - * @author binarywang(Binary Wang) + * @author Binary Wang */ public class WxUserTag implements Serializable { private static final long serialVersionUID = -7722428695667031252L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java index 079210775a..5bdee4370d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java @@ -15,7 +15,7 @@ * Created by Binary Wang on 2016-10-17. *
    * - * @author binarywang(Binary Wang) + * @author Binary Wang */ public class WxMpTemplate implements Serializable { private static final JsonParser JSON_PARSER = new JsonParser(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/constant/WxMpEventConstants.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/constant/WxMpEventConstants.java index 503367cfd7..df1790e3da 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/constant/WxMpEventConstants.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/constant/WxMpEventConstants.java @@ -4,8 +4,9 @@ *
      * 微信公众号事件的相关常量
      * Created by Binary Wang on 2017-5-10.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ public class WxMpEventConstants { /** diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java index ed5845088b..c0703028dc 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java @@ -12,11 +12,12 @@ import java.math.BigDecimal; import java.util.List; -import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.*; /** - * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016-09-23. + * Created by Binary Wang on 2016-09-23. + * + * @author Binary Wang */ @Test @Guice(modules = ApiTestModule.class) diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java index 2c348702ca..96cab2c1ae 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java @@ -20,8 +20,9 @@ /** *
      * Created by Binary Wang on 2016-10-14.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ @Guice(modules = ApiTestModule.class) public class WxMpTemplateMsgServiceImplTest { diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java index cc8676d477..1a96ba510a 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImplTest.java @@ -12,8 +12,9 @@ import java.util.List; /** - * @author binarywang(Binary Wang) - * Created by Binary Wang on 2016/9/2. + * Created by Binary Wang on 2016/9/2. + * + * @author Binary Wang */ @Test @Guice(modules = ApiTestModule.class) diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java index ac415ff454..3bb804d5c8 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessageTest.java @@ -7,8 +7,9 @@ /** *
      * Created by Binary Wang on 2017-3-30.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ public class WxMpTemplateMessageTest { @Test From aa2ca201178796c76dfb3becddf94c8f68fb3232 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 21 Sep 2017 15:09:17 +0800 Subject: [PATCH 095/165] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E5=8C=96=E9=83=A8=E5=88=86javadoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/service/impl/WxPayServiceApacheHttpImpl.java | 2 +- .../binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java index 1b3284f95f..653c1a8d6e 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java @@ -27,7 +27,7 @@ * Created by Binary Wang on 2016/7/28. *
    * - * @author binarywang (https://github.com/binarywang) + * @author Binary Wang */ public class WxPayServiceApacheHttpImpl extends WxPayServiceAbstractImpl { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java index bbe024a309..b342c5cda8 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java @@ -18,7 +18,7 @@ * 微信支付请求实现类,jodd-http实现 * Created by Binary Wang on 2016/7/28. * - * @author binarywang (https://github.com/binarywang) + * @author Binary Wang */ public class WxPayServiceJoddHttpImpl extends WxPayServiceAbstractImpl { From d594656acc4593234c6feb138ec8fe410d0bbe55 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 21 Sep 2017 15:10:12 +0800 Subject: [PATCH 096/165] =?UTF-8?q?pay=E6=A8=A1=E5=9D=97=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?lombok=E6=94=B9=E9=80=A0=EF=BC=8C=E7=B2=BE=E7=AE=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binarywang/wxpay/bean/WxPayApiData.java | 37 +- .../coupon/WxPayCouponInfoQueryRequest.java | 171 +-------- .../coupon/WxPayCouponInfoQueryResult.java | 133 +------ .../bean/coupon/WxPayCouponSendRequest.java | 189 +--------- .../bean/coupon/WxPayCouponSendResult.java | 77 +--- .../coupon/WxPayCouponStockQueryRequest.java | 140 +------ .../coupon/WxPayCouponStockQueryResult.java | 111 +----- .../bean/notify/WxPayNotifyResponse.java | 33 +- .../bean/notify/WxPayOrderNotifyCoupon.java | 33 +- .../bean/notify/WxPayOrderNotifyResult.java | 158 +------- .../bean/notify/WxPayRefundNotifyResult.java | 129 +------ .../WxScanPayNotifyResult.java | 17 +- .../wxpay/bean/order/WxPayAppOrderResult.java | 130 +------ .../wxpay/bean/order/WxPayMpOrderResult.java | 116 +----- .../bean/order/WxPayNativeOrderResult.java | 40 +- .../bean/request/WxEntPayQueryRequest.java | 16 +- .../wxpay/bean/request/WxEntPayRequest.java | 198 +--------- .../request/WxPayAuthcode2OpenidRequest.java | 24 +- .../wxpay/bean/request/WxPayBaseRequest.java | 50 +-- .../request/WxPayDownloadBillRequest.java | 62 +--- .../bean/request/WxPayMicropayRequest.java | 244 +------------ .../bean/request/WxPayOrderCloseRequest.java | 17 +- .../bean/request/WxPayOrderQueryRequest.java | 24 +- .../request/WxPayOrderReverseRequest.java | 124 +------ .../request/WxPayQueryCommentRequest.java | 38 +- .../request/WxPayRedpackQueryRequest.java | 25 +- .../bean/request/WxPayRefundQueryRequest.java | 70 +--- .../bean/request/WxPayRefundRequest.java | 219 +---------- .../bean/request/WxPayReportRequest.java | 117 +----- .../bean/request/WxPaySendRedpackRequest.java | 111 +----- .../bean/request/WxPayShorturlRequest.java | 24 +- .../request/WxPayUnifiedOrderRequest.java | 342 +----------------- .../bean/result/WxEntPayQueryResult.java | 79 +--- .../wxpay/bean/result/WxEntPayResult.java | 47 +-- .../result/WxPayAuthcode2OpenidResult.java | 23 +- .../wxpay/bean/result/WxPayBaseResult.java | 101 +----- .../bean/result/WxPayBillBaseResult.java | 200 +--------- .../wxpay/bean/result/WxPayBillResult.java | 53 +-- .../wxpay/bean/result/WxPayCommonResult.java | 3 +- .../bean/result/WxPayMicropayResult.java | 128 +------ .../bean/result/WxPayOrderCloseResult.java | 16 +- .../bean/result/WxPayOrderQueryResult.java | 191 +--------- .../bean/result/WxPayOrderReverseResult.java | 16 +- .../bean/result/WxPayRedpackQueryResult.java | 153 +------- .../bean/result/WxPayRefundQueryResult.java | 191 +--------- .../wxpay/bean/result/WxPayRefundResult.java | 118 +----- .../result/WxPaySandboxSignKeyResult.java | 13 +- .../bean/result/WxPaySendRedpackResult.java | 53 +-- .../bean/result/WxPayShorturlResult.java | 16 +- .../bean/result/WxPayUnifiedOrderResult.java | 37 +- 50 files changed, 346 insertions(+), 4311 deletions(-) rename weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/{result => notify}/WxScanPayNotifyResult.java (56%) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayApiData.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayApiData.java index ab1dec718c..db9a8833db 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayApiData.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayApiData.java @@ -1,5 +1,8 @@ package com.github.binarywang.wxpay.bean; +import lombok.Data; +import lombok.NoArgsConstructor; + /** *
      * 微信支付接口请求数据封装对象
    @@ -8,6 +11,8 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@NoArgsConstructor
     public class WxPayApiData {
       /**
        * 接口请求地址
    @@ -42,38 +47,6 @@ public WxPayApiData(String url, String requestData, String responseData, String
         this.exceptionMsg = exceptionMsg;
       }
     
    -  public String getUrl() {
    -    return this.url;
    -  }
    -
    -  public void setUrl(String url) {
    -    this.url = url;
    -  }
    -
    -  public String getRequestData() {
    -    return this.requestData;
    -  }
    -
    -  public void setRequestData(String requestData) {
    -    this.requestData = requestData;
    -  }
    -
    -  public String getResponseData() {
    -    return this.responseData;
    -  }
    -
    -  public void setResponseData(String responseData) {
    -    this.responseData = responseData;
    -  }
    -
    -  public String getExceptionMsg() {
    -    return this.exceptionMsg;
    -  }
    -
    -  public void setExceptionMsg(String exceptionMsg) {
    -    this.exceptionMsg = exceptionMsg;
    -  }
    -
       @Override
       public String toString() {
         if (this.exceptionMsg != null) {
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java
    index 3d83d0a6c6..54d16bd96a 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryRequest.java
    @@ -2,6 +2,7 @@
     
     import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     import me.chanjar.weixin.common.annotation.Required;
     
     /**
    @@ -12,8 +13,13 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@Builder(builderMethodName = "newBuilder")
    +@NoArgsConstructor
    +@AllArgsConstructor
     @XStreamAlias("xml")
    -public class WxPayCouponInfoQueryRequest  extends WxPayBaseRequest {
    +public class WxPayCouponInfoQueryRequest extends WxPayBaseRequest {
       /**
        * 
        * 字段名:代金券id
    @@ -108,173 +114,10 @@ public class WxPayCouponInfoQueryRequest  extends WxPayBaseRequest {
       @XStreamAlias("type")
       private String type;
     
    -  private WxPayCouponInfoQueryRequest(Builder builder) {
    -    setAppid(builder.appid);
    -    setMchId(builder.mchId);
    -    setSubAppId(builder.subAppId);
    -    setSubMchId(builder.subMchId);
    -    setNonceStr(builder.nonceStr);
    -    setSign(builder.sign);
    -    setCouponId(builder.couponId);
    -    setStockId(builder.stockId);
    -    setOpenid(builder.openid);
    -    setOpUserId(builder.opUserId);
    -    setDeviceInfo(builder.deviceInfo);
    -    setVersion(builder.version);
    -    setType(builder.type);
    -  }
    -
    -  public static Builder newBuilder() {
    -    return new Builder();
    -  }
    -
    -  public String getCouponId() {
    -    return this.couponId;
    -  }
    -
    -  public void setCouponId(String couponId) {
    -    this.couponId = couponId;
    -  }
    -
    -  public String getStockId() {
    -    return this.stockId;
    -  }
    -
    -  public void setStockId(String stockId) {
    -    this.stockId = stockId;
    -  }
    -
    -  public String getOpenid() {
    -    return this.openid;
    -  }
    -
    -  public void setOpenid(String openid) {
    -    this.openid = openid;
    -  }
    -
    -  public String getOpUserId() {
    -    return this.opUserId;
    -  }
    -
    -  public void setOpUserId(String opUserId) {
    -    this.opUserId = opUserId;
    -  }
    -
    -  public String getDeviceInfo() {
    -    return this.deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getVersion() {
    -    return this.version;
    -  }
    -
    -  public void setVersion(String version) {
    -    this.version = version;
    -  }
    -
    -  public String getType() {
    -    return this.type;
    -  }
    -
    -  public void setType(String type) {
    -    this.type = type;
    -  }
     
       @Override
       protected void checkConstraints() {
         //do nothing
       }
     
    -
    -  public static final class Builder {
    -    private String appid;
    -    private String mchId;
    -    private String subAppId;
    -    private String subMchId;
    -    private String nonceStr;
    -    private String sign;
    -    private String couponId;
    -    private String stockId;
    -    private String openid;
    -    private String opUserId;
    -    private String deviceInfo;
    -    private String version;
    -    private String type;
    -
    -    private Builder() {
    -    }
    -
    -    public Builder appid(String appid) {
    -      this.appid = appid;
    -      return this;
    -    }
    -
    -    public Builder mchId(String mchId) {
    -      this.mchId = mchId;
    -      return this;
    -    }
    -
    -    public Builder subAppId(String subAppId) {
    -      this.subAppId = subAppId;
    -      return this;
    -    }
    -
    -    public Builder subMchId(String subMchId) {
    -      this.subMchId = subMchId;
    -      return this;
    -    }
    -
    -    public Builder nonceStr(String nonceStr) {
    -      this.nonceStr = nonceStr;
    -      return this;
    -    }
    -
    -    public Builder sign(String sign) {
    -      this.sign = sign;
    -      return this;
    -    }
    -
    -    public Builder couponId(String couponId) {
    -      this.couponId = couponId;
    -      return this;
    -    }
    -
    -    public Builder stockId(String stockId) {
    -      this.stockId = stockId;
    -      return this;
    -    }
    -
    -    public Builder openid(String openid) {
    -      this.openid = openid;
    -      return this;
    -    }
    -
    -    public Builder opUserId(String opUserId) {
    -      this.opUserId = opUserId;
    -      return this;
    -    }
    -
    -    public Builder deviceInfo(String deviceInfo) {
    -      this.deviceInfo = deviceInfo;
    -      return this;
    -    }
    -
    -    public Builder version(String version) {
    -      this.version = version;
    -      return this;
    -    }
    -
    -    public Builder type(String type) {
    -      this.type = type;
    -      return this;
    -    }
    -
    -    public WxPayCouponInfoQueryRequest build() {
    -      return new WxPayCouponInfoQueryRequest(this);
    -    }
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java
    index bec1c9e10a..ad9aceb45e 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java
    @@ -2,6 +2,9 @@
     
     import com.github.binarywang.wxpay.bean.result.WxPayBaseResult;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     
     /**
      * 
    @@ -11,6 +14,9 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@NoArgsConstructor
     @XStreamAlias("xml")
     public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
       /**
    @@ -221,131 +227,4 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
       @XStreamAlias("is_partial_use")
       private String isPartialUse;
     
    -  public String getDeviceInfo() {
    -    return this.deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getCouponStockId() {
    -    return this.couponStockId;
    -  }
    -
    -  public void setCouponStockId(String couponStockId) {
    -    this.couponStockId = couponStockId;
    -  }
    -
    -  public String getCouponId() {
    -    return this.couponId;
    -  }
    -
    -  public void setCouponId(String couponId) {
    -    this.couponId = couponId;
    -  }
    -
    -  public Integer getCouponValue() {
    -    return this.couponValue;
    -  }
    -
    -  public void setCouponValue(Integer couponValue) {
    -    this.couponValue = couponValue;
    -  }
    -
    -  public Integer getCouponMininum() {
    -    return this.couponMininum;
    -  }
    -
    -  public void setCouponMininum(Integer couponMininum) {
    -    this.couponMininum = couponMininum;
    -  }
    -
    -  public String getCouponName() {
    -    return this.couponName;
    -  }
    -
    -  public void setCouponName(String couponName) {
    -    this.couponName = couponName;
    -  }
    -
    -  public Integer getCouponState() {
    -    return this.couponState;
    -  }
    -
    -  public void setCouponState(Integer couponState) {
    -    this.couponState = couponState;
    -  }
    -
    -  public String getCouponDesc() {
    -    return this.couponDesc;
    -  }
    -
    -  public void setCouponDesc(String couponDesc) {
    -    this.couponDesc = couponDesc;
    -  }
    -
    -  public Integer getCouponUseValue() {
    -    return this.couponUseValue;
    -  }
    -
    -  public void setCouponUseValue(Integer couponUseValue) {
    -    this.couponUseValue = couponUseValue;
    -  }
    -
    -  public Integer getCouponRemainValue() {
    -    return this.couponRemainValue;
    -  }
    -
    -  public void setCouponRemainValue(Integer couponRemainValue) {
    -    this.couponRemainValue = couponRemainValue;
    -  }
    -
    -  public String getBeginTime() {
    -    return this.beginTime;
    -  }
    -
    -  public void setBeginTime(String beginTime) {
    -    this.beginTime = beginTime;
    -  }
    -
    -  public String getEndTime() {
    -    return this.endTime;
    -  }
    -
    -  public void setEndTime(String endTime) {
    -    this.endTime = endTime;
    -  }
    -
    -  public String getSendTime() {
    -    return this.sendTime;
    -  }
    -
    -  public void setSendTime(String sendTime) {
    -    this.sendTime = sendTime;
    -  }
    -
    -  public String getConsumerMchId() {
    -    return this.consumerMchId;
    -  }
    -
    -  public void setConsumerMchId(String consumerMchId) {
    -    this.consumerMchId = consumerMchId;
    -  }
    -
    -  public String getSendSource() {
    -    return this.sendSource;
    -  }
    -
    -  public void setSendSource(String sendSource) {
    -    this.sendSource = sendSource;
    -  }
    -
    -  public String getIsPartialUse() {
    -    return this.isPartialUse;
    -  }
    -
    -  public void setIsPartialUse(String isPartialUse) {
    -    this.isPartialUse = isPartialUse;
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java
    index 9a98fd64a2..63b891d8bc 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendRequest.java
    @@ -2,6 +2,7 @@
     
     import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     import me.chanjar.weixin.common.annotation.Required;
     
     /**
    @@ -12,6 +13,12 @@
      *
      * @author Binary Wang
      */
    +
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@Builder(builderMethodName = "newBuilder")
    +@NoArgsConstructor
    +@AllArgsConstructor
     @XStreamAlias("xml")
     public class WxPayCouponSendRequest extends WxPayBaseRequest {
       /**
    @@ -122,190 +129,8 @@ public class WxPayCouponSendRequest extends WxPayBaseRequest {
       @XStreamAlias("type")
       private String type;
     
    -  public WxPayCouponSendRequest() {
    -  }
    -
    -  private WxPayCouponSendRequest(Builder builder) {
    -    setAppid(builder.appid);
    -    setMchId(builder.mchId);
    -    setSubAppId(builder.subAppId);
    -    setSubMchId(builder.subMchId);
    -    setNonceStr(builder.nonceStr);
    -    setSign(builder.sign);
    -    setCouponStockId(builder.couponStockId);
    -    setOpenidCount(builder.openidCount);
    -    setPartnerTradeNo(builder.partnerTradeNo);
    -    setOpenid(builder.openid);
    -    setOpUserId(builder.opUserId);
    -    setDeviceInfo(builder.deviceInfo);
    -    setVersion(builder.version);
    -    setType(builder.type);
    -  }
    -
    -  public static Builder newBuilder() {
    -    return new Builder();
    -  }
    -
    -  public String getCouponStockId() {
    -    return this.couponStockId;
    -  }
    -
    -  public void setCouponStockId(String couponStockId) {
    -    this.couponStockId = couponStockId;
    -  }
    -
    -  public Integer getOpenidCount() {
    -    return this.openidCount;
    -  }
    -
    -  public void setOpenidCount(Integer openidCount) {
    -    this.openidCount = openidCount;
    -  }
    -
    -  public String getPartnerTradeNo() {
    -    return this.partnerTradeNo;
    -  }
    -
    -  public void setPartnerTradeNo(String partnerTradeNo) {
    -    this.partnerTradeNo = partnerTradeNo;
    -  }
    -
    -  public String getOpenid() {
    -    return this.openid;
    -  }
    -
    -  public void setOpenid(String openid) {
    -    this.openid = openid;
    -  }
    -
    -  public String getOpUserId() {
    -    return this.opUserId;
    -  }
    -
    -  public void setOpUserId(String opUserId) {
    -    this.opUserId = opUserId;
    -  }
    -
    -  public String getDeviceInfo() {
    -    return this.deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getVersion() {
    -    return this.version;
    -  }
    -
    -  public void setVersion(String version) {
    -    this.version = version;
    -  }
    -
    -  public String getType() {
    -    return this.type;
    -  }
    -
    -  public void setType(String type) {
    -    this.type = type;
    -  }
    -
       @Override
       protected void checkConstraints() {
         //do nothing
       }
    -
    -  public static final class Builder {
    -    private String appid;
    -    private String mchId;
    -    private String subAppId;
    -    private String subMchId;
    -    private String nonceStr;
    -    private String sign;
    -    private String couponStockId;
    -    private Integer openidCount;
    -    private String partnerTradeNo;
    -    private String openid;
    -    private String opUserId;
    -    private String deviceInfo;
    -    private String version;
    -    private String type;
    -
    -    private Builder() {
    -    }
    -
    -    public Builder appid(String appid) {
    -      this.appid = appid;
    -      return this;
    -    }
    -
    -    public Builder mchId(String mchId) {
    -      this.mchId = mchId;
    -      return this;
    -    }
    -
    -    public Builder subAppId(String subAppId) {
    -      this.subAppId = subAppId;
    -      return this;
    -    }
    -
    -    public Builder subMchId(String subMchId) {
    -      this.subMchId = subMchId;
    -      return this;
    -    }
    -
    -    public Builder nonceStr(String nonceStr) {
    -      this.nonceStr = nonceStr;
    -      return this;
    -    }
    -
    -    public Builder sign(String sign) {
    -      this.sign = sign;
    -      return this;
    -    }
    -
    -    public Builder couponStockId(String couponStockId) {
    -      this.couponStockId = couponStockId;
    -      return this;
    -    }
    -
    -    public Builder openidCount(Integer openidCount) {
    -      this.openidCount = openidCount;
    -      return this;
    -    }
    -
    -    public Builder partnerTradeNo(String partnerTradeNo) {
    -      this.partnerTradeNo = partnerTradeNo;
    -      return this;
    -    }
    -
    -    public Builder openid(String openid) {
    -      this.openid = openid;
    -      return this;
    -    }
    -
    -    public Builder opUserId(String opUserId) {
    -      this.opUserId = opUserId;
    -      return this;
    -    }
    -
    -    public Builder deviceInfo(String deviceInfo) {
    -      this.deviceInfo = deviceInfo;
    -      return this;
    -    }
    -
    -    public Builder version(String version) {
    -      this.version = version;
    -      return this;
    -    }
    -
    -    public Builder type(String type) {
    -      this.type = type;
    -      return this;
    -    }
    -
    -    public WxPayCouponSendRequest build() {
    -      return new WxPayCouponSendRequest(this);
    -    }
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java
    index 1c562adae2..fe26342e7b 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponSendResult.java
    @@ -2,6 +2,9 @@
     
     import com.github.binarywang.wxpay.bean.result.WxPayBaseResult;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     
     /**
      * 
    @@ -11,6 +14,9 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@NoArgsConstructor
     @XStreamAlias("xml")
     public class WxPayCouponSendResult extends WxPayBaseResult {
       /**
    @@ -130,75 +136,4 @@ public class WxPayCouponSendResult extends WxPayBaseResult {
       @XStreamAlias("ret_msg")
       private String retMsg;
     
    -  public String getDeviceInfo() {
    -    return this.deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getCouponStockId() {
    -    return this.couponStockId;
    -  }
    -
    -  public void setCouponStockId(String couponStockId) {
    -    this.couponStockId = couponStockId;
    -  }
    -
    -  public Integer getRespCount() {
    -    return this.respCount;
    -  }
    -
    -  public void setRespCount(Integer respCount) {
    -    this.respCount = respCount;
    -  }
    -
    -  public Integer getSuccessCount() {
    -    return this.successCount;
    -  }
    -
    -  public void setSuccessCount(Integer successCount) {
    -    this.successCount = successCount;
    -  }
    -
    -  public Integer getFailedCount() {
    -    return this.failedCount;
    -  }
    -
    -  public void setFailedCount(Integer failedCount) {
    -    this.failedCount = failedCount;
    -  }
    -
    -  public String getOpenid() {
    -    return this.openid;
    -  }
    -
    -  public void setOpenid(String openid) {
    -    this.openid = openid;
    -  }
    -
    -  public String getRetCode() {
    -    return this.retCode;
    -  }
    -
    -  public void setRetCode(String retCode) {
    -    this.retCode = retCode;
    -  }
    -
    -  public String getCouponId() {
    -    return this.couponId;
    -  }
    -
    -  public void setCouponId(String couponId) {
    -    this.couponId = couponId;
    -  }
    -
    -  public String getRetMsg() {
    -    return this.retMsg;
    -  }
    -
    -  public void setRetMsg(String retMsg) {
    -    this.retMsg = retMsg;
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java
    index 24cec5523c..c7b812d857 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryRequest.java
    @@ -2,6 +2,7 @@
     
     import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     import me.chanjar.weixin.common.annotation.Required;
     
     /**
    @@ -12,6 +13,12 @@
      *
      * @author Binary Wang
      */
    +
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@Builder(builderMethodName = "newBuilder")
    +@NoArgsConstructor
    +@AllArgsConstructor
     @XStreamAlias("xml")
     public class WxPayCouponStockQueryRequest extends WxPayBaseRequest {
       /**
    @@ -80,142 +87,9 @@ public class WxPayCouponStockQueryRequest extends WxPayBaseRequest {
       @XStreamAlias("type")
       private String type;
     
    -  private WxPayCouponStockQueryRequest(Builder builder) {
    -    setAppid(builder.appid);
    -    setMchId(builder.mchId);
    -    setSubAppId(builder.subAppId);
    -    setSubMchId(builder.subMchId);
    -    setNonceStr(builder.nonceStr);
    -    setSign(builder.sign);
    -    setCouponStockId(builder.couponStockId);
    -    setOpUserId(builder.opUserId);
    -    setDeviceInfo(builder.deviceInfo);
    -    setVersion(builder.version);
    -    setType(builder.type);
    -  }
    -
    -  public static Builder newBuilder() {
    -    return new Builder();
    -  }
    -
    -  public String getCouponStockId() {
    -    return this.couponStockId;
    -  }
    -
    -  public void setCouponStockId(String couponStockId) {
    -    this.couponStockId = couponStockId;
    -  }
    -
    -  public String getOpUserId() {
    -    return this.opUserId;
    -  }
    -
    -  public void setOpUserId(String opUserId) {
    -    this.opUserId = opUserId;
    -  }
    -
    -  public String getDeviceInfo() {
    -    return this.deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getVersion() {
    -    return this.version;
    -  }
    -
    -  public void setVersion(String version) {
    -    this.version = version;
    -  }
    -
    -  public String getType() {
    -    return this.type;
    -  }
    -
    -  public void setType(String type) {
    -    this.type = type;
    -  }
    -
       @Override
       protected void checkConstraints() {
         //do nothing
       }
     
    -  public static final class Builder {
    -    private String appid;
    -    private String mchId;
    -    private String subAppId;
    -    private String subMchId;
    -    private String nonceStr;
    -    private String sign;
    -    private String couponStockId;
    -    private String opUserId;
    -    private String deviceInfo;
    -    private String version;
    -    private String type;
    -
    -    private Builder() {
    -    }
    -
    -    public Builder appid(String appid) {
    -      this.appid = appid;
    -      return this;
    -    }
    -
    -    public Builder mchId(String mchId) {
    -      this.mchId = mchId;
    -      return this;
    -    }
    -
    -    public Builder subAppId(String subAppId) {
    -      this.subAppId = subAppId;
    -      return this;
    -    }
    -
    -    public Builder subMchId(String subMchId) {
    -      this.subMchId = subMchId;
    -      return this;
    -    }
    -
    -    public Builder nonceStr(String nonceStr) {
    -      this.nonceStr = nonceStr;
    -      return this;
    -    }
    -
    -    public Builder sign(String sign) {
    -      this.sign = sign;
    -      return this;
    -    }
    -
    -    public Builder couponStockId(String couponStockId) {
    -      this.couponStockId = couponStockId;
    -      return this;
    -    }
    -
    -    public Builder opUserId(String opUserId) {
    -      this.opUserId = opUserId;
    -      return this;
    -    }
    -
    -    public Builder deviceInfo(String deviceInfo) {
    -      this.deviceInfo = deviceInfo;
    -      return this;
    -    }
    -
    -    public Builder version(String version) {
    -      this.version = version;
    -      return this;
    -    }
    -
    -    public Builder type(String type) {
    -      this.type = type;
    -      return this;
    -    }
    -
    -    public WxPayCouponStockQueryRequest build() {
    -      return new WxPayCouponStockQueryRequest(this);
    -    }
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java
    index 065c3f606d..2f97618e1d 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponStockQueryResult.java
    @@ -2,6 +2,10 @@
     
     import com.github.binarywang.wxpay.bean.result.WxPayBaseResult;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.AllArgsConstructor;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     
     /**
      * 
    @@ -11,6 +15,10 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@NoArgsConstructor
    +@AllArgsConstructor
     @XStreamAlias("xml")
     public class WxPayCouponStockQueryResult extends WxPayBaseResult {
       /**
    @@ -182,107 +190,4 @@ public class WxPayCouponStockQueryResult extends WxPayBaseResult {
       @XStreamAlias("coupon_budget")
       private Integer couponBudget;
     
    -  public String getDeviceInfo() {
    -    return this.deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getCouponStockId() {
    -    return this.couponStockId;
    -  }
    -
    -  public void setCouponStockId(String couponStockId) {
    -    this.couponStockId = couponStockId;
    -  }
    -
    -  public String getCouponName() {
    -    return this.couponName;
    -  }
    -
    -  public void setCouponName(String couponName) {
    -    this.couponName = couponName;
    -  }
    -
    -  public Integer getCouponValue() {
    -    return this.couponValue;
    -  }
    -
    -  public void setCouponValue(Integer couponValue) {
    -    this.couponValue = couponValue;
    -  }
    -
    -  public Integer getCouponMininumn() {
    -    return this.couponMininumn;
    -  }
    -
    -  public void setCouponMininumn(Integer couponMininumn) {
    -    this.couponMininumn = couponMininumn;
    -  }
    -
    -  public Integer getCouponStockStatus() {
    -    return this.couponStockStatus;
    -  }
    -
    -  public void setCouponStockStatus(Integer couponStockStatus) {
    -    this.couponStockStatus = couponStockStatus;
    -  }
    -
    -  public Integer getCouponTotal() {
    -    return this.couponTotal;
    -  }
    -
    -  public void setCouponTotal(Integer couponTotal) {
    -    this.couponTotal = couponTotal;
    -  }
    -
    -  public Integer getMaxQuota() {
    -    return this.maxQuota;
    -  }
    -
    -  public void setMaxQuota(Integer maxQuota) {
    -    this.maxQuota = maxQuota;
    -  }
    -
    -  public Integer getIsSendNum() {
    -    return this.isSendNum;
    -  }
    -
    -  public void setIsSendNum(Integer isSendNum) {
    -    this.isSendNum = isSendNum;
    -  }
    -
    -  public String getBeginTime() {
    -    return this.beginTime;
    -  }
    -
    -  public void setBeginTime(String beginTime) {
    -    this.beginTime = beginTime;
    -  }
    -
    -  public String getEndTime() {
    -    return this.endTime;
    -  }
    -
    -  public void setEndTime(String endTime) {
    -    this.endTime = endTime;
    -  }
    -
    -  public String getCreateTime() {
    -    return this.createTime;
    -  }
    -
    -  public void setCreateTime(String createTime) {
    -    this.createTime = createTime;
    -  }
    -
    -  public Integer getCouponBudget() {
    -    return this.couponBudget;
    -  }
    -
    -  public void setCouponBudget(Integer couponBudget) {
    -    this.couponBudget = couponBudget;
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java
    index e7a7ea9099..c7adf850af 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponse.java
    @@ -4,12 +4,20 @@
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     import com.thoughtworks.xstream.annotations.XStreamConverter;
     import com.thoughtworks.xstream.annotations.XStreamOmitField;
    +import lombok.AllArgsConstructor;
    +import lombok.Builder;
    +import lombok.Data;
    +import lombok.NoArgsConstructor;
     import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
     import me.chanjar.weixin.common.util.xml.XStreamInitializer;
     
     /**
      * 微信支付订单和退款的异步通知共用的响应类
      */
    +@Data
    +@Builder(builderMethodName = "newBuilder")
    +@NoArgsConstructor
    +@AllArgsConstructor
     @XStreamAlias("xml")
     public class WxPayNotifyResponse {
       @XStreamOmitField
    @@ -24,16 +32,6 @@ public class WxPayNotifyResponse {
       @XStreamAlias("return_msg")
       private String returnMsg;
     
    -  public WxPayNotifyResponse() {
    -    super();
    -  }
    -
    -  public WxPayNotifyResponse(String returnCode, String returnMsg) {
    -    super();
    -    this.returnCode = returnCode;
    -    this.returnMsg = returnMsg;
    -  }
    -
       public static String fail(String msg) {
         WxPayNotifyResponse response = new WxPayNotifyResponse(FAIL, msg);
         XStream xstream = XStreamInitializer.getInstance();
    @@ -48,19 +46,4 @@ public static String success(String msg) {
         return xstream.toXML(response);
       }
     
    -  public String getReturnCode() {
    -    return returnCode;
    -  }
    -
    -  public void setReturnCode(String returnCode) {
    -    this.returnCode = returnCode;
    -  }
    -
    -  public String getReturnMsg() {
    -    return returnMsg;
    -  }
    -
    -  public void setReturnMsg(String returnMsg) {
    -    this.returnMsg = returnMsg;
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java
    index cd948dfbac..80da09e6f9 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyCoupon.java
    @@ -1,7 +1,8 @@
     package com.github.binarywang.wxpay.bean.notify;
     
    -import org.apache.commons.lang3.builder.ToStringBuilder;
    -import org.apache.commons.lang3.builder.ToStringStyle;
    +import lombok.Data;
    +import lombok.NoArgsConstructor;
    +import me.chanjar.weixin.common.util.ToStringUtils;
     
     import java.io.Serializable;
     import java.util.HashMap;
    @@ -10,6 +11,8 @@
     /**
      * 支付异步通知代金券详细
      */
    +@Data
    +@NoArgsConstructor
     public class WxPayOrderNotifyCoupon implements Serializable {
       private static final long serialVersionUID = -4165343733538156097L;
     
    @@ -17,30 +20,6 @@ public class WxPayOrderNotifyCoupon implements Serializable {
       private String couponType;
       private Integer couponFee;
     
    -  public String getCouponId() {
    -    return couponId;
    -  }
    -
    -  public void setCouponId(String couponId) {
    -    this.couponId = couponId;
    -  }
    -
    -  public String getCouponType() {
    -    return couponType;
    -  }
    -
    -  public void setCouponType(String couponType) {
    -    this.couponType = couponType;
    -  }
    -
    -  public Integer getCouponFee() {
    -    return couponFee;
    -  }
    -
    -  public void setCouponFee(Integer couponFee) {
    -    this.couponFee = couponFee;
    -  }
    -
       public Map toMap(int index) {
         Map map = new HashMap<>();
         map.put("coupon_id_" + index, this.getCouponId());
    @@ -51,6 +30,6 @@ public Map toMap(int index) {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    +    return ToStringUtils.toSimpleString(this);
       }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java
    index 54657ac6ae..8cb94ee03e 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java
    @@ -4,6 +4,9 @@
     import com.github.binarywang.wxpay.converter.WxPayOrderNotifyResultConverter;
     import com.thoughtworks.xstream.XStream;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     import me.chanjar.weixin.common.util.BeanUtils;
     import me.chanjar.weixin.common.util.ToStringUtils;
     import me.chanjar.weixin.common.util.xml.XStreamInitializer;
    @@ -18,6 +21,9 @@
      * @author aimilin6688
      * @since 2.5.0
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@NoArgsConstructor
     @XStreamAlias("xml")
     public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializable {
       private static final long serialVersionUID = 5389718115223345496L;
    @@ -262,158 +268,6 @@ public static WxPayOrderNotifyResult fromXML(String xmlString) {
         return result;
       }
     
    -  public Integer getCouponCount() {
    -    return couponCount;
    -  }
    -
    -  public void setCouponCount(Integer couponCount) {
    -    this.couponCount = couponCount;
    -  }
    -
    -  public List getCouponList() {
    -    return couponList;
    -  }
    -
    -  public void setCouponList(List couponList) {
    -    this.couponList = couponList;
    -  }
    -
    -  public String getDeviceInfo() {
    -    return deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getOpenid() {
    -    return openid;
    -  }
    -
    -  public void setOpenid(String openid) {
    -    this.openid = openid;
    -  }
    -
    -  public String getIsSubscribe() {
    -    return isSubscribe;
    -  }
    -
    -  public void setIsSubscribe(String isSubscribe) {
    -    this.isSubscribe = isSubscribe;
    -  }
    -
    -  public String getTradeType() {
    -    return tradeType;
    -  }
    -
    -  public void setTradeType(String tradeType) {
    -    this.tradeType = tradeType;
    -  }
    -
    -  public String getBankType() {
    -    return bankType;
    -  }
    -
    -  public void setBankType(String bankType) {
    -    this.bankType = bankType;
    -  }
    -
    -  public Integer getTotalFee() {
    -    return totalFee;
    -  }
    -
    -  public void setTotalFee(Integer totalFee) {
    -    this.totalFee = totalFee;
    -  }
    -
    -  public Integer getSettlementTotalFee() {
    -    return settlementTotalFee;
    -  }
    -
    -  public void setSettlementTotalFee(Integer settlementTotalFee) {
    -    this.settlementTotalFee = settlementTotalFee;
    -  }
    -
    -  public String getFeeType() {
    -    return feeType;
    -  }
    -
    -  public void setFeeType(String feeType) {
    -    this.feeType = feeType;
    -  }
    -
    -  public Integer getCashFee() {
    -    return cashFee;
    -  }
    -
    -  public void setCashFee(Integer cashFee) {
    -    this.cashFee = cashFee;
    -  }
    -
    -  public String getCashFeeType() {
    -    return cashFeeType;
    -  }
    -
    -  public void setCashFeeType(String cashFeeType) {
    -    this.cashFeeType = cashFeeType;
    -  }
    -
    -  public Integer getCouponFee() {
    -    return couponFee;
    -  }
    -
    -  public void setCouponFee(Integer couponFee) {
    -    this.couponFee = couponFee;
    -  }
    -
    -  public String getTransactionId() {
    -    return transactionId;
    -  }
    -
    -  public void setTransactionId(String transactionId) {
    -    this.transactionId = transactionId;
    -  }
    -
    -  public String getOutTradeNo() {
    -    return outTradeNo;
    -  }
    -
    -  public void setOutTradeNo(String outTradeNo) {
    -    this.outTradeNo = outTradeNo;
    -  }
    -
    -  public String getAttach() {
    -    return attach;
    -  }
    -
    -  public void setAttach(String attach) {
    -    this.attach = attach;
    -  }
    -
    -  public String getTimeEnd() {
    -    return timeEnd;
    -  }
    -
    -  public void setTimeEnd(String timeEnd) {
    -    this.timeEnd = timeEnd;
    -  }
    -
    -  public String getSubOpenid() {
    -    return this.subOpenid;
    -  }
    -
    -  public void setSubOpenid(String subOpenid) {
    -    this.subOpenid = subOpenid;
    -  }
    -
    -  public String getSubIsSubscribe() {
    -    return this.subIsSubscribe;
    -  }
    -
    -  public void setSubIsSubscribe(String subIsSubscribe) {
    -    this.subIsSubscribe = subIsSubscribe;
    -  }
    -
       @Override
       public Map toMap() {
         Map resultMap = BeanUtils.xmlBean2Map(this);
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java
    index 392c10144c..7006c75215 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java
    @@ -4,6 +4,10 @@
     import com.github.binarywang.wxpay.exception.WxPayException;
     import com.thoughtworks.xstream.XStream;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.AllArgsConstructor;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     import me.chanjar.weixin.common.util.ToStringUtils;
     import me.chanjar.weixin.common.util.xml.XStreamInitializer;
     import org.apache.commons.codec.binary.Base64;
    @@ -22,6 +26,10 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@NoArgsConstructor
    +@AllArgsConstructor
     @XStreamAlias("xml")
     public class WxPayRefundNotifyResult extends WxPayBaseResult implements Serializable {
       private static final long serialVersionUID = 4651725860079259186L;
    @@ -68,6 +76,8 @@ public static WxPayRefundNotifyResult fromXML(String xmlString, String mchKey) t
       /**
        * 加密信息字段解密后的内容
        */
    +  @Data
    +  @NoArgsConstructor
       @XStreamAlias("root")
       public static class ReqInfo {
         @Override
    @@ -243,110 +253,6 @@ public String toString() {
         @XStreamAlias("refund_request_source")
         private String refundRequestSource;
     
    -    public String getTransactionId() {
    -      return transactionId;
    -    }
    -
    -    public void setTransactionId(String transactionId) {
    -      this.transactionId = transactionId;
    -    }
    -
    -    public String getOutTradeNo() {
    -      return outTradeNo;
    -    }
    -
    -    public void setOutTradeNo(String outTradeNo) {
    -      this.outTradeNo = outTradeNo;
    -    }
    -
    -    public String getRefundId() {
    -      return refundId;
    -    }
    -
    -    public void setRefundId(String refundId) {
    -      this.refundId = refundId;
    -    }
    -
    -    public String getOutRefundNo() {
    -      return outRefundNo;
    -    }
    -
    -    public void setOutRefundNo(String outRefundNo) {
    -      this.outRefundNo = outRefundNo;
    -    }
    -
    -    public Integer getTotalFee() {
    -      return totalFee;
    -    }
    -
    -    public void setTotalFee(Integer totalFee) {
    -      this.totalFee = totalFee;
    -    }
    -
    -    public Integer getSettlementTotalFee() {
    -      return settlementTotalFee;
    -    }
    -
    -    public void setSettlementTotalFee(Integer settlementTotalFee) {
    -      this.settlementTotalFee = settlementTotalFee;
    -    }
    -
    -    public Integer getRefundFee() {
    -      return refundFee;
    -    }
    -
    -    public void setRefundFee(Integer refundFee) {
    -      this.refundFee = refundFee;
    -    }
    -
    -    public Integer getSettlementRefundFee() {
    -      return settlementRefundFee;
    -    }
    -
    -    public void setSettlementRefundFee(Integer settlementRefundFee) {
    -      this.settlementRefundFee = settlementRefundFee;
    -    }
    -
    -    public String getRefundStatus() {
    -      return refundStatus;
    -    }
    -
    -    public void setRefundStatus(String refundStatus) {
    -      this.refundStatus = refundStatus;
    -    }
    -
    -    public String getSuccessTime() {
    -      return successTime;
    -    }
    -
    -    public void setSuccessTime(String successTime) {
    -      this.successTime = successTime;
    -    }
    -
    -    public String getRefundRecvAccout() {
    -      return refundRecvAccout;
    -    }
    -
    -    public void setRefundRecvAccout(String refundRecvAccout) {
    -      this.refundRecvAccout = refundRecvAccout;
    -    }
    -
    -    public String getRefundAccount() {
    -      return refundAccount;
    -    }
    -
    -    public void setRefundAccount(String refundAccount) {
    -      this.refundAccount = refundAccount;
    -    }
    -
    -    public String getRefundRequestSource() {
    -      return refundRequestSource;
    -    }
    -
    -    public void setRefundRequestSource(String refundRequestSource) {
    -      this.refundRequestSource = refundRequestSource;
    -    }
    -
         public static ReqInfo fromXML(String xmlString) {
           XStream xstream = XStreamInitializer.getInstance();
           xstream.processAnnotations(ReqInfo.class);
    @@ -354,19 +260,4 @@ public static ReqInfo fromXML(String xmlString) {
         }
       }
     
    -  public String getReqInfoString() {
    -    return reqInfoString;
    -  }
    -
    -  public void setReqInfoString(String reqInfoString) {
    -    this.reqInfoString = reqInfoString;
    -  }
    -
    -  public ReqInfo getReqInfo() {
    -    return reqInfo;
    -  }
    -
    -  public void setReqInfo(ReqInfo reqInfo) {
    -    this.reqInfo = reqInfo;
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxScanPayNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxScanPayNotifyResult.java
    similarity index 56%
    rename from weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxScanPayNotifyResult.java
    rename to weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxScanPayNotifyResult.java
    index cdb94a9b79..6d08136d99 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxScanPayNotifyResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxScanPayNotifyResult.java
    @@ -1,9 +1,16 @@
    -package com.github.binarywang.wxpay.bean.result;
    +package com.github.binarywang.wxpay.bean.notify;
     
    +import com.github.binarywang.wxpay.bean.result.WxPayBaseResult;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     
     import java.io.Serializable;
     
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@NoArgsConstructor
     public class WxScanPayNotifyResult extends WxPayBaseResult implements Serializable {
       private static final long serialVersionUID = 3381324564266118986L;
     
    @@ -13,12 +20,4 @@ public class WxScanPayNotifyResult extends WxPayBaseResult implements Serializab
       @XStreamAlias("prepay_id")
       private String prepayId;
     
    -  public String getPrepayId() {
    -    return prepayId;
    -  }
    -
    -  public void setPrepayId(String prepayId) {
    -    this.prepayId = prepayId;
    -  }
    -
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java
    index 6688d602c9..9e405aa0f9 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayAppOrderResult.java
    @@ -1,5 +1,8 @@
     package com.github.binarywang.wxpay.bean.order;
     
    +import lombok.Builder;
    +import lombok.Data;
    +
     /**
      * 
      * APP支付调用统一下单接口后的组装所需参数的实现类
    @@ -9,6 +12,8 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@Builder
     public class WxPayAppOrderResult {
       private String sign;
       private String prepayId;
    @@ -17,129 +22,4 @@ public class WxPayAppOrderResult {
       private String packageValue;
       private String timeStamp;
       private String nonceStr;
    -
    -  public WxPayAppOrderResult() {
    -  }
    -
    -  private WxPayAppOrderResult(Builder builder) {
    -    setSign(builder.sign);
    -    setPrepayId(builder.prepayId);
    -    setPartnerId(builder.partnerId);
    -    setAppId(builder.appId);
    -    setPackageValue(builder.packageValue);
    -    setTimeStamp(builder.timeStamp);
    -    setNonceStr(builder.nonceStr);
    -  }
    -
    -  public static Builder newBuilder() {
    -    return new Builder();
    -  }
    -
    -  public String getSign() {
    -    return this.sign;
    -  }
    -
    -  public void setSign(String sign) {
    -    this.sign = sign;
    -  }
    -
    -  public String getPrepayId() {
    -    return this.prepayId;
    -  }
    -
    -  public void setPrepayId(String prepayId) {
    -    this.prepayId = prepayId;
    -  }
    -
    -  public String getPartnerId() {
    -    return this.partnerId;
    -  }
    -
    -  public void setPartnerId(String partnerId) {
    -    this.partnerId = partnerId;
    -  }
    -
    -  public String getAppId() {
    -    return this.appId;
    -  }
    -
    -  public void setAppId(String appId) {
    -    this.appId = appId;
    -  }
    -
    -  public String getPackageValue() {
    -    return this.packageValue;
    -  }
    -
    -  public void setPackageValue(String packageValue) {
    -    this.packageValue = packageValue;
    -  }
    -
    -  public String getTimeStamp() {
    -    return this.timeStamp;
    -  }
    -
    -  public void setTimeStamp(String timeStamp) {
    -    this.timeStamp = timeStamp;
    -  }
    -
    -  public String getNonceStr() {
    -    return this.nonceStr;
    -  }
    -
    -  public void setNonceStr(String nonceStr) {
    -    this.nonceStr = nonceStr;
    -  }
    -
    -  public static final class Builder {
    -    private String sign;
    -    private String prepayId;
    -    private String partnerId;
    -    private String appId;
    -    private String packageValue;
    -    private String timeStamp;
    -    private String nonceStr;
    -
    -    private Builder() {
    -    }
    -
    -    public Builder sign(String sign) {
    -      this.sign = sign;
    -      return this;
    -    }
    -
    -    public Builder prepayId(String prepayId) {
    -      this.prepayId = prepayId;
    -      return this;
    -    }
    -
    -    public Builder partnerId(String partnerId) {
    -      this.partnerId = partnerId;
    -      return this;
    -    }
    -
    -    public Builder appId(String appId) {
    -      this.appId = appId;
    -      return this;
    -    }
    -
    -    public Builder packageValue(String packageValue) {
    -      this.packageValue = packageValue;
    -      return this;
    -    }
    -
    -    public Builder timeStamp(String timeStamp) {
    -      this.timeStamp = timeStamp;
    -      return this;
    -    }
    -
    -    public Builder nonceStr(String nonceStr) {
    -      this.nonceStr = nonceStr;
    -      return this;
    -    }
    -
    -    public WxPayAppOrderResult build() {
    -      return new WxPayAppOrderResult(this);
    -    }
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java
    index d1ebdee051..068743d0b8 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java
    @@ -1,5 +1,8 @@
     package com.github.binarywang.wxpay.bean.order;
     
    +import lombok.Builder;
    +import lombok.Data;
    +
     /**
      * 
      * 微信公众号支付进行统一下单后组装所需参数的类
    @@ -9,6 +12,8 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@Builder
     public class WxPayMpOrderResult {
       private String appId;
       private String timeStamp;
    @@ -19,115 +24,4 @@ public class WxPayMpOrderResult {
       private String packageValue;
       private String signType;
       private String paySign;
    -
    -  private WxPayMpOrderResult(Builder builder) {
    -    setAppId(builder.appId);
    -    setTimeStamp(builder.timeStamp);
    -    setNonceStr(builder.nonceStr);
    -    setPackageValue(builder.packageValue);
    -    setSignType(builder.signType);
    -    setPaySign(builder.paySign);
    -  }
    -
    -  public static Builder newBuilder() {
    -    return new Builder();
    -  }
    -
    -  public String getAppId() {
    -    return this.appId;
    -  }
    -
    -  public void setAppId(String appId) {
    -    this.appId = appId;
    -  }
    -
    -  public String getTimeStamp() {
    -    return this.timeStamp;
    -  }
    -
    -  public void setTimeStamp(String timeStamp) {
    -    this.timeStamp = timeStamp;
    -  }
    -
    -  public String getNonceStr() {
    -    return this.nonceStr;
    -  }
    -
    -  public void setNonceStr(String nonceStr) {
    -    this.nonceStr = nonceStr;
    -  }
    -
    -  public String getPackageValue() {
    -    return this.packageValue;
    -  }
    -
    -  public void setPackageValue(String packageValue) {
    -    this.packageValue = packageValue;
    -  }
    -
    -  public String getSignType() {
    -    return this.signType;
    -  }
    -
    -  public void setSignType(String signType) {
    -    this.signType = signType;
    -  }
    -
    -  public String getPaySign() {
    -    return this.paySign;
    -  }
    -
    -  public void setPaySign(String paySign) {
    -    this.paySign = paySign;
    -  }
    -
    -  public WxPayMpOrderResult() {
    -  }
    -
    -
    -  public static final class Builder {
    -    private String appId;
    -    private String timeStamp;
    -    private String nonceStr;
    -    private String packageValue;
    -    private String signType;
    -    private String paySign;
    -
    -    private Builder() {
    -    }
    -
    -    public Builder appId(String appId) {
    -      this.appId = appId;
    -      return this;
    -    }
    -
    -    public Builder timeStamp(String timeStamp) {
    -      this.timeStamp = timeStamp;
    -      return this;
    -    }
    -
    -    public Builder nonceStr(String nonceStr) {
    -      this.nonceStr = nonceStr;
    -      return this;
    -    }
    -
    -    public Builder packageValue(String packageValue) {
    -      this.packageValue = packageValue;
    -      return this;
    -    }
    -
    -    public Builder signType(String signType) {
    -      this.signType = signType;
    -      return this;
    -    }
    -
    -    public Builder paySign(String paySign) {
    -      this.paySign = paySign;
    -      return this;
    -    }
    -
    -    public WxPayMpOrderResult build() {
    -      return new WxPayMpOrderResult(this);
    -    }
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java
    index 3eb0e3748a..99788c2bc9 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayNativeOrderResult.java
    @@ -1,5 +1,8 @@
     package com.github.binarywang.wxpay.bean.order;
     
    +import lombok.Builder;
    +import lombok.Data;
    +
     /**
      * 
      * 微信扫码支付统一下单后发起支付拼接所需参数实现类
    @@ -8,41 +11,8 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@Builder
     public class WxPayNativeOrderResult {
       private String codeUrl;
    -
    -  private WxPayNativeOrderResult(Builder builder) {
    -    setCodeUrl(builder.codeUrl);
    -  }
    -
    -  public static Builder newBuilder() {
    -    return new Builder();
    -  }
    -
    -  public String getCodeUrl() {
    -    return this.codeUrl;
    -  }
    -
    -  public void setCodeUrl(String codeUrl) {
    -    this.codeUrl = codeUrl;
    -  }
    -
    -  public WxPayNativeOrderResult() {
    -  }
    -
    -  public static final class Builder {
    -    private String codeUrl;
    -
    -    private Builder() {
    -    }
    -
    -    public Builder codeUrl(String codeUrl) {
    -      this.codeUrl = codeUrl;
    -      return this;
    -    }
    -
    -    public WxPayNativeOrderResult build() {
    -      return new WxPayNativeOrderResult(this);
    -    }
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayQueryRequest.java
    index f9135c34df..5d48bb4463 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayQueryRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayQueryRequest.java
    @@ -1,6 +1,7 @@
     package com.github.binarywang.wxpay.bean.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     import me.chanjar.weixin.common.annotation.Required;
     import me.chanjar.weixin.common.util.ToStringUtils;
     
    @@ -17,8 +18,13 @@
      * 
    * Created by Binary Wang on 2016/10/19. * - * @author binarywang (https://github.com/binarywang) + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxEntPayQueryRequest extends WxPayBaseRequest { /** @@ -35,14 +41,6 @@ public class WxEntPayQueryRequest extends WxPayBaseRequest { @XStreamAlias("partner_trade_no") private String partnerTradeNo; - public String getPartnerTradeNo() { - return this.partnerTradeNo; - } - - public void setPartnerTradeNo(String partnerTradeNo) { - this.partnerTradeNo = partnerTradeNo; - } - @Override protected void checkConstraints() { //do nothing diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java index 7897ad02da..ac588aa55f 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java @@ -1,6 +1,7 @@ package com.github.binarywang.wxpay.bean.request; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; import me.chanjar.weixin.common.annotation.Required; import me.chanjar.weixin.common.util.ToStringUtils; @@ -10,8 +11,14 @@ *
    * Created by Binary Wang on 2016/10/02. * - * @author binarywang (https://github.com/binarywang) + * @author Binary Wang */ + +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxEntPayRequest extends WxPayBaseRequest { /** @@ -153,32 +160,6 @@ public class WxEntPayRequest extends WxPayBaseRequest { @XStreamAlias("spbill_create_ip") private String spbillCreateIp; - public WxEntPayRequest() { - } - - private WxEntPayRequest(Builder builder) { - setAppid(builder.appid); - setMchId(builder.mchId); - setSubAppId(builder.subAppId); - setSubMchId(builder.subMchId); - setNonceStr(builder.nonceStr); - setSign(builder.sign); - mchAppid = builder.mchAppid; - setMchId(builder.mchId); - setDeviceInfo(builder.deviceInfo); - setPartnerTradeNo(builder.partnerTradeNo); - setOpenid(builder.openid); - setCheckName(builder.checkName); - setReUserName(builder.reUserName); - setAmount(builder.amount); - setDescription(builder.description); - setSpbillCreateIp(builder.spbillCreateIp); - } - - public static Builder newBuilder() { - return new Builder(); - } - @Override protected void checkConstraints() { @@ -204,172 +185,9 @@ public void setMchId(String mchId) { this.mchId = mchId; } - public String getDeviceInfo() { - return this.deviceInfo; - } - - public void setDeviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - } - - public String getPartnerTradeNo() { - return this.partnerTradeNo; - } - - public void setPartnerTradeNo(String partnerTradeNo) { - this.partnerTradeNo = partnerTradeNo; - } - - public String getOpenid() { - return this.openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getCheckName() { - return this.checkName; - } - - public void setCheckName(String checkName) { - this.checkName = checkName; - } - - public String getReUserName() { - return this.reUserName; - } - - public void setReUserName(String reUserName) { - this.reUserName = reUserName; - } - - public Integer getAmount() { - return this.amount; - } - - public void setAmount(Integer amount) { - this.amount = amount; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getSpbillCreateIp() { - return this.spbillCreateIp; - } - - public void setSpbillCreateIp(String spbillCreateIp) { - this.spbillCreateIp = spbillCreateIp; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); } - public static final class Builder { - private String appid; - private String mchId; - private String deviceInfo; - private String partnerTradeNo; - private String openid; - private String checkName; - private String reUserName; - private Integer amount; - private String description; - private String spbillCreateIp; - private String subAppId; - private String subMchId; - private String nonceStr; - private String sign; - private String mchAppid; - - private Builder() { - } - - public Builder appid(String appid) { - this.appid = appid; - return this; - } - - public Builder mchId(String mchId) { - this.mchId = mchId; - return this; - } - - public Builder deviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - return this; - } - - public Builder partnerTradeNo(String partnerTradeNo) { - this.partnerTradeNo = partnerTradeNo; - return this; - } - - public Builder openid(String openid) { - this.openid = openid; - return this; - } - - public Builder checkName(String checkName) { - this.checkName = checkName; - return this; - } - - public Builder reUserName(String reUserName) { - this.reUserName = reUserName; - return this; - } - - public Builder amount(Integer amount) { - this.amount = amount; - return this; - } - - public Builder description(String description) { - this.description = description; - return this; - } - - public Builder spbillCreateIp(String spbillCreateIp) { - this.spbillCreateIp = spbillCreateIp; - return this; - } - - public WxEntPayRequest build() { - return new WxEntPayRequest(this); - } - - public Builder subAppId(String subAppId) { - this.subAppId = subAppId; - return this; - } - - public Builder subMchId(String subMchId) { - this.subMchId = subMchId; - return this; - } - - public Builder nonceStr(String nonceStr) { - this.nonceStr = nonceStr; - return this; - } - - public Builder sign(String sign) { - this.sign = sign; - return this; - } - - public Builder mchAppid(String mchAppid) { - this.mchAppid = mchAppid; - return this; - } - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayAuthcode2OpenidRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayAuthcode2OpenidRequest.java index 594fa4960d..1187bf8df5 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayAuthcode2OpenidRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayAuthcode2OpenidRequest.java @@ -1,14 +1,21 @@ package com.github.binarywang.wxpay.bean.request; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; /** *
      * 授权码查询openid接口请求对象类
      * Created by Binary Wang on 2017-3-27.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayAuthcode2OpenidRequest extends WxPayBaseRequest { @@ -24,21 +31,6 @@ public class WxPayAuthcode2OpenidRequest extends WxPayBaseRequest { @XStreamAlias("auth_code") private String authCode; - public WxPayAuthcode2OpenidRequest() { - } - - public WxPayAuthcode2OpenidRequest(String authCode) { - this.authCode = authCode; - } - - public String getAuthCode() { - return this.authCode; - } - - public void setAuthCode(String authCode) { - this.authCode = authCode; - } - @Override protected void checkConstraints() { // nothing to do diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java index 41a98d0ae4..ad6f9d4c34 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java @@ -5,6 +5,7 @@ import com.github.binarywang.wxpay.util.SignUtils; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.BeanUtils; import me.chanjar.weixin.common.util.ToStringUtils; @@ -19,8 +20,9 @@ * 微信支付请求对象共用的参数存放类 *
    * - * @author binarywang(Binary Wang) + * @author Binary Wang */ +@Data public abstract class WxPayBaseRequest { /** *
    @@ -120,7 +122,7 @@ public static Integer yuanToFee(String yuan) {
       /**
        * 检查请求参数内容,包括必填参数以及特殊约束
        */
    -  protected void checkFields() throws WxPayException {
    +  private void checkFields() throws WxPayException {
         //check required fields
         try {
           BeanUtils.checkRequiredFields(this);
    @@ -137,10 +139,6 @@ protected void checkFields() throws WxPayException {
        */
       protected abstract void checkConstraints() throws WxPayException;
     
    -  public String getAppid() {
    -    return this.appid;
    -  }
    -
       /**
        * 如果配置中已经设置,可以不设置值
        *
    @@ -150,10 +148,6 @@ public void setAppid(String appid) {
         this.appid = appid;
       }
     
    -  public String getMchId() {
    -    return this.mchId;
    -  }
    -
       /**
        * 如果配置中已经设置,可以不设置值
        *
    @@ -163,10 +157,6 @@ public void setMchId(String mchId) {
         this.mchId = mchId;
       }
     
    -  public String getNonceStr() {
    -    return this.nonceStr;
    -  }
    -
       /**
        * 默认采用时间戳为随机字符串,可以不设置
        *
    @@ -176,38 +166,6 @@ public void setNonceStr(String nonceStr) {
         this.nonceStr = nonceStr;
       }
     
    -  public String getSign() {
    -    return this.sign;
    -  }
    -
    -  public void setSign(String sign) {
    -    this.sign = sign;
    -  }
    -
    -  public String getSubAppId() {
    -    return subAppId;
    -  }
    -
    -  public void setSubAppId(String subAppId) {
    -    this.subAppId = subAppId;
    -  }
    -
    -  public String getSubMchId() {
    -    return subMchId;
    -  }
    -
    -  public void setSubMchId(String subMchId) {
    -    this.subMchId = subMchId;
    -  }
    -
    -  public String getSignType() {
    -    return signType;
    -  }
    -
    -  public void setSignType(String signType) {
    -    this.signType = signType;
    -  }
    -
       @Override
       public String toString() {
         return ToStringUtils.toSimpleString(this);
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java
    index 33e410cdd8..6dc7264b33 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayDownloadBillRequest.java
    @@ -3,6 +3,7 @@
     import com.github.binarywang.wxpay.constant.WxPayConstants.BillType;
     import com.github.binarywang.wxpay.exception.WxPayException;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     import me.chanjar.weixin.common.annotation.Required;
     import org.apache.commons.lang3.ArrayUtils;
     import org.apache.commons.lang3.StringUtils;
    @@ -13,9 +14,15 @@
      * 
      *   微信支付下载对账单请求参数类
      * Created by Binary Wang on 2017-01-11.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayDownloadBillRequest extends WxPayBaseRequest { private static final String[] BILL_TYPES = new String[]{BillType.ALL, BillType.SUCCESS, BillType.REFUND, BillType.RECHARGE_REFUND}; @@ -34,19 +41,6 @@ public class WxPayDownloadBillRequest extends WxPayBaseRequest { @XStreamAlias("device_info") private String deviceInfo; - /** - *
    -   * 签名类型
    -   * sign_type
    -   * 否
    -   * String(32)
    -   * HMAC-SHA256
    -   * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5
    -   * 
    - */ - @XStreamAlias("sign_type") - private String signType; - /** *
        * 账单类型
    @@ -90,46 +84,6 @@ public class WxPayDownloadBillRequest extends WxPayBaseRequest {
       @XStreamAlias("tar_type")
       private String tarType;
     
    -  public String getDeviceInfo() {
    -    return deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getSignType() {
    -    return signType;
    -  }
    -
    -  public void setSignType(String signType) {
    -    this.signType = signType;
    -  }
    -
    -  public String getBillType() {
    -    return billType;
    -  }
    -
    -  public void setBillType(String billType) {
    -    this.billType = billType;
    -  }
    -
    -  public String getBillDate() {
    -    return billDate;
    -  }
    -
    -  public void setBillDate(String billDate) {
    -    this.billDate = billDate;
    -  }
    -
    -  public String getTarType() {
    -    return tarType;
    -  }
    -
    -  public void setTarType(String tarType) {
    -    this.tarType = tarType;
    -  }
    -
       @Override
       protected void checkConstraints() throws WxPayException {
         if (StringUtils.isNotBlank(this.getTarType()) && !TAR_TYPE_GZIP.equals(this.getTarType())) {
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayMicropayRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayMicropayRequest.java
    index a025337806..ed85fe76cf 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayMicropayRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayMicropayRequest.java
    @@ -1,29 +1,24 @@
     package com.github.binarywang.wxpay.bean.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     import me.chanjar.weixin.common.annotation.Required;
     
     /**
      * 
      *  提交刷卡支付请求对象类
      * Created by Binary Wang on 2017-3-23.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayMicropayRequest extends WxPayBaseRequest { - /** - *
    -   * 签名类型
    -   * sign_type
    -   * 否
    -   * String(32)
    -   * HMAC-SHA256
    -   * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5
    -   **/
    -  @XStreamAlias("sign_type")
    -  private String signType;
    -
       /**
        * 
        * 商品描述
    @@ -149,232 +144,9 @@ public class WxPayMicropayRequest extends WxPayBaseRequest {
       @XStreamAlias("auth_code")
       private String authCode;
     
    -  private WxPayMicropayRequest(Builder builder) {
    -    setSignType(builder.signType);
    -    setBody(builder.body);
    -    setAppid(builder.appid);
    -    setDetail(builder.detail);
    -    setMchId(builder.mchId);
    -    setAttach(builder.attach);
    -    setSubAppId(builder.subAppId);
    -    setOutTradeNo(builder.outTradeNo);
    -    setSubMchId(builder.subMchId);
    -    setTotalFee(builder.totalFee);
    -    setNonceStr(builder.nonceStr);
    -    setFeeType(builder.feeType);
    -    setSign(builder.sign);
    -    setSpbillCreateIp(builder.spbillCreateIp);
    -    setGoodsTag(builder.goodsTag);
    -    setLimitPay(builder.limitPay);
    -    setAuthCode(builder.authCode);
    -  }
    -
    -  public static Builder newBuilder() {
    -    return new Builder();
    -  }
    -
    -  public String getSignType() {
    -    return this.signType;
    -  }
    -
    -  public void setSignType(String signType) {
    -    this.signType = signType;
    -  }
    -
    -  public String getBody() {
    -    return this.body;
    -  }
    -
    -  public void setBody(String body) {
    -    this.body = body;
    -  }
    -
    -  public String getDetail() {
    -    return this.detail;
    -  }
    -
    -  public void setDetail(String detail) {
    -    this.detail = detail;
    -  }
    -
    -  public String getAttach() {
    -    return this.attach;
    -  }
    -
    -  public void setAttach(String attach) {
    -    this.attach = attach;
    -  }
    -
    -  public String getOutTradeNo() {
    -    return this.outTradeNo;
    -  }
    -
    -  public void setOutTradeNo(String outTradeNo) {
    -    this.outTradeNo = outTradeNo;
    -  }
    -
    -  public Integer getTotalFee() {
    -    return this.totalFee;
    -  }
    -
    -  public void setTotalFee(Integer totalFee) {
    -    this.totalFee = totalFee;
    -  }
    -
    -  public String getFeeType() {
    -    return this.feeType;
    -  }
    -
    -  public void setFeeType(String feeType) {
    -    this.feeType = feeType;
    -  }
    -
    -  public String getSpbillCreateIp() {
    -    return this.spbillCreateIp;
    -  }
    -
    -  public void setSpbillCreateIp(String spbillCreateIp) {
    -    this.spbillCreateIp = spbillCreateIp;
    -  }
    -
    -  public String getGoodsTag() {
    -    return this.goodsTag;
    -  }
    -
    -  public void setGoodsTag(String goodsTag) {
    -    this.goodsTag = goodsTag;
    -  }
    -
    -  public String getLimitPay() {
    -    return this.limitPay;
    -  }
    -
    -  public void setLimitPay(String limitPay) {
    -    this.limitPay = limitPay;
    -  }
    -
    -  public String getAuthCode() {
    -    return this.authCode;
    -  }
    -
    -  public void setAuthCode(String authCode) {
    -    this.authCode = authCode;
    -  }
    -
       @Override
       protected void checkConstraints() {
         //do nothing
       }
     
    -  public static final class Builder {
    -    private String signType;
    -    private String body;
    -    private String appid;
    -    private String detail;
    -    private String mchId;
    -    private String attach;
    -    private String subAppId;
    -    private String outTradeNo;
    -    private String subMchId;
    -    private Integer totalFee;
    -    private String nonceStr;
    -    private String feeType;
    -    private String sign;
    -    private String spbillCreateIp;
    -    private String goodsTag;
    -    private String limitPay;
    -    private String authCode;
    -
    -    private Builder() {
    -    }
    -
    -    public Builder signType(String signType) {
    -      this.signType = signType;
    -      return this;
    -    }
    -
    -    public Builder body(String body) {
    -      this.body = body;
    -      return this;
    -    }
    -
    -    public Builder appid(String appid) {
    -      this.appid = appid;
    -      return this;
    -    }
    -
    -    public Builder detail(String detail) {
    -      this.detail = detail;
    -      return this;
    -    }
    -
    -    public Builder mchId(String mchId) {
    -      this.mchId = mchId;
    -      return this;
    -    }
    -
    -    public Builder attach(String attach) {
    -      this.attach = attach;
    -      return this;
    -    }
    -
    -    public Builder subAppId(String subAppId) {
    -      this.subAppId = subAppId;
    -      return this;
    -    }
    -
    -    public Builder outTradeNo(String outTradeNo) {
    -      this.outTradeNo = outTradeNo;
    -      return this;
    -    }
    -
    -    public Builder subMchId(String subMchId) {
    -      this.subMchId = subMchId;
    -      return this;
    -    }
    -
    -    public Builder totalFee(Integer totalFee) {
    -      this.totalFee = totalFee;
    -      return this;
    -    }
    -
    -    public Builder nonceStr(String nonceStr) {
    -      this.nonceStr = nonceStr;
    -      return this;
    -    }
    -
    -    public Builder feeType(String feeType) {
    -      this.feeType = feeType;
    -      return this;
    -    }
    -
    -    public Builder sign(String sign) {
    -      this.sign = sign;
    -      return this;
    -    }
    -
    -    public Builder spbillCreateIp(String spbillCreateIp) {
    -      this.spbillCreateIp = spbillCreateIp;
    -      return this;
    -    }
    -
    -    public Builder goodsTag(String goodsTag) {
    -      this.goodsTag = goodsTag;
    -      return this;
    -    }
    -
    -    public Builder limitPay(String limitPay) {
    -      this.limitPay = limitPay;
    -      return this;
    -    }
    -
    -    public Builder authCode(String authCode) {
    -      this.authCode = authCode;
    -      return this;
    -    }
    -
    -    public WxPayMicropayRequest build() {
    -      return new WxPayMicropayRequest(this);
    -    }
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderCloseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderCloseRequest.java
    index 21968ac983..29650537c3 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderCloseRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderCloseRequest.java
    @@ -1,14 +1,21 @@
     package com.github.binarywang.wxpay.bean.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     
     /**
      * 
      *  关闭订单请求对象类
      * Created by Binary Wang on 2016-10-27.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayOrderCloseRequest extends WxPayBaseRequest { @@ -25,14 +32,6 @@ public class WxPayOrderCloseRequest extends WxPayBaseRequest { @XStreamAlias("out_trade_no") private String outTradeNo; - public String getOutTradeNo() { - return this.outTradeNo; - } - - public void setOutTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; - } - @Override protected void checkConstraints() { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java index e7767da607..4342fb9519 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderQueryRequest.java @@ -2,6 +2,7 @@ import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; import org.apache.commons.lang3.StringUtils; /** @@ -17,8 +18,13 @@ *
  • 描述 *
  • * - * @author binarywang(Binary Wang) + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayOrderQueryRequest extends WxPayBaseRequest { @@ -48,22 +54,6 @@ public class WxPayOrderQueryRequest extends WxPayBaseRequest { @XStreamAlias("out_trade_no") private String outTradeNo; - public String getTransactionId() { - return this.transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getOutTradeNo() { - return this.outTradeNo; - } - - public void setOutTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; - } - @Override protected void checkConstraints() throws WxPayException { if ((StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)) || diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java index 075295238e..db68179188 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayOrderReverseRequest.java @@ -2,15 +2,22 @@ import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; import org.apache.commons.lang3.StringUtils; /** *
      * 撤销订单请求类
      * Created by Binary Wang on 2017-3-23.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayOrderReverseRequest extends WxPayBaseRequest { @@ -39,58 +46,6 @@ public class WxPayOrderReverseRequest extends WxPayBaseRequest { @XStreamAlias("out_trade_no") private String outTradeNo; - /** - *
    -   * 签名类型
    -   * sign_type
    -   * 否
    -   * String(32)
    -   * HMAC-SHA256
    -   * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5
    -   **/
    -  @XStreamAlias("sign_type")
    -  private String signType;
    -
    -  private WxPayOrderReverseRequest(Builder builder) {
    -    setTransactionId(builder.transactionId);
    -    setAppid(builder.appid);
    -    setOutTradeNo(builder.outTradeNo);
    -    setMchId(builder.mchId);
    -    setSignType(builder.signType);
    -    setSubAppId(builder.subAppId);
    -    setSubMchId(builder.subMchId);
    -    setNonceStr(builder.nonceStr);
    -    setSign(builder.sign);
    -  }
    -
    -  public static Builder newBuilder() {
    -    return new Builder();
    -  }
    -
    -  public String getTransactionId() {
    -    return this.transactionId;
    -  }
    -
    -  public void setTransactionId(String transactionId) {
    -    this.transactionId = transactionId;
    -  }
    -
    -  public String getOutTradeNo() {
    -    return this.outTradeNo;
    -  }
    -
    -  public void setOutTradeNo(String outTradeNo) {
    -    this.outTradeNo = outTradeNo;
    -  }
    -
    -  public String getSignType() {
    -    return this.signType;
    -  }
    -
    -  public void setSignType(String signType) {
    -    this.signType = signType;
    -  }
    -
       @Override
       protected void checkConstraints() throws WxPayException {
         if (StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)) {
    @@ -98,67 +53,4 @@ protected void checkConstraints() throws WxPayException {
         }
       }
     
    -  public static final class Builder {
    -    private String transactionId;
    -    private String appid;
    -    private String outTradeNo;
    -    private String mchId;
    -    private String signType;
    -    private String subAppId;
    -    private String subMchId;
    -    private String nonceStr;
    -    private String sign;
    -
    -    private Builder() {
    -    }
    -
    -    public Builder transactionId(String transactionId) {
    -      this.transactionId = transactionId;
    -      return this;
    -    }
    -
    -    public Builder appid(String appid) {
    -      this.appid = appid;
    -      return this;
    -    }
    -
    -    public Builder outTradeNo(String outTradeNo) {
    -      this.outTradeNo = outTradeNo;
    -      return this;
    -    }
    -
    -    public Builder mchId(String mchId) {
    -      this.mchId = mchId;
    -      return this;
    -    }
    -
    -    public Builder signType(String signType) {
    -      this.signType = signType;
    -      return this;
    -    }
    -
    -    public Builder subAppId(String subAppId) {
    -      this.subAppId = subAppId;
    -      return this;
    -    }
    -
    -    public Builder subMchId(String subMchId) {
    -      this.subMchId = subMchId;
    -      return this;
    -    }
    -
    -    public Builder nonceStr(String nonceStr) {
    -      this.nonceStr = nonceStr;
    -      return this;
    -    }
    -
    -    public Builder sign(String sign) {
    -      this.sign = sign;
    -      return this;
    -    }
    -
    -    public WxPayOrderReverseRequest build() {
    -      return new WxPayOrderReverseRequest(this);
    -    }
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java
    index 1bdbf9bf4e..e1117b0be2 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java
    @@ -2,6 +2,7 @@
     
     import com.github.binarywang.wxpay.exception.WxPayException;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     import me.chanjar.weixin.common.annotation.Required;
     
     /**
    @@ -12,6 +13,11 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@Builder(builderMethodName = "newBuilder")
    +@NoArgsConstructor
    +@AllArgsConstructor
     @XStreamAlias("xml")
     public class WxPayQueryCommentRequest extends WxPayBaseRequest {
       /**
    @@ -77,36 +83,4 @@ protected void checkConstraints() throws WxPayException {
     
       }
     
    -  public String getBeginTime() {
    -    return beginTime;
    -  }
    -
    -  public void setBeginTime(String beginTime) {
    -    this.beginTime = beginTime;
    -  }
    -
    -  public String getEndTime() {
    -    return endTime;
    -  }
    -
    -  public void setEndTime(String endTime) {
    -    this.endTime = endTime;
    -  }
    -
    -  public Integer getOffset() {
    -    return offset;
    -  }
    -
    -  public void setOffset(Integer offset) {
    -    this.offset = offset;
    -  }
    -
    -  public Integer getLimit() {
    -    return limit;
    -  }
    -
    -  public void setLimit(Integer limit) {
    -    this.limit = limit;
    -  }
    -
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRedpackQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRedpackQueryRequest.java
    index 191db46975..e7b5f9c134 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRedpackQueryRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRedpackQueryRequest.java
    @@ -1,6 +1,7 @@
     package com.github.binarywang.wxpay.bean.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     
     /**
      * 
    @@ -12,9 +13,15 @@
      *   类型
      *   说明
      * Created by Binary Wang on 2016-11-28.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayRedpackQueryRequest extends WxPayBaseRequest { /** @@ -39,22 +46,6 @@ public class WxPayRedpackQueryRequest extends WxPayBaseRequest { @XStreamAlias("bill_type") private String billType; - public String getBillType() { - return billType; - } - - public void setBillType(String billType) { - this.billType = billType; - } - - public String getMchBillNo() { - return mchBillNo; - } - - public void setMchBillNo(String mchBillNo) { - this.mchBillNo = mchBillNo; - } - @Override protected void checkConstraints() { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java index 00545f004c..e413377f34 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundQueryRequest.java @@ -2,14 +2,21 @@ import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; import org.apache.commons.lang3.StringUtils; /** *
      * Created by Binary Wang on 2016-11-24.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayRefundQueryRequest extends WxPayBaseRequest { /** @@ -25,19 +32,6 @@ public class WxPayRefundQueryRequest extends WxPayBaseRequest { @XStreamAlias("device_info") private String deviceInfo; - /** - *
    -   * 签名类型
    -   * sign_type
    -   * 否
    -   * String(32)
    -   * HMAC-SHA256
    -   * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5
    -   * 
    - */ - @XStreamAlias("sign_type") - private String signType; - //************以下四选一************ /** *
    @@ -87,54 +81,6 @@ public class WxPayRefundQueryRequest extends WxPayBaseRequest {
       @XStreamAlias("refund_id")
       private String refundId;
     
    -  public String getDeviceInfo() {
    -    return deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getSignType() {
    -    return signType;
    -  }
    -
    -  public void setSignType(String signType) {
    -    this.signType = signType;
    -  }
    -
    -  public String getTransactionId() {
    -    return transactionId;
    -  }
    -
    -  public void setTransactionId(String transactionId) {
    -    this.transactionId = transactionId;
    -  }
    -
    -  public String getOutTradeNo() {
    -    return outTradeNo;
    -  }
    -
    -  public void setOutTradeNo(String outTradeNo) {
    -    this.outTradeNo = outTradeNo;
    -  }
    -
    -  public String getOutRefundNo() {
    -    return outRefundNo;
    -  }
    -
    -  public void setOutRefundNo(String outRefundNo) {
    -    this.outRefundNo = outRefundNo;
    -  }
    -
    -  public String getRefundId() {
    -    return refundId;
    -  }
    -
    -  public void setRefundId(String refundId) {
    -    this.refundId = refundId;
    -  }
    -
       @Override
       protected void checkConstraints() throws WxPayException {
         if ((StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
    index 66808738ca..645e2f7a93 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
    @@ -3,6 +3,7 @@
     import com.github.binarywang.wxpay.config.WxPayConfig;
     import com.github.binarywang.wxpay.exception.WxPayException;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     import me.chanjar.weixin.common.annotation.Required;
     import org.apache.commons.lang3.ArrayUtils;
     import org.apache.commons.lang3.StringUtils;
    @@ -22,8 +23,13 @@
      * Created by Binary Wang on 2016-10-08.
      * 
    * - * @author binarywang(Binary Wang) + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayRefundRequest extends WxPayBaseRequest { private static final String[] REFUND_ACCOUNT = new String[]{"REFUND_SOURCE_RECHARGE_FUNDS", @@ -155,112 +161,6 @@ public class WxPayRefundRequest extends WxPayBaseRequest { @XStreamAlias("refund_desc") private String refundDesc; - private WxPayRefundRequest(Builder builder) { - setDeviceInfo(builder.deviceInfo); - setAppid(builder.appid); - setTransactionId(builder.transactionId); - setMchId(builder.mchId); - setSubAppId(builder.subAppId); - setOutTradeNo(builder.outTradeNo); - setSubMchId(builder.subMchId); - setOutRefundNo(builder.outRefundNo); - setNonceStr(builder.nonceStr); - setTotalFee(builder.totalFee); - setSign(builder.sign); - setRefundFee(builder.refundFee); - setRefundFeeType(builder.refundFeeType); - setOpUserId(builder.opUserId); - setRefundAccount(builder.refundAccount); - setRefundDesc(builder.refundDesc); - } - - public static Builder newBuilder() { - return new Builder(); - } - - public String getDeviceInfo() { - return this.deviceInfo; - } - - public void setDeviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - } - - public String getTransactionId() { - return this.transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getOutTradeNo() { - return this.outTradeNo; - } - - public void setOutTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; - } - - public String getOutRefundNo() { - return this.outRefundNo; - } - - public void setOutRefundNo(String outRefundNo) { - this.outRefundNo = outRefundNo; - } - - public Integer getTotalFee() { - return this.totalFee; - } - - public void setTotalFee(Integer totalFee) { - this.totalFee = totalFee; - } - - public Integer getRefundFee() { - return this.refundFee; - } - - public void setRefundFee(Integer refundFee) { - this.refundFee = refundFee; - } - - public String getRefundFeeType() { - return this.refundFeeType; - } - - public void setRefundFeeType(String refundFeeType) { - this.refundFeeType = refundFeeType; - } - - public String getOpUserId() { - return this.opUserId; - } - - public void setOpUserId(String opUserId) { - this.opUserId = opUserId; - } - - public String getRefundAccount() { - return this.refundAccount; - } - - public void setRefundAccount(String refundAccount) { - this.refundAccount = refundAccount; - } - - public String getRefundDesc() { - return this.refundDesc; - } - - public void setRefundDesc(String refundDesc) { - this.refundDesc = refundDesc; - } - - public WxPayRefundRequest() { - } - @Override public void checkAndSign(WxPayConfig config) throws WxPayException { if (StringUtils.isBlank(this.getOpUserId())) { @@ -284,109 +184,4 @@ protected void checkConstraints() throws WxPayException { } } - public static final class Builder { - private String deviceInfo; - private String appid; - private String transactionId; - private String mchId; - private String subAppId; - private String outTradeNo; - private String subMchId; - private String outRefundNo; - private String nonceStr; - private Integer totalFee; - private String sign; - private Integer refundFee; - private String refundFeeType; - private String opUserId; - private String refundAccount; - private String refundDesc; - - private Builder() { - } - - public Builder deviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - return this; - } - - public Builder appid(String appid) { - this.appid = appid; - return this; - } - - public Builder transactionId(String transactionId) { - this.transactionId = transactionId; - return this; - } - - public Builder mchId(String mchId) { - this.mchId = mchId; - return this; - } - - public Builder subAppId(String subAppId) { - this.subAppId = subAppId; - return this; - } - - public Builder outTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; - return this; - } - - public Builder subMchId(String subMchId) { - this.subMchId = subMchId; - return this; - } - - public Builder outRefundNo(String outRefundNo) { - this.outRefundNo = outRefundNo; - return this; - } - - public Builder nonceStr(String nonceStr) { - this.nonceStr = nonceStr; - return this; - } - - public Builder totalFee(Integer totalFee) { - this.totalFee = totalFee; - return this; - } - - public Builder sign(String sign) { - this.sign = sign; - return this; - } - - public Builder refundFee(Integer refundFee) { - this.refundFee = refundFee; - return this; - } - - public Builder refundFeeType(String refundFeeType) { - this.refundFeeType = refundFeeType; - return this; - } - - public Builder opUserId(String opUserId) { - this.opUserId = opUserId; - return this; - } - - public Builder refundAccount(String refundAccount) { - this.refundAccount = refundAccount; - return this; - } - - public Builder refundDesc(String refundDesc) { - this.refundDesc = refundDesc; - return this; - } - - public WxPayRefundRequest build() { - return new WxPayRefundRequest(this); - } - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayReportRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayReportRequest.java index 8b3f88b9c9..88532ad2b5 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayReportRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayReportRequest.java @@ -1,6 +1,7 @@ package com.github.binarywang.wxpay.bean.request; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; import me.chanjar.weixin.common.annotation.Required; /** @@ -15,8 +16,13 @@ *
  • 描述 *
  • * - * @author binarywang(Binary Wang) + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayReportRequest extends WxPayBaseRequest { /** @@ -32,19 +38,6 @@ public class WxPayReportRequest extends WxPayBaseRequest { @XStreamAlias("device_info") private String deviceInfo; - /** - *
    -   * 签名类型
    -   * sign_type
    -   * 否
    -   * String(32)
    -   * HMAC-SHA256
    -   * 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5
    -   * 
    - */ - @XStreamAlias("sign_type") - private String signType; - /** *
        * 接口URL
    @@ -175,102 +168,6 @@ public class WxPayReportRequest extends WxPayBaseRequest {
       @XStreamAlias("time")
       private String time;
     
    -  public String getDeviceInfo() {
    -    return deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getSignType() {
    -    return signType;
    -  }
    -
    -  public void setSignType(String signType) {
    -    this.signType = signType;
    -  }
    -
    -  public String getInterfaceUrl() {
    -    return interfaceUrl;
    -  }
    -
    -  public void setInterfaceUrl(String interfaceUrl) {
    -    this.interfaceUrl = interfaceUrl;
    -  }
    -
    -  public Integer getExecuteTime() {
    -    return executeTime;
    -  }
    -
    -  public void setExecuteTime(Integer executeTime) {
    -    this.executeTime = executeTime;
    -  }
    -
    -  public String getReturnCode() {
    -    return returnCode;
    -  }
    -
    -  public void setReturnCode(String returnCode) {
    -    this.returnCode = returnCode;
    -  }
    -
    -  public String getReturnMsg() {
    -    return returnMsg;
    -  }
    -
    -  public void setReturnMsg(String returnMsg) {
    -    this.returnMsg = returnMsg;
    -  }
    -
    -  public String getResultCode() {
    -    return resultCode;
    -  }
    -
    -  public void setResultCode(String resultCode) {
    -    this.resultCode = resultCode;
    -  }
    -
    -  public String getErrCode() {
    -    return errCode;
    -  }
    -
    -  public void setErrCode(String errCode) {
    -    this.errCode = errCode;
    -  }
    -
    -  public String getErrCodeDes() {
    -    return errCodeDes;
    -  }
    -
    -  public void setErrCodeDes(String errCodeDes) {
    -    this.errCodeDes = errCodeDes;
    -  }
    -
    -  public String getOutTradeNo() {
    -    return outTradeNo;
    -  }
    -
    -  public void setOutTradeNo(String outTradeNo) {
    -    this.outTradeNo = outTradeNo;
    -  }
    -
    -  public String getUserIp() {
    -    return userIp;
    -  }
    -
    -  public void setUserIp(String userIp) {
    -    this.userIp = userIp;
    -  }
    -
    -  public String getTime() {
    -    return time;
    -  }
    -
    -  public void setTime(String time) {
    -    this.time = time;
    -  }
    -
       @Override
       protected void checkConstraints() {
         //do nothing
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPaySendRedpackRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPaySendRedpackRequest.java
    index f7082fc3da..bc621fc011 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPaySendRedpackRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPaySendRedpackRequest.java
    @@ -1,13 +1,19 @@
     package com.github.binarywang.wxpay.bean.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     
     /**
      * 发送红包请求参数对象
      * Created by Binary Wang on 2016/9/24.
      *
    - * @author binarywang (https://github.com/binarywang)
    + * @author Binary Wang
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@Builder(builderMethodName = "newBuilder")
    +@NoArgsConstructor
    +@AllArgsConstructor
     @XStreamAlias("xml")
     public class WxPaySendRedpackRequest extends WxPayBaseRequest {
       /**
    @@ -137,85 +143,6 @@ public class WxPaySendRedpackRequest extends WxPayBaseRequest {
       @XStreamAlias("consume_mch_id")
       private String consumeMchId;
     
    -  public String getMchBillNo() {
    -    return mchBillNo;
    -  }
    -
    -  public void setMchBillNo(String mchBillNo) {
    -    this.mchBillNo = mchBillNo;
    -  }
    -
    -  public String getSendName() {
    -    return this.sendName;
    -  }
    -
    -  public void setSendName(String sendName) {
    -    this.sendName = sendName;
    -  }
    -
    -  public String getReOpenid() {
    -    return this.reOpenid;
    -  }
    -
    -  public void setReOpenid(String reOpenid) {
    -    this.reOpenid = reOpenid;
    -  }
    -
    -  public Integer getTotalAmount() {
    -    return this.totalAmount;
    -  }
    -
    -  public void setTotalAmount(Integer totalAmount) {
    -    this.totalAmount = totalAmount;
    -  }
    -
    -  public Integer getTotalNum() {
    -    return this.totalNum;
    -  }
    -
    -  public void setTotalNum(Integer totalNum) {
    -    this.totalNum = totalNum;
    -  }
    -
    -  public String getAmtType() {
    -    return this.amtType;
    -  }
    -
    -  public void setAmtType(String amtType) {
    -    this.amtType = amtType;
    -  }
    -
    -  public String getWishing() {
    -    return this.wishing;
    -  }
    -
    -  public void setWishing(String wishing) {
    -    this.wishing = wishing;
    -  }
    -
    -  public String getClientIp() {
    -    return this.clientIp;
    -  }
    -
    -  public void setClientIp(String clientIp) {
    -    this.clientIp = clientIp;
    -  }
    -
    -  public String getActName() {
    -    return this.actName;
    -  }
    -
    -  public void setActName(String actName) {
    -    this.actName = actName;
    -  }
    -
    -  public String getRemark() {
    -    return this.remark;
    -  }
    -
    -  public void setRemark(String remark) {
    -    this.remark = remark;
    -  }
     
       @Override
       protected void checkConstraints() {
    @@ -232,28 +159,4 @@ public void setAppid(String appid) {
         this.wxAppid = appid;
       }
     
    -  public String getSceneId() {
    -    return this.sceneId;
    -  }
    -
    -  public void setSceneId(String sceneId) {
    -    this.sceneId = sceneId;
    -  }
    -
    -  public String getRiskInfo() {
    -    return this.riskInfo;
    -  }
    -
    -  public void setRiskInfo(String riskInfo) {
    -    this.riskInfo = riskInfo;
    -  }
    -
    -  public String getConsumeMchId() {
    -    return this.consumeMchId;
    -  }
    -
    -  public void setConsumeMchId(String consumeMchId) {
    -    this.consumeMchId = consumeMchId;
    -  }
    -
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayShorturlRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayShorturlRequest.java
    index 714e07ea43..3cc9302bcc 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayShorturlRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayShorturlRequest.java
    @@ -1,14 +1,21 @@
     package com.github.binarywang.wxpay.bean.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.*;
     
     /**
      * 
      * 转换短链接请求对象类
      * Created by Binary Wang on 2017-3-27.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayShorturlRequest extends WxPayBaseRequest { /** @@ -24,21 +31,6 @@ public class WxPayShorturlRequest extends WxPayBaseRequest { @XStreamAlias("long_url") private String longUrl; - public WxPayShorturlRequest() { - } - - public WxPayShorturlRequest(String longUrl) { - this.longUrl = longUrl; - } - - public String getLongUrl() { - return this.longUrl; - } - - public void setLongUrl(String longUrl) { - this.longUrl = longUrl; - } - @Override protected void checkConstraints() { //do nothing diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index 8061556cc7..e3c418f351 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -3,6 +3,7 @@ import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; import me.chanjar.weixin.common.annotation.Required; import org.apache.commons.lang3.StringUtils; @@ -10,11 +11,16 @@ *
      * 统一下单请求参数对象
      * 参考文档:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1
    - * 
    * Created by Binary Wang on 2016/9/25. + *
    * - * @author binarywang (https://github.com/binarywang) + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder(builderMethodName = "newBuilder") +@NoArgsConstructor +@AllArgsConstructor @XStreamAlias("xml") public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { private static final String[] TRADE_TYPES = new String[]{"JSAPI", "NATIVE", "APP", "MWEB"}; @@ -310,146 +316,13 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { @XStreamAlias("fingerprint") private String fingerprint; - public WxPayUnifiedOrderRequest() { - } - - private WxPayUnifiedOrderRequest(Builder builder) { - setDeviceInfo(builder.deviceInfo); - setAppid(builder.appid); - setBody(builder.body); - setMchId(builder.mchId); - setSubAppId(builder.subAppId); - setSubMchId(builder.subMchId); - setNonceStr(builder.nonceStr); - setSign(builder.sign); - setDetail(builder.detail); - setAttach(builder.attach); - setOutTradeNo(builder.outTradeNo); - setFeeType(builder.feeType); - setTotalFee(builder.totalFee); - setSpbillCreateIp(builder.spbillCreateIp); - setTimeStart(builder.timeStart); - setTimeExpire(builder.timeExpire); - setGoodsTag(builder.goodsTag); - setNotifyURL(builder.notifyURL); - setTradeType(builder.tradeType); - setProductId(builder.productId); - setLimitPay(builder.limitPay); - setOpenid(builder.openid); - setSubOpenid(builder.subOpenid); - setSceneInfo(builder.sceneInfo); - fingerprint = builder.fingerprint; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public String getDeviceInfo() { - return this.deviceInfo; - } - - public void setDeviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - } - - public String getBody() { - return this.body; - } - - public void setBody(String body) { - this.body = body; - } - - public String getDetail() { - return this.detail; - } - - public void setDetail(String detail) { - this.detail = detail; - } - - public String getAttach() { - return this.attach; - } - - public void setAttach(String attach) { - this.attach = attach; - } - - public String getOutTradeNo() { - return this.outTradeNo; - } - - public void setOutTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; - } - - public String getFeeType() { - return this.feeType; - } - - public void setFeeType(String feeType) { - this.feeType = feeType; - } - - public Integer getTotalFee() { - return this.totalFee; - } - - public void setTotalFee(Integer totalFee) { - this.totalFee = totalFee; - } - - public String getSpbillCreateIp() { - return this.spbillCreateIp; - } - - public void setSpbillCreateIp(String spbillCreateIp) { - this.spbillCreateIp = spbillCreateIp; - } - - public String getTimeStart() { - return this.timeStart; - } - - public void setTimeStart(String timeStart) { - this.timeStart = timeStart; - } - - public String getTimeExpire() { - return this.timeExpire; - } - - public void setTimeExpire(String timeExpire) { - this.timeExpire = timeExpire; - } - - public String getGoodsTag() { - return this.goodsTag; - } - - public void setGoodsTag(String goodsTag) { - this.goodsTag = goodsTag; - } - - public String getNotifyURL() { - return this.notifyURL; - } - /** * 如果配置中已经设置,可以不设置值 - * - * @param notifyURL */ public void setNotifyURL(String notifyURL) { this.notifyURL = notifyURL; } - public String getTradeType() { - return this.tradeType; - } - /** * 如果配置中已经设置,可以不设置值 * @@ -459,46 +332,6 @@ public void setTradeType(String tradeType) { this.tradeType = tradeType; } - public String getProductId() { - return this.productId; - } - - public void setProductId(String productId) { - this.productId = productId; - } - - public String getLimitPay() { - return this.limitPay; - } - - public void setLimitPay(String limitPay) { - this.limitPay = limitPay; - } - - public String getOpenid() { - return this.openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getSubOpenid() { - return this.subOpenid; - } - - public void setSubOpenid(String subOpenid) { - this.subOpenid = subOpenid; - } - - public String getSceneInfo() { - return this.sceneInfo; - } - - public void setSceneInfo(String sceneInfo) { - this.sceneInfo = sceneInfo; - } - @Override protected void checkConstraints() throws WxPayException { // if (!ArrayUtils.contains(TRADE_TYPES, this.getTradeType())) { @@ -528,163 +361,4 @@ public void checkAndSign(WxPayConfig config) throws WxPayException { super.checkAndSign(config); } - public static final class Builder { - private String appid; - private String mchId; - private String subAppId; - private String subMchId; - private String nonceStr; - private String sign; - private String deviceInfo; - private String body; - private String detail; - private String attach; - private String outTradeNo; - private String feeType; - private Integer totalFee; - private String spbillCreateIp; - private String timeStart; - private String timeExpire; - private String goodsTag; - private String notifyURL; - private String tradeType; - private String productId; - private String limitPay; - private String openid; - private String subOpenid; - private String sceneInfo; - private String fingerprint; - - private Builder() { - } - - public Builder appid(String appid) { - this.appid = appid; - return this; - } - - public Builder mchId(String mchId) { - this.mchId = mchId; - return this; - } - - public Builder subAppId(String subAppId) { - this.subAppId = subAppId; - return this; - } - - public Builder subMchId(String subMchId) { - this.subMchId = subMchId; - return this; - } - - public Builder nonceStr(String nonceStr) { - this.nonceStr = nonceStr; - return this; - } - - public Builder sign(String sign) { - this.sign = sign; - return this; - } - - public Builder deviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - return this; - } - - public Builder body(String body) { - this.body = body; - return this; - } - - public Builder detail(String detail) { - this.detail = detail; - return this; - } - - public Builder attach(String attach) { - this.attach = attach; - return this; - } - - public Builder outTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; - return this; - } - - public Builder feeType(String feeType) { - this.feeType = feeType; - return this; - } - - public Builder totalFee(Integer totalFee) { - this.totalFee = totalFee; - return this; - } - - public Builder spbillCreateIp(String spbillCreateIp) { - this.spbillCreateIp = spbillCreateIp; - return this; - } - - public Builder timeStart(String timeStart) { - this.timeStart = timeStart; - return this; - } - - public Builder timeExpire(String timeExpire) { - this.timeExpire = timeExpire; - return this; - } - - public Builder goodsTag(String goodsTag) { - this.goodsTag = goodsTag; - return this; - } - - public Builder notifyURL(String notifyURL) { - this.notifyURL = notifyURL; - return this; - } - - public Builder tradeType(String tradeType) { - this.tradeType = tradeType; - return this; - } - - public Builder productId(String productId) { - this.productId = productId; - return this; - } - - public Builder limitPay(String limitPay) { - this.limitPay = limitPay; - return this; - } - - public Builder openid(String openid) { - this.openid = openid; - return this; - } - - public Builder subOpenid(String subOpenid) { - this.subOpenid = subOpenid; - return this; - } - - public Builder sceneInfo(String sceneInfo) { - this.sceneInfo = sceneInfo; - return this; - } - - public Builder fingerprint(String fingerprint) { - this.fingerprint = fingerprint; - return this; - } - - public WxPayUnifiedOrderRequest build() { - return new WxPayUnifiedOrderRequest(this); - } - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayQueryResult.java index dac69e17c4..b5a0e04345 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayQueryResult.java @@ -1,13 +1,19 @@ package com.github.binarywang.wxpay.bean.result; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** * 企业付款查询返回结果 * Created by Binary Wang on 2016/10/19. * - * @author binarywang (https://github.com/binarywang) + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor @XStreamAlias("xml") public class WxEntPayQueryResult extends WxPayBaseResult { @@ -65,75 +71,4 @@ public class WxEntPayQueryResult extends WxPayBaseResult { @XStreamAlias("desc") private String desc; - public String getPartnerTradeNo() { - return this.partnerTradeNo; - } - - public void setPartnerTradeNo(String partnerTradeNo) { - this.partnerTradeNo = partnerTradeNo; - } - - public String getDetailId() { - return this.detailId; - } - - public void setDetailId(String detailId) { - this.detailId = detailId; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getReason() { - return this.reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - public String getOpenid() { - return this.openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getTransferName() { - return this.transferName; - } - - public void setTransferName(String transferName) { - this.transferName = transferName; - } - - public Integer getPaymentAmount() { - return this.paymentAmount; - } - - public void setPaymentAmount(Integer paymentAmount) { - this.paymentAmount = paymentAmount; - } - - public String getTransferTime() { - return this.transferTime; - } - - public void setTransferTime(String transferTime) { - this.transferTime = transferTime; - } - - public String getDesc() { - return this.desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayResult.java index fa0a4e5fdc..033f6e9639 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxEntPayResult.java @@ -1,13 +1,19 @@ package com.github.binarywang.wxpay.bean.result; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** * 企业付款返回结果 * Created by Binary Wang on 2016/10/02. * - * @author binarywang (https://github.com/binarywang) + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor @XStreamAlias("xml") public class WxEntPayResult extends WxPayBaseResult { @@ -42,43 +48,4 @@ public class WxEntPayResult extends WxPayBaseResult { @XStreamAlias("payment_time") private String paymentTime; - public String getMchAppid() { - return this.mchAppid; - } - - public void setMchAppid(String mchAppid) { - this.mchAppid = mchAppid; - } - - public String getDeviceInfo() { - return this.deviceInfo; - } - - public void setDeviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - } - - public String getPartnerTradeNo() { - return this.partnerTradeNo; - } - - public void setPartnerTradeNo(String partnerTradeNo) { - this.partnerTradeNo = partnerTradeNo; - } - - public String getPaymentNo() { - return this.paymentNo; - } - - public void setPaymentNo(String paymentNo) { - this.paymentNo = paymentNo; - } - - public String getPaymentTime() { - return this.paymentTime; - } - - public void setPaymentTime(String paymentTime) { - this.paymentTime = paymentTime; - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayAuthcode2OpenidResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayAuthcode2OpenidResult.java index f56c61a77f..3f1d53a78e 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayAuthcode2OpenidResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayAuthcode2OpenidResult.java @@ -1,14 +1,21 @@ package com.github.binarywang.wxpay.bean.result; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** *
      *  授权码查询openid接口请求结果类
      * Created by Binary Wang on 2017-3-27.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor @XStreamAlias("xml") public class WxPayAuthcode2OpenidResult extends WxPayBaseResult { /** @@ -23,18 +30,4 @@ public class WxPayAuthcode2OpenidResult extends WxPayBaseResult { @XStreamAlias("openid") private String openid; - public WxPayAuthcode2OpenidResult() { - } - - public WxPayAuthcode2OpenidResult(String openid) { - this.openid = openid; - } - - public String getOpenid() { - return this.openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java index d4b96dc408..63db0e73b1 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java @@ -7,6 +7,7 @@ import com.google.common.collect.Maps; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamInitializer; import org.apache.commons.lang3.StringUtils; @@ -30,9 +31,11 @@ *
      * 微信支付结果共用属性类
      * Created by Binary Wang on 2016-10-24.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data public abstract class WxPayBaseResult { /** * 返回状态码 @@ -124,14 +127,6 @@ public static T fromXML(String xmlString, Class c return result; } - public String getXmlString() { - return this.xmlString; - } - - public void setXmlString(String xmlString) { - this.xmlString = xmlString; - } - protected Logger getLogger() { return LoggerFactory.getLogger(this.getClass()); } @@ -141,94 +136,6 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public String getReturnCode() { - return this.returnCode; - } - - public void setReturnCode(String returnCode) { - this.returnCode = returnCode; - } - - public String getReturnMsg() { - return this.returnMsg; - } - - public void setReturnMsg(String returnMsg) { - this.returnMsg = returnMsg; - } - - public String getResultCode() { - return this.resultCode; - } - - public void setResultCode(String resultCode) { - this.resultCode = resultCode; - } - - public String getErrCode() { - return this.errCode; - } - - public void setErrCode(String errCode) { - this.errCode = errCode; - } - - public String getErrCodeDes() { - return this.errCodeDes; - } - - public void setErrCodeDes(String errCodeDes) { - this.errCodeDes = errCodeDes; - } - - public String getAppid() { - return this.appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public String getMchId() { - return this.mchId; - } - - public void setMchId(String mchId) { - this.mchId = mchId; - } - - public String getNonceStr() { - return this.nonceStr; - } - - public void setNonceStr(String nonceStr) { - this.nonceStr = nonceStr; - } - - public String getSign() { - return this.sign; - } - - public void setSign(String sign) { - this.sign = sign; - } - - public String getSubAppId() { - return subAppId; - } - - public void setSubAppId(String subAppId) { - this.subAppId = subAppId; - } - - public String getSubMchId() { - return subMchId; - } - - public void setSubMchId(String subMchId) { - this.subMchId = subMchId; - } - /** * 将bean通过保存的xml字符串转换成map */ diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java index de58536445..28ed6e7f18 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java @@ -1,5 +1,7 @@ package com.github.binarywang.wxpay.bean.result; +import lombok.Data; +import lombok.NoArgsConstructor; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; @@ -9,6 +11,8 @@ * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00 * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60% */ +@Data +@NoArgsConstructor public class WxPayBillBaseResult implements Serializable { private static final long serialVersionUID = 2226245109137435453L; @@ -114,200 +118,4 @@ public String toString() { */ private String poundageRate; - public static long getSerialversionuid() { - return serialVersionUID; - } - - public String getTradeTime() { - return tradeTime; - } - - public void setTradeTime(String tradeTime) { - this.tradeTime = tradeTime; - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getMchId() { - return mchId; - } - - public void setMchId(String mchId) { - this.mchId = mchId; - } - - public String getSubMchId() { - return subMchId; - } - - public void setSubMchId(String subMchId) { - this.subMchId = subMchId; - } - - public String getDeviceInfo() { - return deviceInfo; - } - - public void setDeviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - } - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getOutTradeNo() { - return outTradeNo; - } - - public void setOutTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; - } - - public String getOpenId() { - return openId; - } - - public void setOpenId(String openId) { - this.openId = openId; - } - - public String getTradeType() { - return tradeType; - } - - public void setTradeType(String tradeType) { - this.tradeType = tradeType; - } - - public String getTradeState() { - return tradeState; - } - - public void setTradeState(String tradeState) { - this.tradeState = tradeState; - } - - public String getBankType() { - return bankType; - } - - public void setBankType(String bankType) { - this.bankType = bankType; - } - - public String getFeeType() { - return feeType; - } - - public void setFeeType(String feeType) { - this.feeType = feeType; - } - - public String getTotalFee() { - return totalFee; - } - - public void setTotalFee(String totalFee) { - this.totalFee = totalFee; - } - - public String getCouponFee() { - return couponFee; - } - - public void setCouponFee(String couponFee) { - this.couponFee = couponFee; - } - - public String getRefundId() { - return refundId; - } - - public void setRefundId(String refundId) { - this.refundId = refundId; - } - - public String getOutRefundNo() { - return outRefundNo; - } - - public void setOutRefundNo(String outRefundNo) { - this.outRefundNo = outRefundNo; - } - - public String getSettlementRefundFee() { - return settlementRefundFee; - } - - public void setSettlementRefundFee(String settlementRefundFee) { - this.settlementRefundFee = settlementRefundFee; - } - - public String getCouponRefundFee() { - return couponRefundFee; - } - - public void setCouponRefundFee(String couponRefundFee) { - this.couponRefundFee = couponRefundFee; - } - - public String getRefundChannel() { - return refundChannel; - } - - public void setRefundChannel(String refundChannel) { - this.refundChannel = refundChannel; - } - - public String getRefundState() { - return refundState; - } - - public void setRefundState(String refundState) { - this.refundState = refundState; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public String getAttach() { - return attach; - } - - public void setAttach(String attach) { - this.attach = attach; - } - - public String getPoundage() { - return poundage; - } - - public void setPoundage(String poundage) { - this.poundage = poundage; - } - - public String getPoundageRate() { - return poundageRate; - } - - public void setPoundageRate(String poundageRate) { - this.poundageRate = poundageRate; - } - } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java index f699a42ba8..0a1a4b2583 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java @@ -1,10 +1,14 @@ package com.github.binarywang.wxpay.bean.result; +import lombok.Data; +import lombok.NoArgsConstructor; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; import java.util.List; +@Data +@NoArgsConstructor public class WxPayBillResult implements Serializable { private static final long serialVersionUID = -7687458652694204070L; @@ -38,53 +42,4 @@ public String toString() { */ private String totalPoundageFee; - public List getWxPayBillBaseResultLst() { - return wxPayBillBaseResultLst; - } - - public void setWxPayBillBaseResultLst(List wxPayBillBaseResultLst) { - this.wxPayBillBaseResultLst = wxPayBillBaseResultLst; - } - - public String getTotalRecord() { - return totalRecord; - } - - public void setTotalRecord(String totalRecord) { - this.totalRecord = totalRecord; - } - - public String getTotalFee() { - return totalFee; - } - - public void setTotalFee(String totalFee) { - this.totalFee = totalFee; - } - - public String getTotalRefundFee() { - return totalRefundFee; - } - - public void setTotalRefundFee(String totalRefundFee) { - this.totalRefundFee = totalRefundFee; - } - - public String getTotalCouponFee() { - return totalCouponFee; - } - - public void setTotalCouponFee(String totalCouponFee) { - this.totalCouponFee = totalCouponFee; - } - - public String getTotalPoundageFee() { - return totalPoundageFee; - } - - public void setTotalPoundageFee(String totalPoundageFee) { - this.totalPoundageFee = totalPoundageFee; - } - - } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayCommonResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayCommonResult.java index 1fc4d30940..8c99c9df37 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayCommonResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayCommonResult.java @@ -6,8 +6,9 @@ *
      * 微信支付结果仅包含有return 和result等相关信息的的属性类
      * Created by Binary Wang on 2017-01-09.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ @XStreamAlias("xml") diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayMicropayResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayMicropayResult.java index 2f8842af82..4f6b04cf3c 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayMicropayResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayMicropayResult.java @@ -1,14 +1,21 @@ package com.github.binarywang.wxpay.bean.result; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** *
      * 提交刷卡支付接口响应结果对象类
      * Created by Binary Wang on 2017-3-23.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor @XStreamAlias("xml") public class WxPayMicropayResult extends WxPayBaseResult { /** @@ -206,123 +213,4 @@ public class WxPayMicropayResult extends WxPayBaseResult { @XStreamAlias("promotion_detail") private String promotionDetail; - public String getOpenid() { - return this.openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getIsSubscribe() { - return this.isSubscribe; - } - - public void setIsSubscribe(String isSubscribe) { - this.isSubscribe = isSubscribe; - } - - public String getTradeType() { - return this.tradeType; - } - - public void setTradeType(String tradeType) { - this.tradeType = tradeType; - } - - public String getBankType() { - return this.bankType; - } - - public void setBankType(String bankType) { - this.bankType = bankType; - } - - public String getFeeType() { - return this.feeType; - } - - public void setFeeType(String feeType) { - this.feeType = feeType; - } - - public String getTotalFee() { - return this.totalFee; - } - - public void setTotalFee(String totalFee) { - this.totalFee = totalFee; - } - - public Integer getSettlementTotalFee() { - return this.settlementTotalFee; - } - - public void setSettlementTotalFee(Integer settlementTotalFee) { - this.settlementTotalFee = settlementTotalFee; - } - - public Integer getCouponFee() { - return this.couponFee; - } - - public void setCouponFee(Integer couponFee) { - this.couponFee = couponFee; - } - - public String getCashFeeType() { - return this.cashFeeType; - } - - public void setCashFeeType(String cashFeeType) { - this.cashFeeType = cashFeeType; - } - - public Integer getCashFee() { - return this.cashFee; - } - - public void setCashFee(Integer cashFee) { - this.cashFee = cashFee; - } - - public String getTransactionId() { - return this.transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getOutTradeNo() { - return this.outTradeNo; - } - - public void setOutTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; - } - - public String getAttach() { - return this.attach; - } - - public void setAttach(String attach) { - this.attach = attach; - } - - public String getTimeEnd() { - return this.timeEnd; - } - - public void setTimeEnd(String timeEnd) { - this.timeEnd = timeEnd; - } - - public String getPromotionDetail() { - return this.promotionDetail; - } - - public void setPromotionDetail(String promotionDetail) { - this.promotionDetail = promotionDetail; - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderCloseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderCloseResult.java index 7221251f10..5451c8535d 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderCloseResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderCloseResult.java @@ -1,14 +1,21 @@ package com.github.binarywang.wxpay.bean.result; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** *
      * 关闭订单结果对象类
      * Created by Binary Wang on 2016-10-27.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor @XStreamAlias("xml") public class WxPayOrderCloseResult extends WxPayBaseResult { @@ -18,11 +25,4 @@ public class WxPayOrderCloseResult extends WxPayBaseResult { @XStreamAlias("result_msg") private String resultMsg; - public String getResultMsg() { - return this.resultMsg; - } - - public void setResultMsg(String resultMsg) { - this.resultMsg = resultMsg; - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderQueryResult.java index ff087bf010..9da15f5a6f 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderQueryResult.java @@ -2,6 +2,7 @@ import com.google.common.collect.Lists; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; import java.util.List; @@ -18,8 +19,11 @@ *
  • 描述 *
  • * - * @author binarywang(Binary Wang) + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor @XStreamAlias("xml") public class WxPayOrderQueryResult extends WxPayBaseResult { @@ -236,158 +240,6 @@ public class WxPayOrderQueryResult extends WxPayBaseResult { @XStreamAlias("trade_state_desc") private String tradeStateDesc; - public String getDeviceInfo() { - return this.deviceInfo; - } - - public void setDeviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - } - - public String getOpenid() { - return this.openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getIsSubscribe() { - return this.isSubscribe; - } - - public void setIsSubscribe(String isSubscribe) { - this.isSubscribe = isSubscribe; - } - - public String getTradeType() { - return this.tradeType; - } - - public void setTradeType(String tradeType) { - this.tradeType = tradeType; - } - - public String getTradeState() { - return this.tradeState; - } - - public void setTradeState(String tradeState) { - this.tradeState = tradeState; - } - - public String getBankType() { - return this.bankType; - } - - public void setBankType(String bankType) { - this.bankType = bankType; - } - - public Integer getTotalFee() { - return this.totalFee; - } - - public void setTotalFee(Integer totalFee) { - this.totalFee = totalFee; - } - - public Integer getSettlementTotalFee() { - return this.settlementTotalFee; - } - - public void setSettlementTotalFee(Integer settlementTotalFee) { - this.settlementTotalFee = settlementTotalFee; - } - - public String getFeeType() { - return this.feeType; - } - - public void setFeeType(String feeType) { - this.feeType = feeType; - } - - public Integer getCashFee() { - return this.cashFee; - } - - public void setCashFee(Integer cashFee) { - this.cashFee = cashFee; - } - - public String getCashFeeType() { - return this.cashFeeType; - } - - public void setCashFeeType(String cashFeeType) { - this.cashFeeType = cashFeeType; - } - - public Integer getCouponFee() { - return this.couponFee; - } - - public void setCouponFee(Integer couponFee) { - this.couponFee = couponFee; - } - - public Integer getCouponCount() { - return this.couponCount; - } - - public void setCouponCount(Integer couponCount) { - this.couponCount = couponCount; - } - - public List getCoupons() { - return this.coupons; - } - - public void setCoupons(List coupons) { - this.coupons = coupons; - } - - public String getTransactionId() { - return this.transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getOutTradeNo() { - return this.outTradeNo; - } - - public void setOutTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; - } - - public String getAttach() { - return this.attach; - } - - public void setAttach(String attach) { - this.attach = attach; - } - - public String getTimeEnd() { - return this.timeEnd; - } - - public void setTimeEnd(String timeEnd) { - this.timeEnd = timeEnd; - } - - public String getTradeStateDesc() { - return this.tradeStateDesc; - } - - public void setTradeStateDesc(String tradeStateDesc) { - this.tradeStateDesc = tradeStateDesc; - } - /** * 通过xml组装coupons属性内容 */ @@ -402,6 +254,9 @@ public void composeCoupons() { } } + @Data + @Builder(builderMethodName = "newBuilder") + @AllArgsConstructor public static class Coupon { /** *
    代金券类型
    @@ -438,35 +293,5 @@ public static class Coupon {
          */
         private Integer couponFee;
     
    -    public Coupon(String couponType, String couponId, Integer couponFee) {
    -      this.couponType = couponType;
    -      this.couponId = couponId;
    -      this.couponFee = couponFee;
    -    }
    -
    -    public String getCouponType() {
    -      return this.couponType;
    -    }
    -
    -    public void setCouponType(String couponType) {
    -      this.couponType = couponType;
    -    }
    -
    -    public String getCouponId() {
    -      return this.couponId;
    -    }
    -
    -    public void setCouponId(String couponId) {
    -      this.couponId = couponId;
    -    }
    -
    -    public Integer getCouponFee() {
    -      return this.couponFee;
    -    }
    -
    -    public void setCouponFee(Integer couponFee) {
    -      this.couponFee = couponFee;
    -    }
    -
       }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderReverseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderReverseResult.java
    index c80b72d216..bf36764f6e 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderReverseResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayOrderReverseResult.java
    @@ -1,14 +1,21 @@
     package com.github.binarywang.wxpay.bean.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     
     /**
      * 
      * 撤销订单响应结果类
      * Created by Binary Wang on 2017-3-23.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor @XStreamAlias("xml") public class WxPayOrderReverseResult extends WxPayBaseResult { @@ -25,11 +32,4 @@ public class WxPayOrderReverseResult extends WxPayBaseResult { @XStreamAlias("recall") private String isRecall; - public String getIsRecall() { - return this.isRecall; - } - - public void setIsRecall(String isRecall) { - this.isRecall = isRecall; - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRedpackQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRedpackQueryResult.java index e0b86732fd..84030f172f 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRedpackQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRedpackQueryResult.java @@ -1,6 +1,9 @@ package com.github.binarywang.wxpay.bean.result; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** *
    @@ -12,9 +15,13 @@
      *   类型
      *   说明
      * Created by Binary Wang on 2016-11-28.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor @XStreamAlias("xml") public class WxPayRedpackQueryResult extends WxPayBaseResult { @@ -259,148 +266,4 @@ public class WxPayRedpackQueryResult extends WxPayBaseResult { */ @XStreamAlias("rcv_time") private String receiveTime; - - public String getMchBillNo() { - return mchBillNo; - } - - public void setMchBillNo(String mchBillNo) { - this.mchBillNo = mchBillNo; - } - - public String getDetailId() { - return detailId; - } - - public void setDetailId(String detailId) { - this.detailId = detailId; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getSendType() { - return sendType; - } - - public void setSendType(String sendType) { - this.sendType = sendType; - } - - public String getHbType() { - return hbType; - } - - public void setHbType(String hbType) { - this.hbType = hbType; - } - - public Integer getTotalNum() { - return totalNum; - } - - public void setTotalNum(Integer totalNum) { - this.totalNum = totalNum; - } - - public Integer getTotalAmount() { - return totalAmount; - } - - public void setTotalAmount(Integer totalAmount) { - this.totalAmount = totalAmount; - } - - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - public String getSendTime() { - return sendTime; - } - - public void setSendTime(String sendTime) { - this.sendTime = sendTime; - } - - public String getRefundTime() { - return refundTime; - } - - public void setRefundTime(String refundTime) { - this.refundTime = refundTime; - } - - public Integer getRefundAmount() { - return refundAmount; - } - - public void setRefundAmount(Integer refundAmount) { - this.refundAmount = refundAmount; - } - - public String getWishing() { - return wishing; - } - - public void setWishing(String wishing) { - this.wishing = wishing; - } - - public String getRemark() { - return remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public String getActName() { - return actName; - } - - public void setActName(String actName) { - this.actName = actName; - } - - public String getHblist() { - return hblist; - } - - public void setHblist(String hblist) { - this.hblist = hblist; - } - - public String getOpenid() { - return openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public Integer getAmount() { - return amount; - } - - public void setAmount(Integer amount) { - this.amount = amount; - } - - public String getReceiveTime() { - return receiveTime; - } - - public void setReceiveTime(String receiveTime) { - this.receiveTime = receiveTime; - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java index 1916fdb9e7..f97336015a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundQueryResult.java @@ -2,15 +2,20 @@ import com.google.common.collect.Lists; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.*; import java.util.List; /** *
      * Created by Binary Wang on 2016-11-24.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor @XStreamAlias("xml") public class WxPayRefundQueryResult extends WxPayBaseResult { /** @@ -111,78 +116,6 @@ public class WxPayRefundQueryResult extends WxPayBaseResult { private List refundRecords; - public String getDeviceInfo() { - return deviceInfo; - } - - public void setDeviceInfo(String deviceInfo) { - this.deviceInfo = deviceInfo; - } - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getOutTradeNo() { - return outTradeNo; - } - - public void setOutTradeNo(String outTradeNo) { - this.outTradeNo = outTradeNo; - } - - public Integer getTotalFee() { - return totalFee; - } - - public void setTotalFee(Integer totalFee) { - this.totalFee = totalFee; - } - - public Integer getSettlementTotalFee() { - return settlementTotalFee; - } - - public void setSettlementTotalFee(Integer settlementTotalFee) { - this.settlementTotalFee = settlementTotalFee; - } - - public String getFeeType() { - return feeType; - } - - public void setFeeType(String feeType) { - this.feeType = feeType; - } - - public Integer getCashFee() { - return cashFee; - } - - public void setCashFee(Integer cashFee) { - this.cashFee = cashFee; - } - - public Integer getRefundCount() { - return refundCount; - } - - public void setRefundCount(Integer refundCount) { - this.refundCount = refundCount; - } - - public List getRefundRecords() { - return refundRecords; - } - - public void setRefundRecords(List refundRecords) { - this.refundRecords = refundRecords; - } - /** * 组装生成退款记录属性的内容 */ @@ -203,7 +136,7 @@ public void composeRefundRecords() { refundRecord.setCouponRefundFee(this.getXmlValueAsInt("xml/coupon_refund_fee_" + i)); refundRecord.setCouponRefundCount(this.getXmlValueAsInt("xml/coupon_refund_count_" + i)); refundRecord.setRefundStatus(this.getXmlValue("xml/refund_status_" + i)); - refundRecord.setRefundRecvAccout(this.getXmlValue("xml/refund_recv_accout_" + i)); + refundRecord.setRefundRecvAccount(this.getXmlValue("xml/refund_recv_accout_" + i)); if (refundRecord.getCouponRefundCount() == null || refundRecord.getCouponRefundCount() == 0) { continue; @@ -223,6 +156,10 @@ public void composeRefundRecords() { } } + @Data + @Builder(builderMethodName = "newBuilder") + @NoArgsConstructor + @AllArgsConstructor public static class RefundRecord { /** *
    @@ -371,104 +308,10 @@ public static class RefundRecord {
          * 
    */ @XStreamAlias("refund_recv_accout") - private String refundRecvAccout; - - public String getOutRefundNo() { - return outRefundNo; - } - - public void setOutRefundNo(String outRefundNo) { - this.outRefundNo = outRefundNo; - } - - public String getRefundId() { - return refundId; - } - - public void setRefundId(String refundId) { - this.refundId = refundId; - } - - public String getRefundChannel() { - return refundChannel; - } - - public void setRefundChannel(String refundChannel) { - this.refundChannel = refundChannel; - } - - public Integer getRefundFee() { - return refundFee; - } - - public void setRefundFee(Integer refundFee) { - this.refundFee = refundFee; - } - - public Integer getSettlementRefundFee() { - return settlementRefundFee; - } - - public void setSettlementRefundFee(Integer settlementRefundFee) { - this.settlementRefundFee = settlementRefundFee; - } - - public String getRefundAccount() { - return refundAccount; - } - - public void setRefundAccount(String refundAccount) { - this.refundAccount = refundAccount; - } - - public String getCouponType() { - return couponType; - } - - public void setCouponType(String couponType) { - this.couponType = couponType; - } - - public Integer getCouponRefundFee() { - return couponRefundFee; - } - - public void setCouponRefundFee(Integer couponRefundFee) { - this.couponRefundFee = couponRefundFee; - } - - public Integer getCouponRefundCount() { - return couponRefundCount; - } - - public void setCouponRefundCount(Integer couponRefundCount) { - this.couponRefundCount = couponRefundCount; - } - - public List getRefundCoupons() { - return refundCoupons; - } - - public void setRefundCoupons(List refundCoupons) { - this.refundCoupons = refundCoupons; - } - - public String getRefundStatus() { - return refundStatus; - } - - public void setRefundStatus(String refundStatus) { - this.refundStatus = refundStatus; - } - - public String getRefundRecvAccout() { - return refundRecvAccout; - } - - public void setRefundRecvAccout(String refundRecvAccout) { - this.refundRecvAccout = refundRecvAccout; - } + private String refundRecvAccount; + @Data + @NoArgsConstructor public static class RefundCoupon { /** *
    @@ -516,12 +359,6 @@ public RefundCoupon(String couponRefundId, Integer couponRefundFee) {
             this.couponRefundFee = couponRefundFee;
           }
     
    -      @Deprecated
    -      public RefundCoupon(String couponRefundBatchId, String couponRefundId, Integer couponRefundFee) {
    -        this.couponRefundBatchId = couponRefundBatchId;
    -        this.couponRefundId = couponRefundId;
    -        this.couponRefundFee = couponRefundFee;
    -      }
         }
     
       }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundResult.java
    index 1e6126b210..2da31a3798 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayRefundResult.java
    @@ -1,6 +1,9 @@
     package com.github.binarywang.wxpay.bean.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     
     import java.io.Serializable;
     
    @@ -12,6 +15,9 @@
      *
      * @author liukaitj
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@NoArgsConstructor
     @XStreamAlias("xml")
     public class WxPayRefundResult extends WxPayBaseResult implements Serializable {
       private static final long serialVersionUID = 1L;
    @@ -58,116 +64,4 @@ public class WxPayRefundResult extends WxPayBaseResult implements Serializable {
       @XStreamAlias("coupon_refund_id")
       private String couponRefundId;
     
    -  public String getDeviceInfo() {
    -    return this.deviceInfo;
    -  }
    -
    -  public void setDeviceInfo(String deviceInfo) {
    -    this.deviceInfo = deviceInfo;
    -  }
    -
    -  public String getTransactionId() {
    -    return this.transactionId;
    -  }
    -
    -  public void setTransactionId(String transactionId) {
    -    this.transactionId = transactionId;
    -  }
    -
    -  public String getOutTradeNo() {
    -    return this.outTradeNo;
    -  }
    -
    -  public void setOutTradeNo(String outTradeNo) {
    -    this.outTradeNo = outTradeNo;
    -  }
    -
    -  public String getOutRefundNo() {
    -    return this.outRefundNo;
    -  }
    -
    -  public void setOutRefundNo(String outRefundNo) {
    -    this.outRefundNo = outRefundNo;
    -  }
    -
    -  public String getRefundId() {
    -    return this.refundId;
    -  }
    -
    -  public void setRefundId(String refundId) {
    -    this.refundId = refundId;
    -  }
    -
    -  public String getRefundChannel() {
    -    return this.refundChannel;
    -  }
    -
    -  public void setRefundChannel(String refundChannel) {
    -    this.refundChannel = refundChannel;
    -  }
    -
    -  public String getRefundFee() {
    -    return this.refundFee;
    -  }
    -
    -  public void setRefundFee(String refundFee) {
    -    this.refundFee = refundFee;
    -  }
    -
    -  public String getTotalFee() {
    -    return this.totalFee;
    -  }
    -
    -  public void setTotalFee(String totalFee) {
    -    this.totalFee = totalFee;
    -  }
    -
    -  public String getFeeType() {
    -    return this.feeType;
    -  }
    -
    -  public void setFeeType(String feeType) {
    -    this.feeType = feeType;
    -  }
    -
    -  public String getCashFee() {
    -    return this.cashFee;
    -  }
    -
    -  public void setCashFee(String cashFee) {
    -    this.cashFee = cashFee;
    -  }
    -
    -  public String getCashRefundFee() {
    -    return this.cashRefundFee;
    -  }
    -
    -  public void setCashRefundFee(String cashRefundFee) {
    -    this.cashRefundFee = cashRefundFee;
    -  }
    -
    -  public String getCouponRefundFee() {
    -    return this.couponRefundFee;
    -  }
    -
    -  public void setCouponRefundFee(String couponRefundFee) {
    -    this.couponRefundFee = couponRefundFee;
    -  }
    -
    -  public String getCouponRefundCount() {
    -    return this.couponRefundCount;
    -  }
    -
    -  public void setCouponRefundCount(String couponRefundCount) {
    -    this.couponRefundCount = couponRefundCount;
    -  }
    -
    -  public String getCouponRefundId() {
    -    return this.couponRefundId;
    -  }
    -
    -  public void setCouponRefundId(String couponRefundId) {
    -    this.couponRefundId = couponRefundId;
    -  }
    -
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySandboxSignKeyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySandboxSignKeyResult.java
    index 6326f694d3..792e00fdeb 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySandboxSignKeyResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySandboxSignKeyResult.java
    @@ -1,6 +1,9 @@
     package com.github.binarywang.wxpay.bean.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     
     /**
      * 
    @@ -9,6 +12,9 @@
      *
      * @author Binary Wang
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@NoArgsConstructor
     @XStreamAlias("xml")
     public class WxPaySandboxSignKeyResult extends WxPayBaseResult {
     
    @@ -25,11 +31,4 @@ public class WxPaySandboxSignKeyResult extends WxPayBaseResult {
       @XStreamAlias("sandbox_signkey")
       private String sandboxSignKey;
     
    -  public String getSandboxSignKey() {
    -    return sandboxSignKey;
    -  }
    -
    -  public void setSandboxSignKey(String sandboxSignKey) {
    -    this.sandboxSignKey = sandboxSignKey;
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySendRedpackResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySendRedpackResult.java
    index 868f089b74..560721f5a8 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySendRedpackResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPaySendRedpackResult.java
    @@ -1,6 +1,9 @@
     package com.github.binarywang.wxpay.bean.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     
     import java.io.Serializable;
     
    @@ -10,6 +13,9 @@
      *
      * @author kane
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@NoArgsConstructor
     @XStreamAlias("xml")
     public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializable {
       private static final long serialVersionUID = -4837415036337132073L;
    @@ -32,51 +38,4 @@ public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializa
       @XStreamAlias("send_listid")
       private String sendListid;
     
    -  public String getMchBillno() {
    -    return this.mchBillno;
    -  }
    -
    -  public void setMchBillno(String mchBillno) {
    -    this.mchBillno = mchBillno;
    -  }
    -
    -  public String getWxappid() {
    -    return this.wxappid;
    -  }
    -
    -  public void setWxappid(String wxappid) {
    -    this.wxappid = wxappid;
    -  }
    -
    -  public String getReOpenid() {
    -    return this.reOpenid;
    -  }
    -
    -  public void setReOpenid(String reOpenid) {
    -    this.reOpenid = reOpenid;
    -  }
    -
    -  public int getTotalAmount() {
    -    return this.totalAmount;
    -  }
    -
    -  public void setTotalAmount(int totalAmount) {
    -    this.totalAmount = totalAmount;
    -  }
    -
    -  public String getSendTime() {
    -    return this.sendTime;
    -  }
    -
    -  public void setSendTime(String sendTime) {
    -    this.sendTime = sendTime;
    -  }
    -
    -  public String getSendListid() {
    -    return this.sendListid;
    -  }
    -
    -  public void setSendListid(String sendListid) {
    -    this.sendListid = sendListid;
    -  }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayShorturlResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayShorturlResult.java
    index 2f93cb81bf..93e74a0cce 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayShorturlResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayShorturlResult.java
    @@ -1,14 +1,21 @@
     package com.github.binarywang.wxpay.bean.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
    +import lombok.NoArgsConstructor;
     
     /**
      * 
      * 转换短链接结果对象类
      * Created by Binary Wang on 2017-3-27.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor @XStreamAlias("xml") public class WxPayShorturlResult extends WxPayBaseResult { /** @@ -24,11 +31,4 @@ public class WxPayShorturlResult extends WxPayBaseResult { @XStreamAlias("short_url") private String shortUrl; - public String getShortUrl() { - return this.shortUrl; - } - - public void setShortUrl(String shortUrl) { - this.shortUrl = shortUrl; - } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java index d8ab2ab6df..4f25421fc2 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayUnifiedOrderResult.java @@ -1,6 +1,9 @@ package com.github.binarywang.wxpay.bean.result; import com.thoughtworks.xstream.annotations.XStreamAlias; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** *
    @@ -10,6 +13,9 @@
      *
      * @author chanjarster
      */
    +@Data
    +@EqualsAndHashCode(callSuper = true)
    +@NoArgsConstructor
     @XStreamAlias("xml")
     public class WxPayUnifiedOrderResult extends WxPayBaseResult {
     
    @@ -37,35 +43,4 @@ public class WxPayUnifiedOrderResult extends WxPayBaseResult {
       @XStreamAlias("code_url")
       private String codeURL;
     
    -  public String getPrepayId() {
    -    return this.prepayId;
    -  }
    -
    -  public void setPrepayId(String prepayId) {
    -    this.prepayId = prepayId;
    -  }
    -
    -  public String getTradeType() {
    -    return this.tradeType;
    -  }
    -
    -  public void setTradeType(String tradeType) {
    -    this.tradeType = tradeType;
    -  }
    -
    -  public String getCodeURL() {
    -    return this.codeURL;
    -  }
    -
    -  public void setCodeURL(String codeURL) {
    -    this.codeURL = codeURL;
    -  }
    -
    -  public String getMwebUrl() {
    -    return mwebUrl;
    -  }
    -
    -  public void setMwebUrl(String mwebUrl) {
    -    this.mwebUrl = mwebUrl;
    -  }
     }
    
    From a0882025073d51c27735fad3d54c839744f0f98e Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Thu, 21 Sep 2017 15:15:35 +0800
    Subject: [PATCH 097/165] =?UTF-8?q?pay=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3?=
     =?UTF-8?q?=E5=A2=9E=E5=8A=A0createOrder=E7=94=A8=E4=BB=A5=E6=9B=BF?=
     =?UTF-8?q?=E6=8D=A2getPayInfo=E6=96=B9=E6=B3=95?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../wxpay/service/WxPayService.java           |  16 ++-
     .../impl/WxPayServiceAbstractImpl.java        |   8 +-
     .../impl/WxPayServiceAbstractImplTest.java    | 105 +++++++++++++++---
     3 files changed, 110 insertions(+), 19 deletions(-)
    
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
    index ae058e1478..33cd56c6c9 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java
    @@ -19,7 +19,7 @@
      * Created by Binary Wang on 2016/7/28.
      * 
    * - * @author binarywang (https://github.com/binarywang) + * @author Binary Wang */ public interface WxPayService { @@ -56,6 +56,15 @@ public interface WxPayService { */ WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException; + /** + * 调用统一下单接口,并组装生成支付所需参数对象 + * + * @param request 统一下单请求参数 + * @param 请使用{@link com.github.binarywang.wxpay.bean.order}包下的类 + * @return 返回 {@link com.github.binarywang.wxpay.bean.order}包下的类对象 + */ + T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException; + /** * 统一下单(详见https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_1) * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识" @@ -70,7 +79,9 @@ public interface WxPayService { * 详见https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_5 * * @param request 请求对象,注意一些参数如appid、mchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置) + * @deprecated 建议使用 {@link com.github.binarywang.wxpay.service.WxPayService#createOrder(WxPayUnifiedOrderRequest)} */ + @Deprecated Map getPayInfo(WxPayUnifiedOrderRequest request) throws WxPayException; /** @@ -117,7 +128,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri /** * @see WxPayService#parseOrderNotifyResult(String) - * @deprecated use WxPayService#parseOrderNotifyResult(String) instead + * @deprecated use {@link WxPayService#parseOrderNotifyResult(String)} instead */ @Deprecated WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxPayException; @@ -403,6 +414,7 @@ WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, Stri * 是否需要证书:需要 * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_17&index=10 *
    + * * @param beginDate 开始时间 * @param endDate 结束时间 * @param offset 位移 diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index ae855d5b5d..0685c6c990 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -204,6 +204,7 @@ public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException return result; } + @Override public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException { WxPayUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request); String prepayId = unifiedOrderResult.getPrepayId(); @@ -217,7 +218,8 @@ public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException Object payResult = null; switch (request.getTradeType()) { case TradeType.NATIVE: { - payResult = WxPayNativeOrderResult.newBuilder().codeUrl(unifiedOrderResult.getCodeURL()) + payResult = WxPayNativeOrderResult.builder() + .codeUrl(unifiedOrderResult.getCodeURL()) .build(); break; } @@ -235,7 +237,7 @@ public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException configMap.put("noncestr", nonceStr); configMap.put("appid", appId); - payResult = WxPayAppOrderResult.newBuilder() + payResult = WxPayAppOrderResult.builder() .sign(SignUtils.createSign(configMap, this.getConfig().getMchKey(), null)) .prepayId(prepayId) .partnerId(partnerId) @@ -247,7 +249,7 @@ public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException break; } case TradeType.JSAPI: { - payResult = WxPayMpOrderResult.newBuilder() + payResult = WxPayMpOrderResult.builder() .appId(unifiedOrderResult.getAppid()) .timeStamp(timestamp) .nonceStr(nonceStr) diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index afea13d8fd..d54942b4a3 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -2,6 +2,9 @@ import com.github.binarywang.utils.qrcode.QrcodeUtils; import com.github.binarywang.wxpay.bean.coupon.*; +import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult; +import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; +import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.constant.WxPayConstants; @@ -29,7 +32,7 @@ * 测试支付相关接口 * Created by Binary Wang on 2016/7/28. * - * @author binarywang (https://github.com/binarywang) + * @author Binary Wang */ @Test @Guice(modules = ApiTestModule.class) @@ -58,17 +61,85 @@ public void testUnifiedOrder() throws WxPayException { this.logger.warn(this.payService.getWxApiData().toString()); } + @Test + public void testCreateOrder() throws Exception { + //see other tests with method name starting with 'testCreateOrder_' + } + + @Test + public void testCreateOrder_jssdk() throws Exception { + WxPayMpOrderResult result = this.payService + .createOrder(WxPayUnifiedOrderRequest.newBuilder() + .body("我去") + .totalFee(1) + .spbillCreateIp("11.1.11.1") + .notifyURL("111111") + .tradeType(TradeType.JSAPI) + .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()) + .outTradeNo("1111112") + .build()); + this.logger.info(result.toString()); + this.logger.warn(this.payService.getWxApiData().toString()); + } + + @Test + public void testCreateOrder_app() throws Exception { + WxPayAppOrderResult result = this.payService + .createOrder(WxPayUnifiedOrderRequest.newBuilder() + .body("我去") + .totalFee(1) + .spbillCreateIp("11.1.11.1") + .notifyURL("111111") + .tradeType(TradeType.APP) + .outTradeNo("1111112") + .build()); + this.logger.info(result.toString()); + this.logger.warn(this.payService.getWxApiData().toString()); + } + + @Test + public void testCreateOrder_native() throws Exception { + WxPayNativeOrderResult result = this.payService + .createOrder(WxPayUnifiedOrderRequest.newBuilder() + .body("我去") + .totalFee(1) + .spbillCreateIp("11.1.11.1") + .notifyURL("111111") + .tradeType(TradeType.NATIVE) + .outTradeNo("1111112") + .build()); + this.logger.info(result.toString()); + this.logger.warn(this.payService.getWxApiData().toString()); + } + + @Test + public void testCreateOrder_micropay() throws Exception { + //TODO 待完善 + Object result = this.payService + .createOrder(WxPayUnifiedOrderRequest.newBuilder() + .body("我去") + .totalFee(1) + .spbillCreateIp("11.1.11.1") + .notifyURL("111111") + .tradeType(TradeType.MICROPAY) + .outTradeNo("1111112") + .build()); + this.logger.info(result.toString()); + this.logger.warn(this.payService.getWxApiData().toString()); + } + @Test public void testGetPayInfo() throws Exception { - Map payInfo = this.payService.getPayInfo(WxPayUnifiedOrderRequest.newBuilder() - .body("我去") - .totalFee(1) - .spbillCreateIp("1.11.1.11") - .notifyURL("111111") - .tradeType(TradeType.JSAPI) - .outTradeNo("1111113") - .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()) - .build()); + Map payInfo = this.payService + .getPayInfo(WxPayUnifiedOrderRequest.newBuilder() + .body("我去") + .totalFee(1) + .spbillCreateIp("1.11.1.11") + .notifyURL("111111") + .tradeType(TradeType.JSAPI) + .outTradeNo("1111113") + .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()) + .build()); this.logger.info(payInfo.toString()); } @@ -237,10 +308,6 @@ public void testCreateScanPayQrcodeMode2() throws Exception { assertEquals(QrcodeUtils.decodeQrcode(qrcodeFilePath.toFile()), qrcodeContent); } - @Test - public void testGetOrderNotifyResult() throws Exception { - } - @Test public void testMicropay() throws Exception { WxPayMicropayResult result = this.payService.micropay(WxPayMicropayRequest.newBuilder() @@ -347,4 +414,14 @@ public void testQueryComment() throws Exception { this.payService.queryComment(beginDate, endDate, 0, null); } + @Test + public void testParseOrderNotifyResult() throws Exception { + // 请参考com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResultTest里的单元测试 + } + + @Test + public void testGetWxApiData() throws Exception { + //see test in testUnifiedOrder() + } + } From 3e75064c5167fbd0f7983f512f7e49ae0e6973e3 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 21 Sep 2017 17:53:48 +0800 Subject: [PATCH 098/165] add ResultCode constant class for wxpay --- .../binarywang/wxpay/constant/WxPayConstants.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java index 47f636d0fc..4785563905 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java @@ -108,4 +108,19 @@ public static class LimitPay { */ public static final String NO_CREDIT = "no_credit"; } + + /** + * 业务结果代码 + */ + public static class ResultCode { + /** + * 成功 + */ + public static final String SUCCESS = "SUCCESS"; + + /** + * 失败 + */ + public static final String FAIL = "FAIL"; + } } From 7bb3a1270d27479c777fd40727cdbee63d54d069 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 22 Sep 2017 10:58:06 +0800 Subject: [PATCH 099/165] =?UTF-8?q?=E6=94=B9=E5=86=99=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BD=BF=E7=94=A8StringUtils.equalsAny=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=EF=BC=8C=E9=81=BF=E5=85=8D=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AFjar=E5=8C=85=E5=86=B2=E7=AA=81=E5=BC=95?= =?UTF-8?q?=E8=B5=B7=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E9=BA=BB=E7=83=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binarywang/wxpay/bean/result/WxPayBaseResult.java | 7 +++++-- .../java/com/github/binarywang/wxpay/util/SignUtils.java | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java index 63db0e73b1..6607b7698e 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java @@ -4,6 +4,7 @@ import com.github.binarywang.wxpay.service.impl.WxPayServiceAbstractImpl; import com.github.binarywang.wxpay.util.SignUtils; import com.google.common.base.Joiner; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.annotations.XStreamAlias; @@ -25,6 +26,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.math.BigDecimal; +import java.util.List; import java.util.Map; /** @@ -222,9 +224,10 @@ public void checkResult(WxPayServiceAbstractImpl wxPayService) throws WxPayExcep throw new WxPayException("参数格式校验错误!"); } + List successStrings = Lists.newArrayList("SUCCESS", ""); //校验结果是否成功 - if (!StringUtils.equalsAny(StringUtils.trimToEmpty(getReturnCode()).toUpperCase(), "SUCCESS", "") - || !StringUtils.equalsAny(StringUtils.trimToEmpty(getResultCode()).toUpperCase(), "SUCCESS", "")) { + if (!successStrings.contains(StringUtils.trimToEmpty(getReturnCode()).toUpperCase()) + || !successStrings.contains(StringUtils.trimToEmpty(getResultCode()).toUpperCase())) { StringBuilder errorMsg = new StringBuilder(); if (getReturnCode() != null) { errorMsg.append("返回代码:").append(getReturnCode()); diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java index b13175a724..6bff4d7a3d 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java @@ -1,10 +1,10 @@ package com.github.binarywang.wxpay.util; import com.github.binarywang.wxpay.constant.WxPayConstants.SignType; +import com.google.common.collect.Lists; import me.chanjar.weixin.common.util.BeanUtils; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.lang3.StringUtils; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; @@ -56,8 +56,7 @@ public static String createSign(Map params, String signKey, Stri StringBuilder toSign = new StringBuilder(); for (String key : sortedMap.keySet()) { String value = params.get(key); - if (StringUtils.isNotEmpty(value) - && !StringUtils.equalsAny(key, "sign", "key", "sign_type")) { + if (!Lists.newArrayList("sign", "key", "sign_type").contains(key)) { toSign.append(key).append("=").append(value).append("&"); } } From b7443f41ae9d11dfe3633b3228fce8c3cc908d06 Mon Sep 17 00:00:00 2001 From: Jink2005 Date: Fri, 22 Sep 2017 11:04:05 +0800 Subject: [PATCH 100/165] =?UTF-8?q?#345=20=E4=BF=AE=E5=A4=8D=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=95=86=E6=A8=A1=E5=BC=8F=E4=B8=8B=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BB=85=E6=9C=89sub=5Fopenid=E6=97=B6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E9=A2=84=E4=B8=8B=E5=8D=95=E7=9A=84=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/bean/request/WxPayUnifiedOrderRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index e3c418f351..edfe3f5274 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -339,8 +339,8 @@ protected void checkConstraints() throws WxPayException { // Arrays.toString(TRADE_TYPES), this.getTradeType())); // } - if ("JSAPI".equals(this.getTradeType()) && this.getOpenid() == null) { - throw new WxPayException("当 trade_type是'JSAPI'时未指定openid"); + if ("JSAPI".equals(this.getTradeType()) && this.getOpenid() == null && this.getSubOpenid() == null) { + throw new WxPayException("当 trade_type是'JSAPI'时未指定openid或sub_openid"); } if ("NATIVE".equals(this.getTradeType()) && this.getProductId() == null) { From 70f7bd7e7a303bc14029b7cf30724df567ec1136 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 22 Sep 2017 11:11:22 +0800 Subject: [PATCH 101/165] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=B0=BD=E9=87=8F=E4=BD=BF=E7=94=A8=E5=B7=B2=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=9A=84=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/WxPayUnifiedOrderRequest.java | 12 ++----- .../impl/WxPayServiceAbstractImplTest.java | 32 ++----------------- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index edfe3f5274..ecd73dd5a8 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -1,6 +1,7 @@ package com.github.binarywang.wxpay.bean.request; import com.github.binarywang.wxpay.config.WxPayConfig; +import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType; import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.annotations.XStreamAlias; import lombok.*; @@ -23,8 +24,6 @@ @AllArgsConstructor @XStreamAlias("xml") public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { - private static final String[] TRADE_TYPES = new String[]{"JSAPI", "NATIVE", "APP", "MWEB"}; - /** *
        * 字段名:设备号
    @@ -334,16 +333,11 @@ public void setTradeType(String tradeType) {
     
       @Override
       protected void checkConstraints() throws WxPayException {
    -//    if (!ArrayUtils.contains(TRADE_TYPES, this.getTradeType())) {
    -//      throw new WxPayException(String.format("trade_type目前必须为%s其中之一,实际值:%s",
    -//        Arrays.toString(TRADE_TYPES), this.getTradeType()));
    -//    }
    -
    -    if ("JSAPI".equals(this.getTradeType()) && this.getOpenid() == null && this.getSubOpenid() == null) {
    +    if (TradeType.JSAPI.equals(this.getTradeType()) && this.getOpenid() == null && this.getSubOpenid() == null) {
           throw new WxPayException("当 trade_type是'JSAPI'时未指定openid或sub_openid");
         }
     
    -    if ("NATIVE".equals(this.getTradeType()) && this.getProductId() == null) {
    +    if (TradeType.NATIVE.equals(this.getTradeType()) && this.getProductId() == null) {
           throw new WxPayException("当 trade_type是'NATIVE'时未指定product_id");
         }
       }
    diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
    index d54942b4a3..3c27ce18d6 100644
    --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
    +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
    @@ -24,7 +24,6 @@
     import java.nio.file.Path;
     import java.util.Calendar;
     import java.util.Date;
    -import java.util.Map;
     
     import static org.testng.Assert.*;
     
    @@ -103,26 +102,11 @@ public void testCreateOrder_native() throws Exception {
           .createOrder(WxPayUnifiedOrderRequest.newBuilder()
             .body("我去")
             .totalFee(1)
    +        .productId("aaa")
             .spbillCreateIp("11.1.11.1")
             .notifyURL("111111")
             .tradeType(TradeType.NATIVE)
    -        .outTradeNo("1111112")
    -        .build());
    -    this.logger.info(result.toString());
    -    this.logger.warn(this.payService.getWxApiData().toString());
    -  }
    -
    -  @Test
    -  public void testCreateOrder_micropay() throws Exception {
    -    //TODO 待完善
    -    Object result = this.payService
    -      .createOrder(WxPayUnifiedOrderRequest.newBuilder()
    -        .body("我去")
    -        .totalFee(1)
    -        .spbillCreateIp("11.1.11.1")
    -        .notifyURL("111111")
    -        .tradeType(TradeType.MICROPAY)
    -        .outTradeNo("1111112")
    +        .outTradeNo("111111290")
             .build());
         this.logger.info(result.toString());
         this.logger.warn(this.payService.getWxApiData().toString());
    @@ -130,17 +114,7 @@ public void testCreateOrder_micropay() throws Exception {
     
       @Test
       public void testGetPayInfo() throws Exception {
    -    Map payInfo = this.payService
    -      .getPayInfo(WxPayUnifiedOrderRequest.newBuilder()
    -        .body("我去")
    -        .totalFee(1)
    -        .spbillCreateIp("1.11.1.11")
    -        .notifyURL("111111")
    -        .tradeType(TradeType.JSAPI)
    -        .outTradeNo("1111113")
    -        .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid())
    -        .build());
    -    this.logger.info(payInfo.toString());
    +    //please use createOrder instead
       }
     
       /**
    
    From 6cabfc3e125740f901ea9bd4e985bc1cb8afbad9 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Fri, 22 Sep 2017 11:18:38 +0800
    Subject: [PATCH 102/165] =?UTF-8?q?#343=20=E5=B0=8F=E7=A8=8B=E5=BA=8F?=
     =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=B8=A4=E4=B8=AAbean=E6=B7=BB=E5=8A=A0?=
     =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8C=96=E6=94=AF=E6=8C=81?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../wx/miniapp/bean/WxMaJscode2SessionResult.java           | 6 +++++-
     .../java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java    | 6 +++++-
     2 files changed, 10 insertions(+), 2 deletions(-)
    
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java
    index 471e6c46ec..98d090ac74 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java
    @@ -3,12 +3,16 @@
     import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
     import com.google.gson.annotations.SerializedName;
     
    +import java.io.Serializable;
    +
     /**
      * {"session_key":"nzoqhc3OnwHzeTxJs+inbQ==","expires_in":2592000,"openid":"oVBkZ0aYgDMDIywRdgPW8-joxXc4"}
      *
      * @author Binary Wang
      */
    -public class WxMaJscode2SessionResult {
    +public class WxMaJscode2SessionResult implements Serializable {
    +  private static final long serialVersionUID = -1060216618475607933L;
    +
       @SerializedName("session_key")
       private String sessionKey;
     
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java
    index e3cc69d913..5114d1b112 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java
    @@ -4,10 +4,14 @@
     import org.apache.commons.lang3.builder.ToStringBuilder;
     import org.apache.commons.lang3.builder.ToStringStyle;
     
    +import java.io.Serializable;
    +
     /**
      * @author Binary Wang
      */
    -public class WxMaUserInfo {
    +public class WxMaUserInfo implements Serializable {
    +  private static final long serialVersionUID = 6719822331555402137L;
    +
       private String openId;
       private String nickName;
       private String gender;
    
    From 57eab45c8118aebf2dc78eb10a6f72c12570b2a0 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Mon, 25 Sep 2017 15:38:40 +0800
    Subject: [PATCH 103/165] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BE=AE=E4=BF=A1?=
     =?UTF-8?q?=E6=94=AF=E4=BB=98=E4=BB=A3=E7=A0=81=EF=BC=8C=E9=81=BF=E5=85=8D?=
     =?UTF-8?q?=E8=BF=87=E5=BA=A6=E6=A3=80=E6=9F=A5?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../wxpay/bean/result/WxPayBaseResult.java    | 48 ++++++++++---------
     .../impl/WxPayServiceAbstractImpl.java        | 37 +++++++-------
     2 files changed, 45 insertions(+), 40 deletions(-)
    
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java
    index 6607b7698e..d2ba58a963 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java
    @@ -215,8 +215,10 @@ protected Integer getXmlValueAsInt(String... path) {
     
       /**
        * 校验返回结果签名
    +   *
    +   * @param checkSuccess 是否同时检查结果是否成功
        */
    -  public void checkResult(WxPayServiceAbstractImpl wxPayService) throws WxPayException {
    +  public void checkResult(WxPayServiceAbstractImpl wxPayService, boolean checkSuccess) throws WxPayException {
         //校验返回结果签名
         Map map = toMap();
         if (getSign() != null && !SignUtils.checkSign(map, wxPayService.getConfig().getMchKey())) {
    @@ -224,29 +226,31 @@ public void checkResult(WxPayServiceAbstractImpl wxPayService) throws WxPayExcep
           throw new WxPayException("参数格式校验错误!");
         }
     
    -    List successStrings = Lists.newArrayList("SUCCESS", "");
         //校验结果是否成功
    -    if (!successStrings.contains(StringUtils.trimToEmpty(getReturnCode()).toUpperCase())
    -      || !successStrings.contains(StringUtils.trimToEmpty(getResultCode()).toUpperCase())) {
    -      StringBuilder errorMsg = new StringBuilder();
    -      if (getReturnCode() != null) {
    -        errorMsg.append("返回代码:").append(getReturnCode());
    -      }
    -      if (getReturnMsg() != null) {
    -        errorMsg.append(",返回信息:").append(getReturnMsg());
    -      }
    -      if (getResultCode() != null) {
    -        errorMsg.append(",结果代码:").append(getResultCode());
    -      }
    -      if (getErrCode() != null) {
    -        errorMsg.append(",错误代码:").append(getErrCode());
    -      }
    -      if (getErrCodeDes() != null) {
    -        errorMsg.append(",错误详情:").append(getErrCodeDes());
    -      }
    +    if (checkSuccess) {
    +      List successStrings = Lists.newArrayList("SUCCESS", "");
    +      if (!successStrings.contains(StringUtils.trimToEmpty(getReturnCode()).toUpperCase())
    +        || !successStrings.contains(StringUtils.trimToEmpty(getResultCode()).toUpperCase())) {
    +        StringBuilder errorMsg = new StringBuilder();
    +        if (getReturnCode() != null) {
    +          errorMsg.append("返回代码:").append(getReturnCode());
    +        }
    +        if (getReturnMsg() != null) {
    +          errorMsg.append(",返回信息:").append(getReturnMsg());
    +        }
    +        if (getResultCode() != null) {
    +          errorMsg.append(",结果代码:").append(getResultCode());
    +        }
    +        if (getErrCode() != null) {
    +          errorMsg.append(",错误代码:").append(getErrCode());
    +        }
    +        if (getErrCodeDes() != null) {
    +          errorMsg.append(",错误详情:").append(getErrCodeDes());
    +        }
     
    -      this.getLogger().error("\n结果业务代码异常,返回結果:{},\n{}", map, errorMsg.toString());
    -      throw WxPayException.from(this);
    +        this.getLogger().error("\n结果业务代码异常,返回結果:{},\n{}", map, errorMsg.toString());
    +        throw WxPayException.from(this);
    +      }
         }
       }
     }
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    index 0685c6c990..b0c799b9c4 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    @@ -77,7 +77,7 @@ public WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayExceptio
         String url = this.getPayBaseUrl() + "/secapi/pay/refund";
         String responseContent = this.post(url, request.toXML(), true);
         WxPayRefundResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    @@ -96,7 +96,7 @@ public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeN
         String responseContent = this.post(url, request.toXML(), false);
         WxPayRefundQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundQueryResult.class);
         result.composeRefundRecords();
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    @@ -112,7 +112,7 @@ public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPa
           log.debug("微信支付异步通知请求参数:{}", xmlData);
           WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData);
           log.debug("微信支付异步通知请求解析后的对象:{}", result);
    -      result.checkResult(this);
    +      result.checkResult(this, false);
           return result;
         } catch (WxPayException e) {
           log.error(e.getMessage(), e);
    @@ -163,7 +163,7 @@ public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayExcept
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo";
         String responseContent = this.post(url, request.toXML(), true);
         WxPayRedpackQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRedpackQueryResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    @@ -182,7 +182,7 @@ public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo)
     
         WxPayOrderQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderQueryResult.class);
         result.composeCoupons();
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    @@ -199,7 +199,7 @@ public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException
         String url = this.getPayBaseUrl() + "/pay/closeorder";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayOrderCloseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderCloseResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
     
         return result;
       }
    @@ -272,11 +272,12 @@ public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) th
         String url = this.getPayBaseUrl() + "/pay/unifiedorder";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayUnifiedOrderResult result = WxPayBaseResult.fromXML(responseContent, WxPayUnifiedOrderResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
       @Override
    +  @Deprecated
       public Map getPayInfo(WxPayUnifiedOrderRequest request) throws WxPayException {
         WxPayUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request);
         String prepayId = unifiedOrderResult.getPrepayId();
    @@ -331,7 +332,7 @@ public WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException {
     
         String responseContent = this.post(url, request.toXML(), true);
         WxEntPayResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    @@ -344,7 +345,7 @@ public WxEntPayQueryResult queryEntPay(String partnerTradeNo) throws WxPayExcept
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gettransferinfo";
         String responseContent = this.post(url, request.toXML(), true);
         WxEntPayQueryResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayQueryResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    @@ -396,7 +397,7 @@ public void report(WxPayReportRequest request) throws WxPayException {
         String url = this.getPayBaseUrl() + "/payitil/report";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
       }
     
       @Override
    @@ -494,7 +495,7 @@ public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxPayEx
         String url = this.getPayBaseUrl() + "/pay/micropay";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayMicropayResult result = WxPayBaseResult.fromXML(responseContent, WxPayMicropayResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    @@ -505,7 +506,7 @@ public WxPayOrderReverseResult reverseOrder(WxPayOrderReverseRequest request) th
         String url = this.getPayBaseUrl() + "/secapi/pay/reverse";
         String responseContent = this.post(url, request.toXML(), true);
         WxPayOrderReverseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderReverseResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    @@ -516,7 +517,7 @@ public String shorturl(WxPayShorturlRequest request) throws WxPayException {
         String url = this.getPayBaseUrl() + "/tools/shorturl";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayShorturlResult result = WxPayBaseResult.fromXML(responseContent, WxPayShorturlResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result.getShortUrl();
       }
     
    @@ -532,7 +533,7 @@ public String authcode2Openid(WxPayAuthcode2OpenidRequest request) throws WxPayE
         String url = this.getPayBaseUrl() + "/tools/authcodetoopenid";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayAuthcode2OpenidResult result = WxPayBaseResult.fromXML(responseContent, WxPayAuthcode2OpenidResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result.getOpenid();
       }
     
    @@ -549,7 +550,7 @@ public String getSandboxSignKey() throws WxPayException {
         String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey";
         String responseContent = this.post(url, request.toXML(), false);
         WxPaySandboxSignKeyResult result = WxPayBaseResult.fromXML(responseContent, WxPaySandboxSignKeyResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result.getSandboxSignKey();
       }
     
    @@ -560,7 +561,7 @@ public WxPayCouponSendResult sendCoupon(WxPayCouponSendRequest request) throws W
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/send_coupon";
         String responseContent = this.post(url, request.toXML(), true);
         WxPayCouponSendResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponSendResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    @@ -571,7 +572,7 @@ public WxPayCouponStockQueryResult queryCouponStock(WxPayCouponStockQueryRequest
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/query_coupon_stock";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayCouponStockQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponStockQueryResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    @@ -582,7 +583,7 @@ public WxPayCouponInfoQueryResult queryCouponInfo(WxPayCouponInfoQueryRequest re
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/querycouponsinfo";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayCouponInfoQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponInfoQueryResult.class);
    -    result.checkResult(this);
    +    result.checkResult(this, true);
         return result;
       }
     
    
    From 1e7cb4d6b9c1fe09843723ea73096fe7cd68affa Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Mon, 25 Sep 2017 18:00:06 +0800
    Subject: [PATCH 104/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?=
     =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.8.2.BETA?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     pom.xml                     | 2 +-
     weixin-java-common/pom.xml  | 2 +-
     weixin-java-cp/pom.xml      | 2 +-
     weixin-java-miniapp/pom.xml | 2 +-
     weixin-java-mp/pom.xml      | 2 +-
     weixin-java-pay/pom.xml     | 2 +-
     6 files changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/pom.xml b/pom.xml
    index fab3357623..27cd3497cf 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -6,7 +6,7 @@
       4.0.0
       com.github.binarywang
       weixin-java-parent
    -  2.8.1.BETA
    +  2.8.2.BETA
       pom
       WeiXin Java Tools - Parent
       微信公众号、企业号上级POM
    diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml
    index cce3b4f9fe..ea3874dd16 100644
    --- a/weixin-java-common/pom.xml
    +++ b/weixin-java-common/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.1.BETA
    +    2.8.2.BETA
       
     
       weixin-java-common
    diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml
    index 8e546507c0..38cc0330f0 100644
    --- a/weixin-java-cp/pom.xml
    +++ b/weixin-java-cp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.1.BETA
    +    2.8.2.BETA
       
     
       weixin-java-cp
    diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml
    index 9e96cc0709..06c2617aba 100644
    --- a/weixin-java-miniapp/pom.xml
    +++ b/weixin-java-miniapp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.1.BETA
    +    2.8.2.BETA
       
       weixin-java-miniapp
       WeiXin Java Tools - MiniApp
    diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml
    index b4a1608b19..4f0a3876df 100644
    --- a/weixin-java-mp/pom.xml
    +++ b/weixin-java-mp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.1.BETA
    +    2.8.2.BETA
       
       weixin-java-mp
       WeiXin Java Tools - MP
    diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml
    index 72714499a7..835e76fac3 100644
    --- a/weixin-java-pay/pom.xml
    +++ b/weixin-java-pay/pom.xml
    @@ -5,7 +5,7 @@
       
         weixin-java-parent
         com.github.binarywang
    -    2.8.1.BETA
    +    2.8.2.BETA
       
       4.0.0
     
    
    From 17a446e3722cda58b373e2ff4c182eb5e35a4b4b Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Mon, 25 Sep 2017 19:25:04 +0800
    Subject: [PATCH 105/165] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=87=A0=E4=B8=AA?=
     =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=9B=B8=E5=85=B3=E7=9A=84=E5=B8=B8=E9=87=8F?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../bean/request/WxPayRefundRequest.java      |   7 +-
     .../wxpay/constant/WxPayConstants.java        | 152 +++++++++++++++++-
     2 files changed, 156 insertions(+), 3 deletions(-)
    
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
    index 645e2f7a93..ce6cf747d2 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java
    @@ -1,6 +1,7 @@
     package com.github.binarywang.wxpay.bean.request;
     
     import com.github.binarywang.wxpay.config.WxPayConfig;
    +import com.github.binarywang.wxpay.constant.WxPayConstants.RefundAccountSource;
     import com.github.binarywang.wxpay.exception.WxPayException;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     import lombok.*;
    @@ -32,8 +33,10 @@
     @AllArgsConstructor
     @XStreamAlias("xml")
     public class WxPayRefundRequest extends WxPayBaseRequest {
    -  private static final String[] REFUND_ACCOUNT = new String[]{"REFUND_SOURCE_RECHARGE_FUNDS",
    -    "REFUND_SOURCE_UNSETTLED_FUNDS"};
    +  private static final String[] REFUND_ACCOUNT = new String[]{
    +    RefundAccountSource.RECHARGE_FUNDS,
    +    RefundAccountSource.UNSETTLED_FUNDS
    +  };
       /**
        * 
        * 设备号
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
    index 4785563905..d56271a8cc 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
    @@ -98,7 +98,6 @@ public static class SignType {
         public static final String MD5 = "MD5";
       }
     
    -
       /**
        * 限定支付方式
        */
    @@ -123,4 +122,155 @@ public static class ResultCode {
          */
         public static final String FAIL = "FAIL";
       }
    +
    +  /**
    +   * 退款资金来源
    +   */
    +  public static class RefundAccountSource {
    +    /**
    +     * 可用余额退款/基本账户
    +     */
    +    public static final String RECHARGE_FUNDS = "REFUND_SOURCE_RECHARGE_FUNDS";
    +
    +    /**
    +     * 未结算资金退款
    +     */
    +    public static final String UNSETTLED_FUNDS = "REFUND_SOURCE_UNSETTLED_FUNDS";
    +
    +  }
    +
    +  /**
    +   * 退款渠道
    +   */
    +  public static class RefundChannel {
    +    /**
    +     * 原路退款
    +     */
    +    public static final String ORIGINAL = "ORIGINAL";
    +
    +    /**
    +     * 退回到余额
    +     */
    +    public static final String BALANCE = "BALANCE";
    +
    +    /**
    +     * 原账户异常退到其他余额账户
    +     */
    +    public static final String OTHER_BALANCE = "OTHER_BALANCE";
    +
    +    /**
    +     * 原银行卡异常退到其他银行卡
    +     */
    +    public static final String OTHER_BANKCARD = "OTHER_BANKCARD";
    +  }
    +
    +  /**
    +   * 交易状态
    +   */
    +  public static class WxpayTradeStatus {
    +    /**
    +     * 支付成功
    +     */
    +    public static final String SUCCESS = "SUCCESS";
    +
    +    /**
    +     * 支付失败(其他原因,如银行返回失败)
    +     */
    +    public static final String PAY_ERROR = "PAYERROR";
    +
    +    /**
    +     * 用户支付中
    +     */
    +    public static final String USER_PAYING = "USERPAYING";
    +
    +    /**
    +     * 已关闭
    +     */
    +    public static final String CLOSED = "CLOSED";
    +
    +    /**
    +     * 未支付
    +     */
    +    public static final String NOTPAY = "NOTPAY";
    +
    +    /**
    +     * 转入退款
    +     */
    +    public static final String REFUND = "REFUND";
    +
    +    /**
    +     * 已撤销(刷卡支付)
    +     */
    +    public static final String REVOKED = "REVOKED";
    +  }
    +
    +  /**
    +   * 退款状态
    +   */
    +  public static class RefundStatus {
    +    /**
    +     * 退款成功
    +     */
    +    public static final String SUCCESS = "SUCCESS";
    +
    +    /**
    +     * 退款关闭
    +     */
    +    public static final String REFUND_CLOSE = "REFUNDCLOSE";
    +
    +    /**
    +     * 退款处理中
    +     */
    +    public static final String PROCESSING = "PROCESSING";
    +
    +    /**
    +     * 退款异常,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往商户平台(pay.weixin.qq.com)-交易中心,手动处理此笔退款。
    +     */
    +    public static final String CHANGE = "CHANGE";
    +  }
    +
    +  /**
    +   * 关闭订单结果错误代码
    +   */
    +  public static class OrderCloseResultErrorCode {
    +    /**
    +     * 订单已支付
    +     */
    +    public static final String ORDER_PAID = "ORDERPAID";
    +
    +    /**
    +     * 系统错误
    +     */
    +    public static final String SYSTEM_ERROR = "SYSTEMERROR";
    +
    +    /**
    +     * 订单不存在
    +     */
    +    public static final String ORDER_NOT_EXIST = "ORDERNOTEXIST";
    +
    +    /**
    +     * 订单已关闭
    +     */
    +    public static final String ORDER_CLOSED = "ORDERCLOSED";
    +
    +    /**
    +     * 签名错误
    +     */
    +    public static final String SIGN_ERROR = "SIGNERROR";
    +
    +    /**
    +     * 未使用POST传递参数
    +     */
    +    public static final String REQUIRE_POST_METHOD = "REQUIRE_POST_METHOD";
    +
    +    /**
    +     * XML格式错误
    +     */
    +    public static final String XML_FORMAT_ERROR = "XML_FORMAT_ERROR";
    +
    +    /**
    +     * 订单状态错误
    +     */
    +    public static final String TRADE_STATE_ERROR = "TRADE_STATE_ERROR";
    +  }
     }
    
    From ffcbb2a9eb60b8885b9b654ed4bdcdebe2e43054 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Wed, 27 Sep 2017 11:14:59 +0800
    Subject: [PATCH 106/165] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=BA=8C?=
     =?UTF-8?q?=E7=BB=B4=E7=A0=81=E6=8E=A5=E5=8F=A3=E4=BB=A3=E7=A0=81=E4=BC=98?=
     =?UTF-8?q?=E5=8C=96?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../wx/miniapp/api/WxMaQrcodeService.java     | 50 +++----------------
     .../api/impl/WxMaQrcodeServiceImpl.java       | 14 +++---
     .../wx/miniapp/bean/WxMaCodeLineColor.java    | 42 ++++++++++++++++
     .../wx/miniapp/bean/WxMaWxcode.java           |  7 ++-
     .../wx/miniapp/bean/WxMaWxcodeLimit.java      |  7 ++-
     5 files changed, 60 insertions(+), 60 deletions(-)
     create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
    
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java
    index c2222bc93e..4b3ec5feba 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaQrcodeService.java
    @@ -1,5 +1,6 @@
     package cn.binarywang.wx.miniapp.api;
     
    +import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor;
     import me.chanjar.weixin.common.exception.WxErrorException;
     
     import java.io.File;
    @@ -16,6 +17,9 @@
      * @author Binary Wang
      */
     public interface WxMaQrcodeService {
    +  String CREATE_QRCODE_URL = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode";
    +  String GET_WXACODE_URL = "https://api.weixin.qq.com/wxa/getwxacode";
    +  String GET_WXACODE_UNLIMIT_URL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit";
     
       /**
        * 接口C
    @@ -42,10 +46,8 @@ public interface WxMaQrcodeService {
        * @param width     默认430 二维码的宽度
        * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
        * @param lineColor auth_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
    -   * @return
    -   * @throws WxErrorException
        */
    -  File createWxCode(String path, int width, boolean autoColor, LineColor lineColor) throws WxErrorException;
    +  File createWxCode(String path, int width, boolean autoColor, WxMaCodeLineColor lineColor) throws WxErrorException;
     
       File createWxCode(String path, int width) throws WxErrorException;
     
    @@ -65,49 +67,9 @@ public interface WxMaQrcodeService {
        * @param width     默认false 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
        * @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
        * @param lineColor auth_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
    -   * @return
    -   * @throws WxErrorException
        */
    -  File createWxCodeLimit(String scene, String page, int width, boolean autoColor, LineColor lineColor) throws WxErrorException;
    +  File createWxCodeLimit(String scene, String page, int width, boolean autoColor, WxMaCodeLineColor lineColor) throws WxErrorException;
     
       File createWxCodeLimit(String scene, String page) throws WxErrorException;
     
    -  /**
    -   * lineColor 包装类
    -   * 用于描述二维码(小程序码)颜色(RGB参数值),详情请查看文档
    -   */
    -  public static class LineColor {
    -
    -    private String r = "0", g = "0", b = "0";
    -
    -    public LineColor(String r, String g, String b) {
    -      this.r = r;
    -      this.g = g;
    -      this.b = b;
    -    }
    -
    -    public String getR() {
    -      return r;
    -    }
    -
    -    public void setR(String r) {
    -      this.r = r;
    -    }
    -
    -    public String getG() {
    -      return g;
    -    }
    -
    -    public void setG(String g) {
    -      this.g = g;
    -    }
    -
    -    public String getB() {
    -      return b;
    -    }
    -
    -    public void setB(String b) {
    -      this.b = b;
    -    }
    -  }
     }
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java
    index fd58855b3d..806e0e99b8 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaQrcodeServiceImpl.java
    @@ -2,6 +2,7 @@
     
     import cn.binarywang.wx.miniapp.api.WxMaQrcodeService;
     import cn.binarywang.wx.miniapp.api.WxMaService;
    +import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor;
     import cn.binarywang.wx.miniapp.bean.WxMaQrcode;
     import cn.binarywang.wx.miniapp.bean.WxMaWxcode;
     import cn.binarywang.wx.miniapp.bean.WxMaWxcodeLimit;
    @@ -22,9 +23,8 @@ public WxMaQrcodeServiceImpl(WxMaService wxMaService) {
     
       @Override
       public File createQrcode(String path, int width) throws WxErrorException {
    -    String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode";
         return this.wxMaService.execute(new QrCodeRequestExecutor(this.wxMaService.getRequestHttp()),
    -      url, new WxMaQrcode(path, width));
    +      CREATE_QRCODE_URL, new WxMaQrcode(path, width));
       }
     
       @Override
    @@ -33,15 +33,14 @@ public File createQrcode(String path) throws WxErrorException {
       }
     
       @Override
    -  public File createWxCode(String path, int width, boolean autoColor, LineColor lineColor) throws WxErrorException {
    -    String url = "https://api.weixin.qq.com/wxa/getwxacode";
    +  public File createWxCode(String path, int width, boolean autoColor, WxMaCodeLineColor lineColor) throws WxErrorException {
         WxMaWxcode wxMaWxcode = new WxMaWxcode();
         wxMaWxcode.setPath(path);
         wxMaWxcode.setWidth(width);
         wxMaWxcode.setAutoColor(autoColor);
         wxMaWxcode.setLineColor(lineColor);
         return this.wxMaService.execute(new QrCodeRequestExecutor(this.wxMaService.getRequestHttp()),
    -      url, wxMaWxcode);
    +      GET_WXACODE_URL, wxMaWxcode);
       }
     
       @Override
    @@ -55,8 +54,7 @@ public File createWxCode(String path) throws WxErrorException {
       }
     
       @Override
    -  public File createWxCodeLimit(String scene, String page, int width, boolean autoColor, LineColor lineColor) throws WxErrorException {
    -    String url = "http://api.weixin.qq.com/wxa/getwxacodeunlimit";
    +  public File createWxCodeLimit(String scene, String page, int width, boolean autoColor, WxMaCodeLineColor lineColor) throws WxErrorException {
         WxMaWxcodeLimit wxMaWxcodeLimit = new WxMaWxcodeLimit();
         wxMaWxcodeLimit.setScene(scene);
         wxMaWxcodeLimit.setPage(page);
    @@ -64,7 +62,7 @@ public File createWxCodeLimit(String scene, String page, int width, boolean auto
         wxMaWxcodeLimit.setAutoColor(autoColor);
         wxMaWxcodeLimit.setLineColor(lineColor);
         return this.wxMaService.execute(new QrCodeRequestExecutor(this.wxMaService.getRequestHttp()),
    -      url, wxMaWxcodeLimit);
    +      GET_WXACODE_UNLIMIT_URL, wxMaWxcodeLimit);
       }
     
       @Override
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
    new file mode 100644
    index 0000000000..5312d9736d
    --- /dev/null
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
    @@ -0,0 +1,42 @@
    +package cn.binarywang.wx.miniapp.bean;
    +
    +/**
    + * 
    + * lineColor 包装类
    + * 用于描述二维码(小程序码)颜色(RGB参数值),
    + * 详情请查看文档 https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html
    + * 
    + */ +public class WxMaCodeLineColor { + private String r = "0", g = "0", b = "0"; + + public WxMaCodeLineColor(String r, String g, String b) { + this.r = r; + this.g = g; + this.b = b; + } + + public String getR() { + return r; + } + + public void setR(String r) { + this.r = r; + } + + public String getG() { + return g; + } + + public void setG(String g) { + this.g = g; + } + + public String getB() { + return b; + } + + public void setB(String b) { + this.b = b; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java index 9ea674ed98..faf78f5884 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java @@ -1,6 +1,5 @@ package cn.binarywang.wx.miniapp.bean; -import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; import com.google.gson.annotations.SerializedName; @@ -19,7 +18,7 @@ public class WxMaWxcode extends WxMaQrcodeWrapper implements Serializable { private boolean autoColor = true; @SerializedName("line_color") - private WxMaQrcodeService.LineColor lineColor = new WxMaQrcodeService.LineColor("0", "0", "0"); + private WxMaCodeLineColor lineColor = new WxMaCodeLineColor("0", "0", "0"); public static WxMaWxcode fromJson(String json) { return WxMaGsonBuilder.create().fromJson(json, WxMaWxcode.class); @@ -53,11 +52,11 @@ public void setAutoColor(boolean autoColor) { this.autoColor = autoColor; } - public WxMaQrcodeService.LineColor getLineColor() { + public WxMaCodeLineColor getLineColor() { return lineColor; } - public void setLineColor(WxMaQrcodeService.LineColor lineColor) { + public void setLineColor(WxMaCodeLineColor lineColor) { this.lineColor = lineColor; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java index 7619fe46f2..864a082e8b 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java @@ -1,6 +1,5 @@ package cn.binarywang.wx.miniapp.bean; -import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; import com.google.gson.annotations.SerializedName; @@ -20,7 +19,7 @@ public class WxMaWxcodeLimit extends WxMaQrcodeWrapper implements Serializable { private boolean autoColor = true; @SerializedName("line_color") - private WxMaQrcodeService.LineColor lineColor = new WxMaQrcodeService.LineColor("0", "0", "0"); + private WxMaCodeLineColor lineColor = new WxMaCodeLineColor("0", "0", "0"); public static WxMaWxcodeLimit fromJson(String json) { return WxMaGsonBuilder.create().fromJson(json, WxMaWxcodeLimit.class); @@ -58,11 +57,11 @@ public void setAutoColor(boolean autoColor) { this.autoColor = autoColor; } - public WxMaQrcodeService.LineColor getLineColor() { + public WxMaCodeLineColor getLineColor() { return lineColor; } - public void setLineColor(WxMaQrcodeService.LineColor lineColor) { + public void setLineColor(WxMaCodeLineColor lineColor) { this.lineColor = lineColor; } } From 972b07a20f4c800dc6262579dfad4a51331c610b Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 27 Sep 2017 11:27:54 +0800 Subject: [PATCH 107/165] =?UTF-8?q?#195=20=E6=8A=BD=E5=8F=96=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=AF=B7=E6=B1=82URL=E4=B8=BA=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/WxMpStoreService.java | 16 +++++++-------- .../mp/api/impl/WxMpStoreServiceImpl.java | 20 ++++++------------- .../mp/api/impl/WxMpStoreServiceImplTest.java | 7 +++---- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java index d996759b00..26958c9fe7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java @@ -15,6 +15,13 @@ * @author Binary Wang */ public interface WxMpStoreService { + String POI_GET_WX_CATEGORY_URL = "https://api.weixin.qq.com/cgi-bin/poi/getwxcategory"; + String POI_UPDATE_URL = "https://api.weixin.qq.com/cgi-bin/poi/updatepoi"; + String POI_LIST_URL = "https://api.weixin.qq.com/cgi-bin/poi/getpoilist"; + String POI_DEL_URL = "https://api.weixin.qq.com/cgi-bin/poi/delpoi"; + String POI_GET_URL = "https://api.weixin.qq.com/cgi-bin/poi/getpoi"; + String POI_ADD_URL = "https://api.weixin.qq.com/cgi-bin/poi/addpoi"; + /** *
        * 创建门店
    @@ -40,7 +47,6 @@ public interface WxMpStoreService {
        * 
    * * @param poiId 门店Id - * @throws WxErrorException */ WxMpStoreBaseInfo get(String poiId) throws WxErrorException; @@ -53,7 +59,6 @@ public interface WxMpStoreService { *
    * * @param poiId 门店Id - * @throws WxErrorException */ void delete(String poiId) throws WxErrorException; @@ -67,7 +72,6 @@ public interface WxMpStoreService { * * @param begin 开始位置,0 即为从第一条开始查询 * @param limit 返回数据条数,最大允许50,默认为20 - * @throws WxErrorException */ WxMpStoreListResult list(int begin, int limit) throws WxErrorException; @@ -78,8 +82,6 @@ public interface WxMpStoreService { * 详情请见: 微信门店接口 * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN *
    - * - * @throws WxErrorException */ List listAll() throws WxErrorException; @@ -90,8 +92,6 @@ public interface WxMpStoreService { * 详情请见: 微信门店接口 * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/updatepoi?access_token=TOKEN *
    - * - * @throws WxErrorException */ void update(WxMpStoreBaseInfo info) throws WxErrorException; @@ -102,8 +102,6 @@ public interface WxMpStoreService { * 详情请见: 微信门店接口 * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/getwxcategory?access_token=TOKEN *
    - * - * @throws WxErrorException */ List listCategories() throws WxErrorException; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImpl.java index 5f1b5f2a82..00c0c1097c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImpl.java @@ -21,8 +21,6 @@ * @author binarywang (https://github.com/binarywang) */ public class WxMpStoreServiceImpl implements WxMpStoreService { - private static final String API_BASE_URL = "http://api.weixin.qq.com/cgi-bin/poi"; - private WxMpService wxMpService; public WxMpStoreServiceImpl(WxMpService wxMpService) { @@ -33,8 +31,7 @@ public WxMpStoreServiceImpl(WxMpService wxMpService) { public void add(WxMpStoreBaseInfo request) throws WxErrorException { BeanUtils.checkRequiredFields(request); - String url = API_BASE_URL + "/addpoi"; - String response = this.wxMpService.post(url, request.toJson()); + String response = this.wxMpService.post(POI_ADD_URL, request.toJson()); WxError wxError = WxError.fromJson(response); if (wxError.getErrorCode() != 0) { throw new WxErrorException(wxError); @@ -43,10 +40,9 @@ public void add(WxMpStoreBaseInfo request) throws WxErrorException { @Override public WxMpStoreBaseInfo get(String poiId) throws WxErrorException { - String url = API_BASE_URL + "/getpoi"; JsonObject paramObject = new JsonObject(); paramObject.addProperty("poi_id", poiId); - String response = this.wxMpService.post(url, paramObject.toString()); + String response = this.wxMpService.post(POI_GET_URL, paramObject.toString()); WxError wxError = WxError.fromJson(response); if (wxError.getErrorCode() != 0) { throw new WxErrorException(wxError); @@ -57,10 +53,9 @@ public WxMpStoreBaseInfo get(String poiId) throws WxErrorException { @Override public void delete(String poiId) throws WxErrorException { - String url = API_BASE_URL + "/delpoi"; JsonObject paramObject = new JsonObject(); paramObject.addProperty("poi_id", poiId); - String response = this.wxMpService.post(url, paramObject.toString()); + String response = this.wxMpService.post(POI_DEL_URL, paramObject.toString()); WxError wxError = WxError.fromJson(response); if (wxError.getErrorCode() != 0) { throw new WxErrorException(wxError); @@ -70,11 +65,10 @@ public void delete(String poiId) throws WxErrorException { @Override public WxMpStoreListResult list(int begin, int limit) throws WxErrorException { - String url = API_BASE_URL + "/getpoilist"; JsonObject params = new JsonObject(); params.addProperty("begin", begin); params.addProperty("limit", limit); - String response = this.wxMpService.post(url, params.toString()); + String response = this.wxMpService.post(POI_LIST_URL, params.toString()); WxError wxError = WxError.fromJson(response); if (wxError.getErrorCode() != 0) { @@ -107,8 +101,7 @@ public List listAll() throws WxErrorException { @Override public void update(WxMpStoreBaseInfo request) throws WxErrorException { - String url = API_BASE_URL + "/updatepoi"; - String response = this.wxMpService.post(url, request.toJson()); + String response = this.wxMpService.post(POI_UPDATE_URL, request.toJson()); WxError wxError = WxError.fromJson(response); if (wxError.getErrorCode() != 0) { throw new WxErrorException(wxError); @@ -117,8 +110,7 @@ public void update(WxMpStoreBaseInfo request) throws WxErrorException { @Override public List listCategories() throws WxErrorException { - String url = API_BASE_URL + "/getwxcategory"; - String response = this.wxMpService.get(url, null); + String response = this.wxMpService.get(POI_GET_WX_CATEGORY_URL, null); WxError wxError = WxError.fromJson(response); if (wxError.getErrorCode() != 0) { throw new WxErrorException(wxError); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java index c0703028dc..3970072bfc 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java @@ -26,18 +26,17 @@ public class WxMpStoreServiceImplTest { private WxMpService wxMpService; /** - * Test method for {@link WxMpStoreServiceImpl#add(me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo)}. - * - * @throws WxErrorException + * Test method for {@link WxMpStoreServiceImpl#add(WxMpStoreBaseInfo)}. */ public void testAdd() throws WxErrorException { - this.wxMpService.getStoreService().add(WxMpStoreBaseInfo.builder().build()); this.wxMpService.getStoreService() .add(WxMpStoreBaseInfo.builder().businessName("haha").branchName("abc") .province("aaa").district("aaa").telephone("122").address("abc").categories(new String[]{"美食,江浙菜"}) .longitude(new BigDecimal("115.32375")) .latitude(new BigDecimal("25.097486")).city("aaa").offsetType(1) .build()); + // 以下运行会抛异常 + this.wxMpService.getStoreService().add(WxMpStoreBaseInfo.builder().build()); } public void testUpdate() throws WxErrorException { From adc4408b8627f644130bdfca1ff33234fd3917ac Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 27 Sep 2017 11:36:45 +0800 Subject: [PATCH 108/165] =?UTF-8?q?=E6=B6=88=E7=81=ADjavadoc=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=9D=9Ehttps=E6=8E=A5=E5=8F=A3=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/api/WxMpKefuService.java | 5 ++--- .../me/chanjar/weixin/mp/api/WxMpStoreService.java | 14 +++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java index 36e13b13c4..9e0de39c4b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java @@ -92,11 +92,10 @@ public interface WxMpKefuService { *
        * 上传客服头像
        * 详情请见:客服管理
    -   * 接口url格式:http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
    +   * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
        * 
    */ - boolean kfAccountUploadHeadImg(String kfAccount, File imgFile) - throws WxErrorException; + boolean kfAccountUploadHeadImg(String kfAccount, File imgFile) throws WxErrorException; /** *
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java
    index 26958c9fe7..fa349c93b2 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java
    @@ -30,7 +30,7 @@ public interface WxMpStoreService {
        * 创建门店接口调用成功后会返回errcode 0、errmsg ok,但不会实时返回poi_id。
        * 成功创建后,会生成poi_id,但该id不一定为最终id。门店信息会经过审核,审核通过后方可获取最终poi_id,该id为门店的唯一id,强烈建议自行存储审核通过后的最终poi_id,并为后续调用使用。
        * 详情请见: 微信门店接口
    -   * 接口格式: http://api.weixin.qq.com/cgi-bin/poi/addpoi?access_token=TOKEN
    +   * 接口格式: https://api.weixin.qq.com/cgi-bin/poi/addpoi?access_token=TOKEN
        * 
    */ void add(WxMpStoreBaseInfo request) throws WxErrorException; @@ -43,7 +43,7 @@ public interface WxMpStoreService { * 最终结果会在5 个工作日内,最终确认是否采纳,并前端生效(但该扩展字段的采纳过程不影响门店的可用性,即available_state仍为审核通过状态) * 注:扩展字段为公共编辑信息(大家都可修改),修改将会审核,并决定是否对修改建议进行采纳,但不会影响该门店的生效可用状态。 * 详情请见: 微信门店接口 - * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/getpoi?access_token=TOKEN + * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoi?access_token=TOKEN *
    * * @param poiId 门店Id @@ -55,7 +55,7 @@ public interface WxMpStoreService { * 删除门店 * 商户可以通过该接口,删除已经成功创建的门店。请商户慎重调用该接口。 * 详情请见: 微信门店接口 - * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/delpoi?access_token=TOKEN + * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/delpoi?access_token=TOKEN *
    * * @param poiId 门店Id @@ -67,7 +67,7 @@ public interface WxMpStoreService { * 查询门店列表(指定查询起始位置和个数) * 商户可以通过该接口,批量查询自己名下的门店list,并获取已审核通过的poi_id(所有状态均会返回poi_id,但该poi_id不一定为最终id)、商户自身sid 用于对应、商户名、分店名、地址字段。 * 详情请见: 微信门店接口 - * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN + * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN *
    * * @param begin 开始位置,0 即为从第一条开始查询 @@ -80,7 +80,7 @@ public interface WxMpStoreService { * 查询门店列表(所有) * 商户可以通过该接口,批量查询自己名下的门店list,并获取已审核通过的poi_id(所有状态均会返回poi_id,但该poi_id不一定为最终id)、商户自身sid 用于对应、商户名、分店名、地址字段。 * 详情请见: 微信门店接口 - * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN + * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token=TOKEN *
    */ List listAll() throws WxErrorException; @@ -90,7 +90,7 @@ public interface WxMpStoreService { * 修改门店服务信息 * 商户可以通过该接口,修改门店的服务信息,包括:sid、图片列表、营业时间、推荐、特色服务、简介、人均价格、电话8个字段(名称、坐标、地址等不可修改)修改后需要人工审核。 * 详情请见: 微信门店接口 - * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/updatepoi?access_token=TOKEN + * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/updatepoi?access_token=TOKEN *
    */ void update(WxMpStoreBaseInfo info) throws WxErrorException; @@ -100,7 +100,7 @@ public interface WxMpStoreService { * 门店类目表 * 类目名称接口是为商户提供自己门店类型信息的接口。门店类目定位的越规范,能够精准的吸引更多用户,提高曝光率。 * 详情请见: 微信门店接口 - * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/getwxcategory?access_token=TOKEN + * 接口格式:https://api.weixin.qq.com/cgi-bin/poi/getwxcategory?access_token=TOKEN *
    */ List listCategories() throws WxErrorException; From 1990b10e13175482cd5b2041a5f264bba11a544f Mon Sep 17 00:00:00 2001 From: "Eric.Tsai" Date: Sat, 30 Sep 2017 11:05:51 +0800 Subject: [PATCH 109/165] =?UTF-8?q?#348=20=E4=BF=AE=E6=AD=A3=E8=8E=B7?= =?UTF-8?q?=E5=8F=96jsticket=E6=97=B6=EF=BC=8C=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=BA=86accessTokenLock=E9=94=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java index e4482d5aa7..7b571ed197 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java @@ -67,7 +67,7 @@ public String getJsapiTicket() throws WxErrorException { @Override public String getJsapiTicket(boolean forceRefresh) throws WxErrorException { - Lock lock = this.getWxMpConfigStorage().getAccessTokenLock(); + Lock lock = this.getWxMpConfigStorage().getJsapiTicketLock(); try { lock.lock(); if (forceRefresh) { From 65ef21b2807d610867f6f2a9ef55d2214ea8377a Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 30 Sep 2017 12:02:42 +0800 Subject: [PATCH 110/165] =?UTF-8?q?=E6=B6=89=E5=8F=8A=E5=88=B0=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=95=86=E6=A8=A1=E5=BC=8F=E7=9A=84=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E5=8F=82=E6=95=B0=EF=BC=8C=E5=9C=A8=E4=B8=BA=E7=A9=BA=E5=80=BC?= =?UTF-8?q?=E6=97=B6=E7=BD=AE=E4=B8=BAnull=EF=BC=8C=E4=BB=A5=E5=85=8D?= =?UTF-8?q?=E5=9C=A8=E8=AF=B7=E6=B1=82=E6=97=B6=E5=B0=86=E7=A9=BA=E5=80=BC?= =?UTF-8?q?=E4=BC=A0=E7=BB=99=E5=BE=AE=E4=BF=A1=E6=9C=8D=E5=8A=A1=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/binarywang/wxpay/bean/request/WxPayBaseRequest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java index ad6f9d4c34..fad6d444f9 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java @@ -173,6 +173,9 @@ public String toString() { public String toXML() { XStream xstream = XStreamInitializer.getInstance(); + //涉及到服务商模式的两个参数,在为空值时置为null,以免在请求时将空值传给微信服务器 + this.setSubAppId(StringUtils.trimToNull(this.getSubAppId())); + this.setSubMchId(StringUtils.trimToNull(this.getSubMchId())); xstream.processAnnotations(this.getClass()); return xstream.toXML(this); } From 2ab389e84fbd1e33e2fc84ab18c26f3d57174ffc Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 13 Oct 2017 10:47:45 +0800 Subject: [PATCH 111/165] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D2.8.2.BETA=E7=89=88=E6=9C=AC=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E7=AD=BE=E5=90=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/service/impl/WxPayServiceAbstractImpl.java | 6 ++---- .../com/github/binarywang/wxpay/util/SignUtils.java | 11 +++-------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index b0c799b9c4..57cef5b826 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -147,10 +147,8 @@ public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throw } String responseContent = this.post(url, request.toXML(), true); - WxPaySendRedpackResult result = WxPayBaseResult.fromXML(responseContent, WxPaySendRedpackResult.class); - //毋须校验,因为没有返回签名信息 - // this.checkResult(result); - return result; + //无需校验,因为没有返回签名信息 + return WxPayBaseResult.fromXML(responseContent, WxPaySendRedpackResult.class); } @Override diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java index 6bff4d7a3d..35a53c2c94 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java @@ -5,6 +5,7 @@ import me.chanjar.weixin.common.util.BeanUtils; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; @@ -44,19 +45,13 @@ public static String createSign(Object xmlBean, String signKey, String signType) * @return 签名字符串 */ public static String createSign(Map params, String signKey, String signType) { -// if (this.getConfig().useSandbox()) { -// //使用仿真测试环境 -// //TODO 目前测试发现,以下两行代码都会出问题,所以暂不建议使用仿真测试环境 -// signKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456"; -// //return "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456"; -// } - SortedMap sortedMap = new TreeMap<>(params); StringBuilder toSign = new StringBuilder(); for (String key : sortedMap.keySet()) { String value = params.get(key); - if (!Lists.newArrayList("sign", "key", "sign_type").contains(key)) { + if (StringUtils.isNotEmpty(value) && + !Lists.newArrayList("sign", "key", "sign_type").contains(key)) { toSign.append(key).append("=").append(value).append("&"); } } From 24e80a90a9cc841dbac70715461a0eb08d5929e3 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 13 Oct 2017 10:49:38 +0800 Subject: [PATCH 112/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.8.3.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 27cd3497cf..53a49b988b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.8.2.BETA + 2.8.3.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index ea3874dd16..a635d8c926 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.2.BETA + 2.8.3.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 38cc0330f0..a03fff6cc4 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.2.BETA + 2.8.3.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 06c2617aba..21545dd0cb 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.2.BETA + 2.8.3.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 4f0a3876df..b26093d5db 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.2.BETA + 2.8.3.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 835e76fac3..10028da97e 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.8.2.BETA + 2.8.3.BETA 4.0.0 From 4f1c66efceeff6be1d3f174c841ed77c69bc7079 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 13 Oct 2017 11:52:44 +0800 Subject: [PATCH 113/165] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E5=8D=95=E6=97=B6=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../bean/request/WxPayUnifiedOrderRequest.java | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 53a49b988b..c5e57b8839 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,7 @@ org.apache.commons commons-lang3 - 3.6 + 3.5 org.slf4j diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index ecd73dd5a8..f45a2d0c56 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -333,12 +333,18 @@ public void setTradeType(String tradeType) { @Override protected void checkConstraints() throws WxPayException { - if (TradeType.JSAPI.equals(this.getTradeType()) && this.getOpenid() == null && this.getSubOpenid() == null) { - throw new WxPayException("当 trade_type是'JSAPI'时未指定openid或sub_openid"); + if (TradeType.JSAPI.equals(this.getTradeType())) { + if (StringUtils.isBlank(this.getSubAppId()) && StringUtils.isBlank(this.getOpenid())) { + throw new WxPayException("当trade_type是'JSAPI'时,需指定非空的openid值"); + } + + if (StringUtils.isNotBlank(this.getSubAppId()) && StringUtils.isBlank(this.getSubOpenid())) { + throw new WxPayException("在服务商模式下,当trade_type是'JSAPI'时,需指定非空的sub_openid值"); + } } - if (TradeType.NATIVE.equals(this.getTradeType()) && this.getProductId() == null) { - throw new WxPayException("当 trade_type是'NATIVE'时未指定product_id"); + if (TradeType.NATIVE.equals(this.getTradeType()) && StringUtils.isBlank(this.getProductId())) { + throw new WxPayException("当trade_type是'NATIVE'时,需指定非空的product_id值"); } } From c65cd34bc936f4f755ceb139bdd03084bce52791 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 13 Oct 2017 14:42:16 +0800 Subject: [PATCH 114/165] =?UTF-8?q?WxMpSelfMenuInfo=E7=9A=84=E5=87=A0?= =?UTF-8?q?=E4=B8=AA=E5=86=85=E9=83=A8=E9=9D=99=E6=80=81=E7=B1=BB=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0Serializable=E6=8E=A5=E5=8F=A3=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/bean/menu/WxMpSelfMenuInfo.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java index f288ab7b7b..91bbdb69ca 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java @@ -36,7 +36,9 @@ public void setButtons(List buttons) { this.buttons = buttons; } - public static class WxMpSelfMenuButton { + public static class WxMpSelfMenuButton implements Serializable { + private static final long serialVersionUID = -4426602953309048341L; + /** *
          * 菜单的类型,公众平台官网上能够设置的菜单类型有view(跳转网页)、text(返回文本,下同)、img、photo、video、voice。
    @@ -149,7 +151,9 @@ public void setNewsInfo(NewsInfo newsInfo) {
           this.newsInfo = newsInfo;
         }
     
    -    public static class SubButtons {
    +    public static class SubButtons implements Serializable {
    +      private static final long serialVersionUID = 1763350658575521079L;
    +
           @SerializedName("list")
           private List subButtons = new ArrayList<>();
     
    @@ -167,7 +171,9 @@ public void setSubButtons(List subButtons) {
           }
         }
     
    -    public static class NewsInfo {
    +    public static class NewsInfo implements Serializable {
    +      private static final long serialVersionUID = 3449813746347818457L;
    +
           @SerializedName("list")
           private List news = new ArrayList<>();
     
    @@ -184,7 +190,9 @@ public void setNews(List news) {
             this.news = news;
           }
     
    -      public static class NewsInButton {
    +      public static class NewsInButton  implements Serializable {
    +        private static final long serialVersionUID = 8701455967664912972L;
    +
             /**
              * 图文消息的标题
              */
    
    From 447c73e43a71093207d35caec77fc6273ebe6d4d Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Mon, 16 Oct 2017 14:32:36 +0800
    Subject: [PATCH 115/165] =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=8C=96=E5=B0=8F?=
     =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E6=A8=A1=E5=9D=97=E7=9A=84=E9=83=A8=E5=88=86?=
     =?UTF-8?q?=E4=BB=A3=E7=A0=81?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../miniapp/api/impl/WxMaMsgServiceImpl.java  |  3 +-
     .../wx/miniapp/api/impl/WxMaServiceImpl.java  |  9 +++--
     .../miniapp/api/impl/WxMaUserServiceImpl.java |  4 +-
     ...er.java => AbstractWxMaQrcodeWrapper.java} |  5 ++-
     .../wx/miniapp/bean/WxMaCodeLineColor.java    |  1 +
     .../wx/miniapp/bean/WxMaKefuMessage.java      |  4 +-
     .../wx/miniapp/bean/WxMaQrcode.java           |  2 +-
     .../wx/miniapp/bean/WxMaWxcode.java           |  6 ++-
     .../wx/miniapp/bean/WxMaWxcodeLimit.java      |  6 ++-
     .../wx/miniapp/builder/ImageBuilder.java      |  4 +-
     .../wx/miniapp/config/WxMaInMemoryConfig.java |  1 +
     .../wx/miniapp/constant/WxMaConstants.java    | 37 +++++++++++++++++--
     .../wx/miniapp/message/WxMaMessageRouter.java | 12 +++---
     .../message/WxMaMessageRouterRule.java        |  2 +-
     .../util/http/QrCodeRequestExecutor.java      |  6 +--
     .../wx/miniapp/bean/WxMaKefuMessageTest.java  |  4 +-
     .../wx/miniapp/demo/WxMaDemoServer.java       |  8 ++--
     17 files changed, 77 insertions(+), 37 deletions(-)
     rename weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/{WxMaQrcodeWrapper.java => AbstractWxMaQrcodeWrapper.java} (76%)
    
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java
    index 70a4e50445..aadc04f8a0 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImpl.java
    @@ -4,6 +4,7 @@
     import cn.binarywang.wx.miniapp.api.WxMaService;
     import cn.binarywang.wx.miniapp.bean.WxMaKefuMessage;
     import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage;
    +import cn.binarywang.wx.miniapp.constant.WxMaConstants;
     import com.google.gson.JsonObject;
     import com.google.gson.JsonParser;
     import me.chanjar.weixin.common.bean.result.WxError;
    @@ -30,7 +31,7 @@ public boolean sendKefuMsg(WxMaKefuMessage message) throws WxErrorException {
       public void sendTemplateMsg(WxMaTemplateMessage templateMessage) throws WxErrorException {
         String responseContent = this.wxMaService.post(TEMPLATE_MSG_SEND_URL, templateMessage.toJson());
         JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject();
    -    if (jsonObject.get("errcode").getAsInt() != 0) {
    +    if (jsonObject.get(WxMaConstants.ERRCODE).getAsInt() != 0) {
           throw new WxErrorException(WxError.fromJson(responseContent));
         }
       }
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java
    index 106f020e53..9cfa7efaa9 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java
    @@ -2,6 +2,7 @@
     
     import cn.binarywang.wx.miniapp.api.*;
     import cn.binarywang.wx.miniapp.config.WxMaConfig;
    +import cn.binarywang.wx.miniapp.constant.WxMaConstants;
     import com.google.gson.JsonParser;
     import me.chanjar.weixin.common.bean.WxAccessToken;
     import me.chanjar.weixin.common.bean.result.WxError;
    @@ -147,6 +148,7 @@ public String post(String url, String postData) throws WxErrorException {
       /**
        * 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求
        */
    +  @Override
       public  T execute(RequestExecutor executor, String uri, E data) throws WxErrorException {
         int retryTimes = 0;
         do {
    @@ -195,11 +197,10 @@ public synchronized  T executeInternal(RequestExecutor executor, Str
           WxError error = e.getError();
           /*
            * 发生以下情况时尝试刷新access_token
    -       * 40001 获取access_token时AppSecret错误,或者access_token无效
    -       * 42001 access_token超时
    -       * 40014 不合法的access_token,请开发者认真比对access_token的有效性(如是否过期)
            */
    -      if (error.getErrorCode() == 42001 || error.getErrorCode() == 40001 || error.getErrorCode() == 40014) {
    +      if (error.getErrorCode() == WxMaConstants.ErrorCode.ERR_40001
    +        || error.getErrorCode() == WxMaConstants.ErrorCode.ERR_42001
    +        || error.getErrorCode() == WxMaConstants.ErrorCode.ERR_40014) {
             // 强制设置wxMpConfigStorage它的access token过期了,这样在下一次请求里就会刷新access token
             this.getWxMaConfig().expireAccessToken();
             if (this.getWxMaConfig().autoRefreshToken()) {
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java
    index e2fdb9dc2b..8dbc139a0b 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java
    @@ -19,14 +19,14 @@
     public class WxMaUserServiceImpl implements WxMaUserService {
       private WxMaService service;
     
    -  WxMaUserServiceImpl(WxMaService service) {
    +  public WxMaUserServiceImpl(WxMaService service) {
         this.service = service;
       }
     
       @Override
       public WxMaJscode2SessionResult getSessionInfo(String jsCode) throws WxErrorException {
         final WxMaConfig config = service.getWxMaConfig();
    -    Map params = new HashMap<>();
    +    Map params = new HashMap<>(8);
         params.put("appid", config.getAppid());
         params.put("secret", config.getSecret());
         params.put("js_code", jsCode);
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcodeWrapper.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/AbstractWxMaQrcodeWrapper.java
    similarity index 76%
    rename from weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcodeWrapper.java
    rename to weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/AbstractWxMaQrcodeWrapper.java
    index 37c5c5db88..b4ad751791 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcodeWrapper.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/AbstractWxMaQrcodeWrapper.java
    @@ -4,9 +4,10 @@
     
     /**
      * 微信二维码(小程序码)包装器
    - * Created by Element on 2017/7/27.
    + *
    + * @author Element
      */
    -public abstract class WxMaQrcodeWrapper {
    +public abstract class AbstractWxMaQrcodeWrapper {
     
       @Override
       public String toString() {
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
    index 5312d9736d..850da06d7a 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
    @@ -6,6 +6,7 @@
      * 用于描述二维码(小程序码)颜色(RGB参数值),
      * 详情请查看文档 https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html
      * 
    + * @author Element */ public class WxMaCodeLineColor { private String r = "0", g = "0", b = "0"; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java index d75fbf12ae..680eeb65a4 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java @@ -25,14 +25,14 @@ public class WxMaKefuMessage implements Serializable { /** * 获得文本消息builder */ - public static TextBuilder TEXT() { + public static TextBuilder newTextBuilder() { return new TextBuilder(); } /** * 获得图片消息builder */ - public static ImageBuilder IMAGE() { + public static ImageBuilder newImageBuilder() { return new ImageBuilder(); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java index a047d7c8b1..39b870fbea 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java @@ -7,7 +7,7 @@ /** * @author Binary Wang */ -public class WxMaQrcode extends WxMaQrcodeWrapper implements Serializable { +public class WxMaQrcode extends AbstractWxMaQrcodeWrapper implements Serializable { private static final long serialVersionUID = 5777119669111011584L; private String path; private int width = 430; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java index faf78f5884..8654ed9991 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java @@ -6,9 +6,11 @@ import java.io.Serializable; /** - * Created by Element on 2017/7/27. + * + * @author Element + * @date 2017/7/27 */ -public class WxMaWxcode extends WxMaQrcodeWrapper implements Serializable { +public class WxMaWxcode extends AbstractWxMaQrcodeWrapper implements Serializable { private static final long serialVersionUID = 1287399621649210322L; private String path; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java index 864a082e8b..92f6837af2 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java @@ -6,9 +6,11 @@ import java.io.Serializable; /** - * Created by Element on 2017/7/27. + * + * @author Element + * @date 2017/7/27 */ -public class WxMaWxcodeLimit extends WxMaQrcodeWrapper implements Serializable { +public class WxMaWxcodeLimit extends AbstractWxMaQrcodeWrapper implements Serializable { private static final long serialVersionUID = 4782193774524960401L; private String scene; private String page; diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java index a903e97c43..d4bd068877 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/ImageBuilder.java @@ -13,8 +13,8 @@ public ImageBuilder() { this.msgType = WxMaConstants.KefuMsgType.IMAGE; } - public ImageBuilder mediaId(String media_id) { - this.mediaId = media_id; + public ImageBuilder mediaId(String mediaId) { + this.mediaId = mediaId; return this; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaInMemoryConfig.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaInMemoryConfig.java index 735a52b56a..7d84c90fbf 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaInMemoryConfig.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaInMemoryConfig.java @@ -175,6 +175,7 @@ public boolean autoRefreshToken() { return true; } + @Override public String getAppid() { return appid; } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java index 14016fa578..ccc492d1e0 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java @@ -8,11 +8,19 @@ * @author Binary Wang */ public class WxMaConstants { + /** + * 微信接口返回的参数errcode + */ + public static final String ERRCODE = "errcode"; + /** * 素材类型 */ public static class MediaType { - public static final String IMAGE = "image";//图片 + /** + * 图片 + */ + public static final String IMAGE = "image"; } /** @@ -27,7 +35,30 @@ public static class MsgDataFormat { * 客服消息的消息类型 */ public static class KefuMsgType { - public static final String TEXT = "text";//文本消息 - public static final String IMAGE = "image";//图片消息 + /** + * 文本消息 + */ + public static final String TEXT = "text"; + /** + * 图片消息 + */ + public static final String IMAGE = "image"; + } + + public static final class ErrorCode { + /** + * 40001 获取access_token时AppSecret错误,或者access_token无效 + */ + public static final int ERR_40001 = 40001; + + /** + * 42001 access_token超时 + */ + public static final int ERR_42001 = 42001; + + /** + * 40014 不合法的access_token,请开发者认真比对access_token的有效性(如是否过期) + */ + public static final int ERR_40014 = 40014; } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java index cbe42b1f26..be3af708bd 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java @@ -2,6 +2,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaMessage; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import me.chanjar.weixin.common.api.WxErrorExceptionHandler; import me.chanjar.weixin.common.api.WxMessageDuplicateChecker; import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker; @@ -17,10 +18,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; +import java.util.concurrent.*; /** * @author Binary Wang @@ -42,7 +40,9 @@ public class WxMaMessageRouter { public WxMaMessageRouter(WxMaService wxMaService) { this.wxMaService = wxMaService; - this.executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE); + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxMaMessageRouter-pool-%d").build(); + this.executorService = new ThreadPoolExecutor(DEFAULT_THREAD_POOL_SIZE, DEFAULT_THREAD_POOL_SIZE, + 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), namedThreadFactory); this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker(); this.sessionManager = new StandardSessionManager(); this.exceptionHandler = new LogExceptionHandler(); @@ -159,7 +159,7 @@ public void run() { } public void route(final WxMaMessage wxMessage) { - this.route(wxMessage, new HashMap()); + this.route(wxMessage, new HashMap(2)); } /** diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java index 835eb2894a..5353652995 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java @@ -196,7 +196,7 @@ protected void service(WxMaMessage wxMessage, WxSessionManager sessionManager, WxErrorExceptionHandler exceptionHandler) { if (context == null) { - context = new HashMap<>(); + context = new HashMap<>(16); } try { diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java index 3c026f4a18..1cbdf3840a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java @@ -1,6 +1,6 @@ package cn.binarywang.wx.miniapp.util.http; -import cn.binarywang.wx.miniapp.bean.WxMaQrcodeWrapper; +import cn.binarywang.wx.miniapp.bean.AbstractWxMaQrcodeWrapper; import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; @@ -25,7 +25,7 @@ /** * @author Binary Wang */ -public class QrCodeRequestExecutor implements RequestExecutor { +public class QrCodeRequestExecutor implements RequestExecutor { protected RequestHttp requestHttp; public QrCodeRequestExecutor(RequestHttp requestHttp) { @@ -33,7 +33,7 @@ public QrCodeRequestExecutor(RequestHttp requestHttp) { } @Override - public File execute(String uri, WxMaQrcodeWrapper ticket) throws WxErrorException, IOException { + public File execute(String uri, AbstractWxMaQrcodeWrapper ticket) throws WxErrorException, IOException { HttpPost httpPost = new HttpPost(uri); if (requestHttp.getRequestHttpProxy() != null) { httpPost diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java index f2ef8bfac5..a2b5261c94 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java @@ -19,7 +19,7 @@ public void testTextReply() { } public void testTextBuild() { - WxMaKefuMessage reply = WxMaKefuMessage.TEXT().toUser("OPENID").content("sfsfdsdf").build(); + WxMaKefuMessage reply = WxMaKefuMessage.newTextBuilder().toUser("OPENID").content("sfsfdsdf").build(); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); } @@ -32,7 +32,7 @@ public void testImageReply() { } public void testImageBuild() { - WxMaKefuMessage reply = WxMaKefuMessage.IMAGE().toUser("OPENID").mediaId("MEDIA_ID").build(); + WxMaKefuMessage reply = WxMaKefuMessage.newImageBuilder().toUser("OPENID").mediaId("MEDIA_ID").build(); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java index f6dcbae27b..9c4493f0c4 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java @@ -34,7 +34,7 @@ public class WxMaDemoServer { public void handle(WxMaMessage wxMessage, Map context, WxMaService service, WxSessionManager sessionManager) throws WxErrorException { System.out.println("收到消息:" + wxMessage.toString()); - service.getMsgService().sendKefuMsg(WxMaKefuMessage.TEXT().content("收到信息为:" + wxMessage.toJson()) + service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("收到信息为:" + wxMessage.toJson()) .toUser(wxMessage.getFromUser()).build()); } }; @@ -44,7 +44,7 @@ public void handle(WxMaMessage wxMessage, Map context, public void handle(WxMaMessage wxMessage, Map context, WxMaService service, WxSessionManager sessionManager) throws WxErrorException { - service.getMsgService().sendKefuMsg(WxMaKefuMessage.TEXT().content("回复文本消息") + service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("回复文本消息") .toUser(wxMessage.getFromUser()).build()); } @@ -60,7 +60,7 @@ public void handle(WxMaMessage wxMessage, Map context, ClassLoader.getSystemResourceAsStream("tmp.png")); service.getMsgService().sendKefuMsg( WxMaKefuMessage - .IMAGE() + .newImageBuilder() .mediaId(uploadResult.getMediaId()) .toUser(wxMessage.getFromUser()) .build()); @@ -79,7 +79,7 @@ public void handle(WxMaMessage wxMessage, Map context, WxMediaUploadResult uploadResult = service.getMediaService().uploadMedia(WxMaConstants.MediaType.IMAGE, file); service.getMsgService().sendKefuMsg( WxMaKefuMessage - .IMAGE() + .newImageBuilder() .mediaId(uploadResult.getMediaId()) .toUser(wxMessage.getFromUser()) .build()); From 64f0e7cf6bb1a642362c1ac5e5341964b7ca6952 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 17 Oct 2017 17:40:33 +0800 Subject: [PATCH 116/165] =?UTF-8?q?#355=20=E4=BF=AE=E5=A4=8D=E4=B8=BA?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8B=89=E5=8F=96=E8=AE=A2=E5=8D=95=E8=AF=84?= =?UTF-8?q?=E4=BB=B7=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3=E8=80=8C=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E7=AD=BE=E5=90=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/bean/menu/WxMpSelfMenuInfo.java | 2 +- .../wxpay/bean/request/WxPayBaseRequest.java | 20 ++++- .../bean/request/WxPayRefundRequest.java | 4 +- .../request/WxPayUnifiedOrderRequest.java | 4 +- .../wxpay/bean/result/WxPayBaseResult.java | 5 +- .../binarywang/wxpay/config/WxPayConfig.java | 14 +++ .../wxpay/constant/WxPayConstants.java | 4 + .../impl/WxPayServiceAbstractImpl.java | 90 ++++++++++--------- .../binarywang/wxpay/util/SignUtils.java | 53 ++++++----- .../impl/WxPayServiceAbstractImplTest.java | 76 +++++++++------- .../binarywang/wxpay/util/SignUtilsTest.java | 4 +- 11 files changed, 168 insertions(+), 108 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java index 91bbdb69ca..2a394ab276 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java @@ -38,7 +38,7 @@ public void setButtons(List buttons) { public static class WxMpSelfMenuButton implements Serializable { private static final long serialVersionUID = -4426602953309048341L; - + /** *
          * 菜单的类型,公众平台官网上能够设置的菜单类型有view(跳转网页)、text(返回文本,下同)、img、photo、video、voice。
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java
    index fad6d444f9..ad1911660e 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java
    @@ -14,6 +14,8 @@
     
     import java.math.BigDecimal;
     
    +import static com.github.binarywang.wxpay.constant.WxPayConstants.SignType.ALL_SIGN_TYPES;
    +
     /**
      * 
      * Created by Binary Wang on 2016-10-24.
    @@ -189,8 +191,9 @@ public String toXML() {
        * 
    * * @param config 支付配置对象,用于读取相应系统配置信息 + * @param isIgnoreSignType 签名时,是否忽略signType */ - public void checkAndSign(WxPayConfig config) throws WxPayException { + public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws WxPayException { this.checkFields(); if (StringUtils.isBlank(getAppid())) { @@ -209,11 +212,24 @@ public void checkAndSign(WxPayConfig config) throws WxPayException { this.setSubMchId(config.getSubMchId()); } + if (StringUtils.isBlank(getSignType())) { + if (config.getSignType() != null && !ALL_SIGN_TYPES.contains(config.getSignType())) { + throw new WxPayException("非法的signType配置:" + config.getSignType() + ",请检查配置!"); + } + this.setSignType(StringUtils.trimToNull(config.getSignType())); + } else { + if (!ALL_SIGN_TYPES.contains(this.getSignType())) { + throw new WxPayException("非法的sign_type参数:" + this.getSignType()); + } + } + if (StringUtils.isBlank(getNonceStr())) { this.setNonceStr(String.valueOf(System.currentTimeMillis())); } + //设置签名字段的值 - this.setSign(SignUtils.createSign(this, config.getMchKey(), this.signType)); + this.setSign(SignUtils.createSign(this, this.getSignType(), config.getMchKey(), + isIgnoreSignType)); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java index ce6cf747d2..1a3b85e83a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java @@ -165,12 +165,12 @@ public class WxPayRefundRequest extends WxPayBaseRequest { private String refundDesc; @Override - public void checkAndSign(WxPayConfig config) throws WxPayException { + public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws WxPayException { if (StringUtils.isBlank(this.getOpUserId())) { this.setOpUserId(config.getMchId()); } - super.checkAndSign(config); + super.checkAndSign(config, isIgnoreSignType); } @Override diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index f45a2d0c56..c2bc9f45fb 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -349,7 +349,7 @@ protected void checkConstraints() throws WxPayException { } @Override - public void checkAndSign(WxPayConfig config) throws WxPayException { + public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws WxPayException { if (StringUtils.isBlank(this.getNotifyURL())) { this.setNotifyURL(config.getNotifyUrl()); } @@ -358,7 +358,7 @@ public void checkAndSign(WxPayConfig config) throws WxPayException { this.setTradeType(config.getTradeType()); } - super.checkAndSign(config); + super.checkAndSign(config, isIgnoreSignType); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java index d2ba58a963..93a3426097 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java @@ -216,12 +216,13 @@ protected Integer getXmlValueAsInt(String... path) { /** * 校验返回结果签名 * + * @param signType 签名类型 * @param checkSuccess 是否同时检查结果是否成功 */ - public void checkResult(WxPayServiceAbstractImpl wxPayService, boolean checkSuccess) throws WxPayException { + public void checkResult(WxPayServiceAbstractImpl wxPayService, String signType, boolean checkSuccess) throws WxPayException { //校验返回结果签名 Map map = toMap(); - if (getSign() != null && !SignUtils.checkSign(map, wxPayService.getConfig().getMchKey())) { + if (getSign() != null && !SignUtils.checkSign(map, signType, wxPayService.getConfig().getMchKey())) { this.getLogger().debug("校验结果签名失败,参数:{}", map); throw new WxPayException("参数格式校验错误!"); } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java index 7d8cd5e1e3..684073d0af 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java @@ -36,6 +36,7 @@ public class WxPayConfig { private String subMchId; private String notifyUrl; private String tradeType; + private String signType; private SSLContext sslContext; private String keyPath; private boolean useSandboxEnv = false; @@ -139,6 +140,19 @@ public void setTradeType(String tradeType) { this.tradeType = tradeType; } + /** + * 签名方式 + * 有两种HMAC_SHA256 和MD5 + * @see com.github.binarywang.wxpay.constant.WxPayConstants.SignType + */ + public String getSignType() { + return this.signType; + } + + public void setSignType(String signType) { + this.signType = signType; + } + public SSLContext getSslContext() { return this.sslContext; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java index d56271a8cc..8e9eea95fc 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java @@ -1,6 +1,9 @@ package com.github.binarywang.wxpay.constant; +import com.google.common.collect.Lists; + import java.text.SimpleDateFormat; +import java.util.List; /** *
    @@ -96,6 +99,7 @@ public static class TradeType {
       public static class SignType {
         public static final String HMAC_SHA256 = "HMAC-SHA256";
         public static final String MD5 = "MD5";
    +    public static final List ALL_SIGN_TYPES = Lists.newArrayList(HMAC_SHA256, MD5);
       }
     
       /**
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    index 57cef5b826..1d5632bb03 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java
    @@ -72,12 +72,12 @@ private String getPayBaseUrl() {
     
       @Override
       public WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/secapi/pay/refund";
         String responseContent = this.post(url, request.toXML(), true);
         WxPayRefundResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
    @@ -90,13 +90,13 @@ public WxPayRefundQueryResult refundQuery(String transactionId, String outTradeN
         request.setOutRefundNo(StringUtils.trimToNull(outRefundNo));
         request.setRefundId(StringUtils.trimToNull(refundId));
     
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/pay/refundquery";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayRefundQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundQueryResult.class);
         result.composeRefundRecords();
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
    @@ -112,7 +112,7 @@ public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPa
           log.debug("微信支付异步通知请求参数:{}", xmlData);
           WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData);
           log.debug("微信支付异步通知请求解析后的对象:{}", result);
    -      result.checkResult(this, false);
    +      result.checkResult(this, null, false);
           return result;
         } catch (WxPayException e) {
           log.error(e.getMessage(), e);
    @@ -138,7 +138,7 @@ public WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws Wx
     
       @Override
       public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/sendredpack";
         if (request.getAmtType() != null) {
    @@ -156,12 +156,12 @@ public WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayExcept
         WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest();
         request.setMchBillNo(mchBillNo);
         request.setBillType(BillType.MCHT);
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo";
         String responseContent = this.post(url, request.toXML(), true);
         WxPayRedpackQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRedpackQueryResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
    @@ -170,7 +170,7 @@ public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo)
         WxPayOrderQueryRequest request = new WxPayOrderQueryRequest();
         request.setOutTradeNo(StringUtils.trimToNull(outTradeNo));
         request.setTransactionId(StringUtils.trimToNull(transactionId));
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/pay/orderquery";
         String responseContent = this.post(url, request.toXML(), false);
    @@ -180,7 +180,7 @@ public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo)
     
         WxPayOrderQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderQueryResult.class);
         result.composeCoupons();
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
    @@ -192,12 +192,12 @@ public WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException
     
         WxPayOrderCloseRequest request = new WxPayOrderCloseRequest();
         request.setOutTradeNo(StringUtils.trimToNull(outTradeNo));
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/pay/closeorder";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayOrderCloseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderCloseResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
     
         return result;
       }
    @@ -236,7 +236,7 @@ public  T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
             configMap.put("appid", appId);
     
             payResult = WxPayAppOrderResult.builder()
    -          .sign(SignUtils.createSign(configMap, this.getConfig().getMchKey(), null))
    +          .sign(SignUtils.createSign(configMap, null, this.getConfig().getMchKey(), false))
               .prepayId(prepayId)
               .partnerId(partnerId)
               .appId(appId)
    @@ -255,9 +255,12 @@ public  T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
               .signType(SignType.MD5)
               .build();
             ((WxPayMpOrderResult) payResult)
    -          .setPaySign(SignUtils.createSign(payResult, this.getConfig().getMchKey(), null));
    +          .setPaySign(SignUtils.createSign(payResult, null, this.getConfig().getMchKey(), false));
             break;
           }
    +      default: {
    +        throw new WxPayException("该交易类型暂不支持");
    +      }
         }
     
         return (T) payResult;
    @@ -265,12 +268,12 @@ public  T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
     
       @Override
       public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/pay/unifiedorder";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayUnifiedOrderResult result = WxPayBaseResult.fromXML(responseContent, WxPayUnifiedOrderResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
    @@ -303,7 +306,7 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W
           configMap.put("noncestr", nonceStr);
           configMap.put("appid", appId);
           // 此map用于客户端与微信服务器交互
    -      payInfo.put("sign", SignUtils.createSign(configMap, this.getConfig().getMchKey(), null));
    +      payInfo.put("sign", SignUtils.createSign(configMap, null, this.getConfig().getMchKey(), false));
           payInfo.put("prepayId", prepayId);
           payInfo.put("partnerId", partnerId);
           payInfo.put("appId", appId);
    @@ -317,7 +320,7 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W
           payInfo.put("nonceStr", nonceStr);
           payInfo.put("package", "prepay_id=" + prepayId);
           payInfo.put("signType", SignType.MD5);
    -      payInfo.put("paySign", SignUtils.createSign(payInfo, this.getConfig().getMchKey(), null));
    +      payInfo.put("paySign", SignUtils.createSign(payInfo, null, this.getConfig().getMchKey(), false));
         }
     
         return payInfo;
    @@ -325,12 +328,12 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W
     
       @Override
       public WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/promotion/transfers";
     
         String responseContent = this.post(url, request.toXML(), true);
         WxEntPayResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
    @@ -338,12 +341,12 @@ public WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException {
       public WxEntPayQueryResult queryEntPay(String partnerTradeNo) throws WxPayException {
         WxEntPayQueryRequest request = new WxEntPayQueryRequest();
         request.setPartnerTradeNo(partnerTradeNo);
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gettransferinfo";
         String responseContent = this.post(url, request.toXML(), true);
         WxEntPayQueryResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayQueryResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
    @@ -364,7 +367,7 @@ public String createScanPayQrcodeMode1(String productId) {
         params.put("time_stamp", String.valueOf(System.currentTimeMillis() / 1000));//这里需要秒,10位数字
         params.put("nonce_str", String.valueOf(System.currentTimeMillis()));
     
    -    String sign = SignUtils.createSign(params, this.getConfig().getMchKey(), null);
    +    String sign = SignUtils.createSign(params, null, this.getConfig().getMchKey(), false);
         params.put("sign", sign);
     
         for (String key : params.keySet()) {
    @@ -389,13 +392,14 @@ private byte[] createQrcode(String content, File logoFile, Integer sideLength) {
         return QrcodeUtils.createQrcode(content, sideLength, logoFile);
       }
     
    +  @Override
       public void report(WxPayReportRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/payitil/report";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
       }
     
       @Override
    @@ -406,7 +410,7 @@ public WxPayBillResult downloadBill(String billDate, String billType, String tar
         request.setTarType(tarType);
         request.setDeviceInfo(deviceInfo);
     
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/pay/downloadbill";
         String responseContent = this.post(url, request.toXML(), false);
    @@ -488,34 +492,34 @@ private WxPayBillResult handleBillInformation(String responseContent) {
     
       @Override
       public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/pay/micropay";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayMicropayResult result = WxPayBaseResult.fromXML(responseContent, WxPayMicropayResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
       @Override
       public WxPayOrderReverseResult reverseOrder(WxPayOrderReverseRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/secapi/pay/reverse";
         String responseContent = this.post(url, request.toXML(), true);
         WxPayOrderReverseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderReverseResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
       @Override
       public String shorturl(WxPayShorturlRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/tools/shorturl";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayShorturlResult result = WxPayBaseResult.fromXML(responseContent, WxPayShorturlResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result.getShortUrl();
       }
     
    @@ -526,12 +530,12 @@ public String shorturl(String longUrl) throws WxPayException {
     
       @Override
       public String authcode2Openid(WxPayAuthcode2OpenidRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/tools/authcodetoopenid";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayAuthcode2OpenidResult result = WxPayBaseResult.fromXML(responseContent, WxPayAuthcode2OpenidResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result.getOpenid();
       }
     
    @@ -543,45 +547,45 @@ public String authcode2Openid(String authCode) throws WxPayException {
       @Override
       public String getSandboxSignKey() throws WxPayException {
         WxPayDefaultRequest request = new WxPayDefaultRequest();
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey";
         String responseContent = this.post(url, request.toXML(), false);
         WxPaySandboxSignKeyResult result = WxPayBaseResult.fromXML(responseContent, WxPaySandboxSignKeyResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result.getSandboxSignKey();
       }
     
       @Override
       public WxPayCouponSendResult sendCoupon(WxPayCouponSendRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/send_coupon";
         String responseContent = this.post(url, request.toXML(), true);
         WxPayCouponSendResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponSendResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
       @Override
       public WxPayCouponStockQueryResult queryCouponStock(WxPayCouponStockQueryRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/query_coupon_stock";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayCouponStockQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponStockQueryResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
       @Override
       public WxPayCouponInfoQueryResult queryCouponInfo(WxPayCouponInfoQueryRequest request) throws WxPayException {
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), false);
     
         String url = this.getPayBaseUrl() + "/mmpaymkttransfers/querycouponsinfo";
         String responseContent = this.post(url, request.toXML(), false);
         WxPayCouponInfoQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponInfoQueryResult.class);
    -    result.checkResult(this, true);
    +    result.checkResult(this, request.getSignType(), true);
         return result;
       }
     
    @@ -605,7 +609,7 @@ public String queryComment(Date beginDate, Date endDate, Integer offset, Integer
         request.setLimit(limit);
         request.setSignType(SignType.HMAC_SHA256);
     
    -    request.checkAndSign(this.getConfig());
    +    request.checkAndSign(this.getConfig(), true);
     
         String url = this.getPayBaseUrl() + "/billcommentsp/batchquerycomment";
     
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java
    index 35a53c2c94..c3014c763a 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java
    @@ -27,31 +27,40 @@ public class SignUtils {
       /**
        * 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
        *
    -   * @param xmlBean  Bean需要标记有XML注解
    -   * @param signKey  签名Key
    -   * @param signType 签名类型,如果为空,则默认为MD5
    +   * @param xmlBean          Bean需要标记有XML注解
    +   * @param signType         签名类型,如果为空,则默认为MD5
    +   * @param signKey          签名Key
    +   * @param isIgnoreSignType 签名时,是否忽略signType
        * @return 签名字符串
        */
    -  public static String createSign(Object xmlBean, String signKey, String signType) {
    -    return createSign(BeanUtils.xmlBean2Map(xmlBean), signKey, signType);
    +  public static String createSign(Object xmlBean, String signType, String signKey, boolean isIgnoreSignType) {
    +    return createSign(BeanUtils.xmlBean2Map(xmlBean), signType, signKey, isIgnoreSignType);
       }
     
       /**
        * 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3)
        *
    -   * @param params   参数信息
    -   * @param signKey  签名Key
    -   * @param signType 签名类型,如果为空,则默认为md5
    +   * @param params           参数信息
    +   * @param signType         签名类型,如果为空,则默认为MD5
    +   * @param signKey          签名Key
    +   * @param isIgnoreSignType 签名时,是否忽略signType
        * @return 签名字符串
        */
    -  public static String createSign(Map params, String signKey, String signType) {
    +  public static String createSign(Map params, String signType, String signKey, boolean isIgnoreSignType) {
         SortedMap sortedMap = new TreeMap<>(params);
     
         StringBuilder toSign = new StringBuilder();
         for (String key : sortedMap.keySet()) {
           String value = params.get(key);
    -      if (StringUtils.isNotEmpty(value) &&
    -        !Lists.newArrayList("sign", "key", "sign_type").contains(key)) {
    +      boolean shouldSign = false;
    +      if (isIgnoreSignType && "sign_type".equals(key)) {
    +        shouldSign = false;
    +      } else if (StringUtils.isNotEmpty(value)
    +        && !Lists.newArrayList("sign", "key").contains(key)) {
    +        shouldSign = true;
    +      }
    +
    +      if (shouldSign) {
             toSign.append(key).append("=").append(value).append("&");
           }
         }
    @@ -81,25 +90,27 @@ private static String createHMACSha256Sign(String message, String key) {
       /**
        * 校验签名是否正确
        *
    -   * @param xmlBean Bean需要标记有XML注解
    -   * @param signKey 校验的签名Key
    +   * @param xmlBean  Bean需要标记有XML注解
    +   * @param signType 签名类型,如果为空,则默认为MD5
    +   * @param signKey  校验的签名Key
        * @return true - 签名校验成功,false - 签名校验失败
    -   * @see #checkSign(Map, String)
    +   * @see #checkSign(Map, String, String)
        */
    -  public static boolean checkSign(Object xmlBean, String signKey) {
    -    return checkSign(BeanUtils.xmlBean2Map(xmlBean), signKey);
    +  public static boolean checkSign(Object xmlBean, String signType, String signKey) {
    +    return checkSign(BeanUtils.xmlBean2Map(xmlBean), signType, signKey);
       }
     
       /**
        * 校验签名是否正确
        *
    -   * @param params  需要校验的参数Map
    -   * @param signKey 校验的签名Key
    +   * @param params   需要校验的参数Map
    +   * @param signType 签名类型,如果为空,则默认为MD5
    +   * @param signKey  校验的签名Key
        * @return true - 签名校验成功,false - 签名校验失败
    -   * @see #checkSign(Map, String)
    +   * @see #checkSign(Map, String, String)
        */
    -  public static boolean checkSign(Map params, String signKey) {
    -    String sign = createSign(params, signKey, null);
    +  public static boolean checkSign(Map params, String signType, String signKey) {
    +    String sign = createSign(params, signType, signKey, false);
         return sign.equals(params.get("sign"));
       }
     }
    diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
    index 3c27ce18d6..b6f7caf16a 100644
    --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
    +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java
    @@ -46,16 +46,17 @@ public class WxPayServiceAbstractImplTest {
        */
       @Test
       public void testUnifiedOrder() throws WxPayException {
    -    WxPayUnifiedOrderResult result = this.payService
    -      .unifiedOrder(WxPayUnifiedOrderRequest.newBuilder()
    -        .body("我去")
    -        .totalFee(1)
    -        .spbillCreateIp("11.1.11.1")
    -        .notifyURL("111111")
    -        .tradeType(TradeType.JSAPI)
    -        .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid())
    -        .outTradeNo("1111112")
    -        .build());
    +    WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder()
    +      .body("我去")
    +      .totalFee(1)
    +      .spbillCreateIp("11.1.11.1")
    +      .notifyURL("111111")
    +      .tradeType(TradeType.JSAPI)
    +      .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid())
    +      .outTradeNo("1111112")
    +      .build();
    +    request.setSignType(SignType.HMAC_SHA256);
    +    WxPayUnifiedOrderResult result = this.payService.unifiedOrder(request);
         this.logger.info(result.toString());
         this.logger.warn(this.payService.getWxApiData().toString());
       }
    @@ -284,13 +285,15 @@ public void testCreateScanPayQrcodeMode2() throws Exception {
     
       @Test
       public void testMicropay() throws Exception {
    -    WxPayMicropayResult result = this.payService.micropay(WxPayMicropayRequest.newBuilder()
    -      .body("body")
    -      .outTradeNo("aaaaa")
    -      .totalFee(123)
    -      .spbillCreateIp("127.0.0.1")
    -      .authCode("aaa")
    -      .build());
    +    WxPayMicropayResult result = this.payService.micropay(
    +      WxPayMicropayRequest
    +        .newBuilder()
    +        .body("body")
    +        .outTradeNo("aaaaa")
    +        .totalFee(123)
    +        .spbillCreateIp("127.0.0.1")
    +        .authCode("aaa")
    +        .build());
         this.logger.info(result.toString());
       }
     
    @@ -306,9 +309,11 @@ public void testSetConfig() throws Exception {
     
       @Test
       public void testReverseOrder() throws Exception {
    -    WxPayOrderReverseResult result = this.payService.reverseOrder(WxPayOrderReverseRequest.newBuilder()
    -      .outTradeNo("1111")
    -      .build());
    +    WxPayOrderReverseResult result = this.payService.reverseOrder(
    +      WxPayOrderReverseRequest
    +        .newBuilder()
    +        .outTradeNo("1111")
    +        .build());
         assertNotNull(result);
         this.logger.info(result.toString());
       }
    @@ -359,33 +364,38 @@ public void testSendCoupon() throws Exception {
     
       @Test
       public void testQueryCouponStock() throws Exception {
    -    WxPayCouponStockQueryResult result = this.payService.queryCouponStock(WxPayCouponStockQueryRequest.newBuilder()
    -      .couponStockId("123")
    -      .build());
    +    WxPayCouponStockQueryResult result = this.payService.queryCouponStock(
    +      WxPayCouponStockQueryRequest
    +        .newBuilder()
    +        .couponStockId("123")
    +        .build());
         this.logger.info(result.toString());
       }
     
       @Test
       public void testQueryCouponInfo() throws Exception {
    -    WxPayCouponInfoQueryResult result = this.payService.queryCouponInfo(WxPayCouponInfoQueryRequest.newBuilder()
    -      .openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4")
    -      .couponId("11")
    -      .stockId("1121")
    -      .build());
    +    WxPayCouponInfoQueryResult result = this.payService.queryCouponInfo(
    +      WxPayCouponInfoQueryRequest
    +        .newBuilder()
    +        .openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4")
    +        .couponId("11")
    +        .stockId("1121")
    +        .build());
         this.logger.info(result.toString());
       }
     
       /**
    -   * 目前调用接口总报“系统繁忙,清稍后再试”,怀疑根本没法使用
    +   * 只支持拉取90天内的评论数据
        */
       @Test
       public void testQueryComment() throws Exception {
         Calendar calendar = Calendar.getInstance();
    -    calendar.add(Calendar.DAY_OF_MONTH, -2);
    -    Date beginDate = calendar.getTime();
    -    calendar.add(Calendar.MONTH, -1);
    +    calendar.add(Calendar.DAY_OF_MONTH, -1);
         Date endDate = calendar.getTime();
    -    this.payService.queryComment(beginDate, endDate, 0, null);
    +    calendar.add(Calendar.DAY_OF_MONTH, -88);
    +    Date beginDate = calendar.getTime();
    +    String result = this.payService.queryComment(beginDate, endDate, 0, null);
    +    this.logger.info(result);
       }
     
       @Test
    diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java
    index 23d7088b7b..57c185b544 100644
    --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java
    +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java
    @@ -20,7 +20,7 @@ public class SignUtilsTest {
       public void testCreateSign() throws Exception {
         String signKey = "192006250b4c09247ec02edce69f6a2d";
         String message = "appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_id=10000100&nonce_str=ibuaiVcKdpRxkhJA";
    -    assertEquals(SignUtils.createSign((Splitter.on("&").withKeyValueSeparator("=").split(message)), signKey, null),
    +    assertEquals(SignUtils.createSign((Splitter.on("&").withKeyValueSeparator("=").split(message)), null, signKey, false),
           "9A0A8659F005D6984697E2CA0A9CF3B7");
       }
     
    @@ -29,7 +29,7 @@ public void testCreateSign_HMACSHA256() throws Exception {
         String signKey = "192006250b4c09247ec02edce69f6a2d";
         final String message = "appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_id=10000100&nonce_str=ibuaiVcKdpRxkhJA";
         String sign = SignUtils.createSign(Splitter.on("&").withKeyValueSeparator("=").split(message),
    -      signKey, HMAC_SHA256);
    +      HMAC_SHA256, signKey, false);
         assertEquals(sign, "6A9AE1657590FD6257D693A078E1C3E4BB6BA4DC30B23E0EE2496E54170DACD6");
       }
     
    
    From 0f007d970ba45c8f67494c255a2be559194142cd Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Wed, 18 Oct 2017 12:27:11 +0800
    Subject: [PATCH 117/165] =?UTF-8?q?#356=20=E4=BF=AE=E5=A4=8DQrCodeRequestE?=
     =?UTF-8?q?xecutor=E7=B1=BBMimeType=E6=AF=94=E8=BE=83=E7=9A=84bug?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../wx/miniapp/util/http/QrCodeRequestExecutor.java        | 3 ++-
     .../chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java | 7 ++++---
     .../mp/util/http/apache/ApacheQrCodeRequestExecutor.java   | 3 ++-
     3 files changed, 8 insertions(+), 5 deletions(-)
    
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java
    index 1cbdf3840a..24d9e99b77 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java
    @@ -48,7 +48,8 @@ public File execute(String uri, AbstractWxMaQrcodeWrapper ticket) throws WxError
              InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);) {
           Header[] contentTypeHeader = response.getHeaders("Content-Type");
           if (contentTypeHeader != null && contentTypeHeader.length > 0
    -        && ContentType.APPLICATION_JSON.getMimeType().equals(contentTypeHeader[0].getValue())) {
    +        && ContentType.APPLICATION_JSON.getMimeType()
    +        .equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) {
             String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
             throw new WxErrorException(WxError.fromJson(responseContent));
           }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java
    index 87c1920cd8..406eec01f9 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java
    @@ -1,5 +1,7 @@
     package me.chanjar.weixin.mp.util.http;
     
    +import me.chanjar.weixin.common.bean.result.WxError;
    +import me.chanjar.weixin.common.exception.WxErrorException;
     import me.chanjar.weixin.common.util.http.RequestExecutor;
     import me.chanjar.weixin.common.util.http.RequestHttp;
     import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
    @@ -21,7 +23,7 @@ public QrCodeRequestExecutor(RequestHttp requestHttp) {
         this.requestHttp = requestHttp;
       }
     
    -  public static RequestExecutor create(RequestHttp requestHttp) {
    +  public static RequestExecutor create(RequestHttp requestHttp) throws WxErrorException {
         switch (requestHttp.getRequestType()) {
           case APACHE_HTTP:
             return new ApacheQrCodeRequestExecutor(requestHttp);
    @@ -30,8 +32,7 @@ public static RequestExecutor create(RequestHttp request
           case OK_HTTP:
             return new OkhttpQrCodeRequestExecutor(requestHttp);
           default:
    -        //TODO 需要优化,最好抛出异常
    -        return null;
    +        throw new WxErrorException(WxError.newBuilder().setErrorMsg("不支持的http框架").build());
         }
       }
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheQrCodeRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheQrCodeRequestExecutor.java
    index d7bfe637c5..59874ee2bd 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheQrCodeRequestExecutor.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheQrCodeRequestExecutor.java
    @@ -52,7 +52,8 @@ public File execute(String uri, WxMpQrCodeTicket ticket) throws WxErrorException
           Header[] contentTypeHeader = response.getHeaders("Content-Type");
           if (contentTypeHeader != null && contentTypeHeader.length > 0) {
             // 出错
    -        if (ContentType.TEXT_PLAIN.getMimeType().equals(contentTypeHeader[0].getValue())) {
    +        if (ContentType.TEXT_PLAIN.getMimeType()
    +          .equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) {
               String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
               throw new WxErrorException(WxError.fromJson(responseContent));
             }
    
    From afb5e6151fc86d44cced396017487b668ddfe482 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Wed, 18 Oct 2017 12:33:52 +0800
    Subject: [PATCH 118/165] =?UTF-8?q?#352=20=E4=BF=AE=E5=A4=8DXStreamTransfo?=
     =?UTF-8?q?rmer=E7=94=B1=E4=BA=8Eclassloader=E5=8E=9F=E5=9B=A0=E5=AF=BC?=
     =?UTF-8?q?=E8=87=B4=E7=9A=84ClassCastException=E9=97=AE=E9=A2=98?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../cp/util/xml/XStreamTransformer.java       | 36 ++++++++++++-------
     .../miniapp/util/xml/XStreamTransformer.java  |  2 ++
     .../mp/util/xml/XStreamTransformer.java       |  2 ++
     3 files changed, 28 insertions(+), 12 deletions(-)
    
    diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java
    index 6b58063062..c86ed1ff67 100644
    --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java
    +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java
    @@ -46,17 +46,19 @@ public static  String toXml(Class clazz, T object) {
     
       private static Map configXStreamInstance() {
         Map map = new HashMap<>();
    -    map.put(WxCpXmlMessage.class, config_WxCpXmlMessage());
    -    map.put(WxCpXmlOutNewsMessage.class, config_WxCpXmlOutNewsMessage());
    -    map.put(WxCpXmlOutTextMessage.class, config_WxCpXmlOutTextMessage());
    -    map.put(WxCpXmlOutImageMessage.class, config_WxCpXmlOutImageMessage());
    -    map.put(WxCpXmlOutVideoMessage.class, config_WxCpXmlOutVideoMessage());
    -    map.put(WxCpXmlOutVoiceMessage.class, config_WxCpXmlOutVoiceMessage());
    +    map.put(WxCpXmlMessage.class, configWxCpXmlMessage());
    +    map.put(WxCpXmlOutNewsMessage.class, configWxCpXmlOutNewsMessage());
    +    map.put(WxCpXmlOutTextMessage.class, configWxCpXmlOutTextMessage());
    +    map.put(WxCpXmlOutImageMessage.class, configWxCpXmlOutImageMessage());
    +    map.put(WxCpXmlOutVideoMessage.class, configWxCpXmlOutVideoMessage());
    +    map.put(WxCpXmlOutVoiceMessage.class, configWxCpXmlOutVoiceMessage());
         return map;
       }
     
    -  private static XStream config_WxCpXmlMessage() {
    +  private static XStream configWxCpXmlMessage() {
         XStream xstream = XStreamInitializer.getInstance();
    +    xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
    +
         xstream.processAnnotations(WxCpXmlMessage.class);
         xstream.processAnnotations(WxCpXmlMessage.ScanCodeInfo.class);
         xstream.processAnnotations(WxCpXmlMessage.SendPicsInfo.class);
    @@ -65,38 +67,48 @@ private static XStream config_WxCpXmlMessage() {
         return xstream;
       }
     
    -  private static XStream config_WxCpXmlOutImageMessage() {
    +  private static XStream configWxCpXmlOutImageMessage() {
         XStream xstream = XStreamInitializer.getInstance();
    +    xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
    +
         xstream.processAnnotations(WxCpXmlOutMessage.class);
         xstream.processAnnotations(WxCpXmlOutImageMessage.class);
         return xstream;
       }
     
    -  private static XStream config_WxCpXmlOutNewsMessage() {
    +  private static XStream configWxCpXmlOutNewsMessage() {
         XStream xstream = XStreamInitializer.getInstance();
    +    xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
    +
         xstream.processAnnotations(WxCpXmlOutMessage.class);
         xstream.processAnnotations(WxCpXmlOutNewsMessage.class);
         xstream.processAnnotations(WxCpXmlOutNewsMessage.Item.class);
         return xstream;
       }
     
    -  private static XStream config_WxCpXmlOutTextMessage() {
    +  private static XStream configWxCpXmlOutTextMessage() {
         XStream xstream = XStreamInitializer.getInstance();
    +    xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
    +
         xstream.processAnnotations(WxCpXmlOutMessage.class);
         xstream.processAnnotations(WxCpXmlOutTextMessage.class);
         return xstream;
       }
     
    -  private static XStream config_WxCpXmlOutVideoMessage() {
    +  private static XStream configWxCpXmlOutVideoMessage() {
         XStream xstream = XStreamInitializer.getInstance();
    +    xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
    +
         xstream.processAnnotations(WxCpXmlOutMessage.class);
         xstream.processAnnotations(WxCpXmlOutVideoMessage.class);
         xstream.processAnnotations(WxCpXmlOutVideoMessage.Video.class);
         return xstream;
       }
     
    -  private static XStream config_WxCpXmlOutVoiceMessage() {
    +  private static XStream configWxCpXmlOutVoiceMessage() {
         XStream xstream = XStreamInitializer.getInstance();
    +    xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
    +
         xstream.processAnnotations(WxCpXmlOutMessage.class);
         xstream.processAnnotations(WxCpXmlOutVoiceMessage.class);
         return xstream;
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java
    index f85c716acb..8c6ec52ad7 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java
    @@ -56,6 +56,8 @@ private static void register(Class clz, XStream xStream) {
        */
       private static void registerClass(Class clz) {
         XStream xstream = XStreamInitializer.getInstance();
    +    xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
    +
         xstream.processAnnotations(clz);
         xstream.processAnnotations(getInnerClasses(clz));
         if (clz.equals(WxMaMessage.class)) {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java
    index 6835fa47a9..68cd475c38 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java
    @@ -60,6 +60,8 @@ private static void register(Class clz, XStream xStream) {
        */
       private static void registerClass(Class clz) {
         XStream xstream = XStreamInitializer.getInstance();
    +    xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
    +
         xstream.processAnnotations(clz);
         xstream.processAnnotations(getInnerClasses(clz));
         if (clz.equals(WxMpXmlMessage.class)) {
    
    From 8d6cfce13c67cb3f9e86e931aaddfb8febe642c1 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Fri, 20 Oct 2017 15:19:19 +0800
    Subject: [PATCH 119/165] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86?=
     =?UTF-8?q?=E4=BB=A3=E7=A0=81?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../chanjar/weixin/common/util/BeanUtils.java  | 15 +++++++++++----
     .../cp/api/impl/WxCpServiceOkHttpImpl.java     | 18 +++++-------------
     .../miniapp/api/impl/WxMaMediaServiceImpl.java | 10 ++--------
     .../mp/api/impl/WxMpMaterialServiceImpl.java   |  3 +--
     .../mp/api/impl/WxMpServiceOkHttpImpl.java     | 11 +++--------
     .../wxpay/bean/request/WxPayBaseRequest.java   |  2 +-
     .../binarywang/wxpay/util/SignUtils.java       |  7 +++++--
     .../impl/WxPayServiceAbstractImplTest.java     |  2 +-
     8 files changed, 29 insertions(+), 39 deletions(-)
    
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java
    index d74f1d8954..9e52aa2234 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java
    @@ -43,15 +43,20 @@ public static void checkRequiredFields(Object bean) throws WxErrorException {
             boolean isAccessible = field.isAccessible();
             field.setAccessible(true);
             if (field.isAnnotationPresent(Required.class)) {
    -          if (field.get(bean) == null || (field.get(bean) instanceof String && StringUtils.isBlank(field.get(bean).toString()))) {
    -            //两种情况,一种是值为null,另外一种情况是类型为字符串,但是字符串内容为空的,都认为是没有提供值
    +          // 两种情况,一种是值为null,
    +          // 另外一种情况是类型为字符串,但是字符串内容为空的,都认为是没有提供值
    +          boolean isRequiredMissing = field.get(bean) == null
    +            || (field.get(bean) instanceof String
    +            && StringUtils.isBlank(field.get(bean).toString())
    +          );
    +          if (isRequiredMissing) {
                 requiredFields.add(field.getName());
               }
             }
             field.setAccessible(isAccessible);
           } catch (SecurityException | IllegalArgumentException
             | IllegalAccessException e) {
    -        e.printStackTrace();
    +        log.error(e.getMessage(), e);
           }
         }
     
    @@ -83,11 +88,13 @@ public static Map xmlBean2Map(Object bean) {
     
             if (field.isAnnotationPresent(XStreamAlias.class)) {
               result.put(field.getAnnotation(XStreamAlias.class).value(), field.get(bean).toString());
    +        } else {
    +          result.put(field.getName(), field.get(bean).toString());
             }
     
             field.setAccessible(isAccessible);
           } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
    -        e.printStackTrace();
    +        log.error(e.getMessage(), e);
           }
     
         }
    diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java
    index f8476ff5af..d3580fe8a0 100644
    --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java
    +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java
    @@ -7,14 +7,10 @@
     import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
     import me.chanjar.weixin.cp.config.WxCpConfigStorage;
     import okhttp3.*;
    -import org.slf4j.Logger;
    -import org.slf4j.LoggerFactory;
     
     import java.io.IOException;
     
     public class WxCpServiceOkHttpImpl extends WxCpServiceAbstractImpl {
    -  private final Logger logger = LoggerFactory.getLogger(this.getClass());
    -
       protected OkHttpClient httpClient;
       protected OkHttpProxyInfo httpProxy;
     
    @@ -36,7 +32,7 @@ public HttpType getRequestType() {
     
       @Override
       public String getAccessToken(boolean forceRefresh) throws WxErrorException {
    -    logger.debug("WxCpServiceOkHttpImpl is running");
    +    this.log.debug("WxCpServiceOkHttpImpl is running");
         if (this.configStorage.isAccessTokenExpired() || forceRefresh) {
           synchronized (this.globalAccessTokenRefreshLock) {
             if (this.configStorage.isAccessTokenExpired()) {
    @@ -47,18 +43,14 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
               OkHttpClient client = getRequestHttpClient();
               //请求的request
               Request request = new Request.Builder().url(url).get().build();
    -          Response response = null;
    -          try {
    -            response = client.newCall(request).execute();
    -          } catch (IOException e) {
    -            e.printStackTrace();
    -          }
               String resultContent = null;
               try {
    +            Response response = client.newCall(request).execute();
                 resultContent = response.body().string();
               } catch (IOException e) {
    -            e.printStackTrace();
    +            this.log.error(e.getMessage(), e);
               }
    +
               WxError error = WxError.fromJson(resultContent);
               if (error.getErrorCode() != 0) {
                 throw new WxErrorException(error);
    @@ -74,7 +66,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
     
       @Override
       public void initHttp() {
    -    logger.debug("WxCpServiceOkHttpImpl initHttp");
    +    this.log.debug("WxCpServiceOkHttpImpl initHttp");
         OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
         //设置代理
         if (httpProxy != null) {
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java
    index 66ad3c2a91..71c42e615e 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java
    @@ -9,8 +9,6 @@
     import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor;
     import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
     import me.chanjar.weixin.common.util.http.RequestExecutor;
    -import org.slf4j.Logger;
    -import org.slf4j.LoggerFactory;
     
     import java.io.File;
     import java.io.IOException;
    @@ -22,8 +20,6 @@
      * @author Binary Wang
      */
     public class WxMaMediaServiceImpl implements WxMaMediaService {
    -  private final Logger log = LoggerFactory.getLogger(this.getClass());
    -
       private WxMaService wxMaService;
     
       public WxMaMediaServiceImpl(WxMaService wxMaService) {
    @@ -35,8 +31,7 @@ public WxMediaUploadResult uploadMedia(String mediaType, String fileType, InputS
         try {
           return this.uploadMedia(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType));
         } catch (IOException e) {
    -      e.printStackTrace();
    -      throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build());
    +      throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e);
         }
       }
     
    @@ -53,8 +48,7 @@ public File getMedia(String mediaId) throws WxErrorException {
             .create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("wxma").toFile());
           return this.wxMaService.execute(executor, MEDIA_GET_URL, "media_id=" + mediaId);
         } catch (IOException e) {
    -      this.log.error(e.getMessage(), e);
    -      throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build());
    +      throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e);
         }
       }
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
    index 90594fe031..91c3fc33fe 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
    @@ -37,8 +37,7 @@ public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputS
         try {
           return this.mediaUpload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType));
         } catch (IOException e) {
    -      e.printStackTrace();
    -      throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build());
    +      throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e);
         }
       }
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
    index 9066dc8d17..cab1dfc606 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
    @@ -8,16 +8,11 @@
     import me.chanjar.weixin.mp.api.WxMpConfigStorage;
     import me.chanjar.weixin.mp.api.WxMpService;
     import okhttp3.*;
    -import org.slf4j.Logger;
    -import org.slf4j.LoggerFactory;
     
     import java.io.IOException;
     import java.util.concurrent.locks.Lock;
     
     public class WxMpServiceOkHttpImpl extends WxMpServiceAbstractImpl {
    -
    -  private final Logger logger = LoggerFactory.getLogger(this.getClass());
    -
       private OkHttpClient httpClient;
       private OkHttpProxyInfo httpProxy;
     
    @@ -38,7 +33,7 @@ public HttpType getRequestType() {
     
       @Override
       public String getAccessToken(boolean forceRefresh) throws WxErrorException {
    -    logger.debug("WxMpServiceOkHttpImpl is running");
    +    this.log.debug("WxMpServiceOkHttpImpl is running");
         Lock lock = this.getWxMpConfigStorage().getAccessTokenLock();
         try {
           lock.lock();
    @@ -59,7 +54,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
               accessToken.getExpiresIn());
           }
         } catch (IOException e) {
    -      e.printStackTrace();
    +      this.log.error(e.getMessage(), e);
         } finally {
           lock.unlock();
         }
    @@ -68,7 +63,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
     
       @Override
       public void initHttp() {
    -    logger.debug("WxMpServiceOkHttpImpl initHttp");
    +    this.log.debug("WxMpServiceOkHttpImpl initHttp");
         WxMpConfigStorage configStorage = this.getWxMpConfigStorage();
     
         if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {
    diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java
    index ad1911660e..7147adfec7 100644
    --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java
    +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayBaseRequest.java
    @@ -190,7 +190,7 @@ public String toXML() {
        * 3、生成签名,并设置进去
        * 
    * - * @param config 支付配置对象,用于读取相应系统配置信息 + * @param config 支付配置对象,用于读取相应系统配置信息 * @param isIgnoreSignType 签名时,是否忽略signType */ public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws WxPayException { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java index c3014c763a..745514d00a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java @@ -6,6 +6,8 @@ import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; @@ -23,11 +25,12 @@ *
    */ public class SignUtils { + private static final Logger log = LoggerFactory.getLogger(SignUtils.class); /** * 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3) * - * @param xmlBean Bean需要标记有XML注解 + * @param xmlBean Bean里的属性如果存在XML注解,则使用其作为key,否则使用变量名 * @param signType 签名类型,如果为空,则默认为MD5 * @param signKey 签名Key * @param isIgnoreSignType 签名时,是否忽略signType @@ -81,7 +84,7 @@ private static String createHMACSha256Sign(String message, String key) { byte[] bytes = hmacSHA256.doFinal(message.getBytes()); return Hex.encodeHexString(bytes).toUpperCase(); } catch (NoSuchAlgorithmException | InvalidKeyException e) { - e.printStackTrace(); + log.error(e.getMessage(), e); } return null; diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index b6f7caf16a..84a9156ba6 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -67,7 +67,7 @@ public void testCreateOrder() throws Exception { } @Test - public void testCreateOrder_jssdk() throws Exception { + public void testCreateOrder_jsapi() throws Exception { WxPayMpOrderResult result = this.payService .createOrder(WxPayUnifiedOrderRequest.newBuilder() .body("我去") From 91838b9c1aabe6e3dc0bceb59750a455ae15d444 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 23 Oct 2017 10:46:09 +0800 Subject: [PATCH 120/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.8.4.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index c5e57b8839..447c3452ca 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.8.3.BETA + 2.8.4.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index a635d8c926..caf28d92d4 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.3.BETA + 2.8.4.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index a03fff6cc4..2a20361aeb 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.3.BETA + 2.8.4.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 21545dd0cb..059aa8cb7a 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.3.BETA + 2.8.4.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index b26093d5db..c0c6b8ee80 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.3.BETA + 2.8.4.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 10028da97e..01cfe29939 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.8.3.BETA + 2.8.4.BETA 4.0.0 From 460dc111bfa75373a6124d8bf58f48094ffe5034 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 25 Oct 2017 12:02:53 +0800 Subject: [PATCH 121/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8DWxPayMpOrderResult?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java index 068743d0b8..4fded06fdf 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/order/WxPayMpOrderResult.java @@ -1,5 +1,6 @@ package com.github.binarywang.wxpay.bean.order; +import com.thoughtworks.xstream.annotations.XStreamAlias; import lombok.Builder; import lombok.Data; @@ -21,6 +22,7 @@ public class WxPayMpOrderResult { /** * 由于package为java保留关键字,因此改为packageValue */ + @XStreamAlias("package") private String packageValue; private String signType; private String paySign; From d282bc0a9cb9a9abdbdcfa3c3212732724e79bb7 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 25 Oct 2017 12:03:37 +0800 Subject: [PATCH 122/165] =?UTF-8?q?WxCpDepart=E7=9A=84order=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=9B=B4=E6=94=B9=E4=B8=BALong?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java index 118c500488..25042eb0b8 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java @@ -15,7 +15,7 @@ public class WxCpDepart implements Serializable { private Integer id; private String name; private Integer parentId; - private Integer order; + private Long order; public static WxCpDepart fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpDepart.class); @@ -45,11 +45,11 @@ public void setParentId(Integer parentId) { this.parentId = parentId; } - public Integer getOrder() { + public Long getOrder() { return this.order; } - public void setOrder(Integer order) { + public void setOrder(Long order) { this.order = order; } From 58348eeb017f1ce47867d1e407d14f8f928c740b Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 25 Oct 2017 12:08:01 +0800 Subject: [PATCH 123/165] =?UTF-8?q?WxCpDepart=E7=9A=84order=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=9B=B4=E6=94=B9=E4=B8=BALong?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java index 431c38039b..a5a11d24f4 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpDepartGsonAdapter.java @@ -49,7 +49,7 @@ public WxCpDepart deserialize(JsonElement json, Type typeOfT, JsonDeserializatio depart.setName(GsonHelper.getAsString(departJson.get("name"))); } if (departJson.get("order") != null && !departJson.get("order").isJsonNull()) { - depart.setOrder(GsonHelper.getAsInteger(departJson.get("order"))); + depart.setOrder(GsonHelper.getAsLong(departJson.get("order"))); } if (departJson.get("parentid") != null && !departJson.get("parentid").isJsonNull()) { depart.setParentId(GsonHelper.getAsInteger(departJson.get("parentid"))); From 590b8c4ea13868b69bde9b3a8fb936d6b995d110 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 25 Oct 2017 12:12:17 +0800 Subject: [PATCH 124/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/api/impl/WxCpDepartmentServiceImplTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImplTest.java index 685f37444f..5e2502082a 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpDepartmentServiceImplTest.java @@ -1,12 +1,10 @@ package me.chanjar.weixin.cp.api.impl; import com.google.inject.Inject; -import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.cp.api.ApiTestModule; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpDepart; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; +import org.testng.annotations.*; import java.util.List; @@ -31,7 +29,7 @@ public void testCreate() throws Exception { WxCpDepart cpDepart = new WxCpDepart(); cpDepart.setName("子部门" + System.currentTimeMillis()); cpDepart.setParentId(1); - cpDepart.setOrder(1); + cpDepart.setOrder(1L); Integer departId = this.wxCpService.getDepartmentService().create(cpDepart); System.out.println(departId); } From 4c79eec2a5b2befb5b6c992eb25bdc6f804e94fe Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 25 Oct 2017 14:21:17 +0800 Subject: [PATCH 125/165] =?UTF-8?q?=E4=BD=BF=E7=94=A8lombok=E7=9A=84@Data?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E7=AE=80=E5=8C=96mp=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E6=89=80=E6=9C=89bean=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/bean/WxMpCard.java | 42 +- .../chanjar/weixin/mp/bean/WxMpMassNews.java | 63 +- .../mp/bean/WxMpMassOpenIdsMessage.java | 73 +-- .../mp/bean/WxMpMassPreviewMessage.java | 55 +- .../weixin/mp/bean/WxMpMassTagMessage.java | 81 +-- .../chanjar/weixin/mp/bean/WxMpMassVideo.java | 26 +- .../weixin/mp/bean/WxMpSemanticQuery.java | 66 +- .../weixin/mp/bean/WxMpShakeInfoResult.java | 123 +--- .../weixin/mp/bean/WxMpShakeQuery.java | 17 +- .../chanjar/weixin/mp/bean/WxMpUserQuery.java | 55 +- .../datacube/WxDataCubeArticleResult.java | 105 +--- .../bean/datacube/WxDataCubeArticleTotal.java | 25 +- .../WxDataCubeArticleTotalDetail.java | 213 +------ .../bean/datacube/WxDataCubeBaseResult.java | 10 +- .../datacube/WxDataCubeInterfaceResult.java | 42 +- .../mp/bean/datacube/WxDataCubeMsgResult.java | 58 +- .../bean/datacube/WxDataCubeUserCumulate.java | 18 +- .../bean/datacube/WxDataCubeUserSummary.java | 34 +- .../mp/bean/device/AbstractDeviceBean.java | 5 +- .../weixin/mp/bean/device/BaseResp.java | 47 +- .../weixin/mp/bean/device/RespMsg.java | 23 +- .../weixin/mp/bean/device/TransMsgResp.java | 38 +- .../weixin/mp/bean/device/WxDevice.java | 93 +-- .../mp/bean/device/WxDeviceAuthorize.java | 37 +- .../bean/device/WxDeviceAuthorizeResult.java | 12 +- .../weixin/mp/bean/device/WxDeviceBind.java | 28 +- .../bean/device/WxDeviceBindDeviceResult.java | 21 +- .../mp/bean/device/WxDeviceBindResult.java | 12 +- .../weixin/mp/bean/device/WxDeviceMsg.java | 37 +- .../mp/bean/device/WxDeviceOpenIdResult.java | 36 +- .../mp/bean/device/WxDeviceQrCodeResult.java | 36 +- .../weixin/mp/bean/kefu/WxMpKefuMessage.java | 137 +---- .../kefu/request/WxMpKfAccountRequest.java | 66 +- .../kefu/request/WxMpKfSessionRequest.java | 10 +- .../mp/bean/kefu/result/WxMpKfInfo.java | 81 +-- .../mp/bean/kefu/result/WxMpKfList.java | 9 +- .../mp/bean/kefu/result/WxMpKfMsgList.java | 30 +- .../mp/bean/kefu/result/WxMpKfMsgRecord.java | 6 +- .../mp/bean/kefu/result/WxMpKfOnlineList.java | 9 +- .../mp/bean/kefu/result/WxMpKfSession.java | 33 +- .../kefu/result/WxMpKfSessionGetResult.java | 18 +- .../bean/kefu/result/WxMpKfSessionList.java | 9 +- .../result/WxMpKfSessionWaitCaseList.java | 10 +- .../bean/material/WxMediaImgUploadResult.java | 9 +- .../weixin/mp/bean/material/WxMpMaterial.java | 40 +- .../material/WxMpMaterialArticleUpdate.java | 31 +- .../material/WxMpMaterialCountResult.java | 34 +- .../WxMpMaterialFileBatchGetResult.java | 59 +- .../mp/bean/material/WxMpMaterialNews.java | 107 +--- .../WxMpMaterialNewsBatchGetResult.java | 51 +- .../material/WxMpMaterialUploadResult.java | 34 +- .../material/WxMpMaterialVideoInfoResult.java | 31 +- .../bean/membercard/MemberCardUserInfo.java | 21 +- .../weixin/mp/bean/membercard/NameValues.java | 30 +- .../mp/bean/membercard/NotifyOptional.java | 42 +- .../WxMpMemberCardActivatedMessage.java | 97 +-- .../WxMpMemberCardUpdateMessage.java | 105 +--- .../WxMpMemberCardUpdateResult.java | 42 +- .../WxMpMemberCardUserInfoResult.java | 86 +-- .../bean/menu/WxMpGetSelfMenuInfoResult.java | 17 +- .../chanjar/weixin/mp/bean/menu/WxMpMenu.java | 42 +- .../weixin/mp/bean/menu/WxMpSelfMenuInfo.java | 141 +---- .../weixin/mp/bean/message/HardWare.java | 18 +- .../weixin/mp/bean/message/ScanCodeInfo.java | 9 +- .../mp/bean/message/SendLocationInfo.java | 44 +- .../weixin/mp/bean/message/SendPicsInfo.java | 22 +- .../mp/bean/message/WxMpXmlMessage.java | 565 +----------------- .../bean/message/WxMpXmlOutImageMessage.java | 10 +- .../mp/bean/message/WxMpXmlOutMessage.java | 34 +- .../bean/message/WxMpXmlOutMusicMessage.java | 83 +-- .../bean/message/WxMpXmlOutNewsMessage.java | 53 +- .../bean/message/WxMpXmlOutTextMessage.java | 11 +- .../WxMpXmlOutTransferKefuMessage.java | 18 +- .../bean/message/WxMpXmlOutVideoMessage.java | 52 +- .../bean/message/WxMpXmlOutVoiceMessage.java | 10 +- .../weixin/mp/bean/result/WxMpCardResult.java | 50 +- .../bean/result/WxMpCurrentAutoReplyInfo.java | 220 +------ .../mp/bean/result/WxMpMassSendResult.java | 34 +- .../mp/bean/result/WxMpMassUploadResult.java | 26 +- .../mp/bean/result/WxMpOAuth2AccessToken.java | 50 +- .../mp/bean/result/WxMpQrCodeTicket.java | 34 +- .../bean/result/WxMpSemanticQueryResult.java | 50 +- .../weixin/mp/bean/result/WxMpUser.java | 129 +--- .../result/WxMpUserBlacklistGetResult.java | 34 +- .../weixin/mp/bean/result/WxMpUserList.java | 34 +- .../mp/bean/store/WxMpStoreBaseInfo.java | 366 +----------- .../weixin/mp/bean/store/WxMpStoreInfo.java | 11 +- .../mp/bean/store/WxMpStoreListResult.java | 34 +- .../weixin/mp/bean/tag/WxTagListUser.java | 35 +- .../chanjar/weixin/mp/bean/tag/WxUserTag.java | 26 +- .../weixin/mp/bean/template/WxMpTemplate.java | 50 +- .../mp/bean/template/WxMpTemplateData.java | 27 +- .../bean/template/WxMpTemplateIndustry.java | 42 +- .../mp/bean/template/WxMpTemplateMessage.java | 120 +--- .../mp/util/json/WxQrCodeTicketAdapter.java | 2 +- .../api/impl/WxMpQrcodeServiceImplTest.java | 6 +- 96 files changed, 319 insertions(+), 4958 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java index 76fc4a6451..0fcb9185ee 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCard.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; @@ -11,6 +12,7 @@ * @author YuJian * @version 15/11/11 */ +@Data public class WxMpCard implements Serializable{ private static final long serialVersionUID = 9214301870017772921L; @@ -24,46 +26,6 @@ public class WxMpCard implements Serializable{ private Boolean canConsume; - public String getCardId() { - return this.cardId; - } - - public void setCardId(String cardId) { - this.cardId = cardId; - } - - public Long getBeginTime() { - return this.beginTime; - } - - public void setBeginTime(Long beginTime) { - this.beginTime = beginTime; - } - - public Long getEndTime() { - return this.endTime; - } - - public void setEndTime(Long endTime) { - this.endTime = endTime; - } - - public String getUserCardStatus() { - return this.userCardStatus; - } - - public void setUserCardStatus(String userCardStatus) { - this.userCardStatus = userCardStatus; - } - - public Boolean getCanConsume() { - return this.canConsume; - } - - public void setCanConsume(Boolean canConsume) { - this.canConsume = canConsume; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java index bb19f0e79e..b2ef87b1d6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassNews.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -12,15 +13,12 @@ * * @author chanjarster */ +@Data public class WxMpMassNews implements Serializable { private static final long serialVersionUID = 565937155013581016L; private List articles = new ArrayList<>(); - public List getArticles() { - return this.articles; - } - public void addArticle(WxMpMassNewsArticle article) { this.articles.add(article); } @@ -52,6 +50,7 @@ public String toString() { * * @author chanjarster */ + @Data public static class WxMpMassNewsArticle { /** * (必填) 图文消息缩略图的media_id,可以在基础支持-上传多媒体文件接口中获得 @@ -82,62 +81,6 @@ public static class WxMpMassNewsArticle { */ private boolean showCoverPic; - public String getThumbMediaId() { - return this.thumbMediaId; - } - - public void setThumbMediaId(String thumbMediaId) { - this.thumbMediaId = thumbMediaId; - } - - public String getAuthor() { - return this.author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getContentSourceUrl() { - return this.contentSourceUrl; - } - - public void setContentSourceUrl(String contentSourceUrl) { - this.contentSourceUrl = contentSourceUrl; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getDigest() { - return this.digest; - } - - public void setDigest(String digest) { - this.digest = digest; - } - - public boolean isShowCoverPic() { - return this.showCoverPic; - } - - public void setShowCoverPic(boolean showCoverPic) { - this.showCoverPic = showCoverPic; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java index 73b6c9e241..eff1e66551 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -11,22 +12,14 @@ * * @author chanjarster */ +@Data public class WxMpMassOpenIdsMessage implements Serializable { private static final long serialVersionUID = -8022910911104788999L; + /** + * openid列表,最多支持10,000个 + */ private List toUsers = new ArrayList<>(); - private String msgType; - private String content; - private String mediaId; - private boolean sendIgnoreReprint = false; - - public WxMpMassOpenIdsMessage() { - super(); - } - - public String getMsgType() { - return this.msgType; - } /** *
    @@ -38,66 +31,28 @@ public String getMsgType() {
        * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
        * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
        * 
    - * - * @param msgType */ - public void setMsgType(String msgType) { - this.msgType = msgType; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getMediaId() { - return this.mediaId; - } + private String msgType; + private String content; + private String mediaId; + /** + * 文章被判定为转载时,是否继续进行群发操作。 + */ + private boolean sendIgnoreReprint = false; - public void setMediaId(String mediaId) { - this.mediaId = mediaId; + public WxMpMassOpenIdsMessage() { + super(); } public String toJson() { return WxMpGsonBuilder.INSTANCE.create().toJson(this); } - /** - * openid列表,最多支持10,000个 - */ - public List getToUsers() { - return this.toUsers; - } - - /** - * 提供set方法,方便客户端直接设置所有群发对象的openid列表 - * - * @param toUsers - */ - public void setToUsers(List toUsers) { - this.toUsers = toUsers; - } - /** * 添加openid,最多支持10,000个 - * - * @param openid */ public void addUser(String openid) { this.toUsers.add(openid); } - public boolean isSendIgnoreReprint() { - return sendIgnoreReprint; - } - - /** - * @param sendIgnoreReprint 文章被判定为转载时,是否继续进行群发操作。 - */ - public void setSendIgnoreReprint(boolean sendIgnoreReprint) { - this.sendIgnoreReprint = sendIgnoreReprint; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java index 503bdec43b..bcb67403f8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -7,33 +8,15 @@ /** * @author miller */ +@Data public class WxMpMassPreviewMessage implements Serializable { private static final long serialVersionUID = 9095211638358424020L; private String toWxUserName; private String toWxUserOpenid; - private String msgType; - private String content; - private String mediaId; - - public WxMpMassPreviewMessage() { - super(); - } - - public String getToWxUserName() { - return this.toWxUserName; - } - - public void setToWxUserName(String toWxUserName) { - this.toWxUserName = toWxUserName; - } - - public String getMsgType() { - return this.msgType; - } - /** *
    +   * 消息类型
        * 请使用
        * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE}
        * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS}
    @@ -42,35 +25,13 @@ public String getMsgType() {
        * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
        * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
        * 
    - * - * @param msgType 消息类型 */ - public void setMsgType(String msgType) { - this.msgType = msgType; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getToWxUserOpenid() { - return this.toWxUserOpenid; - } + private String msgType; + private String content; + private String mediaId; - public void setToWxUserOpenid(String toWxUserOpenid) { - this.toWxUserOpenid = toWxUserOpenid; + public WxMpMassPreviewMessage() { + super(); } public String toJson() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java index acf9d0f4c1..99c103f3d0 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -9,26 +10,17 @@ * * @author chanjarster */ +@Data public class WxMpMassTagMessage implements Serializable { private static final long serialVersionUID = -6625914040986749286L; + /** + * 标签id,如果不设置则就意味着发给所有用户 + */ private Long tagId; - private String msgType; - private String content; - private String mediaId; - private boolean isSendAll = false; - private boolean sendIgnoreReprint = false; - - public WxMpMassTagMessage() { - super(); - } - - public String getMsgType() { - return this.msgType; - } - /** *
    +   * 消息类型
        * 请使用
        * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE}
        * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS}
    @@ -37,62 +29,25 @@ public String getMsgType() {
        * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
        * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
        * 
    - * - * @param msgType 消息类型 */ - public void setMsgType(String msgType) { - this.msgType = msgType; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String toJson() { - return WxMpGsonBuilder.INSTANCE.create().toJson(this); - } - - public Long getTagId() { - return this.tagId; - } - + private String msgType; + private String content; + private String mediaId; /** - * 如果不设置则就意味着发给所有用户 - * - * @param tagId 标签id + * 是否群发给所有用户 */ - public void setTagId(Long tagId) { - this.tagId = tagId; - } - - public boolean isSendIgnoreReprint() { - return sendIgnoreReprint; - } - + private boolean isSendAll = false; /** - * @param sendIgnoreReprint 文章被判定为转载时,是否继续进行群发操作。 + * 文章被判定为转载时,是否继续进行群发操作。 */ - public void setSendIgnoreReprint(boolean sendIgnoreReprint) { - this.sendIgnoreReprint = sendIgnoreReprint; + private boolean sendIgnoreReprint = false; + + public WxMpMassTagMessage() { + super(); } - /** - * 是否群发给所有用户 - */ - public boolean isSendAll() { - return isSendAll; + public String toJson() { + return WxMpGsonBuilder.INSTANCE.create().toJson(this); } public void setSendAll(boolean sendAll) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java index 1683be5bdf..d536ff989f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassVideo.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -9,6 +10,7 @@ * * @author chanjarster */ +@Data public class WxMpMassVideo implements Serializable { private static final long serialVersionUID = 9153925016061915637L; @@ -16,30 +18,6 @@ public class WxMpMassVideo implements Serializable { private String title; private String description; - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - public String toJson() { return WxMpGsonBuilder.INSTANCE.create().toJson(this); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java index 8c18a6a9ea..f9de30f552 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpSemanticQuery.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -11,6 +12,7 @@ * * @author Daniel Qian */ +@Data public class WxMpSemanticQuery implements Serializable { private static final long serialVersionUID = 7685873048199870690L; @@ -23,70 +25,6 @@ public class WxMpSemanticQuery implements Serializable { private String appid; private String uid; - public String getQuery() { - return this.query; - } - - public void setQuery(String query) { - this.query = query; - } - - public String getCategory() { - return this.category; - } - - public void setCategory(String category) { - this.category = category; - } - - public Float getLatitude() { - return this.latitude; - } - - public void setLatitude(Float latitude) { - this.latitude = latitude; - } - - public Float getLongitude() { - return this.longitude; - } - - public void setLongitude(Float longitude) { - this.longitude = longitude; - } - - public String getCity() { - return this.city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getRegion() { - return this.region; - } - - public void setRegion(String region) { - this.region = region; - } - - public String getAppid() { - return this.appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public String getUid() { - return this.uid; - } - - public void setUid(String uid) { - this.uid = uid; - } - public String toJson() { return WxMpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java index 5fb2ab1735..313cfaba84 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeInfoResult.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -10,6 +11,7 @@ * * @author rememberber */ +@Data public class WxMpShakeInfoResult implements Serializable { private static final long serialVersionUID = -1604561297395395468L; @@ -17,13 +19,15 @@ public class WxMpShakeInfoResult implements Serializable { private String errmsg; - private Data data; + private ShakeInfoData data; public static WxMpShakeInfoResult fromJson(String json) { return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpShakeInfoResult.class); } - public class Data { + @Data + public class ShakeInfoData implements Serializable { + private static final long serialVersionUID = -4828142206067489488L; private String page_id; @@ -35,7 +39,9 @@ public class Data { private BeaconInfo beacon_info; - public class BeaconInfo { + @Data + public class BeaconInfo implements Serializable { + private static final long serialVersionUID = -8995733049982933362L; private double distance; @@ -48,118 +54,7 @@ public class BeaconInfo { private Integer rssi; private String uuid; - - public double getDistance() { - return distance; - } - - public void setDistance(double distance) { - this.distance = distance; - } - - public Integer getMajor() { - return major; - } - - public void setMajor(Integer major) { - this.major = major; - } - - public Integer getMeasure_power() { - return measure_power; - } - - public void setMeasure_power(Integer measure_power) { - this.measure_power = measure_power; - } - - public Integer getMinor() { - return minor; - } - - public void setMinor(Integer minor) { - this.minor = minor; - } - - public Integer getRssi() { - return rssi; - } - - public void setRssi(Integer rssi) { - this.rssi = rssi; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - } - - public String getPage_id() { - return page_id; - } - - public void setPage_id(String page_id) { - this.page_id = page_id; - } - - public String getOpenid() { - return openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getPoi_id() { - return poi_id; - } - - public void setPoi_id(String poi_id) { - this.poi_id = poi_id; - } - - public BeaconInfo getBeacon_info() { - return beacon_info; - } - - public void setBeacon_info(BeaconInfo beacon_info) { - this.beacon_info = beacon_info; - } - - public String getBrand_userame() { - return brand_userame; - } - - public void setBrand_userame(String brand_userame) { - this.brand_userame = brand_userame; } } - public Integer getErrcode() { - return errcode; - } - - public void setErrcode(Integer errcode) { - this.errcode = errcode; - } - - public String getErrmsg() { - return errmsg; - } - - public void setErrmsg(String errmsg) { - this.errmsg = errmsg; - } - - public Data getData() { - return data; - } - - public void setData(Data data) { - this.data = data; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java index 0f4aeadd19..709e59e50f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpShakeQuery.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean; import com.google.gson.Gson; +import lombok.Data; import java.io.Serializable; import java.util.HashMap; @@ -11,6 +12,7 @@ * * @author rememberber */ +@Data public class WxMpShakeQuery implements Serializable { private static final long serialVersionUID = 4316527352035275412L; @@ -25,19 +27,4 @@ public String toJsonString() { return new Gson().toJson(map); } - public String getTicket() { - return ticket; - } - - public void setTicket(String ticket) { - this.ticket = ticket; - } - - public int getNeedPoi() { - return needPoi; - } - - public void setNeedPoi(int needPoi) { - this.needPoi = needPoi; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java index 243163c28b..9e73b46159 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpUserQuery.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean; import com.google.gson.Gson; +import lombok.Data; import java.io.Serializable; import java.util.ArrayList; @@ -14,6 +15,7 @@ * * @author LiuJunGuang */ +@Data public class WxMpUserQuery implements Serializable { private static final long serialVersionUID = -1344224837373149313L; @@ -110,19 +112,18 @@ public String toJsonString() { } // 查询参数封装 + @Data public class WxMpUserQueryParam implements Serializable { private static final long serialVersionUID = -6863571795702385319L; private String openid; private String lang; public WxMpUserQueryParam(String openid, String lang) { - super(); this.openid = openid; this.lang = lang; } public WxMpUserQueryParam(String openid) { - super(); this.openid = openid; this.lang = "zh_CN"; } @@ -131,56 +132,6 @@ public WxMpUserQueryParam() { super(); } - public String getOpenid() { - return this.openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getLang() { - return this.lang; - } - - public void setLang(String lang) { - this.lang = lang; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + getOuterType().hashCode(); - result = prime * result + ((this.lang == null) ? 0 : this.lang.hashCode()); - result = prime * result + ((this.openid == null) ? 0 : this.openid.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - WxMpUserQueryParam other = (WxMpUserQueryParam) obj; - if (!getOuterType().equals(other.getOuterType())) - return false; - if (this.lang == null) { - if (other.lang != null) - return false; - } else if (!this.lang.equals(other.lang)) - return false; - if (this.openid == null) { - if (other.openid != null) - return false; - } else if (!this.openid.equals(other.openid)) - return false; - return true; - } - private WxMpUserQuery getOuterType() { return WxMpUserQuery.this; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java index 8b14e055a9..8fa3065136 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.util.List; @@ -13,6 +14,7 @@ * * @author Binary Wang */ +@Data public class WxDataCubeArticleResult extends WxDataCubeBaseResult { private static final long serialVersionUID = -9222452497954511765L; @@ -116,107 +118,4 @@ public static List fromJson(String json) { }.getType()); } - public Integer getRefHour() { - return this.refHour; - } - - public void setRefHour(Integer refHour) { - this.refHour = refHour; - } - - public String getMsgId() { - return this.msgId; - } - - public void setMsgId(String msgId) { - this.msgId = msgId; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public Integer getIntPageReadUser() { - return this.intPageReadUser; - } - - public void setIntPageReadUser(Integer intPageReadUser) { - this.intPageReadUser = intPageReadUser; - } - - public Integer getIntPageReadCount() { - return this.intPageReadCount; - } - - public void setIntPageReadCount(Integer intPageReadCount) { - this.intPageReadCount = intPageReadCount; - } - - public Integer getOriPageReadUser() { - return this.oriPageReadUser; - } - - public void setOriPageReadUser(Integer oriPageReadUser) { - this.oriPageReadUser = oriPageReadUser; - } - - public Integer getOriPageReadCount() { - return this.oriPageReadCount; - } - - public void setOriPageReadCount(Integer oriPageReadCount) { - this.oriPageReadCount = oriPageReadCount; - } - - public Integer getShareScene() { - return this.shareScene; - } - - public void setShareScene(Integer shareScene) { - this.shareScene = shareScene; - } - - public Integer getShareUser() { - return this.shareUser; - } - - public void setShareUser(Integer shareUser) { - this.shareUser = shareUser; - } - - public Integer getShareCount() { - return this.shareCount; - } - - public void setShareCount(Integer shareCount) { - this.shareCount = shareCount; - } - - public Integer getAddToFavUser() { - return this.addToFavUser; - } - - public void setAddToFavUser(Integer addToFavUser) { - this.addToFavUser = addToFavUser; - } - - public Integer getAddToFavCount() { - return this.addToFavCount; - } - - public void setAddToFavCount(Integer addToFavCount) { - this.addToFavCount = addToFavCount; - } - - public Integer getUserSource() { - return this.userSource; - } - - public void setUserSource(Integer userSource) { - this.userSource = userSource; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java index 7cdddad4de..f1c982963b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.util.List; @@ -13,6 +14,7 @@ * * @author Binary Wang */ +@Data public class WxDataCubeArticleTotal extends WxDataCubeBaseResult { private static final long serialVersionUID = -7634365687303052699L; @@ -44,27 +46,4 @@ public static List fromJson(String json) { }.getType()); } - public String getMsgId() { - return this.msgId; - } - - public void setMsgId(String msgId) { - this.msgId = msgId; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public List getDetails() { - return this.details; - } - - public void setDetails(List details) { - this.details = details; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java index ebd4b894bf..0c3bf2916c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.datacube; import com.google.gson.annotations.SerializedName; +import lombok.Data; import java.io.Serializable; @@ -11,6 +12,7 @@ * * @author Binary Wang */ +@Data public class WxDataCubeArticleTotalDetail implements Serializable { private static final long serialVersionUID = -5136169129771430052L; @@ -196,215 +198,4 @@ public class WxDataCubeArticleTotalDetail implements Serializable { @SerializedName("feed_share_from_other_cnt") private Integer feedShareFromOtherCnt; - public String getStatDate() { - return this.statDate; - } - - public void setStatDate(String statDate) { - this.statDate = statDate; - } - - public Integer getTargetUser() { - return this.targetUser; - } - - public void setTargetUser(Integer targetUser) { - this.targetUser = targetUser; - } - - public Integer getIntPageReadUser() { - return this.intPageReadUser; - } - - public void setIntPageReadUser(Integer intPageReadUser) { - this.intPageReadUser = intPageReadUser; - } - - public Integer getIntPageReadCount() { - return this.intPageReadCount; - } - - public void setIntPageReadCount(Integer intPageReadCount) { - this.intPageReadCount = intPageReadCount; - } - - public Integer getOriPageReadUser() { - return this.oriPageReadUser; - } - - public void setOriPageReadUser(Integer oriPageReadUser) { - this.oriPageReadUser = oriPageReadUser; - } - - public Integer getOriPageReadCount() { - return this.oriPageReadCount; - } - - public void setOriPageReadCount(Integer oriPageReadCount) { - this.oriPageReadCount = oriPageReadCount; - } - - public Integer getShareUser() { - return this.shareUser; - } - - public void setShareUser(Integer shareUser) { - this.shareUser = shareUser; - } - - public Integer getShareCount() { - return this.shareCount; - } - - public void setShareCount(Integer shareCount) { - this.shareCount = shareCount; - } - - public Integer getAddToFavUser() { - return this.addToFavUser; - } - - public void setAddToFavUser(Integer addToFavUser) { - this.addToFavUser = addToFavUser; - } - - public Integer getAddToFavCount() { - return this.addToFavCount; - } - - public void setAddToFavCount(Integer addToFavCount) { - this.addToFavCount = addToFavCount; - } - - public Integer getIntPageFromSessionReadUser() { - return this.intPageFromSessionReadUser; - } - - public void setIntPageFromSessionReadUser(Integer intPageFromSessionReadUser) { - this.intPageFromSessionReadUser = intPageFromSessionReadUser; - } - - public Integer getIntPageFromSessionReadCount() { - return this.intPageFromSessionReadCount; - } - - public void setIntPageFromSessionReadCount( - Integer intPageFromSessionReadCount) { - this.intPageFromSessionReadCount = intPageFromSessionReadCount; - } - - public Integer getIntPageFromHistMsgReadUser() { - return this.intPageFromHistMsgReadUser; - } - - public void setIntPageFromHistMsgReadUser(Integer intPageFromHistMsgReadUser) { - this.intPageFromHistMsgReadUser = intPageFromHistMsgReadUser; - } - - public Integer getIntPageFromHistMsgReadCount() { - return this.intPageFromHistMsgReadCount; - } - - public void setIntPageFromHistMsgReadCount( - Integer intPageFromHistMsgReadCount) { - this.intPageFromHistMsgReadCount = intPageFromHistMsgReadCount; - } - - public Integer getIntPageFromFeedReadUser() { - return this.intPageFromFeedReadUser; - } - - public void setIntPageFromFeedReadUser(Integer intPageFromFeedReadUser) { - this.intPageFromFeedReadUser = intPageFromFeedReadUser; - } - - public Integer getIntPageFromFeedReadCount() { - return this.intPageFromFeedReadCount; - } - - public void setIntPageFromFeedReadCount(Integer intPageFromFeedReadCount) { - this.intPageFromFeedReadCount = intPageFromFeedReadCount; - } - - public Integer getIntPageFromFriendsReadUser() { - return this.intPageFromFriendsReadUser; - } - - public void setIntPageFromFriendsReadUser(Integer intPageFromFriendsReadUser) { - this.intPageFromFriendsReadUser = intPageFromFriendsReadUser; - } - - public Integer getIntPageFromFriendsReadCount() { - return this.intPageFromFriendsReadCount; - } - - public void setIntPageFromFriendsReadCount( - Integer intPageFromFriendsReadCount) { - this.intPageFromFriendsReadCount = intPageFromFriendsReadCount; - } - - public Integer getIntPageFromOtherReadUser() { - return this.intPageFromOtherReadUser; - } - - public void setIntPageFromOtherReadUser(Integer intPageFromOtherReadUser) { - this.intPageFromOtherReadUser = intPageFromOtherReadUser; - } - - public Integer getIntPageFromOtherReadCount() { - return this.intPageFromOtherReadCount; - } - - public void setIntPageFromOtherReadCount(Integer intPageFromOtherReadCount) { - this.intPageFromOtherReadCount = intPageFromOtherReadCount; - } - - public Integer getFeedShareFromSessionUser() { - return this.feedShareFromSessionUser; - } - - public void setFeedShareFromSessionUser(Integer feedShareFromSessionUser) { - this.feedShareFromSessionUser = feedShareFromSessionUser; - } - - public Integer getFeedShareFromSessionCnt() { - return this.feedShareFromSessionCnt; - } - - public void setFeedShareFromSessionCnt(Integer feedShareFromSessionCnt) { - this.feedShareFromSessionCnt = feedShareFromSessionCnt; - } - - public Integer getFeedShareFromFeedUser() { - return this.feedShareFromFeedUser; - } - - public void setFeedShareFromFeedUser(Integer feedShareFromFeedUser) { - this.feedShareFromFeedUser = feedShareFromFeedUser; - } - - public Integer getFeedShareFromFeedCnt() { - return this.feedShareFromFeedCnt; - } - - public void setFeedShareFromFeedCnt(Integer feedShareFromFeedCnt) { - this.feedShareFromFeedCnt = feedShareFromFeedCnt; - } - - public Integer getFeedShareFromOtherUser() { - return this.feedShareFromOtherUser; - } - - public void setFeedShareFromOtherUser(Integer feedShareFromOtherUser) { - this.feedShareFromOtherUser = feedShareFromOtherUser; - } - - public Integer getFeedShareFromOtherCnt() { - return this.feedShareFromOtherCnt; - } - - public void setFeedShareFromOtherCnt(Integer feedShareFromOtherCnt) { - this.feedShareFromOtherCnt = feedShareFromOtherCnt; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java index 5b613ebbfb..f12b52b1c6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java @@ -2,6 +2,7 @@ import com.google.gson.JsonParser; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; @@ -14,6 +15,7 @@ * * @author Binary Wang */ +@Data public abstract class WxDataCubeBaseResult implements Serializable { private static final long serialVersionUID = 8780389911053297600L; protected static final JsonParser JSON_PARSER = new JsonParser(); @@ -30,12 +32,4 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public String getRefDate() { - return this.refDate; - } - - public void setRefDate(String refDate) { - this.refDate = refDate; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java index 9ab3adad19..2ffd7f9961 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.util.List; @@ -13,6 +14,7 @@ * * @author Binary Wang */ +@Data public class WxDataCubeInterfaceResult extends WxDataCubeBaseResult { private static final long serialVersionUID = 597734329161281398L; @@ -58,44 +60,4 @@ public static List fromJson(String json) { }.getType()); } - public Integer getRefHour() { - return this.refHour; - } - - public void setRefHour(Integer refHour) { - this.refHour = refHour; - } - - public Integer getCallbackCount() { - return this.callbackCount; - } - - public void setCallbackCount(Integer callbackCount) { - this.callbackCount = callbackCount; - } - - public Integer getFailCount() { - return this.failCount; - } - - public void setFailCount(Integer failCount) { - this.failCount = failCount; - } - - public Integer getTotalTimeCost() { - return this.totalTimeCost; - } - - public void setTotalTimeCost(Integer totalTimeCost) { - this.totalTimeCost = totalTimeCost; - } - - public Integer getMaxTimeCost() { - return this.maxTimeCost; - } - - public void setMaxTimeCost(Integer maxTimeCost) { - this.maxTimeCost = maxTimeCost; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java index 7b8aa0f162..27afd7bf64 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.util.List; @@ -13,6 +14,7 @@ * * @author Binary Wang */ +@Data public class WxDataCubeMsgResult extends WxDataCubeBaseResult { private static final long serialVersionUID = 6932121822150573659L; @@ -72,60 +74,4 @@ public static List fromJson(String json) { }.getType()); } - public Integer getRefHour() { - return this.refHour; - } - - public void setRefHour(Integer refHour) { - this.refHour = refHour; - } - - public Integer getMsgType() { - return this.msgType; - } - - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } - - public Integer getMsgUser() { - return this.msgUser; - } - - public void setMsgUser(Integer msgUser) { - this.msgUser = msgUser; - } - - public Integer getMsgCount() { - return this.msgCount; - } - - public void setMsgCount(Integer msgCount) { - this.msgCount = msgCount; - } - - public Integer getCountInterval() { - return this.countInterval; - } - - public void setCountInterval(Integer countInterval) { - this.countInterval = countInterval; - } - - public Integer getIntPageReadCount() { - return this.intPageReadCount; - } - - public void setIntPageReadCount(Integer intPageReadCount) { - this.intPageReadCount = intPageReadCount; - } - - public Integer getOriPageReadUser() { - return this.oriPageReadUser; - } - - public void setOriPageReadUser(Integer oriPageReadUser) { - this.oriPageReadUser = oriPageReadUser; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserCumulate.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserCumulate.java index d3237a3b6e..ee0db76ad9 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserCumulate.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserCumulate.java @@ -2,6 +2,7 @@ import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -15,6 +16,7 @@ * 详情查看文档:用户分析数据接口 *
    */ +@Data public class WxDataCubeUserCumulate implements Serializable { private static final JsonParser JSON_PARSER = new JsonParser(); @@ -31,22 +33,6 @@ public static List fromJson(String json) { }.getType()); } - public Date getRefDate() { - return this.refDate; - } - - public void setRefDate(Date refDate) { - this.refDate = refDate; - } - - public Integer getCumulateUser() { - return this.cumulateUser; - } - - public void setCumulateUser(Integer cumulateUser) { - this.cumulateUser = cumulateUser; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserSummary.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserSummary.java index 3b76725cc2..48c53a7e0c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserSummary.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeUserSummary.java @@ -2,6 +2,7 @@ import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -15,6 +16,7 @@ * 详情查看文档:用户分析数据接口 * */ +@Data public class WxDataCubeUserSummary implements Serializable { private static final long serialVersionUID = -2336654489906694173L; @@ -35,38 +37,6 @@ public static List fromJson(String json) { }.getType()); } - public Date getRefDate() { - return this.refDate; - } - - public void setRefDate(Date refDate) { - this.refDate = refDate; - } - - public Integer getUserSource() { - return this.userSource; - } - - public void setUserSource(Integer userSource) { - this.userSource = userSource; - } - - public Integer getNewUser() { - return this.newUser; - } - - public void setNewUser(Integer newUser) { - this.newUser = newUser; - } - - public Integer getCancelUser() { - return this.cancelUser; - } - - public void setCancelUser(Integer cancelUser) { - this.cancelUser = cancelUser; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java index 4aef452270..5aaf5ea5eb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java @@ -5,9 +5,10 @@ import java.io.Serializable; /** - * Created by keungtung on 14/12/2016. + * @author keungtung + * @date 14/12/2016 */ -public abstract class AbstractDeviceBean implements Serializable{ +public abstract class AbstractDeviceBean implements Serializable { private static final long serialVersionUID = 4359729626772515385L; public String toJson() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java index 7d1fd8aa77..077f5189a1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java @@ -1,10 +1,13 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; /** - * Created by keungtung on 10/12/2016. + * @author keungtung + * @date 10/12/2016 */ +@Data public class BaseResp extends AbstractDeviceBean { private static final long serialVersionUID = 4252655933699659073L; @@ -15,50 +18,12 @@ public class BaseResp extends AbstractDeviceBean { @SerializedName("errmsg") private String errMsg; - public Integer getErrCode() { - return errCode; - } - - public void setErrCode(Integer errCode) { - this.errCode = errCode; - } - - public BaseInfo getBaseInfo() { - return baseInfo; - } - - public void setBaseInfo(BaseInfo baseInfo) { - this.baseInfo = baseInfo; - } - - public String getErrMsg() { - return errMsg; - } - - public void setErrMsg(String errMsg) { - this.errMsg = errMsg; - } - + @Data private class BaseInfo { @SerializedName("device_type") private String deviceType; + @SerializedName("device_id") private String deviceId; - - public String getDeviceType() { - return deviceType; - } - - public void setDeviceType(String deviceType) { - this.deviceType = deviceType; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java index 9c62d36f93..b618cdaf30 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java @@ -1,11 +1,14 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; /** - * Created by keungtung on 10/12/2016. + * + * @author keungtung + * @date 10/12/2016 */ - +@Data public class RespMsg extends AbstractDeviceBean { private static final long serialVersionUID = -4241272701707684136L; @@ -13,20 +16,4 @@ public class RespMsg extends AbstractDeviceBean { private Integer retCode; @SerializedName("error_info") private String errorInfo; - - public Integer getRetCode() { - return retCode; - } - - public void setRetCode(Integer retCode) { - this.retCode = retCode; - } - - public String getErrorInfo() { - return errorInfo; - } - - public void setErrorInfo(String errorInfo) { - this.errorInfo = errorInfo; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java index 1572da75ac..644a81326a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java @@ -1,11 +1,15 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; /** - * Created by keungtung on 14/12/2016. + * + * @author keungtung + * @date 14/12/2016 */ +@Data public class TransMsgResp extends AbstractDeviceBean { private static final long serialVersionUID = 5386954916622816491L; @@ -20,36 +24,4 @@ public class TransMsgResp extends AbstractDeviceBean { public static TransMsgResp fromJson(String json) { return WxGsonBuilder.create().fromJson(json, TransMsgResp.class); } - - public Integer getRet() { - return ret; - } - - public void setRet(Integer ret) { - this.ret = ret; - } - - public String getRetInfo() { - return retInfo; - } - - public void setRetInfo(String retInfo) { - this.retInfo = retInfo; - } - - public Integer getErrCode() { - return errCode; - } - - public void setErrCode(Integer errCode) { - this.errCode = errCode; - } - - public String getErrMsg() { - return errMsg; - } - - public void setErrMsg(String errMsg) { - this.errMsg = errMsg; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java index 4527d368d2..84c5b2d66d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java @@ -1,12 +1,15 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; import java.io.Serializable; /** - * Created by keungtung on 10/12/2016. + * @author keungtung + * @date 10/12/2016 */ +@Data public class WxDevice implements Serializable { private static final long serialVersionUID = -3284819760735456195L; @@ -30,92 +33,4 @@ public class WxDevice implements Serializable { private String serMacPos; @SerializedName("ble_simple_protocol") private String bleSimpleProtocol; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getMac() { - return mac; - } - - public void setMac(String mac) { - this.mac = mac; - } - - public String getConnectProtocol() { - return connectProtocol; - } - - public void setConnectProtocol(String connectProtocol) { - this.connectProtocol = connectProtocol; - } - - public String getAuthKey() { - return authKey; - } - - public void setAuthKey(String authKey) { - this.authKey = authKey; - } - - public String getCloseStrategy() { - return closeStrategy; - } - - public void setCloseStrategy(String closeStrategy) { - this.closeStrategy = closeStrategy; - } - - public String getConnStrategy() { - return connStrategy; - } - - public void setConnStrategy(String connStrategy) { - this.connStrategy = connStrategy; - } - - public String getCryptMethod() { - return cryptMethod; - } - - public void setCryptMethod(String cryptMethod) { - this.cryptMethod = cryptMethod; - } - - public String getAuthVer() { - return authVer; - } - - public void setAuthVer(String authVer) { - this.authVer = authVer; - } - - public String getManuMacPos() { - return manuMacPos; - } - - public void setManuMacPos(String manuMacPos) { - this.manuMacPos = manuMacPos; - } - - public String getSerMacPos() { - return serMacPos; - } - - public void setSerMacPos(String serMacPos) { - this.serMacPos = serMacPos; - } - - public String getBleSimpleProtocol() { - return bleSimpleProtocol; - } - - public void setBleSimpleProtocol(String bleSimpleProtocol) { - this.bleSimpleProtocol = bleSimpleProtocol; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java index 055e41c879..454628c886 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java @@ -1,14 +1,17 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; import java.util.Arrays; import java.util.LinkedList; import java.util.List; /** - * Created by keungtung on 10/12/2016. + * @author keungtung + * @date 10/12/2016 */ +@Data public class WxDeviceAuthorize extends AbstractDeviceBean { private static final long serialVersionUID = 8786321356569903887L; @@ -21,38 +24,6 @@ public class WxDeviceAuthorize extends AbstractDeviceBean { @SerializedName("device_list") private List deviceList = new LinkedList<>(); - public String getDeviceNum() { - return deviceNum; - } - - public void setDeviceNum(String deviceNum) { - this.deviceNum = deviceNum; - } - - public String getOpType() { - return opType; - } - - public void setOpType(String opType) { - this.opType = opType; - } - - public String getProductId() { - return productId; - } - - public void setProductId(String productId) { - this.productId = productId; - } - - public List getDeviceList() { - return deviceList; - } - - public void setDeviceList(List deviceList) { - this.deviceList = deviceList; - } - public void addDevice(WxDevice... devices) { this.deviceList.addAll(Arrays.asList(devices)); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java index 560f5498bb..6cf01f4dfe 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java @@ -1,12 +1,15 @@ package me.chanjar.weixin.mp.bean.device; +import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.util.List; /** - * Created by keungtung on 10/12/2016. + * @author keungtung + * @date 10/12/2016 */ +@Data public class WxDeviceAuthorizeResult extends AbstractDeviceBean { private static final long serialVersionUID = 9105294570912249811L; @@ -16,11 +19,4 @@ public static WxDeviceAuthorizeResult fromJson(String response) { return WxGsonBuilder.create().fromJson(response, WxDeviceAuthorizeResult.class); } - public List getResp() { - return resp; - } - - public void setResp(List resp) { - this.resp = resp; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java index 4945cfbbf2..7a3c639944 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java @@ -1,10 +1,13 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; /** - * Created by keungtung on 10/12/2016. + * @author keungtung + * @date 10/12/2016 */ +@Data public class WxDeviceBind extends AbstractDeviceBean { private static final long serialVersionUID = 467559769037590880L; @@ -14,27 +17,4 @@ public class WxDeviceBind extends AbstractDeviceBean { @SerializedName("openid") private String openId; - public String getTicket() { - return ticket; - } - - public void setTicket(String ticket) { - this.ticket = ticket; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getOpenId() { - return openId; - } - - public void setOpenId(String openId) { - this.openId = openId; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java index 52c5f45609..06786087dc 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java @@ -1,13 +1,16 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.util.List; /** - * Created by keungtung on 16/12/2016. + * @author keungtung + * @date 16/12/2016 */ +@Data public class WxDeviceBindDeviceResult extends AbstractDeviceBean { private static final long serialVersionUID = 725870295905935355L; @@ -22,27 +25,13 @@ public static WxDeviceBindDeviceResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxDeviceBindDeviceResult.class); } + @Data private class Device { @SerializedName("device_type") private String deviceType; @SerializedName("device_id") private String deviceId; - public String getDeviceType() { - return deviceType; - } - - public void setDeviceType(String deviceType) { - this.deviceType = deviceType; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java index c26e9c85d1..1b04942b49 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java @@ -1,11 +1,14 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** - * Created by keungtung on 10/12/2016. + * @author keungtung + * @date 10/12/2016 */ +@Data public class WxDeviceBindResult extends AbstractDeviceBean { private static final long serialVersionUID = 4687725146279339359L; @@ -16,11 +19,4 @@ public static WxDeviceBindResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxDeviceBindResult.class); } - public BaseResp getBaseResp() { - return baseResp; - } - - public void setBaseResp(BaseResp baseResp) { - this.baseResp = baseResp; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java index 182cb27241..be9239b09d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java @@ -1,11 +1,14 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; /** - * Created by keungtung on 10/12/2016. + * @author keungtung + * @date 10/12/2016 */ +@Data public class WxDeviceMsg extends AbstractDeviceBean { private static final long serialVersionUID = -5567110858455277963L; @@ -21,36 +24,4 @@ public class WxDeviceMsg extends AbstractDeviceBean { public String toString() { return ToStringUtils.toSimpleString(this); } - - public String getDeviceType() { - return deviceType; - } - - public void setDeviceType(String deviceType) { - this.deviceType = deviceType; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getOpenId() { - return openId; - } - - public void setOpenId(String openId) { - this.openId = openId; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java index a2ea56c080..8e3327e519 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java @@ -1,13 +1,16 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.util.List; /** - * Created by keungtung on 16/12/2016. + * @author keungtung + * @date 16/12/2016 */ +@Data public class WxDeviceOpenIdResult extends AbstractDeviceBean { private static final long serialVersionUID = 4980885167833836220L; @@ -24,35 +27,4 @@ public static WxDeviceOpenIdResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxDeviceOpenIdResult.class); } - public Integer getErrCode() { - return errCode; - } - - public void setErrCode(Integer errCode) { - this.errCode = errCode; - } - - public String getErrMsg() { - return errMsg; - } - - public void setErrMsg(String errMsg) { - this.errMsg = errMsg; - } - - public List getOpenIds() { - return openIds; - } - - public void setOpenIds(List openIds) { - this.openIds = openIds; - } - - public RespMsg getRespMsg() { - return respMsg; - } - - public void setRespMsg(RespMsg respMsg) { - this.respMsg = respMsg; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java index 8d6efac90b..f8b6309ea0 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java @@ -1,11 +1,14 @@ package me.chanjar.weixin.mp.bean.device; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** - * Created by keungtung on 10/12/2016. + * @author keungtung + * @date 10/12/2016 */ +@Data public class WxDeviceQrCodeResult extends AbstractDeviceBean { private static final long serialVersionUID = -4312858303060918266L; @@ -22,35 +25,4 @@ public static WxDeviceQrCodeResult fromJson(String json) { return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxDeviceQrCodeResult.class); } - public String getDeviceLicence() { - return deviceLicence; - } - - public void setDeviceLicence(String deviceLicence) { - this.deviceLicence = deviceLicence; - } - - public BaseResp getBaseResp() { - return baseResp; - } - - public void setBaseResp(BaseResp baseResp) { - this.baseResp = baseResp; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getQrTicket() { - return qrTicket; - } - - public void setQrTicket(String qrTicket) { - this.qrTicket = qrTicket; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java index 2c02a6207d..bf5b019432 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.kefu; +import lombok.Data; import me.chanjar.weixin.mp.builder.kefu.*; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -12,6 +13,7 @@ * * @author chanjarster */ +@Data public class WxMpKefuMessage implements Serializable { private static final long serialVersionUID = -9196732086954365246L; @@ -85,18 +87,6 @@ public static WxCardBuilder WXCARD() { return new WxCardBuilder(); } - public String getToUser() { - return this.toUser; - } - - public void setToUser(String toUser) { - this.toUser = toUser; - } - - public String getMsgType() { - return this.msgType; - } - /** *
        * 请使用
    @@ -110,141 +100,20 @@ public String getMsgType() {
        * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_WXCARD}
        * 
    * - * @param msgType */ public void setMsgType(String msgType) { this.msgType = msgType; } - public String getMpNewsMediaId() { - return this.mpNewsMediaId; - } - - public void setMpNewsMediaId(String mpNewsMediaId) { - this.mpNewsMediaId = mpNewsMediaId; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getThumbMediaId() { - return this.thumbMediaId; - } - - public void setThumbMediaId(String thumbMediaId) { - this.thumbMediaId = thumbMediaId; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getMusicUrl() { - return this.musicUrl; - } - - public void setMusicUrl(String musicUrl) { - this.musicUrl = musicUrl; - } - - public String getHqMusicUrl() { - return this.hqMusicUrl; - } - - public void setHqMusicUrl(String hqMusicUrl) { - this.hqMusicUrl = hqMusicUrl; - } - - public String getCardId() { - return this.cardId; - } - - public void setCardId(String cardId) { - this.cardId = cardId; - } - - public List getArticles() { - return this.articles; - } - - public void setArticles(List articles) { - this.articles = articles; - } - public String toJson() { return WxMpGsonBuilder.INSTANCE.create().toJson(this); } - public String getKfAccount() { - return this.kfAccount; - } - - public void setKfAccount(String kfAccount) { - this.kfAccount = kfAccount; - } - + @Data public static class WxArticle { private String title; private String description; private String url; private String picUrl; - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getPicUrl() { - return this.picUrl; - } - - public void setPicUrl(String picUrl) { - this.picUrl = picUrl; - } - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfAccountRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfAccountRequest.java index 85cdfe5507..fdbb705813 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfAccountRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfAccountRequest.java @@ -1,11 +1,13 @@ package me.chanjar.weixin.mp.bean.kefu.request; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import java.io.Serializable; +@Data public class WxMpKfAccountRequest implements Serializable { private static final long serialVersionUID = -5451863610674856927L; @@ -27,10 +29,6 @@ public class WxMpKfAccountRequest implements Serializable { @SerializedName("invite_wx") private String inviteWx; - public static Builder builder() { - return new Builder(); - } - @Override public String toString() { return ToStringBuilder.reflectionToString(this); @@ -40,64 +38,4 @@ public String toJson() { return WxMpGsonBuilder.INSTANCE.create().toJson(this); } - public String getKfAccount() { - return this.kfAccount; - } - - public void setKfAccount(String kfAccount) { - this.kfAccount = kfAccount; - } - - public String getNickName() { - return this.nickName; - } - - public void setNickName(String nickName) { - this.nickName = nickName; - } - - public String getInviteWx() { - return this.inviteWx; - } - - public void setInviteWx(String inviteWx) { - this.inviteWx = inviteWx; - } - - public static class Builder { - private String kfAccount; - private String nickName; - private String inviteWx; - - public Builder kfAccount(String kfAccount) { - this.kfAccount = kfAccount; - return this; - } - - public Builder nickName(String nickName) { - this.nickName = nickName; - return this; - } - - public Builder inviteWx(String inviteWx) { - this.inviteWx = inviteWx; - return this; - } - - public Builder from(WxMpKfAccountRequest origin) { - this.kfAccount(origin.kfAccount); - this.nickName(origin.nickName); - this.inviteWx(origin.inviteWx); - return this; - } - - public WxMpKfAccountRequest build() { - WxMpKfAccountRequest m = new WxMpKfAccountRequest(); - m.kfAccount = this.kfAccount; - m.nickName = this.nickName; - m.inviteWx = this.inviteWx; - return m; - } - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfSessionRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfSessionRequest.java index ac59e3238e..2f077d3f59 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfSessionRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfSessionRequest.java @@ -1,11 +1,13 @@ package me.chanjar.weixin.mp.bean.kefu.request; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; +@Data public class WxMpKfSessionRequest implements Serializable { private static final long serialVersionUID = -5451863610674856927L; @@ -35,12 +37,4 @@ public String toJson() { return WxMpGsonBuilder.INSTANCE.create().toJson(this); } - public String getKfAccount() { - return this.kfAccount; - } - - public void setKfAccount(String kfAccount) { - this.kfAccount = kfAccount; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfInfo.java index c879e9f63a..60b5370d8e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfInfo.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; @@ -11,6 +12,7 @@ * * @author Binary Wang */ +@Data public class WxMpKfInfo implements Serializable { private static final long serialVersionUID = -5877300750666022290L; @@ -75,88 +77,9 @@ public class WxMpKfInfo implements Serializable { @SerializedName("accepted_case") private Integer acceptedCase; - public Integer getStatus() { - return this.status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public Integer getAcceptedCase() { - return this.acceptedCase; - } - - public void setAcceptedCase(Integer acceptedCase) { - this.acceptedCase = acceptedCase; - } - - public String getAccount() { - return this.account; - } - - public void setAccount(String account) { - this.account = account; - } - - public String getHeadImgUrl() { - return this.headImgUrl; - } - - public void setHeadImgUrl(String headImgUrl) { - this.headImgUrl = headImgUrl; - } - - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } - - public String getNick() { - return this.nick; - } - - public void setNick(String nick) { - this.nick = nick; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); } - public String getWxAccount() { - return this.wxAccount; - } - - public void setWxAccount(String wxAccount) { - this.wxAccount = wxAccount; - } - - public String getInviteWx() { - return this.inviteWx; - } - - public void setInviteWx(String inviteWx) { - this.inviteWx = inviteWx; - } - - public Long getInviteExpireTime() { - return this.inviteExpireTime; - } - - public void setInviteExpireTime(Long inviteExpireTime) { - this.inviteExpireTime = inviteExpireTime; - } - - public String getInviteStatus() { - return this.inviteStatus; - } - - public void setInviteStatus(String inviteStatus) { - this.inviteStatus = inviteStatus; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfList.java index 5cce093dfc..3d9a8872ab 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfList.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.kefu.result; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -10,6 +11,7 @@ /** * @author Binary Wang */ +@Data public class WxMpKfList implements Serializable { private static final long serialVersionUID = -8194193505173564894L; @@ -25,11 +27,4 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public List getKfList() { - return this.kfList; - } - - public void setKfList(List kfList) { - this.kfList = kfList; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java index 253652a883..ee2f751473 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgList.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.kefu.result; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -8,8 +9,11 @@ import java.util.List; /** - * Created by Binary Wang on 2016/7/15. + * + * @author Binary Wang + * @date 2016/7/15 */ +@Data public class WxMpKfMsgList implements Serializable { private static final long serialVersionUID = 4524296707435188202L; @@ -26,30 +30,6 @@ public static WxMpKfMsgList fromJson(String responseContent) { return WxMpGsonBuilder.INSTANCE.create().fromJson(responseContent, WxMpKfMsgList.class); } - public List getRecords() { - return this.records; - } - - public void setRecords(List records) { - this.records = records; - } - - public Integer getNumber() { - return this.number; - } - - public void setNumber(Integer number) { - this.number = number; - } - - public Long getMsgId() { - return this.msgId; - } - - public void setMsgId(Long msgId) { - this.msgId = msgId; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java index 1b32164879..baba81da04 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java @@ -1,13 +1,17 @@ package me.chanjar.weixin.mp.bean.kefu.result; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; /** - * Created by Binary Wang on 2016/7/18. + * + * @author Binary Wang + * @date 2016/7/18 */ +@Data public class WxMpKfMsgRecord implements Serializable { private static final long serialVersionUID = -280692188908528688L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfOnlineList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfOnlineList.java index 6778520c2b..cb5f90719d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfOnlineList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfOnlineList.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.kefu.result; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -10,6 +11,7 @@ /** * @author Binary Wang */ +@Data public class WxMpKfOnlineList implements Serializable { private static final long serialVersionUID = -6154705288500854617L; @@ -25,11 +27,4 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public List getKfOnlineList() { - return this.kfOnlineList; - } - - public void setKfOnlineList(List kfOnlineList) { - this.kfOnlineList = kfOnlineList; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSession.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSession.java index b36edb9f2d..1611025412 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSession.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSession.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.kefu.result; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; @@ -8,6 +9,7 @@ /** * @author Binary Wang */ +@Data public class WxMpKfSession implements Serializable { private static final long serialVersionUID = 7804332813164994062L; @@ -42,35 +44,4 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public String getKfAccount() { - return this.kfAccount; - } - - public void setKfAccount(String kfAccount) { - this.kfAccount = kfAccount; - } - - public long getCreateTime() { - return this.createTime; - } - - public void setCreateTime(long createTime) { - this.createTime = createTime; - } - - public String getOpenid() { - return this.openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public long getLatestTime() { - return this.latestTime; - } - - public void setLatestTime(long latestTime) { - this.latestTime = latestTime; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionGetResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionGetResult.java index d6ed763e9f..5f4b318c50 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionGetResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionGetResult.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.kefu.result; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -9,6 +10,7 @@ /** * @author Binary Wang */ +@Data public class WxMpKfSessionGetResult implements Serializable { private static final long serialVersionUID = 8474846575200033152L; @@ -33,20 +35,4 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public String getKfAccount() { - return this.kfAccount; - } - - public void setKfAccount(String kfAccount) { - this.kfAccount = kfAccount; - } - - public long getCreateTime() { - return this.createTime; - } - - public void setCreateTime(long createTime) { - this.createTime = createTime; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionList.java index f1eb4dd7cb..e12def669c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionList.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.kefu.result; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -10,6 +11,7 @@ /** * @author Binary Wang */ +@Data public class WxMpKfSessionList implements Serializable { private static final long serialVersionUID = -7680371346226640206L; @@ -29,11 +31,4 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public List getKfSessionList() { - return this.kfSessionList; - } - - public void setKfSessionList(List kfSessionList) { - this.kfSessionList = kfSessionList; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java index 7dd8def8cf..872ba7db3c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.kefu.result; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -10,6 +11,7 @@ /** * @author Binary Wang */ +@Data public class WxMpKfSessionWaitCaseList implements Serializable { private static final long serialVersionUID = 2432132626631361922L; @@ -35,12 +37,4 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public List getKfSessionWaitCaseList() { - return this.kfSessionWaitCaseList; - } - - public void setKfSessionWaitCaseList(List kfSessionWaitCaseList) { - this.kfSessionWaitCaseList = kfSessionWaitCaseList; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMediaImgUploadResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMediaImgUploadResult.java index 1110a1f16b..b60b2791c8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMediaImgUploadResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMediaImgUploadResult.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.material; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -7,6 +8,7 @@ /** * @author miller */ +@Data public class WxMediaImgUploadResult implements Serializable { private static final long serialVersionUID = 1996392453428768829L; private String url; @@ -15,11 +17,4 @@ public static WxMediaImgUploadResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMediaImgUploadResult.class); } - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterial.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterial.java index e176620f43..a554834d01 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterial.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterial.java @@ -1,10 +1,13 @@ package me.chanjar.weixin.mp.bean.material; +import lombok.Data; + import java.io.File; import java.io.Serializable; import java.util.HashMap; import java.util.Map; +@Data public class WxMpMaterial implements Serializable { private static final long serialVersionUID = -1651816949780969485L; @@ -29,41 +32,4 @@ public Map getForm() { form.put("introduction", this.videoIntroduction); return form; } - - public String getVideoTitle() { - return this.videoTitle; - } - - public void setVideoTitle(String videoTitle) { - this.videoTitle = videoTitle; - } - - public String getVideoIntroduction() { - return this.videoIntroduction; - } - - public void setVideoIntroduction(String videoIntroduction) { - this.videoIntroduction = videoIntroduction; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public File getFile() { - return this.file; - } - - public void setFile(File file) { - this.file = file; - } - - @Override - public String toString() { - return "WxMpMaterial [" + "name=" + this.name + ", file=" + this.file + ", videoTitle=" + this.videoTitle + ", videoIntroduction=" + this.videoIntroduction + "]"; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialArticleUpdate.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialArticleUpdate.java index f2f7aa1201..13e7701bb7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialArticleUpdate.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialArticleUpdate.java @@ -1,9 +1,11 @@ package me.chanjar.weixin.mp.bean.material; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; +@Data public class WxMpMaterialArticleUpdate implements Serializable { private static final long serialVersionUID = -7611963949517780270L; @@ -11,36 +13,7 @@ public class WxMpMaterialArticleUpdate implements Serializable { private int index; private WxMpMaterialNews.WxMpMaterialNewsArticle articles; - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public int getIndex() { - return this.index; - } - - public void setIndex(int index) { - this.index = index; - } - - public WxMpMaterialNews.WxMpMaterialNewsArticle getArticles() { - return this.articles; - } - - public void setArticles(WxMpMaterialNews.WxMpMaterialNewsArticle articles) { - this.articles = articles; - } - public String toJson() { return WxMpGsonBuilder.create().toJson(this); } - - @Override - public String toString() { - return "WxMpMaterialArticleUpdate [" + "mediaId=" + this.mediaId + ", index=" + this.index + ", articles=" + this.articles + "]"; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialCountResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialCountResult.java index 4a74b6b64b..0bb3384154 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialCountResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialCountResult.java @@ -1,9 +1,11 @@ package me.chanjar.weixin.mp.bean.material; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; +@Data public class WxMpMaterialCountResult implements Serializable { private static final long serialVersionUID = -5568772662085874138L; @@ -12,38 +14,6 @@ public class WxMpMaterialCountResult implements Serializable { private int imageCount; private int newsCount; - public int getVoiceCount() { - return this.voiceCount; - } - - public void setVoiceCount(int voiceCount) { - this.voiceCount = voiceCount; - } - - public int getVideoCount() { - return this.videoCount; - } - - public void setVideoCount(int videoCount) { - this.videoCount = videoCount; - } - - public int getImageCount() { - return this.imageCount; - } - - public void setImageCount(int imageCount) { - this.imageCount = imageCount; - } - - public int getNewsCount() { - return this.newsCount; - } - - public void setNewsCount(int newsCount) { - this.newsCount = newsCount; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialFileBatchGetResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialFileBatchGetResult.java index b08a0ce3c4..4f445a288b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialFileBatchGetResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialFileBatchGetResult.java @@ -1,11 +1,13 @@ package me.chanjar.weixin.mp.bean.material; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; import java.util.Date; import java.util.List; +@Data public class WxMpMaterialFileBatchGetResult implements Serializable { private static final long serialVersionUID = -560388368297267884L; @@ -13,73 +15,18 @@ public class WxMpMaterialFileBatchGetResult implements Serializable { private int itemCount; private List items; - public int getTotalCount() { - return this.totalCount; - } - - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - public int getItemCount() { - return this.itemCount; - } - - public void setItemCount(int itemCount) { - this.itemCount = itemCount; - } - - public List getItems() { - return this.items; - } - - public void setItems(List items) { - this.items = items; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); } + @Data public static class WxMaterialFileBatchGetNewsItem { private String mediaId; private Date updateTime; private String name; private String url; - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public Date getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNews.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNews.java index 51f2d0c6bd..2a2439da93 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNews.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNews.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.material; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -8,6 +9,7 @@ import java.util.ArrayList; import java.util.List; +@Data public class WxMpMaterialNews implements Serializable { private static final long serialVersionUID = -3283203652013494976L; @@ -32,22 +34,6 @@ public boolean isEmpty() { return this.articles == null || this.articles.isEmpty(); } - public Date getCreatedTime() { - return this.createdTime; - } - - public void setCreatedTime(Date createdTime) { - this.createdTime = createdTime; - } - - public Date getUpdatedTime() { - return this.updatedTime; - } - - public void setUpdatedTime(Date updatedTime) { - this.updatedTime = updatedTime; - } - @Override public String toString() { return this.toJson(); @@ -70,6 +56,7 @@ public String toString() { * * @author chanjarster */ + @Data public static class WxMpMaterialNewsArticle { /** * (必填) 图文消息缩略图的media_id,可以在基础支持-上传多媒体文件接口中获得 @@ -121,94 +108,6 @@ public static class WxMpMaterialNewsArticle { */ private Boolean onlyFansCanComment; - public String getThumbMediaId() { - return this.thumbMediaId; - } - - public void setThumbMediaId(String thumbMediaId) { - this.thumbMediaId = thumbMediaId; - } - - public String getAuthor() { - return this.author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getContentSourceUrl() { - return this.contentSourceUrl; - } - - public void setContentSourceUrl(String contentSourceUrl) { - this.contentSourceUrl = contentSourceUrl; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getDigest() { - return this.digest; - } - - public void setDigest(String digest) { - this.digest = digest; - } - - public boolean isShowCoverPic() { - return this.showCoverPic; - } - - public void setShowCoverPic(boolean showCoverPic) { - this.showCoverPic = showCoverPic; - } - - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getThumbUrl() { - return this.thumbUrl; - } - - public void setThumbUrl(String thumbUrl) { - this.thumbUrl = thumbUrl; - } - - public Boolean getNeedOpenComment() { - return this.needOpenComment; - } - - public void setNeedOpenComment(Boolean needOpenComment) { - this.needOpenComment = needOpenComment; - } - - public Boolean getOnlyFansCanComment() { - return this.onlyFansCanComment; - } - - public void setOnlyFansCanComment(Boolean onlyFansCanComment) { - this.onlyFansCanComment = onlyFansCanComment; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNewsBatchGetResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNewsBatchGetResult.java index 03f0a6d854..77fe8b562d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNewsBatchGetResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNewsBatchGetResult.java @@ -1,11 +1,13 @@ package me.chanjar.weixin.mp.bean.material; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; import java.util.Date; import java.util.List; +@Data public class WxMpMaterialNewsBatchGetResult implements Serializable { private static final long serialVersionUID = -1617952797921001666L; @@ -13,64 +15,17 @@ public class WxMpMaterialNewsBatchGetResult implements Serializable { private int itemCount; private List items; - public int getTotalCount() { - return this.totalCount; - } - - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - public int getItemCount() { - return this.itemCount; - } - - public void setItemCount(int itemCount) { - this.itemCount = itemCount; - } - - public List getItems() { - return this.items; - } - - public void setItems(List items) { - this.items = items; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); } + @Data public static class WxMaterialNewsBatchGetNewsItem { private String mediaId; private Date updateTime; private WxMpMaterialNews content; - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public Date getUpdateTime() { - return this.updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } - - public WxMpMaterialNews getContent() { - return this.content; - } - - public void setContent(WxMpMaterialNews content) { - this.content = content; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialUploadResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialUploadResult.java index 0e5546b9aa..6a4630e567 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialUploadResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialUploadResult.java @@ -1,10 +1,12 @@ package me.chanjar.weixin.mp.bean.material; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; +@Data public class WxMpMaterialUploadResult implements Serializable { private static final long serialVersionUID = -128818731449449537L; private String mediaId; @@ -16,38 +18,6 @@ public static WxMpMaterialUploadResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMpMaterialUploadResult.class); } - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } - - public Integer getErrCode() { - return this.errCode; - } - - public void setErrCode(Integer errCode) { - this.errCode = errCode; - } - - public String getErrMsg() { - return this.errMsg; - } - - public void setErrMsg(String errMsg) { - this.errMsg = errMsg; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialVideoInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialVideoInfoResult.java index e0558cc888..8a783e6809 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialVideoInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialVideoInfoResult.java @@ -1,9 +1,11 @@ package me.chanjar.weixin.mp.bean.material; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; +@Data public class WxMpMaterialVideoInfoResult implements Serializable { private static final long serialVersionUID = 1269131745333792202L; @@ -15,33 +17,4 @@ public static WxMpMaterialVideoInfoResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMpMaterialVideoInfoResult.class); } - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDownUrl() { - return this.downUrl; - } - - public void setDownUrl(String downUrl) { - this.downUrl = downUrl; - } - - @Override - public String toString() { - return "WxMpMaterialVideoInfoResult [title=" + this.title + ", description=" + this.description + ", downUrl=" + this.downUrl + "]"; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java index b9c771c487..c039d72a15 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/MemberCardUserInfo.java @@ -1,10 +1,14 @@ package me.chanjar.weixin.mp.bean.membercard; +import lombok.Data; + import java.io.Serializable; /** - * Created by YuJian on 2017/7/11. + * @author YuJian + * @date 2017/7/11 */ +@Data public class MemberCardUserInfo implements Serializable { private static final long serialVersionUID = -4259196162619282129L; @@ -12,19 +16,4 @@ public class MemberCardUserInfo implements Serializable { private NameValues[] customFieldList; - public NameValues[] getCommonFieldList() { - return commonFieldList; - } - - public void setCommonFieldList(NameValues[] commonFieldList) { - this.commonFieldList = commonFieldList; - } - - public NameValues[] getCustomFieldList() { - return customFieldList; - } - - public void setCustomFieldList(NameValues[] customFieldList) { - this.customFieldList = customFieldList; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java index a5c62e5e6a..f285855535 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NameValues.java @@ -1,10 +1,15 @@ package me.chanjar.weixin.mp.bean.membercard; +import lombok.Data; + import java.io.Serializable; /** - * Created by YuJian on 2017/7/11. + * + * @author YuJian + * @date 2017/7/11 */ +@Data public class NameValues implements Serializable{ private static final long serialVersionUID = -8529369702944594330L; @@ -14,27 +19,4 @@ public class NameValues implements Serializable{ private String[] valueList; - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String[] getValueList() { - return valueList; - } - - public void setValueList(String[] valueList) { - this.valueList = valueList; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java index e44ec4b5ac..c4d25c97e8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/NotifyOptional.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.membercard; import com.google.gson.annotations.SerializedName; +import lombok.Data; import java.io.Serializable; @@ -15,6 +16,7 @@ * @author YuJian(mgcnrx11@gmail.com) * @version 2017/7/15 */ +@Data public class NotifyOptional implements Serializable { private static final long serialVersionUID = 4488842021504939176L; @@ -41,44 +43,4 @@ public class NotifyOptional implements Serializable { @SerializedName("is_notify_custom_field3") private Boolean isNotifyCustomField3; - - public Boolean getNotifyBonus() { - return isNotifyBonus; - } - - public void setNotifyBonus(Boolean notifyBonus) { - isNotifyBonus = notifyBonus; - } - - public Boolean getNotifyBalance() { - return isNotifyBalance; - } - - public void setNotifyBalance(Boolean notifyBalance) { - isNotifyBalance = notifyBalance; - } - - public Boolean getNotifyCustomField1() { - return isNotifyCustomField1; - } - - public void setNotifyCustomField1(Boolean notifyCustomField1) { - isNotifyCustomField1 = notifyCustomField1; - } - - public Boolean getNotifyCustomField2() { - return isNotifyCustomField2; - } - - public void setNotifyCustomField2(Boolean notifyCustomField2) { - isNotifyCustomField2 = notifyCustomField2; - } - - public Boolean getNotifyCustomField3() { - return isNotifyCustomField3; - } - - public void setNotifyCustomField3(Boolean notifyCustomField3) { - isNotifyCustomField3 = notifyCustomField3; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java index 0c782e3c51..d9232844dc 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardActivatedMessage.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.membercard; import com.google.gson.annotations.SerializedName; +import lombok.Data; import java.io.Serializable; @@ -10,6 +11,7 @@ * @author YuJian(mgcnrx11@hotmail.com) * @version 2017/7/8 */ +@Data public class WxMpMemberCardActivatedMessage implements Serializable { private static final long serialVersionUID = -5972713484594266480L; @@ -73,99 +75,4 @@ public class WxMpMemberCardActivatedMessage implements Serializable { @SerializedName("init_custom_field_value3") private String initCustomFieldValue3; - public String getMembershipNumber() { - return membershipNumber; - } - - public void setMembershipNumber(String membershipNumber) { - this.membershipNumber = membershipNumber; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getCardId() { - return cardId; - } - - public void setCardId(String cardId) { - this.cardId = cardId; - } - - public String getBackgroundPicUrl() { - return backgroundPicUrl; - } - - public void setBackgroundPicUrl(String backgroundPicUrl) { - this.backgroundPicUrl = backgroundPicUrl; - } - - public Integer getActivateBeginTime() { - return activateBeginTime; - } - - public void setActivateBeginTime(Integer activateBeginTime) { - this.activateBeginTime = activateBeginTime; - } - - public Integer getActivateEndTime() { - return activateEndTime; - } - - public void setActivateEndTime(Integer activateEndTime) { - this.activateEndTime = activateEndTime; - } - - public Integer getInitBonus() { - return initBonus; - } - - public void setInitBonus(Integer initBonus) { - this.initBonus = initBonus; - } - - public String getInitBonusRecord() { - return initBonusRecord; - } - - public void setInitBonusRecord(String initBonusRecord) { - this.initBonusRecord = initBonusRecord; - } - - public Integer getInitBalance() { - return initBalance; - } - - public void setInitBalance(Integer initBalance) { - this.initBalance = initBalance; - } - - public String getInitCustomFieldValue1() { - return initCustomFieldValue1; - } - - public void setInitCustomFieldValue1(String initCustomFieldValue1) { - this.initCustomFieldValue1 = initCustomFieldValue1; - } - - public String getInitCustomFieldValue2() { - return initCustomFieldValue2; - } - - public void setInitCustomFieldValue2(String initCustomFieldValue2) { - this.initCustomFieldValue2 = initCustomFieldValue2; - } - - public String getInitCustomFieldValue3() { - return initCustomFieldValue3; - } - - public void setInitCustomFieldValue3(String initCustomFieldValue3) { - this.initCustomFieldValue3 = initCustomFieldValue3; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java index 313ba66282..f666e65504 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateMessage.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.membercard; import com.google.gson.annotations.SerializedName; +import lombok.Data; import java.io.Serializable; @@ -16,6 +17,7 @@ * @author YuJian(mgcnrx11@gmail.com) * @version 2017/7/15 */ +@Data public class WxMpMemberCardUpdateMessage implements Serializable { private static final long serialVersionUID = 4953923160718911058L; @@ -75,107 +77,4 @@ public class WxMpMemberCardUpdateMessage implements Serializable { @SerializedName("notify_optional") private NotifyOptional notifyOptional; - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getCardId() { - return cardId; - } - - public void setCardId(String cardId) { - this.cardId = cardId; - } - - public String getBackgroundPicUrl() { - return backgroundPicUrl; - } - - public void setBackgroundPicUrl(String backgroundPicUrl) { - this.backgroundPicUrl = backgroundPicUrl; - } - - public Integer getBonus() { - return bonus; - } - - public void setBonus(Integer bonus) { - this.bonus = bonus; - } - - public Integer getAddBounus() { - return addBounus; - } - - public void setAddBounus(Integer addBounus) { - this.addBounus = addBounus; - } - - public String getRecordBonus() { - return recordBonus; - } - - public void setRecordBonus(String recordBonus) { - this.recordBonus = recordBonus; - } - - public Integer getBalance() { - return balance; - } - - public void setBalance(Integer balance) { - this.balance = balance; - } - - public Integer getAddBalance() { - return addBalance; - } - - public void setAddBalance(Integer addBalance) { - this.addBalance = addBalance; - } - - public String getRecordBalance() { - return recordBalance; - } - - public void setRecordBalance(String recordBalance) { - this.recordBalance = recordBalance; - } - - public String getCustomFieldValue1() { - return customFieldValue1; - } - - public void setCustomFieldValue1(String customFieldValue1) { - this.customFieldValue1 = customFieldValue1; - } - - public String getCustomFieldValue2() { - return customFieldValue2; - } - - public void setCustomFieldValue2(String customFieldValue2) { - this.customFieldValue2 = customFieldValue2; - } - - public String getCustomFieldValue3() { - return customFieldValue3; - } - - public void setCustomFieldValue3(String customFieldValue3) { - this.customFieldValue3 = customFieldValue3; - } - - public NotifyOptional getNotifyOptional() { - return notifyOptional; - } - - public void setNotifyOptional(NotifyOptional notifyOptional) { - this.notifyOptional = notifyOptional; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java index 2cbe2efb2f..7ceac8e81c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUpdateResult.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.membercard; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -14,6 +15,7 @@ * @author YuJian(mgcnrx11@gmail.com) * @version 2017/7/15 */ +@Data public class WxMpMemberCardUpdateResult implements Serializable { private static final long serialVersionUID = 9084886191442098311L; @@ -28,46 +30,6 @@ public class WxMpMemberCardUpdateResult implements Serializable { private Integer resultBalance; - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getErrorMsg() { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) { - this.errorMsg = errorMsg; - } - - public String getOpenId() { - return openId; - } - - public void setOpenId(String openId) { - this.openId = openId; - } - - public Integer getResultBonus() { - return resultBonus; - } - - public void setResultBonus(Integer resultBonus) { - this.resultBonus = resultBonus; - } - - public Integer getResultBalance() { - return resultBalance; - } - - public void setResultBalance(Integer resultBalance) { - this.resultBalance = resultBalance; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java index 82a24cd297..a0ad47f356 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/membercard/WxMpMemberCardUserInfoResult.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.membercard; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -15,6 +16,7 @@ * @author YuJian * @version 2017/7/9 */ +@Data public class WxMpMemberCardUserInfoResult implements Serializable { private static final long serialVersionUID = 9084777967442098311L; @@ -39,90 +41,6 @@ public class WxMpMemberCardUserInfoResult implements Serializable { private Boolean hasActive; - public static long getSerialVersionUID() { - return serialVersionUID; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getErrorMsg() { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) { - this.errorMsg = errorMsg; - } - - public String getOpenId() { - return openId; - } - - public void setOpenId(String openId) { - this.openId = openId; - } - - public String getNickname() { - return nickname; - } - - public void setNickname(String nickname) { - this.nickname = nickname; - } - - public String getMembershipNumber() { - return membershipNumber; - } - - public void setMembershipNumber(String membershipNumber) { - this.membershipNumber = membershipNumber; - } - - public Integer getBonus() { - return bonus; - } - - public void setBonus(Integer bonus) { - this.bonus = bonus; - } - - public String getSex() { - return sex; - } - - public void setSex(String sex) { - this.sex = sex; - } - - public MemberCardUserInfo getUserInfo() { - return userInfo; - } - - public void setUserInfo(MemberCardUserInfo userInfo) { - this.userInfo = userInfo; - } - - public String getUserCardStatus() { - return userCardStatus; - } - - public void setUserCardStatus(String userCardStatus) { - this.userCardStatus = userCardStatus; - } - - public Boolean getHasActive() { - return hasActive; - } - - public void setHasActive(Boolean hasActive) { - this.hasActive = hasActive; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java index 1202f9ab9b..b8258b1d1c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpGetSelfMenuInfoResult.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.menu; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.json.WxGsonBuilder; @@ -13,6 +14,7 @@ * * @author Binary Wang */ +@Data public class WxMpGetSelfMenuInfoResult implements Serializable { private static final long serialVersionUID = -5612495636936835166L; @@ -31,19 +33,4 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public WxMpSelfMenuInfo getSelfMenuInfo() { - return selfMenuInfo; - } - - public void setSelfMenuInfo(WxMpSelfMenuInfo selfMenuInfo) { - this.selfMenuInfo = selfMenuInfo; - } - - public Integer getIsMenuOpen() { - return isMenuOpen; - } - - public void setIsMenuOpen(Integer isMenuOpen) { - this.isMenuOpen = isMenuOpen; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java index 8ab3cc8937..1847be3f08 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpMenu.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.menu; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.bean.menu.WxMenuButton; import me.chanjar.weixin.common.bean.menu.WxMenuRule; import me.chanjar.weixin.common.util.ToStringUtils; @@ -17,6 +18,7 @@ * * @author Binary Wang */ +@Data public class WxMpMenu implements Serializable { private static final long serialVersionUID = -5794350513426702252L; @@ -30,22 +32,6 @@ public static WxMpMenu fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpMenu.class); } - public WxMpConditionalMenu getMenu() { - return menu; - } - - public void setMenu(WxMpConditionalMenu menu) { - this.menu = menu; - } - - public List getConditionalMenu() { - return conditionalMenu; - } - - public void setConditionalMenu(List conditionalMenu) { - this.conditionalMenu = conditionalMenu; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -55,6 +41,7 @@ public String toJson() { return WxGsonBuilder.create().toJson(this); } + @Data public static class WxMpConditionalMenu implements Serializable { private static final long serialVersionUID = -2279946921755382289L; @@ -70,29 +57,6 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public List getButtons() { - return buttons; - } - - public void setButtons(List buttons) { - this.buttons = buttons; - } - - public WxMenuRule getRule() { - return rule; - } - - public void setRule(WxMenuRule rule) { - this.rule = rule; - } - - public String getMenuId() { - return menuId; - } - - public void setMenuId(String menuId) { - this.menuId = menuId; - } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java index 2a394ab276..2532a092de 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/menu/WxMpSelfMenuInfo.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.menu; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; @@ -14,6 +15,7 @@ * * @author Binary Wang */ +@Data public class WxMpSelfMenuInfo implements Serializable { private static final long serialVersionUID = -81203094124202901L; @@ -28,14 +30,7 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public List getButtons() { - return this.buttons; - } - - public void setButtons(List buttons) { - this.buttons = buttons; - } - + @Data public static class WxMpSelfMenuButton implements Serializable { private static final long serialVersionUID = -4426602953309048341L; @@ -95,62 +90,7 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public SubButtons getSubButtons() { - return subButtons; - } - - public void setSubButtons(SubButtons subButtons) { - this.subButtons = subButtons; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public NewsInfo getNewsInfo() { - return newsInfo; - } - - public void setNewsInfo(NewsInfo newsInfo) { - this.newsInfo = newsInfo; - } - + @Data public static class SubButtons implements Serializable { private static final long serialVersionUID = 1763350658575521079L; @@ -161,16 +101,9 @@ public static class SubButtons implements Serializable { public String toString() { return ToStringUtils.toSimpleString(this); } - - public List getSubButtons() { - return subButtons; - } - - public void setSubButtons(List subButtons) { - this.subButtons = subButtons; - } } + @Data public static class NewsInfo implements Serializable { private static final long serialVersionUID = 3449813746347818457L; @@ -182,14 +115,7 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public List getNews() { - return news; - } - - public void setNews(List news) { - this.news = news; - } - + @Data public static class NewsInButton implements Serializable { private static final long serialVersionUID = 8701455967664912972L; @@ -235,61 +161,6 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDigest() { - return digest; - } - - public void setDigest(String digest) { - this.digest = digest; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public Integer getShowCover() { - return showCover; - } - - public void setShowCover(Integer showCover) { - this.showCover = showCover; - } - - public String getCoverUrl() { - return coverUrl; - } - - public void setCoverUrl(String coverUrl) { - this.coverUrl = coverUrl; - } - - public String getContentUrl() { - return contentUrl; - } - - public void setContentUrl(String contentUrl) { - this.contentUrl = contentUrl; - } - - public String getSourceUrl() { - return sourceUrl; - } - - public void setSourceUrl(String sourceUrl) { - this.sourceUrl = sourceUrl; - } } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java index 1ef3ee6b7c..6cef393eb5 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/HardWare.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @@ -15,6 +16,7 @@ * @author Binary Wang */ @XStreamAlias("HardWare") +@Data public class HardWare implements Serializable{ private static final long serialVersionUID = -1295785297354896461L; @@ -35,20 +37,4 @@ public class HardWare implements Serializable{ public String toString() { return ToStringUtils.toSimpleString(this); } - - public String getMessageView() { - return messageView; - } - - public void setMessageView(String messageView) { - this.messageView = messageView; - } - - public String getMessageAction() { - return messageAction; - } - - public void setMessageAction(String messageAction) { - this.messageAction = messageAction; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java index c5c32cb522..630090c2f2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/ScanCodeInfo.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @@ -15,6 +16,7 @@ * @author Binary Wang */ @XStreamAlias("ScanCodeInfo") +@Data public class ScanCodeInfo implements Serializable { private static final long serialVersionUID = 4745181270645050122L; @@ -37,10 +39,6 @@ public String getScanType() { return this.scanType; } - public void setScanType(String scanType) { - this.scanType = scanType; - } - /** * 扫描结果,即二维码对应的字符串信息 */ @@ -48,8 +46,5 @@ public String getScanResult() { return this.scanResult; } - public void setScanResult(String scanResult) { - this.scanResult = scanResult; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java index 8ecb3c8bff..c7c8fda6b8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendLocationInfo.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @@ -15,6 +16,7 @@ * @author Binary Wang */ @XStreamAlias("SendLocationInfo") +@Data public class SendLocationInfo implements Serializable { private static final long serialVersionUID = 6633214140499161130L; @@ -36,50 +38,10 @@ public class SendLocationInfo implements Serializable { @XStreamAlias("Poiname") @XStreamConverter(value = XStreamCDataConverter.class) - private String poiname; + private String poiName; @Override public String toString() { return ToStringUtils.toSimpleString(this); } - - public String getLocationX() { - return this.locationX; - } - - public void setLocationX(String locationX) { - this.locationX = locationX; - } - - public String getLocationY() { - return this.locationY; - } - - public void setLocationY(String locationY) { - this.locationY = locationY; - } - - public String getScale() { - return this.scale; - } - - public void setScale(String scale) { - this.scale = scale; - } - - public String getLabel() { - return this.label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getPoiname() { - return this.poiname; - } - - public void setPoiname(String poiname) { - this.poiname = poiname; - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java index cf5c374edf..51806768a2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/SendPicsInfo.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @@ -17,6 +18,7 @@ * @author Binary Wang */ @XStreamAlias("SendPicsInfo") +@Data public class SendPicsInfo implements Serializable { private static final long serialVersionUID = -4572837013294199227L; @@ -31,19 +33,8 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public Long getCount() { - return this.count; - } - - public void setCount(Long count) { - this.count = count; - } - - public List getPicList() { - return this.picList; - } - @XStreamAlias("item") + @Data public static class Item implements Serializable { private static final long serialVersionUID = 7706235740094081194L; @@ -56,12 +47,5 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public String getPicMd5Sum() { - return this.picMd5Sum; - } - - public void setPicMd5Sum(String picMd5Sum) { - this.picMd5Sum = picMd5Sum; - } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java index 2ea17b9e07..9b8b34d893 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.mp.api.WxMpConfigStorage; @@ -24,6 +25,7 @@ * @author chanjarster */ @XStreamAlias("xml") +@Data public class WxMpXmlMessage implements Serializable { private static final long serialVersionUID = -3586245291677274914L; @@ -462,183 +464,6 @@ public static WxMpXmlMessage fromEncryptedXml(InputStream is, } } - public Integer getOpType() { - return opType; - } - - public void setOpType(Integer opType) { - this.opType = opType; - } - - public Integer getDeviceStatus() { - - return deviceStatus; - } - - public void setDeviceStatus(Integer deviceStatus) { - this.deviceStatus = deviceStatus; - } - - public HardWare getHardWare() { - return hardWare; - } - - public void setHardWare(HardWare hardWare) { - this.hardWare = hardWare; - } - - public String getDeviceType() { - return deviceType; - } - - public void setDeviceType(String deviceType) { - this.deviceType = deviceType; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getOpenId() { - return openId; - } - - public void setOpenId(String openId) { - this.openId = openId; - } - - public Long getExpiredTime() { - return this.expiredTime; - } - - public void setExpiredTime(Long expiredTime) { - this.expiredTime = expiredTime; - } - - public Long getFailTime() { - return this.failTime; - } - - public void setFailTime(Long failTime) { - this.failTime = failTime; - } - - public String getFailReason() { - return this.failReason; - } - - public void setFailReason(String failReason) { - this.failReason = failReason; - } - - public String getDetail() { - return detail; - } - - public void setDetail(String detail) { - this.detail = detail; - } - - public String getModifyBonus() { - return modifyBonus; - } - - public void setModifyBonus(String modifyBonus) { - this.modifyBonus = modifyBonus; - } - - public String getModifyBalance() { - return modifyBalance; - } - - public void setModifyBalance(String modifyBalance) { - this.modifyBalance = modifyBalance; - } - - public String getTransId() { - return transId; - } - - public void setTransId(String transId) { - this.transId = transId; - } - - public String getLocationId() { - return locationId; - } - - public void setLocationId(String locationId) { - this.locationId = locationId; - } - - public String getFee() { - return fee; - } - - public void setFee(String fee) { - this.fee = fee; - } - - public String getOriginalFee() { - return originalFee; - } - - public void setOriginalFee(String originalFee) { - this.originalFee = originalFee; - } - - public String getStoreUniqId() { - return this.storeUniqId; - } - - public void setStoreUniqId(String storeUniqId) { - this.storeUniqId = storeUniqId; - } - - public String getPoiId() { - return this.poiId; - } - - public void setPoiId(String poiId) { - this.poiId = poiId; - } - - public String getResult() { - return this.result; - } - - public void setResult(String result) { - this.result = result; - } - - public String getMsg() { - return this.msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public String getToUser() { - return this.toUser; - } - - public void setToUser(String toUser) { - this.toUser = toUser; - } - - public Long getCreateTime() { - return this.createTime; - } - - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } - /** *
        * 当接受用户消息时,可能会获得以下值:
    @@ -666,397 +491,11 @@ public String getMsgType() {
        * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_MUSIC}
        * 
    * - * @param msgType */ public void setMsgType(String msgType) { this.msgType = msgType; } - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public Long getMsgId() { - return this.msgId; - } - - public void setMsgId(Long msgId) { - this.msgId = msgId; - } - - public String getPicUrl() { - return this.picUrl; - } - - public void setPicUrl(String picUrl) { - this.picUrl = picUrl; - } - - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getFormat() { - return this.format; - } - - public void setFormat(String format) { - this.format = format; - } - - public String getThumbMediaId() { - return this.thumbMediaId; - } - - public void setThumbMediaId(String thumbMediaId) { - this.thumbMediaId = thumbMediaId; - } - - public Double getLocationX() { - return this.locationX; - } - - public void setLocationX(Double locationX) { - this.locationX = locationX; - } - - public Double getLocationY() { - return this.locationY; - } - - public void setLocationY(Double locationY) { - this.locationY = locationY; - } - - public Double getScale() { - return this.scale; - } - - public void setScale(Double scale) { - this.scale = scale; - } - - public String getLabel() { - return this.label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getEvent() { - return this.event; - } - - public void setEvent(String event) { - this.event = event; - } - - public String getEventKey() { - return this.eventKey; - } - - public void setEventKey(String eventKey) { - this.eventKey = eventKey; - } - - public String getTicket() { - return this.ticket; - } - - public void setTicket(String ticket) { - this.ticket = ticket; - } - - public Double getLatitude() { - return this.latitude; - } - - public void setLatitude(Double latitude) { - this.latitude = latitude; - } - - public Double getLongitude() { - return this.longitude; - } - - public void setLongitude(Double longitude) { - this.longitude = longitude; - } - - public Double getPrecision() { - return this.precision; - } - - public void setPrecision(Double precision) { - this.precision = precision; - } - - public String getRecognition() { - return this.recognition; - } - - public void setRecognition(String recognition) { - this.recognition = recognition; - } - - public String getFromUser() { - return this.fromUser; - } - - public void setFromUser(String fromUser) { - this.fromUser = fromUser; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Integer getTotalCount() { - return this.totalCount; - } - - public void setTotalCount(Integer totalCount) { - this.totalCount = totalCount; - } - - public Integer getFilterCount() { - return this.filterCount; - } - - public void setFilterCount(Integer filterCount) { - this.filterCount = filterCount; - } - - public Integer getSentCount() { - return this.sentCount; - } - - public void setSentCount(Integer sentCount) { - this.sentCount = sentCount; - } - - public Integer getErrorCount() { - return this.errorCount; - } - - public void setErrorCount(Integer errorCount) { - this.errorCount = errorCount; - } - - public String getCardId() { - return this.cardId; - } - - public void setCardId(String cardId) { - this.cardId = cardId; - } - - public String getFriendUserName() { - return this.friendUserName; - } - - public void setFriendUserName(String friendUserName) { - this.friendUserName = friendUserName; - } - - public Integer getIsGiveByFriend() { - return this.isGiveByFriend; - } - - public void setIsGiveByFriend(Integer isGiveByFriend) { - this.isGiveByFriend = isGiveByFriend; - } - - public String getUserCardCode() { - return this.userCardCode; - } - - public void setUserCardCode(String userCardCode) { - this.userCardCode = userCardCode; - } - - public String getOldUserCardCode() { - return this.oldUserCardCode; - } - - public void setOldUserCardCode(String oldUserCardCode) { - this.oldUserCardCode = oldUserCardCode; - } - - public Integer getOuterId() { - return this.outerId; - } - - public void setOuterId(Integer outerId) { - this.outerId = outerId; - } - - public ScanCodeInfo getScanCodeInfo() { - return this.scanCodeInfo; - } - - public void setScanCodeInfo(ScanCodeInfo scanCodeInfo) { - this.scanCodeInfo = scanCodeInfo; - } - - public SendPicsInfo getSendPicsInfo() { - return this.sendPicsInfo; - } - - public void setSendPicsInfo(SendPicsInfo sendPicsInfo) { - this.sendPicsInfo = sendPicsInfo; - } - - public SendLocationInfo getSendLocationInfo() { - return this.sendLocationInfo; - } - - public void setSendLocationInfo( - SendLocationInfo sendLocationInfo) { - this.sendLocationInfo = sendLocationInfo; - } - - public Long getMenuId() { - return this.menuId; - } - - public void setMenuId(Long menuId) { - this.menuId = menuId; - } - - public String getKfAccount() { - return this.kfAccount; - } - - public void setKfAccount(String kfAccount) { - this.kfAccount = kfAccount; - } - - public String getToKfAccount() { - return this.toKfAccount; - } - - public void setToKfAccount(String toKfAccount) { - this.toKfAccount = toKfAccount; - } - - public String getFromKfAccount() { - return this.fromKfAccount; - } - - public void setFromKfAccount(String fromKfAccount) { - this.fromKfAccount = fromKfAccount; - } - - public String getIsRestoreMemberCard() { - return isRestoreMemberCard; - } - - public void setIsRestoreMemberCard(String isRestoreMemberCard) { - this.isRestoreMemberCard = isRestoreMemberCard; - } - - public String getOuterStr() { - return outerStr; - } - - public void setOuterStr(String outerStr) { - this.outerStr = outerStr; - } - - public String getIsReturnBack() { - return isReturnBack; - } - - public void setIsReturnBack(String isReturnBack) { - this.isReturnBack = isReturnBack; - } - - public String getIsChatRoom() { - return isChatRoom; - } - - public void setIsChatRoom(String isChatRoom) { - this.isChatRoom = isChatRoom; - } - - public String getConsumeSource() { - return this.consumeSource; - } - - public void setConsumeSource(String consumeSource) { - this.consumeSource = consumeSource; - } - - public String getLocationName() { - return this.locationName; - } - - public void setLocationName(String locationName) { - this.locationName = locationName; - } - - public String getStaffOpenId() { - return this.staffOpenId; - } - - public void setStaffOpenId(String staffOpenId) { - this.staffOpenId = staffOpenId; - } - - public String getVerifyCode() { - return this.verifyCode; - } - - public void setVerifyCode(String verifyCode) { - this.verifyCode = verifyCode; - } - - public String getRemarkAmount() { - return this.remarkAmount; - } - - public void setRemarkAmount(String remarkAmount) { - this.remarkAmount = remarkAmount; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java index c18508b527..92db6ba2c7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java @@ -2,10 +2,12 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter; @XStreamAlias("xml") +@Data public class WxMpXmlOutImageMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = -2684778597067990723L; @@ -17,12 +19,4 @@ public WxMpXmlOutImageMessage() { this.msgType = WxConsts.XML_MSG_IMAGE; } - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java index c84cc665b9..b1940fc487 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMessage.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.mp.api.WxMpConfigStorage; import me.chanjar.weixin.mp.builder.outxml.*; @@ -11,6 +12,7 @@ import java.io.Serializable; @XStreamAlias("xml") +@Data public abstract class WxMpXmlOutMessage implements Serializable { private static final long serialVersionUID = -381382011286216263L; @@ -78,38 +80,6 @@ public static TransferCustomerServiceBuilder TRANSFER_CUSTOMER_SERVICE() { return new TransferCustomerServiceBuilder(); } - public String getToUserName() { - return this.toUserName; - } - - public void setToUserName(String toUserName) { - this.toUserName = toUserName; - } - - public String getFromUserName() { - return this.fromUserName; - } - - public void setFromUserName(String fromUserName) { - this.fromUserName = fromUserName; - } - - public Long getCreateTime() { - return this.createTime; - } - - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } - - public String getMsgType() { - return this.msgType; - } - - public void setMsgType(String msgType) { - this.msgType = msgType; - } - @SuppressWarnings("unchecked") public String toXml() { return XStreamTransformer.toXml((Class) this.getClass(), this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java index 2676e69077..c06b76f306 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java @@ -2,10 +2,12 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @XStreamAlias("xml") +@Data public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = -4159937804975448945L; @@ -16,47 +18,8 @@ public WxMpXmlOutMusicMessage() { this.msgType = WxConsts.XML_MSG_MUSIC; } - public String getTitle() { - return this.music.getTitle(); - } - - public void setTitle(String title) { - this.music.setTitle(title); - } - - public String getDescription() { - return this.music.getDescription(); - } - - public void setDescription(String description) { - this.music.setDescription(description); - } - - public String getThumbMediaId() { - return this.music.getThumbMediaId(); - } - - public void setThumbMediaId(String thumbMediaId) { - this.music.setThumbMediaId(thumbMediaId); - } - - public String getMusicUrl() { - return this.music.getMusicUrl(); - } - - public void setMusicUrl(String musicUrl) { - this.music.setMusicUrl(musicUrl); - } - - public String getHqMusicUrl() { - return this.music.getHqMusicUrl(); - } - - public void setHqMusicUrl(String hqMusicUrl) { - this.music.setHqMusicUrl(hqMusicUrl); - } - @XStreamAlias("Music") + @Data public static class Music { @XStreamAlias("Title") @@ -79,46 +42,6 @@ public static class Music { @XStreamConverter(value = XStreamCDataConverter.class) private String hqMusicUrl; - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getThumbMediaId() { - return this.thumbMediaId; - } - - public void setThumbMediaId(String thumbMediaId) { - this.thumbMediaId = thumbMediaId; - } - - public String getMusicUrl() { - return this.musicUrl; - } - - public void setMusicUrl(String musicUrl) { - this.musicUrl = musicUrl; - } - - public String getHqMusicUrl() { - return this.hqMusicUrl; - } - - public void setHqMusicUrl(String hqMusicUrl) { - this.hqMusicUrl = hqMusicUrl; - } - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java index 797b042525..5e00bf3f89 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @@ -10,6 +11,7 @@ import java.util.List; @XStreamAlias("xml") +@Data public class WxMpXmlOutNewsMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = -4604402850905714772L; @@ -22,72 +24,31 @@ public WxMpXmlOutNewsMessage() { this.msgType = WxConsts.XML_MSG_NEWS; } - public int getArticleCount() { - return this.articleCount; - } - public void addArticle(Item item) { this.articles.add(item); this.articleCount = this.articles.size(); } - public List getArticles() { - return this.articles; - } - - @XStreamAlias("item") + @Data public static class Item implements Serializable { - private static final long serialVersionUID = -4971456355028904754L; @XStreamAlias("Title") @XStreamConverter(value = XStreamCDataConverter.class) - private String Title; + private String title; @XStreamAlias("Description") @XStreamConverter(value = XStreamCDataConverter.class) - private String Description; + private String description; @XStreamAlias("PicUrl") @XStreamConverter(value = XStreamCDataConverter.class) - private String PicUrl; + private String picUrl; @XStreamAlias("Url") @XStreamConverter(value = XStreamCDataConverter.class) - private String Url; - - public String getTitle() { - return this.Title; - } - - public void setTitle(String title) { - this.Title = title; - } - - public String getDescription() { - return this.Description; - } - - public void setDescription(String description) { - this.Description = description; - } - - public String getPicUrl() { - return this.PicUrl; - } - - public void setPicUrl(String picUrl) { - this.PicUrl = picUrl; - } - - public String getUrl() { - return this.Url; - } - - public void setUrl(String url) { - this.Url = url; - } + private String url; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java index 7c98c625e7..bc8d4a8e90 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java @@ -2,10 +2,12 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @XStreamAlias("xml") +@Data public class WxMpXmlOutTextMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = -3972786455288763361L; @@ -17,13 +19,4 @@ public WxMpXmlOutTextMessage() { this.msgType = WxConsts.XML_MSG_TEXT; } - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java index 3a3cfc4b4c..0c19bd7a66 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java @@ -2,12 +2,14 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import java.io.Serializable; @XStreamAlias("xml") +@Data public class WxMpXmlOutTransferKefuMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = 1850903037285841322L; @@ -18,15 +20,8 @@ public WxMpXmlOutTransferKefuMessage() { this.msgType = WxConsts.CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE; } - public TransInfo getTransInfo() { - return this.transInfo; - } - - public void setTransInfo(TransInfo transInfo) { - this.transInfo = transInfo; - } - @XStreamAlias("TransInfo") + @Data public static class TransInfo implements Serializable { private static final long serialVersionUID = -6317885617135706056L; @@ -34,12 +29,5 @@ public static class TransInfo implements Serializable { @XStreamConverter(value = XStreamCDataConverter.class) private String kfAccount; - public String getKfAccount() { - return this.kfAccount; - } - - public void setKfAccount(String kfAccount) { - this.kfAccount = kfAccount; - } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java index 346cd5b160..fe8ed8ebfb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java @@ -2,12 +2,14 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import java.io.Serializable; @XStreamAlias("xml") +@Data public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = 1745902309380113978L; @@ -18,32 +20,8 @@ public WxMpXmlOutVideoMessage() { this.msgType = WxConsts.XML_MSG_VIDEO; } - public String getMediaId() { - return this.video.getMediaId(); - } - - public void setMediaId(String mediaId) { - this.video.setMediaId(mediaId); - } - - public String getTitle() { - return this.video.getTitle(); - } - - public void setTitle(String title) { - this.video.setTitle(title); - } - - public String getDescription() { - return this.video.getDescription(); - } - - public void setDescription(String description) { - this.video.setDescription(description); - } - - @XStreamAlias("Video") + @Data public static class Video implements Serializable { private static final long serialVersionUID = -6445448977569651183L; @@ -59,30 +37,6 @@ public static class Video implements Serializable { @XStreamConverter(value = XStreamCDataConverter.class) private String description; - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java index a810e5a0f1..70738935e8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java @@ -2,10 +2,12 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter; @XStreamAlias("xml") +@Data public class WxMpXmlOutVoiceMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = 240367390249860551L; @@ -17,12 +19,4 @@ public WxMpXmlOutVoiceMessage() { this.msgType = WxConsts.XML_MSG_VOICE; } - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCardResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCardResult.java index 5684557bea..2f478a2053 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCardResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCardResult.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.result; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.bean.WxMpCard; @@ -11,6 +12,7 @@ * @author YuJian * @version 15/11/11 */ +@Data public class WxMpCardResult implements Serializable { private static final long serialVersionUID = -7950878428289035637L; @@ -26,57 +28,9 @@ public class WxMpCardResult implements Serializable { private Boolean canConsume; - public String getErrorCode() { - return this.errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getErrorMsg() { - return this.errorMsg; - } - - public void setErrorMsg(String errorMsg) { - this.errorMsg = errorMsg; - } - - public String getOpenId() { - return this.openId; - } - - public void setOpenId(String openId) { - this.openId = openId; - } - - public WxMpCard getCard() { - return this.card; - } - - public void setCard(WxMpCard card) { - this.card = card; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); } - public String getUserCardStatus() { - return this.userCardStatus; - } - - public void setUserCardStatus(String userCardStatus) { - this.userCardStatus = userCardStatus; - } - - public Boolean getCanConsume() { - return this.canConsume; - } - - public void setCanConsume(Boolean canConsume) { - this.canConsume = canConsume; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java index 563dc6aca8..52bebcf90d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfo.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.json.WxBooleanTypeAdapter; import me.chanjar.weixin.common.util.json.WxDateTypeAdapter; @@ -18,6 +19,7 @@ * @author Binary Wang * */ +@Data public class WxMpCurrentAutoReplyInfo implements Serializable { private static final long serialVersionUID = 8294705001262751638L; @@ -47,46 +49,7 @@ public static WxMpCurrentAutoReplyInfo fromJson(String json) { @SerializedName("keyword_autoreply_info") private KeywordAutoReplyInfo keywordAutoReplyInfo; - public Boolean getAddFriendReplyOpen() { - return this.isAddFriendReplyOpen; - } - - public void setAddFriendReplyOpen(Boolean addFriendReplyOpen) { - isAddFriendReplyOpen = addFriendReplyOpen; - } - - public Boolean getAutoReplyOpen() { - return this.isAutoReplyOpen; - } - - public void setAutoReplyOpen(Boolean autoReplyOpen) { - isAutoReplyOpen = autoReplyOpen; - } - - public AutoReplyInfo getAddFriendAutoReplyInfo() { - return this.addFriendAutoReplyInfo; - } - - public void setAddFriendAutoReplyInfo(AutoReplyInfo addFriendAutoReplyInfo) { - this.addFriendAutoReplyInfo = addFriendAutoReplyInfo; - } - - public AutoReplyInfo getMessageDefaultAutoReplyInfo() { - return this.messageDefaultAutoReplyInfo; - } - - public void setMessageDefaultAutoReplyInfo(AutoReplyInfo messageDefaultAutoReplyInfo) { - this.messageDefaultAutoReplyInfo = messageDefaultAutoReplyInfo; - } - - public KeywordAutoReplyInfo getKeywordAutoReplyInfo() { - return this.keywordAutoReplyInfo; - } - - public void setKeywordAutoReplyInfo(KeywordAutoReplyInfo keywordAutoReplyInfo) { - this.keywordAutoReplyInfo = keywordAutoReplyInfo; - } - + @Data public static class AutoReplyRule implements Serializable { private static final long serialVersionUID = -6415971838145909046L; @@ -111,47 +74,9 @@ public String toString() { @SerializedName("reply_list_info") private List replyListInfo; - public String getRuleName() { - return this.ruleName; - } - - public void setRuleName(String ruleName) { - this.ruleName = ruleName; - } - - public Date getCreateTime() { - return this.createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public String getReplyMode() { - return this.replyMode; - } - - public void setReplyMode(String replyMode) { - this.replyMode = replyMode; - } - - public List getKeywordListInfo() { - return this.keywordListInfo; - } - - public void setKeywordListInfo(List keywordListInfo) { - this.keywordListInfo = keywordListInfo; - } - - public List getReplyListInfo() { - return this.replyListInfo; - } - - public void setReplyListInfo(List replyListInfo) { - this.replyListInfo = replyListInfo; - } } + @Data public static class ReplyInfo implements Serializable { private static final long serialVersionUID = -3429575601599101690L; @@ -166,31 +91,9 @@ public String toString() { @SerializedName("news_info") private NewsInfo newsInfo; - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public NewsInfo getNewsInfo() { - return this.newsInfo; - } - - public void setNewsInfo(NewsInfo newsInfo) { - this.newsInfo = newsInfo; - } } + @Data public static class NewsInfo implements Serializable { private static final long serialVersionUID = 2958827725972593328L; @@ -201,15 +104,9 @@ public String toString() { private List list; - public List getList() { - return this.list; - } - - public void setList(List list) { - this.list = list; - } } + @Data public static class NewsItem implements Serializable { private static final long serialVersionUID = -680356309029767176L; @@ -231,63 +128,9 @@ public String toString() { private String sourceUrl; private String title; - public String getCoverUrl() { - return this.coverUrl; - } - - public void setCoverUrl(String coverUrl) { - this.coverUrl = coverUrl; - } - - public String getAuthor() { - return this.author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public String getContentUrl() { - return this.contentUrl; - } - - public void setContentUrl(String contentUrl) { - this.contentUrl = contentUrl; - } - - public String getDigest() { - return this.digest; - } - - public void setDigest(String digest) { - this.digest = digest; - } - - public Boolean getShowCover() { - return this.showCover; - } - - public void setShowCover(Boolean showCover) { - this.showCover = showCover; - } - - public String getSourceUrl() { - return this.sourceUrl; - } - - public void setSourceUrl(String sourceUrl) { - this.sourceUrl = sourceUrl; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } } + @Data public static class KeywordInfo implements Serializable { private static final long serialVersionUID = 7720246983986706379L; @@ -301,31 +144,9 @@ public String toString() { private String matchMode; private String content; - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMatchMode() { - return this.matchMode; - } - - public void setMatchMode(String matchMode) { - this.matchMode = matchMode; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } } + @Data public static class KeywordAutoReplyInfo implements Serializable { private static final long serialVersionUID = -8789197949404753083L; @@ -335,16 +156,9 @@ public String toString() { } private List list; - - public List getList() { - return this.list; - } - - public void setList(List list) { - this.list = list; - } } + @Data public static class AutoReplyInfo implements Serializable { private static final long serialVersionUID = 4993719555937843712L; @@ -355,22 +169,6 @@ public String toString() { private String type; private String content; - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassSendResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassSendResult.java index 56cfd13d97..d0d2a9d82f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassSendResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassSendResult.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.result; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -16,6 +17,7 @@ * * @author chanjarster */ +@Data public class WxMpMassSendResult implements Serializable { private static final long serialVersionUID = -4816336807575562818L; @@ -28,38 +30,6 @@ public static WxMpMassSendResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMpMassSendResult.class); } - public String getErrorCode() { - return this.errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getErrorMsg() { - return this.errorMsg; - } - - public void setErrorMsg(String errorMsg) { - this.errorMsg = errorMsg; - } - - public String getMsgId() { - return this.msgId; - } - - public void setMsgId(String msgId) { - this.msgId = msgId; - } - - public String getMsgDataId() { - return this.msgDataId; - } - - public void setMsgDataId(String msgDataId) { - this.msgDataId = msgDataId; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassUploadResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassUploadResult.java index f8ca889652..a13627257b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassUploadResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpMassUploadResult.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.result; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -13,6 +14,7 @@ * * @author chanjarster */ +@Data public class WxMpMassUploadResult implements Serializable { private static final long serialVersionUID = 6568157943644994029L; @@ -24,30 +26,6 @@ public static WxMpMassUploadResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMpMassUploadResult.class); } - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public long getCreatedAt() { - return this.createdAt; - } - - public void setCreatedAt(long createdAt) { - this.createdAt = createdAt; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpOAuth2AccessToken.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpOAuth2AccessToken.java index 3f49397975..0193efee20 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpOAuth2AccessToken.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpOAuth2AccessToken.java @@ -1,10 +1,12 @@ package me.chanjar.weixin.mp.bean.result; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; +@Data public class WxMpOAuth2AccessToken implements Serializable { private static final long serialVersionUID = -1345910558078620805L; @@ -24,54 +26,6 @@ public static WxMpOAuth2AccessToken fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMpOAuth2AccessToken.class); } - public String getRefreshToken() { - return this.refreshToken; - } - - public void setRefreshToken(String refreshToken) { - this.refreshToken = refreshToken; - } - - public String getOpenId() { - return this.openId; - } - - public void setOpenId(String openId) { - this.openId = openId; - } - - public String getScope() { - return this.scope; - } - - public void setScope(String scope) { - this.scope = scope; - } - - public String getAccessToken() { - return this.accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - public int getExpiresIn() { - return this.expiresIn; - } - - public void setExpiresIn(int expiresIn) { - this.expiresIn = expiresIn; - } - - public String getUnionId() { - return this.unionId; - } - - public void setUnionId(String unionId) { - this.unionId = unionId; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpQrCodeTicket.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpQrCodeTicket.java index 7ba6151c3e..ee78096b33 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpQrCodeTicket.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpQrCodeTicket.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.result; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -9,44 +10,21 @@ * * @author chanjarster */ +@Data public class WxMpQrCodeTicket implements Serializable { private static final long serialVersionUID = 5777119669111011584L; protected String ticket; - protected int expire_seconds = -1; + /** + * 如果为-1,说明是永久 + */ + protected int expireSeconds = -1; protected String url; public static WxMpQrCodeTicket fromJson(String json) { return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpQrCodeTicket.class); } - public String getTicket() { - return this.ticket; - } - - public void setTicket(String ticket) { - this.ticket = ticket; - } - - /** - * 如果返回-1说明是永久 - */ - public int getExpire_seconds() { - return this.expire_seconds; - } - - public void setExpire_seconds(int expire_seconds) { - this.expire_seconds = expire_seconds; - } - - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } - @Override public String toString() { return WxMpGsonBuilder.INSTANCE.create().toJson(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpSemanticQueryResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpSemanticQueryResult.java index 723ea7adc9..5c2962b82a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpSemanticQueryResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpSemanticQueryResult.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.result; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -11,6 +12,7 @@ * * @author Daniel Qian */ +@Data public class WxMpSemanticQueryResult implements Serializable { private static final long serialVersionUID = 4811088544804441365L; @@ -25,52 +27,4 @@ public static WxMpSemanticQueryResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMpSemanticQueryResult.class); } - public String getQuery() { - return this.query; - } - - public void setQuery(String query) { - this.query = query; - } - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getSemantic() { - return this.semantic; - } - - public void setSemantic(String semantic) { - this.semantic = semantic; - } - - public String getResult() { - return this.result; - } - - public void setResult(String result) { - this.result = result; - } - - public String getAnswer() { - return this.answer; - } - - public void setAnswer(String answer) { - this.answer = answer; - } - - public String getText() { - return this.text; - } - - public void setText(String text) { - this.text = text; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java index e9e2bae6c1..ec969e2872 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java @@ -3,6 +3,7 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -15,6 +16,7 @@ * * @author chanjarster */ +@Data public class WxMpUser implements Serializable { private static final long serialVersionUID = 5788154322646488738L; @@ -28,6 +30,9 @@ public class WxMpUser implements Serializable { private String country; private String headImgUrl; private Long subscribeTime; + /** + * 只有在将公众号绑定到微信开放平台帐号后,才会出现该字段。 + */ private String unionId; private Integer sexId; private String remark; @@ -46,130 +51,6 @@ public static List fromJsonList(String json) { return gson.fromJson(jsonObject.get("user_info_list"), collectionType); } - public Boolean getSubscribe() { - return this.subscribe; - } - - public void setSubscribe(Boolean subscribe) { - this.subscribe = subscribe; - } - - public String getOpenId() { - return this.openId; - } - - public void setOpenId(String openId) { - this.openId = openId; - } - - public String getNickname() { - return this.nickname; - } - - public void setNickname(String nickname) { - this.nickname = nickname; - } - - public String getSex() { - return this.sex; - } - - public void setSex(String sex) { - this.sex = sex; - } - - public String getLanguage() { - return this.language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public String getCity() { - return this.city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getProvince() { - return this.province; - } - - public void setProvince(String province) { - this.province = province; - } - - public String getCountry() { - return this.country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getHeadImgUrl() { - return this.headImgUrl; - } - - public void setHeadImgUrl(String headImgUrl) { - this.headImgUrl = headImgUrl; - } - - public Long getSubscribeTime() { - return this.subscribeTime; - } - - public void setSubscribeTime(Long subscribeTime) { - this.subscribeTime = subscribeTime; - } - - /** - * 只有在将公众号绑定到微信开放平台帐号后,才会出现该字段。 - */ - public String getUnionId() { - return this.unionId; - } - - public void setUnionId(String unionId) { - this.unionId = unionId; - } - - public Integer getSexId() { - - return this.sexId; - } - - public void setSexId(Integer sexId) { - this.sexId = sexId; - } - - public String getRemark() { - return this.remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public Integer getGroupId() { - return this.groupId; - } - - public void setGroupId(Integer groupId) { - this.groupId = groupId; - } - - public Long[] getTagIds() { - return this.tagIds; - } - - public void setTagIds(Long[] tagIds) { - this.tagIds = tagIds; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserBlacklistGetResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserBlacklistGetResult.java index 5fe0a9448b..83e1e24424 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserBlacklistGetResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserBlacklistGetResult.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.result; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -9,6 +10,7 @@ /** * @author miller */ +@Data public class WxMpUserBlacklistGetResult implements Serializable { private static final long serialVersionUID = -8780216463588687626L; @@ -21,38 +23,6 @@ public static WxMpUserBlacklistGetResult fromJson(String json) { return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUserBlacklistGetResult.class); } - public int getTotal() { - return this.total; - } - - public void setTotal(int total) { - this.total = total; - } - - public int getCount() { - return this.count; - } - - public void setCount(int count) { - this.count = count; - } - - public List getOpenidList() { - return this.openidList; - } - - public void setOpenidList(List openidList) { - this.openidList = openidList; - } - - public String getNextOpenid() { - return this.nextOpenid; - } - - public void setNextOpenid(String nextOpenid) { - this.nextOpenid = nextOpenid; - } - @Override public String toString() { return WxMpGsonBuilder.INSTANCE.create().toJson(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserList.java index 6e367aeca1..5f816456e1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserList.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMpUserList.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.result; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -11,6 +12,7 @@ * * @author chanjarster */ +@Data public class WxMpUserList implements Serializable { private static final long serialVersionUID = 1389073042674901032L; @@ -23,38 +25,6 @@ public static WxMpUserList fromJson(String json) { return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUserList.class); } - public long getTotal() { - return this.total; - } - - public void setTotal(long total) { - this.total = total; - } - - public int getCount() { - return this.count; - } - - public void setCount(int count) { - this.count = count; - } - - public List getOpenids() { - return this.openids; - } - - public void setOpenids(List openids) { - this.openids = openids; - } - - public String getNextOpenid() { - return this.nextOpenid; - } - - public void setNextOpenid(String nextOpenid) { - this.nextOpenid = nextOpenid; - } - @Override public String toString() { return WxMpGsonBuilder.INSTANCE.create().toJson(this); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java index 2c098b5347..86614218eb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java @@ -3,6 +3,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.annotation.Required; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -19,6 +20,7 @@ * * @author Binary Wang */ +@Data public class WxMpStoreBaseInfo implements Serializable { private static final long serialVersionUID = 829577606838118218L; @@ -170,192 +172,21 @@ public static WxMpStoreBaseInfo fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMpStoreBaseInfo.class); } - public static WxMpStoreBaseInfoBuilder builder() { - return new WxMpStoreBaseInfoBuilder(); - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); } public String toJson() { - JsonElement base_info = WxMpGsonBuilder.create().toJsonTree(this); + JsonElement baseInfo = WxMpGsonBuilder.create().toJsonTree(this); JsonObject jsonObject = new JsonObject(); - jsonObject.add("base_info", base_info); + jsonObject.add("base_info", baseInfo); JsonObject business = new JsonObject(); business.add("business", jsonObject); return business.toString(); } - public String getSid() { - return this.sid; - } - - public void setSid(String sid) { - this.sid = sid; - } - - public String getBusinessName() { - return this.businessName; - } - - public void setBusinessName(String businessName) { - this.businessName = businessName; - } - - public String getBranchName() { - return this.branchName; - } - - public void setBranchName(String branchName) { - this.branchName = branchName; - } - - public String getProvince() { - return this.province; - } - - public void setProvince(String province) { - this.province = province; - } - - public String getCity() { - return this.city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getDistrict() { - return this.district; - } - - public void setDistrict(String district) { - this.district = district; - } - - public String getAddress() { - return this.address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getTelephone() { - return this.telephone; - } - - public void setTelephone(String telephone) { - this.telephone = telephone; - } - - public String[] getCategories() { - return this.categories; - } - - public void setCategories(String[] categories) { - this.categories = categories; - } - - public Integer getOffsetType() { - return this.offsetType; - } - - public void setOffsetType(Integer offsetType) { - this.offsetType = offsetType; - } - - public BigDecimal getLongitude() { - return this.longitude; - } - - public void setLongitude(BigDecimal longitude) { - this.longitude = longitude; - } - - public BigDecimal getLatitude() { - return this.latitude; - } - - public void setLatitude(BigDecimal latitude) { - this.latitude = latitude; - } - - public List getPhotos() { - return this.photos; - } - - public void setPhotos(List photos) { - this.photos = photos; - } - - public String getRecommend() { - return this.recommend; - } - - public void setRecommend(String recommend) { - this.recommend = recommend; - } - - public String getSpecial() { - return this.special; - } - - public void setSpecial(String special) { - this.special = special; - } - - public String getIntroduction() { - return this.introduction; - } - - public void setIntroduction(String introduction) { - this.introduction = introduction; - } - - public String getOpenTime() { - return this.openTime; - } - - public void setOpenTime(String openTime) { - this.openTime = openTime; - } - - public Integer getAvgPrice() { - return this.avgPrice; - } - - public void setAvgPrice(Integer avgPrice) { - this.avgPrice = avgPrice; - } - - public Integer getAvailableState() { - return this.availableState; - } - - public void setAvailableState(Integer availableState) { - this.availableState = availableState; - } - - public Integer getUpdateStatus() { - return this.updateStatus; - } - - public void setUpdateStatus(Integer updateStatus) { - this.updateStatus = updateStatus; - } - - public String getPoiId() { - return this.poiId; - } - - public void setPoiId(String poiId) { - this.poiId = poiId; - } - + @Data public static class WxMpStorePhoto implements Serializable { private static final long serialVersionUID = -2942447907614186861L; /** @@ -364,193 +195,6 @@ public static class WxMpStorePhoto implements Serializable { @SerializedName("photo_url") private String photoUrl; - public String getPhotoUrl() { - return photoUrl; - } - - public void setPhotoUrl(String photoUrl) { - this.photoUrl = photoUrl; - } - } - - public static class WxMpStoreBaseInfoBuilder { - private String sid; - private String businessName; - private String branchName; - private String province; - private String city; - private String district; - private String address; - private String telephone; - private String[] categories; - private Integer offsetType; - private BigDecimal longitude; - private BigDecimal latitude; - private List photos; - private String recommend; - private String special; - private String introduction; - private String openTime; - private Integer avgPrice; - private Integer availableState; - private Integer updateStatus; - private String poiId; - - public WxMpStoreBaseInfoBuilder sid(String sid) { - this.sid = sid; - return this; - } - - public WxMpStoreBaseInfoBuilder businessName(String businessName) { - this.businessName = businessName; - return this; - } - - public WxMpStoreBaseInfoBuilder branchName(String branchName) { - this.branchName = branchName; - return this; - } - - public WxMpStoreBaseInfoBuilder province(String province) { - this.province = province; - return this; - } - - public WxMpStoreBaseInfoBuilder city(String city) { - this.city = city; - return this; - } - - public WxMpStoreBaseInfoBuilder district(String district) { - this.district = district; - return this; - } - - public WxMpStoreBaseInfoBuilder address(String address) { - this.address = address; - return this; - } - - public WxMpStoreBaseInfoBuilder telephone(String telephone) { - this.telephone = telephone; - return this; - } - - public WxMpStoreBaseInfoBuilder categories(String[] categories) { - this.categories = categories; - return this; - } - - public WxMpStoreBaseInfoBuilder offsetType(Integer offsetType) { - this.offsetType = offsetType; - return this; - } - - public WxMpStoreBaseInfoBuilder longitude(BigDecimal longitude) { - this.longitude = longitude; - return this; - } - - public WxMpStoreBaseInfoBuilder latitude(BigDecimal latitude) { - this.latitude = latitude; - return this; - } - - public WxMpStoreBaseInfoBuilder photos(List photos) { - this.photos = photos; - return this; - } - - public WxMpStoreBaseInfoBuilder recommend(String recommend) { - this.recommend = recommend; - return this; - } - - public WxMpStoreBaseInfoBuilder special(String special) { - this.special = special; - return this; - } - - public WxMpStoreBaseInfoBuilder introduction(String introduction) { - this.introduction = introduction; - return this; - } - - public WxMpStoreBaseInfoBuilder openTime(String openTime) { - this.openTime = openTime; - return this; - } - - public WxMpStoreBaseInfoBuilder avgPrice(Integer avgPrice) { - this.avgPrice = avgPrice; - return this; - } - - public WxMpStoreBaseInfoBuilder availableState(Integer availableState) { - this.availableState = availableState; - return this; - } - - public WxMpStoreBaseInfoBuilder updateStatus(Integer updateStatus) { - this.updateStatus = updateStatus; - return this; - } - - public WxMpStoreBaseInfoBuilder poiId(String poiId) { - this.poiId = poiId; - return this; - } - - public WxMpStoreBaseInfoBuilder from(WxMpStoreBaseInfo origin) { - this.sid(origin.sid); - this.businessName(origin.businessName); - this.branchName(origin.branchName); - this.province(origin.province); - this.city(origin.city); - this.district(origin.district); - this.address(origin.address); - this.telephone(origin.telephone); - this.categories(origin.categories); - this.offsetType(origin.offsetType); - this.longitude(origin.longitude); - this.latitude(origin.latitude); - this.photos(origin.photos); - this.recommend(origin.recommend); - this.special(origin.special); - this.introduction(origin.introduction); - this.openTime(origin.openTime); - this.avgPrice(origin.avgPrice); - this.availableState(origin.availableState); - this.updateStatus(origin.updateStatus); - this.poiId(origin.poiId); - return this; - } - - public WxMpStoreBaseInfo build() { - WxMpStoreBaseInfo m = new WxMpStoreBaseInfo(); - m.sid = this.sid; - m.businessName = this.businessName; - m.branchName = this.branchName; - m.province = this.province; - m.city = this.city; - m.district = this.district; - m.address = this.address; - m.telephone = this.telephone; - m.categories = this.categories; - m.offsetType = this.offsetType; - m.longitude = this.longitude; - m.latitude = this.latitude; - m.photos = this.photos; - m.recommend = this.recommend; - m.special = this.special; - m.introduction = this.introduction; - m.openTime = this.openTime; - m.avgPrice = this.avgPrice; - m.availableState = this.availableState; - m.updateStatus = this.updateStatus; - m.poiId = this.poiId; - return m; - } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreInfo.java index fcbb9aa5ea..a72fb5d46f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreInfo.java @@ -1,10 +1,12 @@ package me.chanjar.weixin.mp.bean.store; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import java.io.Serializable; +@Data public class WxMpStoreInfo implements Serializable{ private static final long serialVersionUID = 7300598931768355461L; @@ -15,13 +17,4 @@ public class WxMpStoreInfo implements Serializable{ public String toString() { return ToStringUtils.toSimpleString(this); } - - public WxMpStoreBaseInfo getBaseInfo() { - return this.baseInfo; - } - - public void setBaseInfo(WxMpStoreBaseInfo baseInfo) { - this.baseInfo = baseInfo; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java index 3eac16add2..5fdfa94483 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreListResult.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.store; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -15,6 +16,7 @@ * * @author Binary Wang */ +@Data public class WxMpStoreListResult implements Serializable { private static final long serialVersionUID = 5388907559949538663L; @@ -48,36 +50,4 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public Integer getTotalCount() { - return this.totalCount; - } - - public void setTotalCount(Integer totalCount) { - this.totalCount = totalCount; - } - - public Integer getErrCode() { - return this.errCode; - } - - public void setErrCode(Integer errCode) { - this.errCode = errCode; - } - - public String getErrMsg() { - return this.errMsg; - } - - public void setErrMsg(String errMsg) { - this.errMsg = errMsg; - } - - public List getBusinessList() { - return this.businessList; - } - - public void setBusinessList(List businessList) { - this.businessList = businessList; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java index 14f2f0b296..f969792355 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxTagListUser.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.tag; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -15,6 +16,7 @@ * * @author Binary Wang */ +@Data public class WxTagListUser implements Serializable { private static final long serialVersionUID = -4551768374200676112L; @@ -47,30 +49,7 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public Integer getCount() { - return this.count; - } - - public void setCount(Integer count) { - this.count = count; - } - - public WxTagListUserData getData() { - return this.data; - } - - public void setData(WxTagListUserData data) { - this.data = data; - } - - public String getNextOpenid() { - return this.nextOpenid; - } - - public void setNextOpenid(String nextOpenid) { - this.nextOpenid = nextOpenid; - } - + @Data public static class WxTagListUserData implements Serializable { private static final long serialVersionUID = -8584537400336245701L; @@ -84,13 +63,5 @@ public static class WxTagListUserData implements Serializable { public String toString() { return ToStringUtils.toSimpleString(this); } - - public List getOpenidList() { - return this.openidList; - } - - public void setOpenidList(List openidList) { - this.openidList = openidList; - } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java index d39031cd14..a54199efa4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java @@ -2,6 +2,7 @@ import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -16,6 +17,7 @@ * * @author Binary Wang */ +@Data public class WxUserTag implements Serializable { private static final long serialVersionUID = -7722428695667031252L; @@ -47,30 +49,6 @@ public static List listFromJson(String json) { }.getType()); } - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getCount() { - return this.count; - } - - public void setCount(Integer count) { - this.count = count; - } - - public Long getId() { - return this.id; - } - - public void setId(Long id) { - this.id = id; - } - public String toJson() { return WxMpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java index 5bdee4370d..c9b12cdf28 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java @@ -3,6 +3,7 @@ import com.google.gson.JsonParser; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -17,6 +18,7 @@ * * @author Binary Wang */ +@Data public class WxMpTemplate implements Serializable { private static final JsonParser JSON_PARSER = new JsonParser(); private static final long serialVersionUID = -7366474522571199372L; @@ -69,52 +71,4 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public String getTemplateId() { - return this.templateId; - } - - public void setTemplateId(String templateId) { - this.templateId = templateId; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getPrimaryIndustry() { - return this.primaryIndustry; - } - - public void setPrimaryIndustry(String primaryIndustry) { - this.primaryIndustry = primaryIndustry; - } - - public String getDeputyIndustry() { - return this.deputyIndustry; - } - - public void setDeputyIndustry(String deputyIndustry) { - this.deputyIndustry = deputyIndustry; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getExample() { - return this.example; - } - - public void setExample(String example) { - this.example = example; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java index f9d81e4028..ada9952040 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java @@ -1,10 +1,13 @@ package me.chanjar.weixin.mp.bean.template; +import lombok.Data; + import java.io.Serializable; /** * @author Daniel Qian */ +@Data public class WxMpTemplateData implements Serializable { private static final long serialVersionUID = 6301835292940277870L; @@ -26,28 +29,4 @@ public WxMpTemplateData(String name, String value, String color) { this.color = color; } - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getColor() { - return this.color; - } - - public void setColor(String color) { - this.color = color; - } - } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java index b142c3f70f..363ddad7ce 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.template; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -9,6 +10,7 @@ /** * @author miller */ +@Data public class WxMpTemplateIndustry implements Serializable { private static final long serialVersionUID = -7700398224795914722L; @@ -36,26 +38,11 @@ public String toJson() { return WxMpGsonBuilder.create().toJson(this); } - public Industry getPrimaryIndustry() { - return this.primaryIndustry; - } - - public void setPrimaryIndustry(Industry primaryIndustry) { - this.primaryIndustry = primaryIndustry; - } - - public Industry getSecondIndustry() { - return this.secondIndustry; - } - - public void setSecondIndustry(Industry secondIndustry) { - this.secondIndustry = secondIndustry; - } - /** * @author miller * 官方文档中,创建和获取的数据结构不一样。所以采用冗余字段的方式,实现相应的接口 */ + @Data public static class Industry implements Serializable { private static final long serialVersionUID = -1707184885588012142L; private String id; @@ -80,28 +67,5 @@ public String toString() { return ToStringUtils.toSimpleString(this); } - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } - - public String getFirstClass() { - return this.firstClass; - } - - public void setFirstClass(String firstClass) { - this.firstClass = firstClass; - } - - public String getSecondClass() { - return this.secondClass; - } - - public void setSecondClass(String secondClass) { - this.secondClass = secondClass; - } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java index 95d619a486..2eeea5fd34 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.template; +import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -9,6 +10,7 @@ /** * 参考 http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN 发送模板消息接口部分 */ +@Data public class WxMpTemplateMessage implements Serializable { private static final long serialVersionUID = 5063374783759519418L; @@ -45,138 +47,22 @@ public class WxMpTemplateMessage implements Serializable { public WxMpTemplateMessage() { } - public static WxMpTemplateMessageBuilder builder() { - return new WxMpTemplateMessageBuilder(); - } - - public String getToUser() { - return this.toUser; - } - - public void setToUser(String toUser) { - this.toUser = toUser; - } - - public String getTemplateId() { - return this.templateId; - } - - public void setTemplateId(String templateId) { - this.templateId = templateId; - } - - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } - - public List getData() { - return this.data; - } - - public void setData(List data) { - this.data = data; - } - - public void addWxMpTemplateData(WxMpTemplateData datum) { - this.data.add(datum); - } - - public MiniProgram getMiniProgram() { - return this.miniProgram; - } - - public void setMiniProgram(MiniProgram miniProgram) { - this.miniProgram = miniProgram; - } - public String toJson() { return WxMpGsonBuilder.INSTANCE.create().toJson(this); } + @Data public static class MiniProgram implements Serializable { private static final long serialVersionUID = -7945254706501974849L; private String appid; private String pagePath; - public MiniProgram() { - } - public MiniProgram(String appid, String pagePath) { this.appid = appid; this.pagePath = pagePath; } - public String getAppid() { - return this.appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public String getPagePath() { - return this.pagePath; - } - - public void setPagePath(String pagePath) { - this.pagePath = pagePath; - } - } - - public static class WxMpTemplateMessageBuilder { - private String toUser; - private String templateId; - private String url; - private List data = new ArrayList<>(); - private MiniProgram miniProgram; - - public WxMpTemplateMessageBuilder toUser(String toUser) { - this.toUser = toUser; - return this; - } - - public WxMpTemplateMessageBuilder templateId(String templateId) { - this.templateId = templateId; - return this; - } - - public WxMpTemplateMessageBuilder url(String url) { - this.url = url; - return this; - } - - public WxMpTemplateMessageBuilder data(List data) { - this.data = data; - return this; - } - - public WxMpTemplateMessageBuilder from(WxMpTemplateMessage origin) { - this.toUser(origin.toUser); - this.templateId(origin.templateId); - this.url(origin.url); - this.data(origin.data); - return this; - } - - public WxMpTemplateMessageBuilder miniProgram(MiniProgram miniProgram) { - this.miniProgram = miniProgram; - return this; - } - - public WxMpTemplateMessage build() { - WxMpTemplateMessage m = new WxMpTemplateMessage(); - m.toUser = this.toUser; - m.templateId = this.templateId; - m.url = this.url; - m.data = this.data; - m.miniProgram = this.miniProgram; - return m; - } } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxQrCodeTicketAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxQrCodeTicketAdapter.java index bd1bbd90ff..80b5bc90ed 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxQrCodeTicketAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxQrCodeTicketAdapter.java @@ -28,7 +28,7 @@ public WxMpQrCodeTicket deserialize(JsonElement json, Type typeOfT, JsonDeserial ticket.setTicket(GsonHelper.getAsString(ticketJsonObject.get("ticket"))); } if (ticketJsonObject.get("expire_seconds") != null && !ticketJsonObject.get("expire_seconds").isJsonNull()) { - ticket.setExpire_seconds(GsonHelper.getAsPrimitiveInt(ticketJsonObject.get("expire_seconds"))); + ticket.setExpireSeconds(GsonHelper.getAsPrimitiveInt(ticketJsonObject.get("expire_seconds"))); } if (ticketJsonObject.get("url") != null && !ticketJsonObject.get("url").isJsonNull()) { ticket.setUrl(GsonHelper.getAsString(ticketJsonObject.get("url"))); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java index 216eec77f0..862a50c3ea 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java @@ -37,7 +37,7 @@ public void testQrCodeCreateTmpTicket(int sceneId) throws WxErrorException { WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateTmpTicket(sceneId, null); Assert.assertNotNull(ticket.getUrl()); Assert.assertNotNull(ticket.getTicket()); - Assert.assertTrue(ticket.getExpire_seconds() != -1); + Assert.assertTrue(ticket.getExpireSeconds() != -1); System.out.println(ticket); } @@ -47,7 +47,7 @@ public void testQrCodeCreateTmpTicketWithSceneStr(String sceneStr) throws WxErro WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateTmpTicket(sceneStr, null); Assert.assertNotNull(ticket.getUrl()); Assert.assertNotNull(ticket.getTicket()); - Assert.assertTrue(ticket.getExpire_seconds() != -1); + Assert.assertTrue(ticket.getExpireSeconds() != -1); System.out.println(ticket); } @@ -56,7 +56,7 @@ public void testQrCodeCreateLastTicket(int sceneId) throws WxErrorException { WxMpQrCodeTicket ticket = this.wxService.getQrcodeService().qrCodeCreateLastTicket(sceneId); Assert.assertNotNull(ticket.getUrl()); Assert.assertNotNull(ticket.getTicket()); - Assert.assertTrue(ticket.getExpire_seconds() == -1); + Assert.assertTrue(ticket.getExpireSeconds() == -1); System.out.println(ticket); } From 5db97256858d9e6815f24255c16eafc7c6f6ddb3 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 25 Oct 2017 14:45:51 +0800 Subject: [PATCH 126/165] =?UTF-8?q?=E4=BD=BF=E7=94=A8lombok=E7=9A=84@Data?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E7=AE=80=E5=8C=96mp=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E6=89=80=E6=9C=89bean=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kefu/request/WxMpKfAccountRequest.java | 2 + .../bean/message/WxMpXmlOutMusicMessage.java | 46 ++++++++++++++++++- .../bean/message/WxMpXmlOutVideoMessage.java | 25 ++++++++++ .../mp/bean/store/WxMpStoreBaseInfo.java | 5 +- .../mp/bean/template/WxMpTemplateMessage.java | 8 +++- .../weixin/mp/builder/kefu/MusicBuilder.java | 4 +- .../mp/builder/outxml/VideoBuilder.java | 6 +-- .../mp/bean/message/WxMpXmlMessageTest.java | 4 +- .../message/WxMpXmlOutMusicMessageTest.java | 2 +- .../result/WxMpCurrentAutoReplyInfoTest.java | 4 +- 10 files changed, 92 insertions(+), 14 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfAccountRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfAccountRequest.java index fdbb705813..273282a6a9 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfAccountRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/request/WxMpKfAccountRequest.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.kefu.request; import com.google.gson.annotations.SerializedName; +import lombok.Builder; import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -8,6 +9,7 @@ import java.io.Serializable; @Data +@Builder public class WxMpKfAccountRequest implements Serializable { private static final long serialVersionUID = -5451863610674856927L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java index c06b76f306..b2649ddc5a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java @@ -3,11 +3,15 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; +import java.io.Serializable; + @XStreamAlias("xml") @Data +@EqualsAndHashCode(callSuper = true) public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = -4159937804975448945L; @@ -20,7 +24,8 @@ public WxMpXmlOutMusicMessage() { @XStreamAlias("Music") @Data - public static class Music { + public static class Music implements Serializable { + private static final long serialVersionUID = -5492592401691895334L; @XStreamAlias("Title") @XStreamConverter(value = XStreamCDataConverter.class) @@ -41,7 +46,46 @@ public static class Music { @XStreamAlias("HQMusicUrl") @XStreamConverter(value = XStreamCDataConverter.class) private String hqMusicUrl; + } + + public String getTitle() { + return this.music.title; + } + + public void setTitle(String title) { + this.music.title = title; + } + + public String getDescription() { + return this.music.description; + } + + public void setDescription(String description) { + this.music.description = description; + } + + public String getThumbMediaId() { + return this.music.thumbMediaId; + } + + public void setThumbMediaId(String thumbMediaId) { + this.music.thumbMediaId = thumbMediaId; + } + + public String getMusicUrl() { + return this.music.musicUrl; + } + + public void setMusicUrl(String musicUrl) { + this.music.musicUrl = musicUrl; + } + + public String getHqMusicUrl() { + return this.music.hqMusicUrl; + } + public void setHqMusicUrl(String hqMusicUrl) { + this.music.hqMusicUrl = hqMusicUrl; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java index fe8ed8ebfb..288ca8619d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java @@ -3,6 +3,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @@ -10,6 +11,7 @@ @XStreamAlias("xml") @Data +@EqualsAndHashCode(callSuper = true) public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = 1745902309380113978L; @@ -39,4 +41,27 @@ public static class Video implements Serializable { } + public String getMediaId() { + return this.video.mediaId; + } + + public void setMediaId(String mediaId) { + this.video.mediaId = mediaId; + } + + public String getTitle() { + return this.video.title; + } + + public void setTitle(String title) { + this.video.title = title; + } + + public String getDescription() { + return this.video.description; + } + + public void setDescription(String description) { + this.video.description = description; + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java index 86614218eb..007826bb67 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java @@ -3,6 +3,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.annotations.SerializedName; +import lombok.Builder; import lombok.Data; import me.chanjar.weixin.common.annotation.Required; import me.chanjar.weixin.common.util.ToStringUtils; @@ -21,6 +22,7 @@ * @author Binary Wang */ @Data +@Builder public class WxMpStoreBaseInfo implements Serializable { private static final long serialVersionUID = 829577606838118218L; @@ -98,7 +100,8 @@ public class WxMpStoreBaseInfo implements Serializable { */ @Required @SerializedName("offset_type") - private Integer offsetType = 1; + @Builder.Default + private final Integer offsetType = 1; /** * longitude * 门店所在地理位置的经度 diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java index 2eeea5fd34..aa5a180487 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.template; +import lombok.Builder; import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -11,6 +12,7 @@ * 参考 http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN 发送模板消息接口部分 */ @Data +@Builder public class WxMpTemplateMessage implements Serializable { private static final long serialVersionUID = 5063374783759519418L; @@ -42,9 +44,11 @@ public class WxMpTemplateMessage implements Serializable { /** * 模板数据 */ - private List data = new ArrayList<>(); + @Builder.Default + private final List data = new ArrayList<>(); - public WxMpTemplateMessage() { + public void addWxMpTemplateData(WxMpTemplateData datum) { + this.data.add(datum); } public String toJson() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MusicBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MusicBuilder.java index 8d23bacd4e..0002b2c0df 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MusicBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MusicBuilder.java @@ -47,8 +47,8 @@ public MusicBuilder description(String description) { return this; } - public MusicBuilder thumbMediaId(String thumb_media_id) { - this.thumbMediaId = thumb_media_id; + public MusicBuilder thumbMediaId(String thumbMediaId) { + this.thumbMediaId = thumbMediaId; return this; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/VideoBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/VideoBuilder.java index e9f7c85b42..9a965f5b78 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/VideoBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/outxml/VideoBuilder.java @@ -32,9 +32,9 @@ public VideoBuilder mediaId(String mediaId) { public WxMpXmlOutVideoMessage build() { WxMpXmlOutVideoMessage m = new WxMpXmlOutVideoMessage(); setCommon(m); - m.setTitle(this.title); - m.setDescription(this.description); - m.setMediaId(this.mediaId); + m.getVideo().setTitle(this.title); + m.getVideo().setDescription(this.description); + m.getVideo().setMediaId(this.mediaId); return m; } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java index 9c2bbf56ac..8bcbc0de24 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java @@ -86,7 +86,7 @@ public void testFromXml() { assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); assertEquals(wxMessage.getSendLocationInfo().getScale(), "15"); assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号"); - assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi"); + assertEquals(wxMessage.getSendLocationInfo().getPoiName(), "wo de poi"); } public void testFromXml2() { @@ -167,7 +167,7 @@ public void testFromXml2() { assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); assertEquals(wxMessage.getSendLocationInfo().getScale(), "15"); assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号"); - assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi"); + assertEquals(wxMessage.getSendLocationInfo().getPoiName(), "wo de poi"); } } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessageTest.java index f75e6321e6..592a6a50ed 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessageTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessageTest.java @@ -13,7 +13,7 @@ public void test() { m.setHqMusicUrl("hQMusicUrl"); m.setMusicUrl("musicUrl"); m.setThumbMediaId("thumbMediaId"); - m.setCreateTime(1122l); + m.setCreateTime(1122L); m.setFromUserName("fromUser"); m.setToUserName("toUser"); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java index da2cddff40..dbed60bac9 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/result/WxMpCurrentAutoReplyInfoTest.java @@ -145,8 +145,8 @@ public void testFromJson() throws Exception { WxMpCurrentAutoReplyInfo autoReplyInfo = WxMpCurrentAutoReplyInfo.fromJson(json); assertNotNull(autoReplyInfo); - assertTrue(autoReplyInfo.getAddFriendReplyOpen()); - assertTrue(autoReplyInfo.getAutoReplyOpen()); + assertTrue(autoReplyInfo.getIsAddFriendReplyOpen()); + assertTrue(autoReplyInfo.getIsAutoReplyOpen()); assertNotNull(autoReplyInfo.getAddFriendAutoReplyInfo()); assertNotNull(autoReplyInfo.getMessageDefaultAutoReplyInfo()); assertTrue(autoReplyInfo.getKeywordAutoReplyInfo().getList().size() > 0); From 8a31c188ca9c09f4278634c530759f360e185160 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 26 Oct 2017 18:57:39 +0800 Subject: [PATCH 127/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp/api/impl/WxMpStoreServiceImplTest.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java index 3970072bfc..e6f4c15570 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java @@ -30,10 +30,17 @@ public class WxMpStoreServiceImplTest { */ public void testAdd() throws WxErrorException { this.wxMpService.getStoreService() - .add(WxMpStoreBaseInfo.builder().businessName("haha").branchName("abc") - .province("aaa").district("aaa").telephone("122").address("abc").categories(new String[]{"美食,江浙菜"}) + .add(WxMpStoreBaseInfo.builder() + .businessName("haha") + .branchName("abc") + .province("aaa") + .district("aaa") + .telephone("122") + .address("abc") + .categories(new String[]{"美食,江浙菜"}) .longitude(new BigDecimal("115.32375")) - .latitude(new BigDecimal("25.097486")).city("aaa").offsetType(1) + .latitude(new BigDecimal("25.097486")) + .city("aaa") .build()); // 以下运行会抛异常 this.wxMpService.getStoreService().add(WxMpStoreBaseInfo.builder().build()); @@ -41,9 +48,14 @@ public void testAdd() throws WxErrorException { public void testUpdate() throws WxErrorException { this.wxMpService.getStoreService() - .update(WxMpStoreBaseInfo.builder().poiId("291503654").telephone("020-12345678") - .sid("aaa").avgPrice(35).openTime("8:00-20:00").special("免费wifi,外卖服务") - .introduction("麦当劳是全球大型跨国连锁餐厅,1940 年创立于美国,在世界上大约拥有3 万间分店。主要售卖汉堡包,以及薯条、炸鸡、汽水、冰品、沙拉、水果等快餐食品").offsetType(1) + .update(WxMpStoreBaseInfo.builder() + .poiId("291503654") + .telephone("020-12345678") + .sid("aaa") + .avgPrice(35) + .openTime("8:00-20:00") + .special("免费wifi,外卖服务") + .introduction("麦当劳是全球大型跨国连锁餐厅,1940 年创立于美国,在世界上大约拥有3 万间分店。主要售卖汉堡包,以及薯条、炸鸡、汽水、冰品、沙拉、水果等快餐食品") .build()); } From b39380f8e8cecf072cc9cf004cf9d1b3c22340a3 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 26 Oct 2017 18:58:29 +0800 Subject: [PATCH 128/165] =?UTF-8?q?=E4=B8=BA=E5=85=BC=E5=AE=B9=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=89=88=E6=9C=AC=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E4=B8=A4=E4=B8=AA=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binarywang/wxpay/util/SignUtils.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java index 745514d00a..0cd40f7d2e 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java @@ -28,7 +28,23 @@ public class SignUtils { private static final Logger log = LoggerFactory.getLogger(SignUtils.class); /** - * 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3) + * 请参考并使用 {@link #createSign(Object, String, String, boolean)} + */ + @Deprecated + public static String createSign(Object xmlBean, String signKey) { + return createSign(BeanUtils.xmlBean2Map(xmlBean), signKey); + } + + /** + * 请参考并使用 {@link #createSign(Map, String, String, boolean)} + */ + @Deprecated + public static String createSign(Map params, String signKey) { + return createSign(params, null, signKey, false); + } + + /** + * 微信支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3) * * @param xmlBean Bean里的属性如果存在XML注解,则使用其作为key,否则使用变量名 * @param signType 签名类型,如果为空,则默认为MD5 @@ -41,7 +57,7 @@ public static String createSign(Object xmlBean, String signType, String signKey, } /** - * 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3) + * 微信支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3) * * @param params 参数信息 * @param signType 签名类型,如果为空,则默认为MD5 @@ -97,7 +113,6 @@ private static String createHMACSha256Sign(String message, String key) { * @param signType 签名类型,如果为空,则默认为MD5 * @param signKey 校验的签名Key * @return true - 签名校验成功,false - 签名校验失败 - * @see #checkSign(Map, String, String) */ public static boolean checkSign(Object xmlBean, String signType, String signKey) { return checkSign(BeanUtils.xmlBean2Map(xmlBean), signType, signKey); @@ -110,7 +125,6 @@ public static boolean checkSign(Object xmlBean, String signType, String signKey) * @param signType 签名类型,如果为空,则默认为MD5 * @param signKey 校验的签名Key * @return true - 签名校验成功,false - 签名校验失败 - * @see #checkSign(Map, String, String) */ public static boolean checkSign(Map params, String signType, String signKey) { String sign = createSign(params, signType, signKey, false); From c7cfc9aa45caa4e13e723ba5c5bd7b9bf07ac670 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 27 Oct 2017 18:08:35 +0800 Subject: [PATCH 129/165] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BF=AE=E5=A4=8Dxml?= =?UTF-8?q?Bean2Map=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/chanjar/weixin/common/util/BeanUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java index 9e52aa2234..b9a22600b7 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -88,7 +89,8 @@ public static Map xmlBean2Map(Object bean) { if (field.isAnnotationPresent(XStreamAlias.class)) { result.put(field.getAnnotation(XStreamAlias.class).value(), field.get(bean).toString()); - } else { + } else if (!Modifier.isStatic(field.getModifiers())) { + //忽略掉静态成员变量 result.put(field.getName(), field.get(bean).toString()); } From 05a680c98bd9c65019bcf7260e4872b927208d58 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 27 Oct 2017 18:14:13 +0800 Subject: [PATCH 130/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.8.5.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 447c3452ca..b5f33fe5ef 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.8.4.BETA + 2.8.5.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index caf28d92d4..5f845c6d0d 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.4.BETA + 2.8.5.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 2a20361aeb..9058adc9d7 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.4.BETA + 2.8.5.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 059aa8cb7a..a05c45c3cc 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.4.BETA + 2.8.5.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index c0c6b8ee80..61a45cf0d4 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.4.BETA + 2.8.5.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 01cfe29939..955201c572 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.8.4.BETA + 2.8.5.BETA 4.0.0 From 5231f8c9691dfd524c620695f1620e1d01794430 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 30 Oct 2017 10:52:54 +0800 Subject: [PATCH 131/165] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WxPayServiceAbstractImpl.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index 1d5632bb03..07c3627998 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -213,14 +213,13 @@ public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException String timestamp = String.valueOf(System.currentTimeMillis() / 1000); String nonceStr = String.valueOf(System.currentTimeMillis()); - Object payResult = null; switch (request.getTradeType()) { case TradeType.NATIVE: { - payResult = WxPayNativeOrderResult.builder() + return (T) WxPayNativeOrderResult.builder() .codeUrl(unifiedOrderResult.getCodeURL()) .build(); - break; } + case TradeType.APP: { // APP支付绑定的是微信开放平台上的账号,APPID为开放平台上绑定APP后发放的参数 String appId = this.getConfig().getAppId(); @@ -235,7 +234,7 @@ public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException configMap.put("noncestr", nonceStr); configMap.put("appid", appId); - payResult = WxPayAppOrderResult.builder() + return (T) WxPayAppOrderResult.builder() .sign(SignUtils.createSign(configMap, null, this.getConfig().getMchKey(), false)) .prepayId(prepayId) .partnerId(partnerId) @@ -244,26 +243,33 @@ public T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException .timeStamp(timestamp) .nonceStr(nonceStr) .build(); - break; } + case TradeType.JSAPI: { - payResult = WxPayMpOrderResult.builder() + String signType = SignType.MD5; + WxPayMpOrderResult payResult = WxPayMpOrderResult.builder() .appId(unifiedOrderResult.getAppid()) .timeStamp(timestamp) .nonceStr(nonceStr) .packageValue("prepay_id=" + prepayId) - .signType(SignType.MD5) + .signType(signType) .build(); - ((WxPayMpOrderResult) payResult) - .setPaySign(SignUtils.createSign(payResult, null, this.getConfig().getMchKey(), false)); - break; + + payResult.setPaySign( + SignUtils.createSign( + payResult, + signType, + this.getConfig().getMchKey(), + false) + ); + return (T) payResult; } + default: { throw new WxPayException("该交易类型暂不支持"); } } - return (T) payResult; } @Override From 8a587174a1f71cef762b6d403ee37f653a5f5085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=B3=A2?= Date: Thu, 2 Nov 2017 14:50:00 +0800 Subject: [PATCH 132/165] =?UTF-8?q?#361=20WxMpKefuMessage=E7=B1=BB?= =?UTF-8?q?=E7=9A=84=E5=86=85=E9=83=A8=E7=B1=BB=E5=AE=9E=E7=8E=B0=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java index bf5b019432..c7a4c81091 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java @@ -110,7 +110,9 @@ public String toJson() { } @Data - public static class WxArticle { + public static class WxArticle implements Serializable { + private static final long serialVersionUID = 5145137235440507379L; + private String title; private String description; private String url; From 29149424ac52f69629db9b23c27de489980b9c53 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 3 Nov 2017 12:04:33 +0800 Subject: [PATCH 133/165] =?UTF-8?q?#362=20=E4=BF=AE=E5=A4=8Dokhttp?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=9A=84qrcode=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E4=B8=8B=E8=BD=BD=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/common/util/fs/FileUtils.java | 31 +++++------------ .../okhttp/OkhttpQrCodeRequestExecutor.java | 34 ++++++++++++------- .../api/impl/WxMpQrcodeServiceImplTest.java | 8 +++++ .../weixin/mp/api/test/ApiTestModule.java | 1 - 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java index df031b3371..9d24d6d3f5 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/fs/FileUtils.java @@ -1,52 +1,37 @@ package me.chanjar.weixin.common.util.fs; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; public class FileUtils { - /** * 创建临时文件 * - * @param inputStream + * @param inputStream 输入文件流 * @param name 文件名 * @param ext 扩展名 * @param tmpDirFile 临时文件夹目录 */ public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException { - File tmpFile; - if (tmpDirFile == null) { - tmpFile = File.createTempFile(name, '.' + ext); - } else { - tmpFile = File.createTempFile(name, '.' + ext, tmpDirFile); - } - - tmpFile.deleteOnExit(); - - try (FileOutputStream fos = new FileOutputStream(tmpFile)) { - int read = 0; - byte[] bytes = new byte[1024 * 100]; - while ((read = inputStream.read(bytes)) != -1) { - fos.write(bytes, 0, read); - } + File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile); - fos.flush(); - return tmpFile; - } + resultFile.deleteOnExit(); + org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, resultFile); + return resultFile; } /** * 创建临时文件 * - * @param inputStream + * @param inputStream 输入文件流 * @param name 文件名 * @param ext 扩展名 */ public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException { - return createTmpFile(inputStream, name, ext, null); + return createTmpFile(inputStream, name, ext, Files.createTempDirectory("weixin-java-tools-temp").toFile()); } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java index 6feb137925..79fd294e24 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java @@ -7,21 +7,22 @@ import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; import me.chanjar.weixin.mp.util.http.QrCodeRequestExecutor; - -import okhttp3.*; -import okio.BufferedSink; -import okio.Okio; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.net.URLEncoder; import java.util.UUID; /** - * Created by ecoolper on 2017/5/5. + * + * @author ecoolper + * @date 2017/5/5 */ public class OkhttpQrCodeRequestExecutor extends QrCodeRequestExecutor { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -31,9 +32,18 @@ public OkhttpQrCodeRequestExecutor(RequestHttp requestHttp) { } @Override - public File execute(String uri, WxMpQrCodeTicket data) throws WxErrorException, IOException { + public File execute(String uri, WxMpQrCodeTicket ticket) throws WxErrorException, IOException { logger.debug("OkhttpQrCodeRequestExecutor is running"); - //得到httpClient + + if (ticket != null) { + if (uri.indexOf('?') == -1) { + uri += '?'; + } + uri += uri.endsWith("?") + ? "ticket=" + URLEncoder.encode(ticket.getTicket(), "UTF-8") + : "&ticket=" + URLEncoder.encode(ticket.getTicket(), "UTF-8"); + } + OkHttpClient client = requestHttp.getRequestHttpClient(); Request request = new Request.Builder().url(uri).get().build(); Response response = client.newCall(request).execute(); @@ -42,12 +52,10 @@ public File execute(String uri, WxMpQrCodeTicket data) throws WxErrorException, String responseContent = response.body().string(); throw new WxErrorException(WxError.fromJson(responseContent)); } - File temp = File.createTempFile(UUID.randomUUID().toString(), ".png"); - try (BufferedSink sink = Okio.buffer(Okio.sink(temp))) { - sink.writeAll(response.body().source()); + + try (InputStream inputStream = response.body().byteStream()) { + return FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), "jpg"); } - temp.deleteOnExit(); - return temp; } } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java index 862a50c3ea..75eb291a04 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImplTest.java @@ -5,11 +5,13 @@ import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.test.ApiTestModule; import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.RandomStringUtils; import org.testng.*; import org.testng.annotations.*; import java.io.File; +import java.io.IOException; /** * 测试用户相关的接口 @@ -65,6 +67,12 @@ public void testQrCodePicture() throws WxErrorException { File file = this.wxService.getQrcodeService().qrCodePicture(ticket); Assert.assertNotNull(file); System.out.println(file.getAbsolutePath()); + + try { + FileUtils.copyFile(file,new File("d:\\t.jpg")); + } catch (IOException e) { + e.printStackTrace(); + } } public void testQrCodePictureUrl() throws WxErrorException { diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java index 2a9421a499..030da968e9 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java @@ -6,7 +6,6 @@ import me.chanjar.weixin.common.util.xml.XStreamInitializer; import me.chanjar.weixin.mp.api.WxMpConfigStorage; import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.impl.WxMpServiceApacheHttpClientImpl; import me.chanjar.weixin.mp.api.impl.WxMpServiceOkHttpImpl; import java.io.IOException; From 73017552eb188d0bf0d63ec864affa3ecbcc9bfc Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 6 Nov 2017 16:20:54 +0800 Subject: [PATCH 134/165] =?UTF-8?q?WxMpTemplateMessage=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=9E=84=E9=80=A0=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java index aa5a180487..8dd4f11703 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java @@ -2,6 +2,7 @@ import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -13,6 +14,7 @@ */ @Data @Builder +@NoArgsConstructor public class WxMpTemplateMessage implements Serializable { private static final long serialVersionUID = 5063374783759519418L; From 96d385664f0458fd44f2531b824462e53b9e3582 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 6 Nov 2017 16:21:43 +0800 Subject: [PATCH 135/165] =?UTF-8?q?=E7=AD=BE=E5=90=8D=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E9=87=8C=E5=BF=BD=E7=95=A5=E5=87=A0=E4=B8=AA=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89key=EF=BC=8C=E4=BB=A5=E5=85=8D=E5=AF=B9=E7=AD=BE?= =?UTF-8?q?=E5=90=8D=E9=80=A0=E6=88=90=E5=B9=B2=E6=89=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/github/binarywang/wxpay/util/SignUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java index 0cd40f7d2e..9928447575 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java @@ -75,7 +75,9 @@ public static String createSign(Map params, String signType, Str if (isIgnoreSignType && "sign_type".equals(key)) { shouldSign = false; } else if (StringUtils.isNotEmpty(value) - && !Lists.newArrayList("sign", "key").contains(key)) { + && !Lists.newArrayList( + "sign", "key", "xmlString", "xmlDoc", "couponList").contains(key) + ) { shouldSign = true; } From c85190259ae320d0c3e332559cbdd10e620b147d Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 6 Nov 2017 19:03:57 +0800 Subject: [PATCH 136/165] =?UTF-8?q?WxMpTemplateMessage=E7=B1=BB=E5=8E=BB?= =?UTF-8?q?=E6=8E=89@NoArgsConstructor=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java index 8dd4f11703..aa5a180487 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java @@ -2,7 +2,6 @@ import lombok.Builder; import lombok.Data; -import lombok.NoArgsConstructor; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -14,7 +13,6 @@ */ @Data @Builder -@NoArgsConstructor public class WxMpTemplateMessage implements Serializable { private static final long serialVersionUID = 5063374783759519418L; From 092b8392347d3914aee53ec1955b4bafba2ea481 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 6 Nov 2017 19:14:44 +0800 Subject: [PATCH 137/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/binarywang/wxpay/bean/result/WxPayBaseResult.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java index 93a3426097..1e0527ebda 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBaseResult.java @@ -249,7 +249,7 @@ public void checkResult(WxPayServiceAbstractImpl wxPayService, String signType, errorMsg.append(",错误详情:").append(getErrCodeDes()); } - this.getLogger().error("\n结果业务代码异常,返回結果:{},\n{}", map, errorMsg.toString()); + this.getLogger().error("\n结果业务代码异常,返回结果:{},\n{}", map, errorMsg.toString()); throw WxPayException.from(this); } } From 160ace5fab07c32b967addd4f1fd39e30e9aef7c Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 7 Nov 2017 10:30:26 +0800 Subject: [PATCH 138/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.8.6.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index b5f33fe5ef..7eb78c33ca 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.8.5.BETA + 2.8.6.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 5f845c6d0d..61839da214 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.5.BETA + 2.8.6.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 9058adc9d7..64dfe320a6 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.5.BETA + 2.8.6.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index a05c45c3cc..5b1a2772fa 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.5.BETA + 2.8.6.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 61a45cf0d4..3405388824 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.5.BETA + 2.8.6.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 955201c572..b4940b2712 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.8.5.BETA + 2.8.6.BETA 4.0.0 From f65e2fbdb8c4d4609cc52a6a0333f451e8466b66 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 7 Nov 2017 11:03:39 +0800 Subject: [PATCH 139/165] =?UTF-8?q?=E8=A7=84=E8=8C=83=E7=B1=BB=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tExecutor.java => BaseMediaDownloadRequestExecutor.java} | 6 +++--- .../http/apache/ApacheMediaDownloadRequestExecutor.java | 4 ++-- .../http/jodd/JoddHttpMediaDownloadRequestExecutor.java | 4 ++-- .../http/okhttp/OkHttpMediaDownloadRequestExecutor.java | 4 ++-- .../me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImpl.java | 4 ++-- .../wx/miniapp/api/impl/WxMaMediaServiceImpl.java | 4 ++-- .../chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) rename weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/{MediaDownloadRequestExecutor.java => BaseMediaDownloadRequestExecutor.java} (85%) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/BaseMediaDownloadRequestExecutor.java similarity index 85% rename from weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java rename to weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/BaseMediaDownloadRequestExecutor.java index d948859748..990e162008 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/BaseMediaDownloadRequestExecutor.java @@ -12,11 +12,11 @@ * * @author Daniel Qian */ -public abstract class MediaDownloadRequestExecutor implements RequestExecutor { - +public abstract class BaseMediaDownloadRequestExecutor implements RequestExecutor { protected RequestHttp requestHttp; protected File tmpDirFile; - public MediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { + + public BaseMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { this.requestHttp = requestHttp; this.tmpDirFile = tmpDirFile; } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java index 0a5a504873..be2d91b84f 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMediaDownloadRequestExecutor.java @@ -4,7 +4,7 @@ import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; import me.chanjar.weixin.common.util.http.HttpResponseProxy; -import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; +import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; @@ -23,7 +23,7 @@ /** * Created by ecoolper on 2017/5/5. */ -public class ApacheMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor { +public class ApacheMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor { public ApacheMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { super(requestHttp, tmpDirFile); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java index bbd8bec47c..f3442aaa6d 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaDownloadRequestExecutor.java @@ -9,7 +9,7 @@ import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; import me.chanjar.weixin.common.util.http.HttpResponseProxy; -import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; +import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; @@ -22,7 +22,7 @@ /** * Created by ecoolper on 2017/5/5. */ -public class JoddHttpMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor { +public class JoddHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor { public JoddHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { super(requestHttp, tmpDirFile); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java index 0923527b71..2eb71b52f1 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java @@ -3,7 +3,7 @@ import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.http.HttpResponseProxy; -import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; +import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -21,7 +21,7 @@ /** * Created by ecoolper on 2017/5/5. */ -public class OkHttpMediaDownloadRequestExecutor extends MediaDownloadRequestExecutor { +public class OkHttpMediaDownloadRequestExecutor extends BaseMediaDownloadRequestExecutor { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public OkHttpMediaDownloadRequestExecutor(RequestHttp requestHttp, File tmpDirFile) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImpl.java index 1364550aac..706ba2e01d 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImpl.java @@ -3,7 +3,7 @@ import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; -import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; +import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.cp.api.WxCpMediaService; import me.chanjar.weixin.cp.api.WxCpService; @@ -43,7 +43,7 @@ public WxMediaUploadResult upload(String mediaType, File file) throws WxErrorExc public File download(String mediaId) throws WxErrorException { String url = "https://qyapi.weixin.qq.com/cgi-bin/media/get"; return this.mainService.execute( - MediaDownloadRequestExecutor.create(this.mainService.getRequestHttp(), + BaseMediaDownloadRequestExecutor.create(this.mainService.getRequestHttp(), this.mainService.getWxCpConfigStorage().getTmpDirFile()), url, "media_id=" + mediaId); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java index 71c42e615e..b00a20a143 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java @@ -6,7 +6,7 @@ import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; -import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; +import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestExecutor; @@ -44,7 +44,7 @@ public WxMediaUploadResult uploadMedia(String mediaType, File file) throws WxErr @Override public File getMedia(String mediaId) throws WxErrorException { try { - RequestExecutor executor = MediaDownloadRequestExecutor + RequestExecutor executor = BaseMediaDownloadRequestExecutor .create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("wxma").toFile()); return this.wxMaService.execute(executor, MEDIA_GET_URL, "media_id=" + mediaId); } catch (IOException e) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java index 91c3fc33fe..23f7fb2514 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java @@ -5,7 +5,7 @@ import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.fs.FileUtils; -import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor; +import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.mp.api.WxMpMaterialService; @@ -50,7 +50,7 @@ public WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErr @Override public File mediaDownload(String mediaId) throws WxErrorException { return this.wxMpService.execute( - MediaDownloadRequestExecutor.create(this.wxMpService.getRequestHttp(), this.wxMpService.getWxMpConfigStorage().getTmpDirFile()), + BaseMediaDownloadRequestExecutor.create(this.wxMpService.getRequestHttp(), this.wxMpService.getWxMpConfigStorage().getTmpDirFile()), MEDIA_GET_URL, "media_id=" + mediaId); } From 2146372502d8c93b72a8e0ef677d6a0620a4a416 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 7 Nov 2017 11:41:55 +0800 Subject: [PATCH 140/165] =?UTF-8?q?=E9=87=8D=E6=9E=84WxConsts=E7=B1=BB?= =?UTF-8?q?=EF=BC=8C=E5=AF=B9=E6=89=80=E6=9C=89=E5=B8=B8=E9=87=8F=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E5=88=86=E7=B1=BB=E6=95=B4=E7=90=86=EF=BC=8C=E4=BE=BF?= =?UTF-8?q?=E4=BA=8E=E9=98=85=E8=AF=BB=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/common/api/WxConsts.java | 338 ++++++++++-------- .../chanjar/weixin/cp/bean/WxCpMessage.java | 15 +- .../weixin/cp/bean/WxCpXmlMessage.java | 25 +- .../cp/bean/WxCpXmlOutImageMessage.java | 2 +- .../weixin/cp/bean/WxCpXmlOutNewsMessage.java | 2 +- .../weixin/cp/bean/WxCpXmlOutTextMessage.java | 2 +- .../cp/bean/WxCpXmlOutVideoMessage.java | 2 +- .../cp/bean/WxCpXmlOutVoiceMessage.java | 2 +- .../cp/bean/messagebuilder/BaseBuilder.java | 2 +- .../cp/bean/messagebuilder/FileBuilder.java | 2 +- .../cp/bean/messagebuilder/ImageBuilder.java | 2 +- .../cp/bean/messagebuilder/MpnewsBuilder.java | 2 +- .../cp/bean/messagebuilder/NewsBuilder.java | 2 +- .../cp/bean/messagebuilder/TextBuilder.java | 2 +- .../bean/messagebuilder/TextCardBuilder.java | 2 +- .../cp/bean/messagebuilder/VideoBuilder.java | 2 +- .../cp/bean/messagebuilder/VoiceBuilder.java | 2 +- .../cp/util/json/WxCpMessageGsonAdapter.java | 16 +- .../weixin/cp/api/WxCpMessageAPITest.java | 3 +- .../weixin/cp/api/WxCpMessageRouterTest.java | 30 +- .../cp/api/impl/WxCpMediaServiceImplTest.java | 10 +- .../cp/api/impl/WxCpMenuServiceImplTest.java | 10 +- .../weixin/cp/bean/WxCpXmlMessageTest.java | 4 +- .../api/impl/WxMaMsgServiceImplTest.java | 4 +- .../wx/miniapp/bean/WxMaKefuMessageTest.java | 4 +- .../wx/miniapp/bean/WxMaMessageTest.java | 4 +- .../mp/api/impl/WxMpMaterialServiceImpl.java | 2 +- .../mp/bean/WxMpMassOpenIdsMessage.java | 11 +- .../mp/bean/WxMpMassPreviewMessage.java | 11 +- .../weixin/mp/bean/WxMpMassTagMessage.java | 11 +- .../weixin/mp/bean/kefu/WxMpKefuMessage.java | 17 +- .../mp/bean/message/WxMpXmlMessage.java | 27 +- .../bean/message/WxMpXmlOutImageMessage.java | 2 +- .../bean/message/WxMpXmlOutMusicMessage.java | 2 +- .../bean/message/WxMpXmlOutNewsMessage.java | 2 +- .../bean/message/WxMpXmlOutTextMessage.java | 2 +- .../WxMpXmlOutTransferKefuMessage.java | 2 +- .../bean/message/WxMpXmlOutVideoMessage.java | 2 +- .../bean/message/WxMpXmlOutVoiceMessage.java | 2 +- .../weixin/mp/builder/kefu/ImageBuilder.java | 2 +- .../weixin/mp/builder/kefu/MpNewsBuilder.java | 2 +- .../weixin/mp/builder/kefu/MusicBuilder.java | 2 +- .../weixin/mp/builder/kefu/NewsBuilder.java | 2 +- .../weixin/mp/builder/kefu/TextBuilder.java | 2 +- .../weixin/mp/builder/kefu/VideoBuilder.java | 2 +- .../weixin/mp/builder/kefu/VoiceBuilder.java | 2 +- .../weixin/mp/builder/kefu/WxCardBuilder.java | 2 +- .../util/json/WxMpKefuMessageGsonAdapter.java | 16 +- .../WxMpMassOpenIdsMessageGsonAdapter.java | 20 +- .../WxMpMassPreviewMessageGsonAdapter.java | 20 +- .../json/WxMpMassTagMessageGsonAdapter.java | 20 +- .../weixin/mp/api/WxMpMessageRouterTest.java | 30 +- .../mp/api/impl/WxMpKefuServiceImplTest.java | 6 +- .../impl/WxMpMassMessageServiceImplTest.java | 20 +- .../api/impl/WxMpMaterialServiceImplTest.java | 24 +- .../mp/api/impl/WxMpMenuServiceImplTest.java | 10 +- .../mp/api/impl/WxMpServiceImplTest.java | 2 +- .../mp/bean/kefu/WxMpKefuMessageTest.java | 12 +- .../mp/bean/message/WxMpXmlMessageTest.java | 4 +- .../weixin/mp/demo/DemoImageHandler.java | 2 +- .../weixin/mp/demo/DemoOAuth2Handler.java | 2 +- .../weixin/mp/demo/WxMpDemoServer.java | 2 +- 62 files changed, 412 insertions(+), 378 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java index e416323e02..fac0843d22 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java @@ -3,187 +3,215 @@ import java.util.HashMap; import java.util.Map; +/** + * 微信开发所使用到的常量类 + * + * @author chanjarster & binarywang + */ public class WxConsts { - - /////////////////////// - // 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型 - /////////////////////// - public static final String XML_MSG_TEXT = "text"; - public static final String XML_MSG_IMAGE = "image"; - public static final String XML_MSG_VOICE = "voice"; - public static final String XML_MSG_SHORTVIDEO = "shortvideo"; - public static final String XML_MSG_VIDEO = "video"; - public static final String XML_MSG_NEWS = "news"; - public static final String XML_MSG_MUSIC = "music"; - public static final String XML_MSG_LOCATION = "location"; - public static final String XML_MSG_LINK = "link"; - public static final String XML_MSG_EVENT = "event"; - public static final String XML_MSG_DEVICE_TEXT = "device_text"; - public static final String XML_MSG_DEVICE_EVENT = "device_event"; - public static final String XML_MSG_DEVICE_STATUS = "device_status"; - public static final String XML_MSG_HARDWARE = "hardware"; - public static final String XML_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; - - /////////////////////// - // 主动发送消息(即客服消息)的消息类型 - /////////////////////// - public static final String CUSTOM_MSG_TEXT = "text";//文本消息 - public static final String CUSTOM_MSG_IMAGE = "image";//图片消息 - public static final String CUSTOM_MSG_VOICE = "voice";//语音消息 - public static final String CUSTOM_MSG_VIDEO = "video";//视频消息 - public static final String CUSTOM_MSG_MUSIC = "music";//音乐消息 - public static final String CUSTOM_MSG_NEWS = "news";//图文消息(点击跳转到外链) - public static final String CUSTOM_MSG_MPNEWS = "mpnews";//图文消息(点击跳转到图文消息页面) - public static final String CUSTOM_MSG_FILE = "file";//发送文件(CP专用) - public static final String CUSTOM_MSG_TEXTCARD = "textcard";//文本卡片消息(CP专用) - public static final String CUSTOM_MSG_WXCARD = "wxcard";//卡券消息 - public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; - public static final String CUSTOM_MSG_SAFE_NO = "0"; - public static final String CUSTOM_MSG_SAFE_YES = "1"; - - /////////////////////// - // 群发消息的消息类型 - /////////////////////// - public static final String MASS_MSG_NEWS = "mpnews"; - public static final String MASS_MSG_TEXT = "text"; - public static final String MASS_MSG_VOICE = "voice"; - public static final String MASS_MSG_IMAGE = "image"; - public static final String MASS_MSG_VIDEO = "mpvideo"; - - /////////////////////// - // 群发消息后微信端推送给服务器的反馈消息 - /////////////////////// - public static final String MASS_ST_SUCCESS = "send success"; - public static final String MASS_ST_FAIL = "send fail"; - public static final String MASS_ST_10001 = "err(10001)"; - public static final String MASS_ST_20001 = "err(20001)"; - public static final String MASS_ST_20004 = "err(20004)"; - public static final String MASS_ST_20002 = "err(20002)"; - public static final String MASS_ST_20006 = "err(20006)"; - public static final String MASS_ST_20008 = "err(20008)"; - public static final String MASS_ST_20013 = "err(20013)"; - public static final String MASS_ST_22000 = "err(22000)"; - public static final String MASS_ST_21000 = "err(21000)"; - /** - * 群发反馈消息代码所对应的文字描述 + * 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型 */ - public static final Map MASS_ST_2_DESC = new HashMap<>(); - - /////////////////////// - // 微信端推送过来的事件类型 - /////////////////////// - public static final String EVT_SUBSCRIBE = "subscribe"; - public static final String EVT_UNSUBSCRIBE = "unsubscribe"; - public static final String EVT_SCAN = "SCAN"; - public static final String EVT_LOCATION = "LOCATION"; - public static final String EVT_CLICK = "CLICK"; - public static final String EVT_VIEW = "VIEW"; - public static final String EVT_MASS_SEND_JOB_FINISH = "MASSSENDJOBFINISH"; - public static final String EVT_SCANCODE_PUSH = "scancode_push"; - public static final String EVT_SCANCODE_WAITMSG = "scancode_waitmsg"; - public static final String EVT_PIC_SYSPHOTO = "pic_sysphoto"; - public static final String EVT_PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; - public static final String EVT_PIC_WEIXIN = "pic_weixin"; - public static final String EVT_LOCATION_SELECT = "location_select"; - public static final String EVT_TEMPLATESENDJOBFINISH = "TEMPLATESENDJOBFINISH"; - public static final String EVT_ENTER_AGENT = "enter_agent"; - - /////////////////////// - // 上传多媒体文件的类型 - /////////////////////// - public static final String MEDIA_IMAGE = "image"; - public static final String MEDIA_VOICE = "voice"; - public static final String MEDIA_VIDEO = "video"; - public static final String MEDIA_THUMB = "thumb"; - public static final String MEDIA_FILE = "file"; - + public static class XmlMsgType { + public static final String TEXT = "text"; + public static final String IMAGE = "image"; + public static final String VOICE = "voice"; + public static final String SHORTVIDEO = "shortvideo"; + public static final String VIDEO = "video"; + public static final String NEWS = "news"; + public static final String MUSIC = "music"; + public static final String LOCATION = "location"; + public static final String LINK = "link"; + public static final String EVENT = "event"; + public static final String DEVICE_TEXT = "device_text"; + public static final String DEVICE_EVENT = "device_event"; + public static final String DEVICE_STATUS = "device_status"; + public static final String HARDWARE = "hardware"; + public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; + } - /////////////////////// - // 自定义菜单的按钮类型 - /////////////////////// - /** - * 点击推事件 - */ - public static final String BUTTON_CLICK = "click"; - /** - * 跳转URL - */ - public static final String BUTTON_VIEW = "view"; - /** - * 跳转到小程序 - */ - public static final String BUTTON_MINIPROGRAM = "miniprogram"; - /** - * 扫码推事件 - */ - public static final String BUTTON_SCANCODE_PUSH = "scancode_push"; /** - * 扫码推事件且弹出“消息接收中”提示框 + * 主动发送消息(即客服消息)的消息类型 */ - public static final String BUTTON_SCANCODE_WAITMSG = "scancode_waitmsg"; + public static class KefuMsgType { + public static final String TEXT = "text";//文本消息 + public static final String IMAGE = "image";//图片消息 + public static final String VOICE = "voice";//语音消息 + public static final String VIDEO = "video";//视频消息 + public static final String MUSIC = "music";//音乐消息 + public static final String NEWS = "news";//图文消息(点击跳转到外链) + public static final String MPNEWS = "mpnews";//图文消息(点击跳转到图文消息页面) + public static final String FILE = "file";//发送文件(CP专用) + public static final String TEXTCARD = "textcard";//文本卡片消息(CP专用) + public static final String WXCARD = "wxcard";//卡券消息 + public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; + } + /** - * 弹出系统拍照发图 + * 表示是否是保密消息,0表示否,1表示是,默认0 */ - public static final String BUTTON_PIC_SYSPHOTO = "pic_sysphoto"; + public static class KefuMsgSafe { + public static final String NO = "0"; + public static final String YES = "1"; + } + /** - * 弹出拍照或者相册发图 + * 群发消息的消息类型 */ - public static final String BUTTON_PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; + public static class MassMsgType { + public static final String MPNEWS = "mpnews"; + public static final String TEXT = "text"; + public static final String VOICE = "voice"; + public static final String IMAGE = "image"; + public static final String MPVIDEO = "mpvideo"; + } + /** - * 弹出微信相册发图器 + * 群发消息后微信端推送给服务器的反馈消息 */ - public static final String BUTTON_PIC_WEIXIN = "pic_weixin"; + public static class MassMsgStatus { + public static final String SEND_SUCCESS = "send success"; + public static final String SEND_FAIL = "send fail"; + public static final String ERR_10001 = "err(10001)"; + public static final String ERR_20001 = "err(20001)"; + public static final String ERR_20004 = "err(20004)"; + public static final String ERR_20002 = "err(20002)"; + public static final String ERR_20006 = "err(20006)"; + public static final String ERR_20008 = "err(20008)"; + public static final String ERR_20013 = "err(20013)"; + public static final String ERR_22000 = "err(22000)"; + public static final String ERR_21000 = "err(21000)"; + + /** + * 群发反馈消息代码所对应的文字描述 + */ + public static final Map STATUS_DESC = new HashMap<>(); + + static { + STATUS_DESC.put(SEND_SUCCESS, "发送成功"); + STATUS_DESC.put(SEND_FAIL, "发送失败"); + STATUS_DESC.put(ERR_10001, "涉嫌广告"); + STATUS_DESC.put(ERR_20001, "涉嫌政治"); + STATUS_DESC.put(ERR_20004, "涉嫌社会"); + STATUS_DESC.put(ERR_20002, "涉嫌色情"); + STATUS_DESC.put(ERR_20006, "涉嫌违法犯罪"); + STATUS_DESC.put(ERR_20008, "涉嫌欺诈"); + STATUS_DESC.put(ERR_20013, "涉嫌版权"); + STATUS_DESC.put(ERR_22000, "涉嫌互推_互相宣传"); + STATUS_DESC.put(ERR_21000, "涉嫌其他"); + } + } + /** - * 弹出地理位置选择器 + * 微信端推送过来的事件类型 */ - public static final String BUTTON_LOCATION_SELECT = "location_select"; + public static class EventType { + public static final String SUBSCRIBE = "subscribe"; + public static final String UNSUBSCRIBE = "unsubscribe"; + public static final String SCAN = "SCAN"; + public static final String LOCATION = "LOCATION"; + public static final String CLICK = "CLICK"; + public static final String VIEW = "VIEW"; + public static final String MASS_SEND_JOB_FINISH = "MASSSENDJOBFINISH"; + public static final String SCANCODE_PUSH = "scancode_push"; + public static final String SCANCODE_WAITMSG = "scancode_waitmsg"; + public static final String PIC_SYSPHOTO = "pic_sysphoto"; + public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; + public static final String PIC_WEIXIN = "pic_weixin"; + public static final String LOCATION_SELECT = "location_select"; + public static final String TEMPLATE_SEND_JOB_FINISH = "TEMPLATESENDJOBFINISH"; + public static final String ENTER_AGENT = "enter_agent"; + } + /** - * 下发消息(除文本消息) + * 上传多媒体(临时素材)文件的类型 */ - public static final String BUTTON_MEDIA_ID = "media_id"; + public static class MediaFileType { + public static final String IMAGE = "image"; + public static final String VOICE = "voice"; + public static final String VIDEO = "video"; + public static final String THUMB = "thumb"; + public static final String FILE = "file"; + } + /** - * 跳转图文消息URL + * 自定义菜单的按钮类型 */ - public static final String BUTTON_VIEW_LIMITED = "view_limited"; + public static class MenuButtonType { + /** + * 点击推事件 + */ + public static final String CLICK = "click"; + /** + * 跳转URL + */ + public static final String VIEW = "view"; + /** + * 跳转到小程序 + */ + public static final String MINIPROGRAM = "miniprogram"; + /** + * 扫码推事件 + */ + public static final String SCANCODE_PUSH = "scancode_push"; + /** + * 扫码推事件且弹出“消息接收中”提示框 + */ + public static final String SCANCODE_WAITMSG = "scancode_waitmsg"; + /** + * 弹出系统拍照发图 + */ + public static final String PIC_SYSPHOTO = "pic_sysphoto"; + /** + * 弹出拍照或者相册发图 + */ + public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; + /** + * 弹出微信相册发图器 + */ + public static final String PIC_WEIXIN = "pic_weixin"; + /** + * 弹出地理位置选择器 + */ + public static final String LOCATION_SELECT = "location_select"; + /** + * 下发消息(除文本消息) + */ + public static final String MEDIA_ID = "media_id"; + /** + * 跳转图文消息URL + */ + public static final String VIEW_LIMITED = "view_limited"; + } /** - * 不弹出授权页面,直接跳转,只能获取用户openid + * oauth2网页授权的scope */ - public static final String OAUTH2_SCOPE_BASE = "snsapi_base"; + public static class OAuth2Scope { + /** + * 不弹出授权页面,直接跳转,只能获取用户openid + */ + public static final String SNSAPI_BASE = "snsapi_base"; + /** + * 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息 + */ + public static final String SNSAPI_USERINFO = "snsapi_userinfo"; + } - /////////////////////// - // oauth2网页授权的scope - /////////////////////// /** - * 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息 + * 网页应用登录授权作用域 */ - public static final String OAUTH2_SCOPE_USER_INFO = "snsapi_userinfo"; + public static class QrConnectScope { + public static final String SNSAPI_LOGIN = "snsapi_login"; + } /** - * 网页应用登录授权作用域 snsapi_login + * 永久素材类型 */ - public static final String QRCONNECT_SCOPE_SNSAPI_LOGIN = "snsapi_login"; - - /////////////////////// - // 永久素材类型 - /////////////////////// - public static final String MATERIAL_NEWS = "news"; - public static final String MATERIAL_VOICE = "voice"; - public static final String MATERIAL_IMAGE = "image"; - public static final String MATERIAL_VIDEO = "video"; - - static { - MASS_ST_2_DESC.put(MASS_ST_SUCCESS, "发送成功"); - MASS_ST_2_DESC.put(MASS_ST_FAIL, "发送失败"); - MASS_ST_2_DESC.put(MASS_ST_10001, "涉嫌广告"); - MASS_ST_2_DESC.put(MASS_ST_20001, "涉嫌政治"); - MASS_ST_2_DESC.put(MASS_ST_20004, "涉嫌社会"); - MASS_ST_2_DESC.put(MASS_ST_20002, "涉嫌色情"); - MASS_ST_2_DESC.put(MASS_ST_20006, "涉嫌违法犯罪"); - MASS_ST_2_DESC.put(MASS_ST_20008, "涉嫌欺诈"); - MASS_ST_2_DESC.put(MASS_ST_20013, "涉嫌版权"); - MASS_ST_2_DESC.put(MASS_ST_22000, "涉嫌互推_互相宣传"); - MASS_ST_2_DESC.put(MASS_ST_21000, "涉嫌其他"); + public static class MaterialType { + public static final String NEWS = "news"; + public static final String VOICE = "voice"; + public static final String IMAGE = "image"; + public static final String VIDEO = "video"; } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java index c59ca87e1f..53e82edf63 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.cp.bean; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.cp.bean.article.MpnewsArticle; import me.chanjar.weixin.cp.bean.article.NewArticle; import me.chanjar.weixin.cp.bean.messagebuilder.*; @@ -137,13 +138,13 @@ public String getMsgType() { /** *
        * 请使用
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MPNEWS}
    +   * {@link WxConsts.KefuMsgType#TEXT}
    +   * {@link WxConsts.KefuMsgType#IMAGE}
    +   * {@link WxConsts.KefuMsgType#VOICE}
    +   * {@link WxConsts.KefuMsgType#MUSIC}
    +   * {@link WxConsts.KefuMsgType#VIDEO}
    +   * {@link WxConsts.KefuMsgType#NEWS}
    +   * {@link WxConsts.KefuMsgType#MPNEWS}
        * 
    * * @param msgType 消息类型 diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java index bbf9ccca68..0beb53eef9 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.cp.config.WxCpConfigStorage; @@ -224,13 +225,13 @@ public void setCreateTime(Long createTime) { /** *
        * 当接受用户消息时,可能会获得以下值:
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LOCATION}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT}
    +   * {@link WxConsts.XmlMsgType#TEXT}
    +   * {@link WxConsts.XmlMsgType#IMAGE}
    +   * {@link WxConsts.XmlMsgType#VOICE}
    +   * {@link WxConsts.XmlMsgType#VIDEO}
    +   * {@link WxConsts.XmlMsgType#LOCATION}
    +   * {@link WxConsts.XmlMsgType#LINK}
    +   * {@link WxConsts.XmlMsgType#EVENT}
        * 
    */ public String getMsgType() { @@ -240,11 +241,11 @@ public String getMsgType() { /** *
        * 当发送消息的时候使用:
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_NEWS}
    +   * {@link WxConsts.XmlMsgType#TEXT}
    +   * {@link WxConsts.XmlMsgType#IMAGE}
    +   * {@link WxConsts.XmlMsgType#VOICE}
    +   * {@link WxConsts.XmlMsgType#VIDEO}
    +   * {@link WxConsts.XmlMsgType#NEWS}
        * 
    * * @param msgType diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutImageMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutImageMessage.java index 2ddb78afc9..1d3b3e4ebc 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutImageMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutImageMessage.java @@ -14,7 +14,7 @@ public class WxCpXmlOutImageMessage extends WxCpXmlOutMessage { private String mediaId; public WxCpXmlOutImageMessage() { - this.msgType = WxConsts.XML_MSG_IMAGE; + this.msgType = WxConsts.XmlMsgType.IMAGE; } public String getMediaId() { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessage.java index 0997841081..9e23aefe7e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessage.java @@ -18,7 +18,7 @@ public class WxCpXmlOutNewsMessage extends WxCpXmlOutMessage { protected int articleCount; public WxCpXmlOutNewsMessage() { - this.msgType = WxConsts.XML_MSG_NEWS; + this.msgType = WxConsts.XmlMsgType.NEWS; } public int getArticleCount() { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutTextMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutTextMessage.java index 5f09abf485..ca1382b004 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutTextMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutTextMessage.java @@ -14,7 +14,7 @@ public class WxCpXmlOutTextMessage extends WxCpXmlOutMessage { private String content; public WxCpXmlOutTextMessage() { - this.msgType = WxConsts.XML_MSG_TEXT; + this.msgType = WxConsts.XmlMsgType.TEXT; } public String getContent() { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVideoMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVideoMessage.java index 46dae31c3f..44a447e2ca 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVideoMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVideoMessage.java @@ -13,7 +13,7 @@ public class WxCpXmlOutVideoMessage extends WxCpXmlOutMessage { protected final Video video = new Video(); public WxCpXmlOutVideoMessage() { - this.msgType = WxConsts.XML_MSG_VIDEO; + this.msgType = WxConsts.XmlMsgType.VIDEO; } public String getMediaId() { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVoiceMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVoiceMessage.java index b1827706dd..4b91fcf4bc 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVoiceMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVoiceMessage.java @@ -14,7 +14,7 @@ public class WxCpXmlOutVoiceMessage extends WxCpXmlOutMessage { private String mediaId; public WxCpXmlOutVoiceMessage() { - this.msgType = WxConsts.XML_MSG_VOICE; + this.msgType = WxConsts.XmlMsgType.VOICE; } public String getMediaId() { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java index 784de9a769..1064f00526 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java @@ -44,7 +44,7 @@ public WxCpMessage build() { m.setToUser(this.toUser); m.setToParty(this.toParty); m.setToTag(this.toTag); - m.setSafe(StringUtils.defaultIfBlank(this.safe, WxConsts.CUSTOM_MSG_SAFE_NO)); + m.setSafe(StringUtils.defaultIfBlank(this.safe, WxConsts.KefuMsgSafe.NO)); return m; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/FileBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/FileBuilder.java index 1da7816926..f67cf6e50d 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/FileBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/FileBuilder.java @@ -15,7 +15,7 @@ public final class FileBuilder extends BaseBuilder { private String mediaId; public FileBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_FILE; + this.msgType = WxConsts.KefuMsgType.FILE; } public FileBuilder mediaId(String media_id) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/ImageBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/ImageBuilder.java index a74f5016e4..ddf3b7373b 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/ImageBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/ImageBuilder.java @@ -15,7 +15,7 @@ public final class ImageBuilder extends BaseBuilder { private String mediaId; public ImageBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_IMAGE; + this.msgType = WxConsts.KefuMsgType.IMAGE; } public ImageBuilder mediaId(String media_id) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java index 55ed20abab..75739803f4 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/MpnewsBuilder.java @@ -23,7 +23,7 @@ public final class MpnewsBuilder extends BaseBuilder { private String mediaId; public MpnewsBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_MPNEWS; + this.msgType = WxConsts.KefuMsgType.MPNEWS; } public MpnewsBuilder mediaId(String mediaId) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java index dd23941244..9d0d2f603a 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/NewsBuilder.java @@ -22,7 +22,7 @@ public final class NewsBuilder extends BaseBuilder { private List articles = new ArrayList<>(); public NewsBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_NEWS; + this.msgType = WxConsts.KefuMsgType.NEWS; } public NewsBuilder addArticle(NewArticle... articles) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextBuilder.java index 8c1ee1d014..5079b5f846 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextBuilder.java @@ -15,7 +15,7 @@ public final class TextBuilder extends BaseBuilder { private String content; public TextBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_TEXT; + this.msgType = WxConsts.KefuMsgType.TEXT; } public TextBuilder content(String content) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java index a30b9d4059..f453bddb9b 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/TextCardBuilder.java @@ -18,7 +18,7 @@ public class TextCardBuilder extends BaseBuilder { private String url; public TextCardBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_TEXTCARD; + this.msgType = WxConsts.KefuMsgType.TEXTCARD; } public TextCardBuilder title(String title) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VideoBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VideoBuilder.java index 52cba28703..8d47399407 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VideoBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VideoBuilder.java @@ -24,7 +24,7 @@ public final class VideoBuilder extends BaseBuilder { private String thumbMediaId; public VideoBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_VIDEO; + this.msgType = WxConsts.KefuMsgType.VIDEO; } public VideoBuilder mediaId(String mediaId) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VoiceBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VoiceBuilder.java index 0960fe8f0c..33c36abcbe 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VoiceBuilder.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/VoiceBuilder.java @@ -15,7 +15,7 @@ public final class VoiceBuilder extends BaseBuilder { private String mediaId; public VoiceBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_VOICE; + this.msgType = WxConsts.KefuMsgType.VOICE; } public VoiceBuilder mediaId(String media_id) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java index 67e43c4ccc..5e19b50121 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java @@ -37,13 +37,13 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat if (StringUtils.isNotBlank(message.getToTag())) { messageJson.addProperty("totag", message.getToTag()); } - if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.TEXT.equals(message.getMsgType())) { JsonObject text = new JsonObject(); text.addProperty("content", message.getContent()); messageJson.add("text", text); } - if (WxConsts.CUSTOM_MSG_TEXTCARD.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.TEXTCARD.equals(message.getMsgType())) { JsonObject text = new JsonObject(); text.addProperty("title", message.getTitle()); text.addProperty("description", message.getDescription()); @@ -51,19 +51,19 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat messageJson.add("textcard", text); } - if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.IMAGE.equals(message.getMsgType())) { JsonObject image = new JsonObject(); image.addProperty("media_id", message.getMediaId()); messageJson.add("image", image); } - if (WxConsts.CUSTOM_MSG_FILE.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.FILE.equals(message.getMsgType())) { JsonObject image = new JsonObject(); image.addProperty("media_id", message.getMediaId()); messageJson.add("file", image); } - if (WxConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.VOICE.equals(message.getMsgType())) { JsonObject voice = new JsonObject(); voice.addProperty("media_id", message.getMediaId()); messageJson.add("voice", voice); @@ -73,7 +73,7 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat messageJson.addProperty("safe", message.getSafe()); } - if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.VIDEO.equals(message.getMsgType())) { JsonObject video = new JsonObject(); video.addProperty("media_id", message.getMediaId()); video.addProperty("thumb_media_id", message.getThumbMediaId()); @@ -82,7 +82,7 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat messageJson.add("video", video); } - if (WxConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.NEWS.equals(message.getMsgType())) { JsonObject newsJsonObject = new JsonObject(); JsonArray articleJsonArray = new JsonArray(); for (NewArticle article : message.getArticles()) { @@ -97,7 +97,7 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat messageJson.add("news", newsJsonObject); } - if (WxConsts.CUSTOM_MSG_MPNEWS.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.MPNEWS.equals(message.getMsgType())) { JsonObject newsJsonObject = new JsonObject(); if (message.getMediaId() != null) { newsJsonObject.addProperty("media_id", message.getMediaId()); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java index 0cecc01588..4194efc17a 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageAPITest.java @@ -3,7 +3,6 @@ import com.google.inject.Inject; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; import me.chanjar.weixin.cp.bean.WxCpMessage; import me.chanjar.weixin.cp.bean.WxCpMessageSendResult; import org.testng.annotations.*; @@ -32,7 +31,7 @@ public void setup() { public void testSendMessage() throws WxErrorException { WxCpMessage message = new WxCpMessage(); // message.setAgentId(configStorage.getAgentId()); - message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); + message.setMsgType(WxConsts.KefuMsgType.TEXT); message.setToUser(configStorage.getUserId()); message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World"); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java index e52101f508..d37f45354a 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java @@ -27,21 +27,21 @@ public void prepare(boolean async, StringBuffer sb, WxCpMessageRouter router) { router .rule() .async(async) - .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1") + .msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1").content("CONTENT_1") .handler(new WxEchoCpMessageHandler(sb, "COMBINE_4")) .end() .rule() .async(async) - .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1") + .msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1") .handler(new WxEchoCpMessageHandler(sb, "COMBINE_3")) .end() .rule() .async(async) - .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK) + .msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK) .handler(new WxEchoCpMessageHandler(sb, "COMBINE_2")) .end() - .rule().async(async).msgType(WxConsts.XML_MSG_TEXT).handler(new WxEchoCpMessageHandler(sb, WxConsts.XML_MSG_TEXT)).end() - .rule().async(async).event(WxConsts.EVT_CLICK).handler(new WxEchoCpMessageHandler(sb, WxConsts.EVT_CLICK)).end() + .rule().async(async).msgType(WxConsts.XmlMsgType.TEXT).handler(new WxEchoCpMessageHandler(sb, WxConsts.XmlMsgType.TEXT)).end() + .rule().async(async).event(WxConsts.EventType.CLICK).handler(new WxEchoCpMessageHandler(sb, WxConsts.EventType.CLICK)).end() .rule().async(async).eventKey("KEY_1").handler(new WxEchoCpMessageHandler(sb, "KEY_1")).end() .rule().async(async).content("CONTENT_1").handler(new WxEchoCpMessageHandler(sb, "CONTENT_1")).end() .rule().async(async).rContent(".*bc.*").handler(new WxEchoCpMessageHandler(sb, "abcd")).end() @@ -104,10 +104,10 @@ public void run() { @DataProvider(name = "messages-1") public Object[][] messages2() { WxCpXmlMessage message1 = new WxCpXmlMessage(); - message1.setMsgType(WxConsts.XML_MSG_TEXT); + message1.setMsgType(WxConsts.XmlMsgType.TEXT); WxCpXmlMessage message2 = new WxCpXmlMessage(); - message2.setEvent(WxConsts.EVT_CLICK); + message2.setEvent(WxConsts.EventType.CLICK); WxCpXmlMessage message3 = new WxCpXmlMessage(); message3.setEventKey("KEY_1"); @@ -125,24 +125,24 @@ public Object[][] messages2() { message7.setFormat("strangeformat"); WxCpXmlMessage c2 = new WxCpXmlMessage(); - c2.setMsgType(WxConsts.XML_MSG_TEXT); - c2.setEvent(WxConsts.EVT_CLICK); + c2.setMsgType(WxConsts.XmlMsgType.TEXT); + c2.setEvent(WxConsts.EventType.CLICK); WxCpXmlMessage c3 = new WxCpXmlMessage(); - c3.setMsgType(WxConsts.XML_MSG_TEXT); - c3.setEvent(WxConsts.EVT_CLICK); + c3.setMsgType(WxConsts.XmlMsgType.TEXT); + c3.setEvent(WxConsts.EventType.CLICK); c3.setEventKey("KEY_1"); WxCpXmlMessage c4 = new WxCpXmlMessage(); - c4.setMsgType(WxConsts.XML_MSG_TEXT); - c4.setEvent(WxConsts.EVT_CLICK); + c4.setMsgType(WxConsts.XmlMsgType.TEXT); + c4.setEvent(WxConsts.EventType.CLICK); c4.setEventKey("KEY_1"); c4.setContent("CONTENT_1"); return new Object[][]{ - new Object[]{message1, WxConsts.XML_MSG_TEXT + ","}, - new Object[]{message2, WxConsts.EVT_CLICK + ","}, + new Object[]{message1, WxConsts.XmlMsgType.TEXT + ","}, + new Object[]{message2, WxConsts.EventType.CLICK + ","}, new Object[]{message3, "KEY_1,"}, new Object[]{message4, "CONTENT_1,"}, new Object[]{message5, "ALL,"}, diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java index 4bdb73413d..084f59f289 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMediaServiceImplTest.java @@ -34,11 +34,11 @@ public class WxCpMediaServiceImplTest { @DataProvider public Object[][] mediaData() { return new Object[][]{ - new Object[]{WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, "mm.jpeg"}, - new Object[]{WxConsts.MEDIA_VOICE, TestConstants.FILE_MP3, "mm.mp3"}, - new Object[]{WxConsts.MEDIA_VOICE, TestConstants.FILE_AMR, "mm.amr"},//{"errcode":301017,"errmsg":"voice file only support amr like myvoice.amr"} - new Object[]{WxConsts.MEDIA_VIDEO, TestConstants.FILE_MP4, "mm.mp4"}, - new Object[]{WxConsts.MEDIA_FILE, TestConstants.FILE_JPG, "mm.jpeg"} + new Object[]{WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, "mm.jpeg"}, + new Object[]{WxConsts.MediaFileType.VOICE, TestConstants.FILE_MP3, "mm.mp3"}, + new Object[]{WxConsts.MediaFileType.VOICE, TestConstants.FILE_AMR, "mm.amr"},//{"errcode":301017,"errmsg":"voice file only support amr like myvoice.amr"} + new Object[]{WxConsts.MediaFileType.VIDEO, TestConstants.FILE_MP4, "mm.mp4"}, + new Object[]{WxConsts.MediaFileType.FILE, TestConstants.FILE_JPG, "mm.jpeg"} }; } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImplTest.java index def6419820..b9dbbd3aa1 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImplTest.java @@ -26,12 +26,12 @@ public class WxCpMenuServiceImplTest { public Object[][] menuData() { WxMenu menu = new WxMenu(); WxMenuButton button1 = new WxMenuButton(); - button1.setType(WxConsts.BUTTON_CLICK); + button1.setType(WxConsts.MenuButtonType.CLICK); button1.setName("今日歌曲"); button1.setKey("V1001_TODAY_MUSIC"); WxMenuButton button2 = new WxMenuButton(); - button2.setType(WxConsts.BUTTON_CLICK); + button2.setType(WxConsts.MenuButtonType.CLICK); button2.setName("歌手简介"); button2.setKey("V1001_TODAY_SINGER"); @@ -43,17 +43,17 @@ public Object[][] menuData() { menu.getButtons().add(button3); WxMenuButton button31 = new WxMenuButton(); - button31.setType(WxConsts.BUTTON_VIEW); + button31.setType(WxConsts.MenuButtonType.VIEW); button31.setName("搜索"); button31.setUrl("http://www.soso.com/"); WxMenuButton button32 = new WxMenuButton(); - button32.setType(WxConsts.BUTTON_VIEW); + button32.setType(WxConsts.MenuButtonType.VIEW); button32.setName("视频"); button32.setUrl("http://v.qq.com/"); WxMenuButton button33 = new WxMenuButton(); - button33.setType(WxConsts.BUTTON_CLICK); + button33.setType(WxConsts.MenuButtonType.CLICK); button33.setName("赞一下我们"); button33.setKey("V1001_GOOD"); diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java index 87e16d773a..f9be8c1534 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java @@ -58,7 +58,7 @@ public void testFromXml() { assertEquals(wxMessage.getToUserName(), "toUser"); assertEquals(wxMessage.getFromUserName(), "fromUser"); assertEquals(wxMessage.getCreateTime(), new Long(1348831860l)); - assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); + assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); assertEquals(wxMessage.getContent(), "this is a test"); assertEquals(wxMessage.getMsgId(), new Long(1234567890123456l)); assertEquals(wxMessage.getPicUrl(), "this is a url"); @@ -108,7 +108,7 @@ public void testSendPicsInfo() { assertEquals(wxMessage.getToUserName(), "wx45a0972125658be9"); assertEquals(wxMessage.getFromUserName(), "xiaohe"); assertEquals(wxMessage.getCreateTime(), new Long(1502012364L)); - assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_EVENT); + assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT); assertEquals(wxMessage.getAgentId(), Integer.valueOf(1000004)); assertEquals(wxMessage.getEvent(), "pic_weixin"); assertEquals(wxMessage.getEventKey(), "faceSimilarity"); diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java index 37e3608bff..f07481ffbf 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java @@ -31,7 +31,7 @@ public void testSendKefuMpNewsMessage() throws WxErrorException { TestConfig configStorage = (TestConfig) this.wxService .getWxMaConfig(); WxMaKefuMessage message = new WxMaKefuMessage(); - message.setMsgType(WxConsts.CUSTOM_MSG_MPNEWS); + message.setMsgType(WxConsts.KefuMsgType.MPNEWS); message.setToUser(configStorage.getOpenid()); this.wxService.getMsgService().sendKefuMsg(message); @@ -41,7 +41,7 @@ public void testSendKefuMessage() throws WxErrorException { TestConfig config = (TestConfig) this.wxService .getWxMaConfig(); WxMaKefuMessage message = new WxMaKefuMessage(); - message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); + message.setMsgType(WxConsts.KefuMsgType.TEXT); message.setToUser(config.getOpenid()); message.setContent( "欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World"); diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java index a2b5261c94..667ab2de63 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessageTest.java @@ -13,7 +13,7 @@ public class WxMaKefuMessageTest { public void testTextReply() { WxMaKefuMessage reply = new WxMaKefuMessage(); reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT); + reply.setMsgType(WxConsts.KefuMsgType.TEXT); reply.setContent("sfsfdsdf"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); } @@ -26,7 +26,7 @@ public void testTextBuild() { public void testImageReply() { WxMaKefuMessage reply = new WxMaKefuMessage(); reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE); + reply.setMsgType(WxConsts.KefuMsgType.IMAGE); reply.setMediaId("MEDIA_ID"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java index cdf989a6af..fa7d3ebb92 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java @@ -60,7 +60,7 @@ public void testFromXml() { assertEquals(wxMessage.getToUser(), "toUser"); assertEquals(wxMessage.getFromUser(), "fromUser"); assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); - assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); + assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); assertEquals(wxMessage.getContent(), "this is a test"); assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); assertEquals(wxMessage.getPicUrl(), "this is a url"); @@ -118,7 +118,7 @@ public void testFromXml2() { assertEquals(wxMessage.getToUser(), "toUser"); assertEquals(wxMessage.getFromUser(), "fromUser"); assertEquals(wxMessage.getCreateTime(), new Integer(1348831860)); - assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); + assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); assertEquals(wxMessage.getContent(), "this is a test"); assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); assertEquals(wxMessage.getPicUrl(), "this is a url"); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java index 23f7fb2514..3683bb7f53 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java @@ -121,7 +121,7 @@ public WxMpMaterialCountResult materialCount() throws WxErrorException { @Override public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException { Map params = new HashMap<>(); - params.put("type", WxConsts.MATERIAL_NEWS); + params.put("type", WxConsts.MaterialType.NEWS); params.put("offset", offset); params.put("count", count); String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params)); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java index eff1e66551..7f480e3fa4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassOpenIdsMessage.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean; import lombok.Data; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -24,11 +25,11 @@ public class WxMpMassOpenIdsMessage implements Serializable { /** *
        * 请使用
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
    +   * {@link WxConsts.MassMsgType#IMAGE}
    +   * {@link WxConsts.MassMsgType#MPNEWS}
    +   * {@link WxConsts.MassMsgType#TEXT}
    +   * {@link WxConsts.MassMsgType#MPVIDEO}
    +   * {@link WxConsts.MassMsgType#VOICE}
        * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
        * 
    */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java index bcb67403f8..512c454c47 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassPreviewMessage.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean; import lombok.Data; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -18,11 +19,11 @@ public class WxMpMassPreviewMessage implements Serializable { *
        * 消息类型
        * 请使用
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
    +   * {@link WxConsts.MassMsgType#IMAGE}
    +   * {@link WxConsts.MassMsgType#MPNEWS}
    +   * {@link WxConsts.MassMsgType#TEXT}
    +   * {@link WxConsts.MassMsgType#MPVIDEO}
    +   * {@link WxConsts.MassMsgType#VOICE}
        * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
        * 
    */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java index 99c103f3d0..5bcd408441 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean; import lombok.Data; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @@ -22,11 +23,11 @@ public class WxMpMassTagMessage implements Serializable { *
        * 消息类型
        * 请使用
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_IMAGE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_NEWS}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_TEXT}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VIDEO}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#MASS_MSG_VOICE}
    +   * {@link WxConsts.MassMsgType#IMAGE}
    +   * {@link WxConsts.MassMsgType#MPNEWS}
    +   * {@link WxConsts.MassMsgType#TEXT}
    +   * {@link WxConsts.MassMsgType#MPVIDEO}
    +   * {@link WxConsts.MassMsgType#VOICE}
        * 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
        * 
    */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java index c7a4c81091..97b40920ea 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.kefu; import lombok.Data; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.mp.builder.kefu.*; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -90,14 +91,14 @@ public static WxCardBuilder WXCARD() { /** *
        * 请使用
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MPNEWS}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_WXCARD}
    +   * {@link WxConsts.KefuMsgType#TEXT}
    +   * {@link WxConsts.KefuMsgType#IMAGE}
    +   * {@link WxConsts.KefuMsgType#VOICE}
    +   * {@link WxConsts.KefuMsgType#MUSIC}
    +   * {@link WxConsts.KefuMsgType#VIDEO}
    +   * {@link WxConsts.KefuMsgType#NEWS}
    +   * {@link WxConsts.KefuMsgType#MPNEWS}
    +   * {@link WxConsts.KefuMsgType#WXCARD}
        * 
    * */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java index 9b8b34d893..8c67e0368a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java @@ -3,6 +3,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; +import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.mp.api.WxMpConfigStorage; @@ -467,13 +468,13 @@ public static WxMpXmlMessage fromEncryptedXml(InputStream is, /** *
        * 当接受用户消息时,可能会获得以下值:
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LOCATION}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT}
    +   * {@link WxConsts.XmlMsgType#TEXT}
    +   * {@link WxConsts.XmlMsgType#IMAGE}
    +   * {@link WxConsts.XmlMsgType#VOICE}
    +   * {@link WxConsts.XmlMsgType#VIDEO}
    +   * {@link WxConsts.XmlMsgType#LOCATION}
    +   * {@link WxConsts.XmlMsgType#LINK}
    +   * {@link WxConsts.XmlMsgType#EVENT}
        * 
    */ public String getMsgType() { @@ -483,12 +484,12 @@ public String getMsgType() { /** *
        * 当发送消息的时候使用:
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_NEWS}
    -   * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_MUSIC}
    +   * {@link WxConsts.XmlMsgType#TEXT}
    +   * {@link WxConsts.XmlMsgType#IMAGE}
    +   * {@link WxConsts.XmlMsgType#VOICE}
    +   * {@link WxConsts.XmlMsgType#VIDEO}
    +   * {@link WxConsts.XmlMsgType#NEWS}
    +   * {@link WxConsts.XmlMsgType#MUSIC}
        * 
    * */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java index 92db6ba2c7..9947de1806 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java @@ -16,7 +16,7 @@ public class WxMpXmlOutImageMessage extends WxMpXmlOutMessage { private String mediaId; public WxMpXmlOutImageMessage() { - this.msgType = WxConsts.XML_MSG_IMAGE; + this.msgType = WxConsts.XmlMsgType.IMAGE; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java index b2649ddc5a..1124f45857 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutMusicMessage.java @@ -19,7 +19,7 @@ public class WxMpXmlOutMusicMessage extends WxMpXmlOutMessage { protected final Music music = new Music(); public WxMpXmlOutMusicMessage() { - this.msgType = WxConsts.XML_MSG_MUSIC; + this.msgType = WxConsts.XmlMsgType.MUSIC; } @XStreamAlias("Music") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java index 5e00bf3f89..7ec26a6ea3 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java @@ -21,7 +21,7 @@ public class WxMpXmlOutNewsMessage extends WxMpXmlOutMessage { protected int articleCount; public WxMpXmlOutNewsMessage() { - this.msgType = WxConsts.XML_MSG_NEWS; + this.msgType = WxConsts.XmlMsgType.NEWS; } public void addArticle(Item item) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java index bc8d4a8e90..208367b4cb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java @@ -16,7 +16,7 @@ public class WxMpXmlOutTextMessage extends WxMpXmlOutMessage { private String content; public WxMpXmlOutTextMessage() { - this.msgType = WxConsts.XML_MSG_TEXT; + this.msgType = WxConsts.XmlMsgType.TEXT; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java index 0c19bd7a66..aae4512bf1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java @@ -17,7 +17,7 @@ public class WxMpXmlOutTransferKefuMessage extends WxMpXmlOutMessage { protected TransInfo transInfo; public WxMpXmlOutTransferKefuMessage() { - this.msgType = WxConsts.CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE; + this.msgType = WxConsts.KefuMsgType.TRANSFER_CUSTOMER_SERVICE; } @XStreamAlias("TransInfo") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java index 288ca8619d..7f43a56809 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVideoMessage.java @@ -19,7 +19,7 @@ public class WxMpXmlOutVideoMessage extends WxMpXmlOutMessage { protected final Video video = new Video(); public WxMpXmlOutVideoMessage() { - this.msgType = WxConsts.XML_MSG_VIDEO; + this.msgType = WxConsts.XmlMsgType.VIDEO; } @XStreamAlias("Video") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java index 70738935e8..51ff53758a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java @@ -16,7 +16,7 @@ public class WxMpXmlOutVoiceMessage extends WxMpXmlOutMessage { private String mediaId; public WxMpXmlOutVoiceMessage() { - this.msgType = WxConsts.XML_MSG_VOICE; + this.msgType = WxConsts.XmlMsgType.VOICE; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/ImageBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/ImageBuilder.java index 24d8aabab9..438b0a98a1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/ImageBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/ImageBuilder.java @@ -15,7 +15,7 @@ public final class ImageBuilder extends BaseBuilder { private String mediaId; public ImageBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_IMAGE; + this.msgType = WxConsts.KefuMsgType.IMAGE; } public ImageBuilder mediaId(String media_id) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MpNewsBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MpNewsBuilder.java index b8fac10258..0d520132f4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MpNewsBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MpNewsBuilder.java @@ -16,7 +16,7 @@ public final class MpNewsBuilder extends BaseBuilder { private String mediaId; public MpNewsBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_MPNEWS; + this.msgType = WxConsts.KefuMsgType.MPNEWS; } public MpNewsBuilder mediaId(String mediaId) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MusicBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MusicBuilder.java index 0002b2c0df..0cd40db438 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MusicBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/MusicBuilder.java @@ -24,7 +24,7 @@ public final class MusicBuilder extends BaseBuilder { private String hqMusicUrl; public MusicBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_MUSIC; + this.msgType = WxConsts.KefuMsgType.MUSIC; } public MusicBuilder musicUrl(String musicurl) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/NewsBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/NewsBuilder.java index 11e866e84a..3c00303557 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/NewsBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/NewsBuilder.java @@ -20,7 +20,7 @@ public final class NewsBuilder extends BaseBuilder { private List articles = new ArrayList<>(); public NewsBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_NEWS; + this.msgType = WxConsts.KefuMsgType.NEWS; } public NewsBuilder addArticle(WxMpKefuMessage.WxArticle... articles) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/TextBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/TextBuilder.java index 6d9100e94a..b8f58bdd34 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/TextBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/TextBuilder.java @@ -15,7 +15,7 @@ public final class TextBuilder extends BaseBuilder { private String content; public TextBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_TEXT; + this.msgType = WxConsts.KefuMsgType.TEXT; } public TextBuilder content(String content) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/VideoBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/VideoBuilder.java index d7d3772bda..e9276637d3 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/VideoBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/VideoBuilder.java @@ -24,7 +24,7 @@ public final class VideoBuilder extends BaseBuilder { private String thumbMediaId; public VideoBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_VIDEO; + this.msgType = WxConsts.KefuMsgType.VIDEO; } public VideoBuilder mediaId(String mediaId) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/VoiceBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/VoiceBuilder.java index 9fa92f21c8..a5211548cb 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/VoiceBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/VoiceBuilder.java @@ -15,7 +15,7 @@ public final class VoiceBuilder extends BaseBuilder { private String mediaId; public VoiceBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_VOICE; + this.msgType = WxConsts.KefuMsgType.VOICE; } public VoiceBuilder mediaId(String media_id) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/WxCardBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/WxCardBuilder.java index c9eacf0c13..64cb067206 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/WxCardBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/builder/kefu/WxCardBuilder.java @@ -15,7 +15,7 @@ public final class WxCardBuilder extends BaseBuilder { private String cardId; public WxCardBuilder() { - this.msgType = WxConsts.CUSTOM_MSG_WXCARD; + this.msgType = WxConsts.KefuMsgType.WXCARD; } public WxCardBuilder cardId(String cardId) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpKefuMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpKefuMessageGsonAdapter.java index 56297ce2bd..34b91e5a98 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpKefuMessageGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpKefuMessageGsonAdapter.java @@ -23,25 +23,25 @@ public JsonElement serialize(WxMpKefuMessage message, Type typeOfSrc, JsonSerial messageJson.addProperty("touser", message.getToUser()); messageJson.addProperty("msgtype", message.getMsgType()); - if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.TEXT.equals(message.getMsgType())) { JsonObject text = new JsonObject(); text.addProperty("content", message.getContent()); messageJson.add("text", text); } - if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.IMAGE.equals(message.getMsgType())) { JsonObject image = new JsonObject(); image.addProperty("media_id", message.getMediaId()); messageJson.add("image", image); } - if (WxConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.VOICE.equals(message.getMsgType())) { JsonObject voice = new JsonObject(); voice.addProperty("media_id", message.getMediaId()); messageJson.add("voice", voice); } - if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.VIDEO.equals(message.getMsgType())) { JsonObject video = new JsonObject(); video.addProperty("media_id", message.getMediaId()); video.addProperty("thumb_media_id", message.getThumbMediaId()); @@ -50,7 +50,7 @@ public JsonElement serialize(WxMpKefuMessage message, Type typeOfSrc, JsonSerial messageJson.add("video", video); } - if (WxConsts.CUSTOM_MSG_MUSIC.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.MUSIC.equals(message.getMsgType())) { JsonObject music = new JsonObject(); music.addProperty("title", message.getTitle()); music.addProperty("description", message.getDescription()); @@ -60,7 +60,7 @@ public JsonElement serialize(WxMpKefuMessage message, Type typeOfSrc, JsonSerial messageJson.add("music", music); } - if (WxConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.NEWS.equals(message.getMsgType())) { JsonObject newsJsonObject = new JsonObject(); JsonArray articleJsonArray = new JsonArray(); for (WxMpKefuMessage.WxArticle article : message.getArticles()) { @@ -75,13 +75,13 @@ public JsonElement serialize(WxMpKefuMessage message, Type typeOfSrc, JsonSerial messageJson.add("news", newsJsonObject); } - if (WxConsts.CUSTOM_MSG_MPNEWS.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.MPNEWS.equals(message.getMsgType())) { JsonObject json = new JsonObject(); json.addProperty("media_id", message.getMpNewsMediaId()); messageJson.add("mpnews", json); } - if (WxConsts.CUSTOM_MSG_WXCARD.equals(message.getMsgType())) { + if (WxConsts.KefuMsgType.WXCARD.equals(message.getMsgType())) { JsonObject wxcard = new JsonObject(); wxcard.addProperty("card_id", message.getCardId()); messageJson.add("wxcard", wxcard); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassOpenIdsMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassOpenIdsMessageGsonAdapter.java index 64dfbb1234..cbb5bf6b35 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassOpenIdsMessageGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassOpenIdsMessageGsonAdapter.java @@ -26,30 +26,30 @@ public JsonElement serialize(WxMpMassOpenIdsMessage message, Type typeOfSrc, Jso } messageJson.add("touser", toUsers); - if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgType())) { + if (WxConsts.MassMsgType.MPNEWS.equals(message.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", message.getMediaId()); - messageJson.add(WxConsts.MASS_MSG_NEWS, sub); + messageJson.add(WxConsts.MassMsgType.MPNEWS, sub); } - if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgType())) { + if (WxConsts.MassMsgType.TEXT.equals(message.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("content", message.getContent()); - messageJson.add(WxConsts.MASS_MSG_TEXT, sub); + messageJson.add(WxConsts.MassMsgType.TEXT, sub); } - if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgType())) { + if (WxConsts.MassMsgType.VOICE.equals(message.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", message.getMediaId()); - messageJson.add(WxConsts.MASS_MSG_VOICE, sub); + messageJson.add(WxConsts.MassMsgType.VOICE, sub); } - if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgType())) { + if (WxConsts.MassMsgType.IMAGE.equals(message.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", message.getMediaId()); - messageJson.add(WxConsts.MASS_MSG_IMAGE, sub); + messageJson.add(WxConsts.MassMsgType.IMAGE, sub); } - if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgType())) { + if (WxConsts.MassMsgType.MPVIDEO.equals(message.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", message.getMediaId()); - messageJson.add(WxConsts.MASS_MSG_VIDEO, sub); + messageJson.add(WxConsts.MassMsgType.MPVIDEO, sub); } messageJson.addProperty("msgtype", message.getMsgType()); messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 0 : 1); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassPreviewMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassPreviewMessageGsonAdapter.java index fd210fb33a..bd8ede336d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassPreviewMessageGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassPreviewMessageGsonAdapter.java @@ -18,30 +18,30 @@ public JsonElement serialize(WxMpMassPreviewMessage wxMpMassPreviewMessage, Type JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("towxname", wxMpMassPreviewMessage.getToWxUserName()); jsonObject.addProperty("touser", wxMpMassPreviewMessage.getToWxUserOpenid()); - if (WxConsts.MASS_MSG_NEWS.equals(wxMpMassPreviewMessage.getMsgType())) { + if (WxConsts.MassMsgType.MPNEWS.equals(wxMpMassPreviewMessage.getMsgType())) { JsonObject news = new JsonObject(); news.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); - jsonObject.add(WxConsts.MASS_MSG_NEWS, news); + jsonObject.add(WxConsts.MassMsgType.MPNEWS, news); } - if (WxConsts.MASS_MSG_TEXT.equals(wxMpMassPreviewMessage.getMsgType())) { + if (WxConsts.MassMsgType.TEXT.equals(wxMpMassPreviewMessage.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("content", wxMpMassPreviewMessage.getContent()); - jsonObject.add(WxConsts.MASS_MSG_TEXT, sub); + jsonObject.add(WxConsts.MassMsgType.TEXT, sub); } - if (WxConsts.MASS_MSG_VOICE.equals(wxMpMassPreviewMessage.getMsgType())) { + if (WxConsts.MassMsgType.VOICE.equals(wxMpMassPreviewMessage.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); - jsonObject.add(WxConsts.MASS_MSG_VOICE, sub); + jsonObject.add(WxConsts.MassMsgType.VOICE, sub); } - if (WxConsts.MASS_MSG_IMAGE.equals(wxMpMassPreviewMessage.getMsgType())) { + if (WxConsts.MassMsgType.IMAGE.equals(wxMpMassPreviewMessage.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); - jsonObject.add(WxConsts.MASS_MSG_IMAGE, sub); + jsonObject.add(WxConsts.MassMsgType.IMAGE, sub); } - if (WxConsts.MASS_MSG_VIDEO.equals(wxMpMassPreviewMessage.getMsgType())) { + if (WxConsts.MassMsgType.MPVIDEO.equals(wxMpMassPreviewMessage.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", wxMpMassPreviewMessage.getMediaId()); - jsonObject.add(WxConsts.MASS_MSG_VIDEO, sub); + jsonObject.add(WxConsts.MassMsgType.MPVIDEO, sub); } jsonObject.addProperty("msgtype", wxMpMassPreviewMessage.getMsgType()); return jsonObject; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java index 5b133b0ed1..75c7f4d6fe 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java @@ -32,30 +32,30 @@ public JsonElement serialize(WxMpMassTagMessage message, Type typeOfSrc, JsonSer } messageJson.add("filter", filter); - if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgType())) { + if (WxConsts.MassMsgType.MPNEWS.equals(message.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", message.getMediaId()); - messageJson.add(WxConsts.MASS_MSG_NEWS, sub); + messageJson.add(WxConsts.MassMsgType.MPNEWS, sub); } - if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgType())) { + if (WxConsts.MassMsgType.TEXT.equals(message.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("content", message.getContent()); - messageJson.add(WxConsts.MASS_MSG_TEXT, sub); + messageJson.add(WxConsts.MassMsgType.TEXT, sub); } - if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgType())) { + if (WxConsts.MassMsgType.VOICE.equals(message.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", message.getMediaId()); - messageJson.add(WxConsts.MASS_MSG_VOICE, sub); + messageJson.add(WxConsts.MassMsgType.VOICE, sub); } - if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgType())) { + if (WxConsts.MassMsgType.IMAGE.equals(message.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", message.getMediaId()); - messageJson.add(WxConsts.MASS_MSG_IMAGE, sub); + messageJson.add(WxConsts.MassMsgType.IMAGE, sub); } - if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgType())) { + if (WxConsts.MassMsgType.MPVIDEO.equals(message.getMsgType())) { JsonObject sub = new JsonObject(); sub.addProperty("media_id", message.getMediaId()); - messageJson.add(WxConsts.MASS_MSG_VIDEO, sub); + messageJson.add(WxConsts.MassMsgType.MPVIDEO, sub); } messageJson.addProperty("msgtype", message.getMsgType()); messageJson.addProperty("send_ignore_reprint", message.isSendIgnoreReprint() ? 0 : 1); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMessageRouterTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMessageRouterTest.java index 35d13ee1e9..ba35e11045 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMessageRouterTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpMessageRouterTest.java @@ -23,21 +23,21 @@ public void prepare(boolean async, StringBuffer sb, WxMpMessageRouter router) { router .rule() .async(async) - .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1") + .msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1").content("CONTENT_1") .handler(new WxEchoMpMessageHandler(sb, "COMBINE_4")) .end() .rule() .async(async) - .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1") + .msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK).eventKey("KEY_1") .handler(new WxEchoMpMessageHandler(sb, "COMBINE_3")) .end() .rule() .async(async) - .msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK) + .msgType(WxConsts.XmlMsgType.TEXT).event(WxConsts.EventType.CLICK) .handler(new WxEchoMpMessageHandler(sb, "COMBINE_2")) .end() - .rule().async(async).msgType(WxConsts.XML_MSG_TEXT).handler(new WxEchoMpMessageHandler(sb, WxConsts.XML_MSG_TEXT)).end() - .rule().async(async).event(WxConsts.EVT_CLICK).handler(new WxEchoMpMessageHandler(sb, WxConsts.EVT_CLICK)).end() + .rule().async(async).msgType(WxConsts.XmlMsgType.TEXT).handler(new WxEchoMpMessageHandler(sb, WxConsts.XmlMsgType.TEXT)).end() + .rule().async(async).event(WxConsts.EventType.CLICK).handler(new WxEchoMpMessageHandler(sb, WxConsts.EventType.CLICK)).end() .rule().async(async).eventKey("KEY_1").handler(new WxEchoMpMessageHandler(sb, "KEY_1")).end() .rule().async(async).eventKeyRegex("KEY_1*").handler(new WxEchoMpMessageHandler(sb, "KEY_123")).end() .rule().async(async).content("CONTENT_1").handler(new WxEchoMpMessageHandler(sb, "CONTENT_1")).end() @@ -101,10 +101,10 @@ public void run() { @DataProvider(name = "messages-1") public Object[][] messages2() { WxMpXmlMessage message1 = new WxMpXmlMessage(); - message1.setMsgType(WxConsts.XML_MSG_TEXT); + message1.setMsgType(WxConsts.XmlMsgType.TEXT); WxMpXmlMessage message2 = new WxMpXmlMessage(); - message2.setEvent(WxConsts.EVT_CLICK); + message2.setEvent(WxConsts.EventType.CLICK); WxMpXmlMessage message3 = new WxMpXmlMessage(); message3.setEventKey("KEY_1"); @@ -122,23 +122,23 @@ public Object[][] messages2() { message7.setFormat("strangeformat"); WxMpXmlMessage c2 = new WxMpXmlMessage(); - c2.setMsgType(WxConsts.XML_MSG_TEXT); - c2.setEvent(WxConsts.EVT_CLICK); + c2.setMsgType(WxConsts.XmlMsgType.TEXT); + c2.setEvent(WxConsts.EventType.CLICK); WxMpXmlMessage c3 = new WxMpXmlMessage(); - c3.setMsgType(WxConsts.XML_MSG_TEXT); - c3.setEvent(WxConsts.EVT_CLICK); + c3.setMsgType(WxConsts.XmlMsgType.TEXT); + c3.setEvent(WxConsts.EventType.CLICK); c3.setEventKey("KEY_1"); WxMpXmlMessage c4 = new WxMpXmlMessage(); - c4.setMsgType(WxConsts.XML_MSG_TEXT); - c4.setEvent(WxConsts.EVT_CLICK); + c4.setMsgType(WxConsts.XmlMsgType.TEXT); + c4.setEvent(WxConsts.EventType.CLICK); c4.setEventKey("KEY_1"); c4.setContent("CONTENT_1"); return new Object[][]{ - new Object[]{message1, WxConsts.XML_MSG_TEXT + ","}, - new Object[]{message2, WxConsts.EVT_CLICK + ","}, + new Object[]{message1, WxConsts.XmlMsgType.TEXT + ","}, + new Object[]{message2, WxConsts.EventType.CLICK + ","}, new Object[]{message3, "KEY_1,"}, new Object[]{message4, "CONTENT_1,"}, new Object[]{message5, "ALL,"}, diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java index 2bf5de1dc4..309d381804 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImplTest.java @@ -32,7 +32,7 @@ public void testSendKefuMpNewsMessage() throws WxErrorException { TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpKefuMessage message = new WxMpKefuMessage(); - message.setMsgType(WxConsts.CUSTOM_MSG_MPNEWS); + message.setMsgType(WxConsts.KefuMsgType.MPNEWS); message.setToUser(configStorage.getOpenid()); message.setMpNewsMediaId("52R6dL2FxDpM9N1rCY3sYBqHwq-L7K_lz1sPI71idMg"); @@ -43,7 +43,7 @@ public void testSendKefuMessage() throws WxErrorException { TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpKefuMessage message = new WxMpKefuMessage(); - message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); + message.setMsgType(WxConsts.KefuMsgType.TEXT); message.setToUser(configStorage.getOpenid()); message.setContent( "欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World"); @@ -55,7 +55,7 @@ public void testSendKefuMessageWithKfAccount() throws WxErrorException { TestConfigStorage configStorage = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpKefuMessage message = new WxMpKefuMessage(); - message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); + message.setMsgType(WxConsts.KefuMsgType.TEXT); message.setToUser(configStorage.getOpenid()); message.setKfAccount(configStorage.getKfAccount()); message.setContent( diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java index 3b6c048981..92667e95b7 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImplTest.java @@ -38,7 +38,7 @@ public void testTextMassOpenIdsMessageSend() throws WxErrorException { TestConfigStorage configProvider = (TestConfigStorage) this.wxService .getWxMpConfigStorage(); WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage(); - massMessage.setMsgType(WxConsts.MASS_MSG_TEXT); + massMessage.setMsgType(WxConsts.MassMsgType.TEXT); massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World"); massMessage.getToUsers().add(configProvider.getOpenid()); @@ -67,7 +67,7 @@ public void testMediaMassOpenIdsMessageSend(String massMsgType, String mediaId) @Test public void testTextMassGroupMessageSend() throws WxErrorException { WxMpMassTagMessage massMessage = new WxMpMassTagMessage(); - massMessage.setMsgType(WxConsts.MASS_MSG_TEXT); + massMessage.setMsgType(WxConsts.MassMsgType.TEXT); massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World"); massMessage .setTagId(this.wxService.getUserTagService().tagGet().get(0).getId()); @@ -103,7 +103,7 @@ public Object[][] massMessages() throws WxErrorException, IOException { .getSystemResourceAsStream("mm.mp4")) { // 上传视频到媒体库 WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() - .mediaUpload(WxConsts.MEDIA_VIDEO, TestConstants.FILE_MP4, inputStream); + .mediaUpload(WxConsts.MediaFileType.VIDEO, TestConstants.FILE_MP4, inputStream); assertNotNull(uploadMediaRes); assertNotNull(uploadMediaRes.getMediaId()); @@ -115,7 +115,7 @@ public Object[][] massMessages() throws WxErrorException, IOException { WxMpMassUploadResult uploadResult = this.wxService.getMassMessageService().massVideoUpload(video); assertNotNull(uploadResult); assertNotNull(uploadResult.getMediaId()); - messages[0] = new Object[]{WxConsts.MASS_MSG_VIDEO, uploadResult.getMediaId()}; + messages[0] = new Object[]{WxConsts.MassMsgType.MPVIDEO, uploadResult.getMediaId()}; } /* @@ -124,10 +124,10 @@ public Object[][] massMessages() throws WxErrorException, IOException { try (InputStream inputStream = ClassLoader .getSystemResourceAsStream("mm.jpeg")) { WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() - .mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, inputStream); + .mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream); assertNotNull(uploadMediaRes); assertNotNull(uploadMediaRes.getMediaId()); - messages[1] = new Object[]{WxConsts.MASS_MSG_IMAGE, uploadMediaRes.getMediaId()}; + messages[1] = new Object[]{WxConsts.MassMsgType.IMAGE, uploadMediaRes.getMediaId()}; } /* @@ -136,10 +136,10 @@ public Object[][] massMessages() throws WxErrorException, IOException { try (InputStream inputStream = ClassLoader .getSystemResourceAsStream("mm.mp3")) { WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() - .mediaUpload(WxConsts.MEDIA_VOICE, TestConstants.FILE_MP3, inputStream); + .mediaUpload(WxConsts.MediaFileType.VOICE, TestConstants.FILE_MP3, inputStream); assertNotNull(uploadMediaRes); assertNotNull(uploadMediaRes.getMediaId()); - messages[2] = new Object[]{WxConsts.MASS_MSG_VOICE, uploadMediaRes.getMediaId()}; + messages[2] = new Object[]{WxConsts.MassMsgType.VOICE, uploadMediaRes.getMediaId()}; } /* @@ -149,7 +149,7 @@ public Object[][] massMessages() throws WxErrorException, IOException { .getSystemResourceAsStream("mm.jpeg")) { // 上传照片到媒体库 WxMediaUploadResult uploadMediaRes = this.wxService.getMaterialService() - .mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, inputStream); + .mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, inputStream); assertNotNull(uploadMediaRes); assertNotNull(uploadMediaRes.getMediaId()); @@ -175,7 +175,7 @@ public Object[][] massMessages() throws WxErrorException, IOException { .massNewsUpload(news); assertNotNull(massUploadResult); assertNotNull(uploadMediaRes.getMediaId()); - messages[3] = new Object[]{WxConsts.MASS_MSG_NEWS, massUploadResult.getMediaId()}; + messages[3] = new Object[]{WxConsts.MassMsgType.MPNEWS, massUploadResult.getMediaId()}; } return messages; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java index 3d1c7ff0cc..919b4cb43b 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImplTest.java @@ -48,10 +48,10 @@ public class WxMpMaterialServiceImplTest { @DataProvider public Object[][] mediaFiles() { return new Object[][]{ - new Object[]{WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, "mm.jpeg"}, - new Object[]{WxConsts.MEDIA_VOICE, TestConstants.FILE_MP3, "mm.mp3"}, - new Object[]{WxConsts.MEDIA_VIDEO, TestConstants.FILE_MP4, "mm.mp4"}, - new Object[]{WxConsts.MEDIA_THUMB, TestConstants.FILE_JPG, "mm.jpeg"} + new Object[]{WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, "mm.jpeg"}, + new Object[]{WxConsts.MediaFileType.VOICE, TestConstants.FILE_MP3, "mm.mp3"}, + new Object[]{WxConsts.MediaFileType.VIDEO, TestConstants.FILE_MP4, "mm.mp4"}, + new Object[]{WxConsts.MediaFileType.THUMB, TestConstants.FILE_JPG, "mm.jpeg"} }; } @@ -69,7 +69,7 @@ public void testUploadMaterial(String mediaType, String fileType, String fileNam WxMpMaterial wxMaterial = new WxMpMaterial(); wxMaterial.setFile(tempFile); wxMaterial.setName(fileName); - if (WxConsts.MEDIA_VIDEO.equals(mediaType)) { + if (WxConsts.MediaFileType.VIDEO.equals(mediaType)) { wxMaterial.setVideoTitle("title"); wxMaterial.setVideoIntroduction("test video description"); } @@ -78,12 +78,12 @@ public void testUploadMaterial(String mediaType, String fileType, String fileNam .materialFileUpload(mediaType, wxMaterial); assertNotNull(res.getMediaId()); - if (WxConsts.MEDIA_IMAGE.equals(mediaType) - || WxConsts.MEDIA_THUMB.equals(mediaType)) { + if (WxConsts.MediaFileType.IMAGE.equals(mediaType) + || WxConsts.MediaFileType.THUMB.equals(mediaType)) { assertNotNull(res.getUrl()); } - if (WxConsts.MEDIA_THUMB.equals(mediaType)) { + if (WxConsts.MediaFileType.THUMB.equals(mediaType)) { this.thumbMediaId = res.getMediaId(); } @@ -233,9 +233,9 @@ public void testMaterialNewsList() throws WxErrorException { @Test//(dependsOnMethods = {"testMaterialNewsList"}) public void testMaterialFileList() throws WxErrorException { - WxMpMaterialFileBatchGetResult wxMpMaterialVoiceBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MATERIAL_VOICE, 0, 20); - WxMpMaterialFileBatchGetResult wxMpMaterialVideoBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MATERIAL_VIDEO, 0, 20); - WxMpMaterialFileBatchGetResult wxMpMaterialImageBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MATERIAL_IMAGE, 0, 20); + WxMpMaterialFileBatchGetResult wxMpMaterialVoiceBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.VOICE, 0, 20); + WxMpMaterialFileBatchGetResult wxMpMaterialVideoBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.VIDEO, 0, 20); + WxMpMaterialFileBatchGetResult wxMpMaterialImageBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.IMAGE, 0, 20); assertNotNull(wxMpMaterialVoiceBatchGetResult); assertNotNull(wxMpMaterialVideoBatchGetResult); assertNotNull(wxMpMaterialImageBatchGetResult); @@ -277,7 +277,7 @@ public void testUploadMedia(String mediaType, String fileType, String fileName) assertNotNull(res.getCreatedAt()); assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null); - if (res.getMediaId() != null && !mediaType.equals(WxConsts.MEDIA_VIDEO)) { + if (res.getMediaId() != null && !mediaType.equals(WxConsts.MediaFileType.VIDEO)) { //video 不支持下载,所以不加入 this.mediaIdsToDownload.add(res.getMediaId()); } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java index 922cbb7e08..ff00d474a7 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpMenuServiceImplTest.java @@ -156,12 +156,12 @@ public void testMenuDelete() throws WxErrorException { public Object[][] getMenu() { WxMenu menu = new WxMenu(); WxMenuButton button1 = new WxMenuButton(); - button1.setType(WxConsts.BUTTON_CLICK); + button1.setType(WxConsts.MenuButtonType.CLICK); button1.setName("今日歌曲"); button1.setKey("V1001_TODAY_MUSIC"); // WxMenuButton button2 = new WxMenuButton(); -// button2.setType(WxConsts.BUTTON_MINIPROGRAM); +// button2.setType(WxConsts.MenuButtonType.MINIPROGRAM); // button2.setName("小程序"); // button2.setAppId("wx286b93c14bbf93aa"); // button2.setPagePath("pages/lunar/index.html"); @@ -175,17 +175,17 @@ public Object[][] getMenu() { menu.getButtons().add(button3); WxMenuButton button31 = new WxMenuButton(); - button31.setType(WxConsts.BUTTON_VIEW); + button31.setType(WxConsts.MenuButtonType.VIEW); button31.setName("搜索"); button31.setUrl("http://www.soso.com/"); WxMenuButton button32 = new WxMenuButton(); - button32.setType(WxConsts.BUTTON_VIEW); + button32.setType(WxConsts.MenuButtonType.VIEW); button32.setName("视频"); button32.setUrl("http://v.qq.com/"); WxMenuButton button33 = new WxMenuButton(); - button33.setType(WxConsts.BUTTON_CLICK); + button33.setType(WxConsts.MenuButtonType.CLICK); button33.setName("赞一下我们"); button33.setKey("V1001_GOOD"); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java index c3f9f69d7b..9cb9e1d115 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java @@ -116,7 +116,7 @@ public void testOauth2buildAuthorizationUrl() { public void testBuildQrConnectUrl() { String qrconnectRedirectUrl = ((TestConfigStorage) this.wxService.getWxMpConfigStorage()).getQrconnectRedirectUrl(); String qrConnectUrl = this.wxService.buildQrConnectUrl(qrconnectRedirectUrl, - WxConsts.QRCONNECT_SCOPE_SNSAPI_LOGIN, null); + WxConsts.QrConnectScope.SNSAPI_LOGIN, null); Assert.assertNotNull(qrConnectUrl); System.out.println(qrConnectUrl); } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java index c25c502495..bfeb84c119 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java @@ -11,7 +11,7 @@ public class WxMpKefuMessageTest { public void testTextReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT); + reply.setMsgType(WxConsts.KefuMsgType.TEXT); reply.setContent("sfsfdsdf"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); } @@ -24,7 +24,7 @@ public void testTextBuild() { public void testImageReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE); + reply.setMsgType(WxConsts.KefuMsgType.IMAGE); reply.setMediaId("MEDIA_ID"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); } @@ -37,7 +37,7 @@ public void testImageBuild() { public void testVoiceReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_VOICE); + reply.setMsgType(WxConsts.KefuMsgType.VOICE); reply.setMediaId("MEDIA_ID"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}"); } @@ -50,7 +50,7 @@ public void testVoiceBuild() { public void testVideoReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_VIDEO); + reply.setMsgType(WxConsts.KefuMsgType.VIDEO); reply.setMediaId("MEDIA_ID"); reply.setThumbMediaId("MEDIA_ID"); reply.setTitle("TITLE"); @@ -66,7 +66,7 @@ public void testVideoBuild() { public void testMusicReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_MUSIC); + reply.setMsgType(WxConsts.KefuMsgType.MUSIC); reply.setThumbMediaId("MEDIA_ID"); reply.setDescription("DESCRIPTION"); reply.setTitle("TITLE"); @@ -90,7 +90,7 @@ public void testMusicBuild() { public void testNewsReply() { WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); - reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS); + reply.setMsgType(WxConsts.KefuMsgType.NEWS); WxArticle article1 = new WxArticle(); article1.setUrl("URL"); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java index 8bcbc0de24..2224329b26 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java @@ -58,7 +58,7 @@ public void testFromXml() { assertEquals(wxMessage.getToUser(), "toUser"); assertEquals(wxMessage.getFromUser(), "fromUser"); assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); - assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); + assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); assertEquals(wxMessage.getContent(), "this is a test"); assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); assertEquals(wxMessage.getPicUrl(), "this is a url"); @@ -139,7 +139,7 @@ public void testFromXml2() { assertEquals(wxMessage.getToUser(), "toUser"); assertEquals(wxMessage.getFromUser(), "fromUser"); assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); - assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); + assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.TEXT); assertEquals(wxMessage.getContent(), "this is a test"); assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); assertEquals(wxMessage.getPicUrl(), "this is a url"); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java index 2390071b6c..5578f637be 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java @@ -19,7 +19,7 @@ public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map co WxMpService wxMpService, WxSessionManager sessionManager) { try { WxMediaUploadResult wxMediaUploadResult = wxMpService.getMaterialService() - .mediaUpload(WxConsts.MEDIA_IMAGE, TestConstants.FILE_JPG, ClassLoader.getSystemResourceAsStream("mm.jpeg")); + .mediaUpload(WxConsts.MediaFileType.IMAGE, TestConstants.FILE_JPG, ClassLoader.getSystemResourceAsStream("mm.jpeg")); WxMpXmlOutImageMessage m = WxMpXmlOutMessage .IMAGE() diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoOAuth2Handler.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoOAuth2Handler.java index 6460f851d0..91020c4ece 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoOAuth2Handler.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoOAuth2Handler.java @@ -19,7 +19,7 @@ public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, WxSessionManager sessionManager) { String href = "测试oauth2"; + WxConsts.OAuth2Scope.SNSAPI_USERINFO, null) + "\">测试oauth2"; return WxMpXmlOutMessage.TEXT().content(href) .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) .build(); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpDemoServer.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpDemoServer.java index 3e16042d7f..2f5f25eea7 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpDemoServer.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpDemoServer.java @@ -58,7 +58,7 @@ private static void initWeixin() { wxMpMessageRouter = new WxMpMessageRouter(wxMpService); wxMpMessageRouter.rule().handler(logHandler).next().rule() - .msgType(WxConsts.XML_MSG_TEXT).matcher(guessNumberHandler) + .msgType(WxConsts.XmlMsgType.TEXT).matcher(guessNumberHandler) .handler(guessNumberHandler).end().rule().async(false).content("哈哈") .handler(textHandler).end().rule().async(false).content("图片") .handler(imageHandler).end().rule().async(false).content("oauth") From 97d6f90ac4e2fbd04773d44f8e8b0ed4858e4ae5 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 7 Nov 2017 13:56:21 +0800 Subject: [PATCH 141/165] =?UTF-8?q?=E4=BF=AE=E6=94=B9checkstyle=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E4=BB=A5=E7=AC=A6=E5=90=88IDEA=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=9A=84import=E9=A1=BA=E5=BA=8F=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quality-checks/google_checks.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/quality-checks/google_checks.xml b/quality-checks/google_checks.xml index 925172dab6..9fe031d902 100644 --- a/quality-checks/google_checks.xml +++ b/quality-checks/google_checks.xml @@ -163,9 +163,12 @@ + + + - - + From 67abc9216f87a554ad376692cbe5c71402e61964 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 7 Nov 2017 15:29:10 +0800 Subject: [PATCH 142/165] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcheckstyle=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=87=BA=E6=9D=A5=E7=9A=84=E9=83=A8=E5=88=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quality-checks/google_checks.xml | 4 +- .../chanjar/weixin/common/api/WxConsts.java | 105 ++++++++++++------ .../common/api/WxErrorExceptionHandler.java | 2 +- .../common/api/WxMessageDuplicateChecker.java | 11 +- .../WxMessageInMemoryDuplicateChecker.java | 21 ++-- .../weixin/common/bean/menu/WxMenu.java | 5 +- .../weixin/common/bean/menu/WxMenuButton.java | 15 +-- .../weixin/common/bean/menu/WxMenuRule.java | 2 +- .../weixin/common/bean/result/WxError.java | 5 +- .../http/apache/ApacheHttpClientBuilder.java | 24 ++-- .../apache/ApacheHttpDnsClientBuilder.java | 42 ++++--- .../OkHttpMediaDownloadRequestExecutor.java | 2 +- .../cp/util/xml/XStreamTransformer.java | 2 +- .../bean/AbstractWxMaQrcodeWrapper.java | 2 +- .../wx/miniapp/builder/BaseBuilder.java | 3 + .../util/http/QrCodeRequestExecutor.java | 12 +- .../miniapp/util/xml/XStreamTransformer.java | 8 +- .../mp/bean/device/AbstractDeviceBean.java | 2 + ...ApacheMaterialNewsInfoRequestExecutor.java | 8 +- .../binarywang/wxpay/util/SignUtils.java | 43 ++++--- .../impl/WxPayServiceAbstractImplTest.java | 37 +++++- 21 files changed, 217 insertions(+), 138 deletions(-) diff --git a/quality-checks/google_checks.xml b/quality-checks/google_checks.xml index 9fe031d902..af44980285 100644 --- a/quality-checks/google_checks.xml +++ b/quality-checks/google_checks.xml @@ -40,7 +40,7 @@ - + @@ -52,7 +52,7 @@ - + diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java index fac0843d22..6380749224 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java @@ -4,13 +4,13 @@ import java.util.Map; /** - * 微信开发所使用到的常量类 + * 微信开发所使用到的常量类. * * @author chanjarster & binarywang */ public class WxConsts { /** - * 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型 + * 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型. */ public static class XmlMsgType { public static final String TEXT = "text"; @@ -31,24 +31,57 @@ public static class XmlMsgType { } /** - * 主动发送消息(即客服消息)的消息类型 + * 主动发送消息(即客服消息)的消息类型. */ public static class KefuMsgType { - public static final String TEXT = "text";//文本消息 - public static final String IMAGE = "image";//图片消息 - public static final String VOICE = "voice";//语音消息 - public static final String VIDEO = "video";//视频消息 - public static final String MUSIC = "music";//音乐消息 - public static final String NEWS = "news";//图文消息(点击跳转到外链) - public static final String MPNEWS = "mpnews";//图文消息(点击跳转到图文消息页面) - public static final String FILE = "file";//发送文件(CP专用) - public static final String TEXTCARD = "textcard";//文本卡片消息(CP专用) - public static final String WXCARD = "wxcard";//卡券消息 + /** + * 文本消息. + */ + public static final String TEXT = "text"; + /** + * 图片消息. + */ + public static final String IMAGE = "image"; + /** + * 语音消息. + */ + public static final String VOICE = "voice"; + /** + * 视频消息. + */ + public static final String VIDEO = "video"; + /** + * 音乐消息. + */ + public static final String MUSIC = "music"; + /** + * 图文消息(点击跳转到外链). + */ + public static final String NEWS = "news"; + /** + * 图文消息(点击跳转到图文消息页面). + */ + public static final String MPNEWS = "mpnews"; + /** + * 发送文件(CP专用). + */ + public static final String FILE = "file"; + /** + * 文本卡片消息(CP专用). + */ + public static final String TEXTCARD = "textcard"; + /** + * 卡券消息. + */ + public static final String WXCARD = "wxcard"; + /** + * 转发到客服的消息. + */ public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service"; } /** - * 表示是否是保密消息,0表示否,1表示是,默认0 + * 表示是否是保密消息,0表示否,1表示是,默认0. */ public static class KefuMsgSafe { public static final String NO = "0"; @@ -56,7 +89,7 @@ public static class KefuMsgSafe { } /** - * 群发消息的消息类型 + * 群发消息的消息类型. */ public static class MassMsgType { public static final String MPNEWS = "mpnews"; @@ -67,7 +100,7 @@ public static class MassMsgType { } /** - * 群发消息后微信端推送给服务器的反馈消息 + * 群发消息后微信端推送给服务器的反馈消息. */ public static class MassMsgStatus { public static final String SEND_SUCCESS = "send success"; @@ -83,7 +116,7 @@ public static class MassMsgStatus { public static final String ERR_21000 = "err(21000)"; /** - * 群发反馈消息代码所对应的文字描述 + * 群发反馈消息代码所对应的文字描述. */ public static final Map STATUS_DESC = new HashMap<>(); @@ -103,7 +136,7 @@ public static class MassMsgStatus { } /** - * 微信端推送过来的事件类型 + * 微信端推送过来的事件类型. */ public static class EventType { public static final String SUBSCRIBE = "subscribe"; @@ -124,7 +157,7 @@ public static class EventType { } /** - * 上传多媒体(临时素材)文件的类型 + * 上传多媒体(临时素材)文件的类型. */ public static class MediaFileType { public static final String IMAGE = "image"; @@ -135,78 +168,78 @@ public static class MediaFileType { } /** - * 自定义菜单的按钮类型 + * 自定义菜单的按钮类型. */ public static class MenuButtonType { /** - * 点击推事件 + * 点击推事件. */ public static final String CLICK = "click"; /** - * 跳转URL + * 跳转URL. */ public static final String VIEW = "view"; /** - * 跳转到小程序 + * 跳转到小程序. */ public static final String MINIPROGRAM = "miniprogram"; /** - * 扫码推事件 + * 扫码推事件. */ public static final String SCANCODE_PUSH = "scancode_push"; /** - * 扫码推事件且弹出“消息接收中”提示框 + * 扫码推事件且弹出“消息接收中”提示框. */ public static final String SCANCODE_WAITMSG = "scancode_waitmsg"; /** - * 弹出系统拍照发图 + * 弹出系统拍照发图. */ public static final String PIC_SYSPHOTO = "pic_sysphoto"; /** - * 弹出拍照或者相册发图 + * 弹出拍照或者相册发图. */ public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album"; /** - * 弹出微信相册发图器 + * 弹出微信相册发图器. */ public static final String PIC_WEIXIN = "pic_weixin"; /** - * 弹出地理位置选择器 + * 弹出地理位置选择器. */ public static final String LOCATION_SELECT = "location_select"; /** - * 下发消息(除文本消息) + * 下发消息(除文本消息). */ public static final String MEDIA_ID = "media_id"; /** - * 跳转图文消息URL + * 跳转图文消息URL. */ public static final String VIEW_LIMITED = "view_limited"; } /** - * oauth2网页授权的scope + * oauth2网页授权的scope. */ public static class OAuth2Scope { /** - * 不弹出授权页面,直接跳转,只能获取用户openid + * 不弹出授权页面,直接跳转,只能获取用户openid. */ public static final String SNSAPI_BASE = "snsapi_base"; /** - * 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息 + * 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息. */ public static final String SNSAPI_USERINFO = "snsapi_userinfo"; } /** - * 网页应用登录授权作用域 + * 网页应用登录授权作用域. */ public static class QrConnectScope { public static final String SNSAPI_LOGIN = "snsapi_login"; } /** - * 永久素材类型 + * 永久素材类型. */ public static class MaterialType { public static final String NEWS = "news"; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxErrorExceptionHandler.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxErrorExceptionHandler.java index d6acf55b52..5117c765f3 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxErrorExceptionHandler.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxErrorExceptionHandler.java @@ -3,7 +3,7 @@ import me.chanjar.weixin.common.exception.WxErrorException; /** - * WxErrorException处理器 + * WxErrorException处理器. */ public interface WxErrorExceptionHandler { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageDuplicateChecker.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageDuplicateChecker.java index 831458a443..fdb0cd81bc 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageDuplicateChecker.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageDuplicateChecker.java @@ -2,22 +2,21 @@ /** *
    - * 消息重复检查器
    + * 消息重复检查器.
      * 微信服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次
      * 
    */ public interface WxMessageDuplicateChecker { /** + * 判断消息是否重复. *

    公众号的排重方式

    - *

    + * *

    普通消息:关于重试的消息排重,推荐使用msgid排重。文档参考

    *

    事件消息:关于重试的消息排重,推荐使用FromUserName + CreateTime 排重。文档参考

    - *

    + * *

    企业号的排重方式

    - *

    - * 官方文档完全没有写,参照公众号的方式排重。 - *

    + *

    官方文档完全没有写,参照公众号的方式排重。

    *

    或者可以采取更简单的方式,如果有MsgId就用MsgId排重,如果没有就用FromUserName+CreateTime排重

    * * @param messageId messageId需要根据上面讲的方式构造 diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java index 1281e26012..d8be08f446 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java @@ -6,46 +6,46 @@ /** *
    - * 默认消息重复检查器
    + * 默认消息重复检查器.
      * 将每个消息id保存在内存里,每隔5秒清理已经过期的消息id,每个消息id的过期时间是15秒
      * 
    */ public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChecker { /** - * 一个消息ID在内存的过期时间:15秒 + * 一个消息ID在内存的过期时间:15秒. */ private final Long timeToLive; /** - * 每隔多少周期检查消息ID是否过期:5秒 + * 每隔多少周期检查消息ID是否过期:5秒. */ private final Long clearPeriod; /** - * 消息id->消息时间戳的map + * 消息id->消息时间戳的map. */ private final ConcurrentHashMap msgId2Timestamp = new ConcurrentHashMap<>(); /** - * 后台清理线程是否已经开启 + * 后台清理线程是否已经开启. */ private final AtomicBoolean backgroundProcessStarted = new AtomicBoolean(false); /** - * WxMsgIdInMemoryDuplicateChecker构造函数 + * 无参构造方法. *
        * 一个消息ID在内存的过期时间:15秒
        * 每隔多少周期检查消息ID是否过期:5秒
        * 
    */ public WxMessageInMemoryDuplicateChecker() { - this.timeToLive = 15 * 1000l; - this.clearPeriod = 5 * 1000l; + this.timeToLive = 15 * 1000L; + this.clearPeriod = 5 * 1000L; } /** - * WxMsgIdInMemoryDuplicateChecker构造函数 + * 构造方法. * * @param timeToLive 一个消息ID在内存的过期时间:毫秒 * @param clearPeriod 每隔多少周期检查消息ID是否过期:毫秒 @@ -66,7 +66,8 @@ public void run() { while (true) { Thread.sleep(WxMessageInMemoryDuplicateChecker.this.clearPeriod); Long now = System.currentTimeMillis(); - for (Map.Entry entry : WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet()) { + for (Map.Entry entry : + WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet()) { if (now - entry.getValue() > WxMessageInMemoryDuplicateChecker.this.timeToLive) { WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet().remove(entry); } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenu.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenu.java index 4e61a46591..d82431c96a 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenu.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenu.java @@ -11,7 +11,7 @@ import java.util.List; /** - * 菜单(公众号和企业号共用的) + * 菜单(公众号和企业号共用的). * * @author Daniel Qian */ @@ -36,7 +36,8 @@ public static WxMenu fromJson(String json) { * 相比 http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html 的格式,外层多套了一个menu */ public static WxMenu fromJson(InputStream is) { - return WxGsonBuilder.create().fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), WxMenu.class); + return WxGsonBuilder.create() + .fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), WxMenu.class); } public List getButtons() { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java index aa6ea4cfb2..1c32ef104a 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java @@ -12,7 +12,7 @@ public class WxMenuButton implements Serializable { /** *
    -   * 菜单的响应动作类型:
    +   * 菜单的响应动作类型.
        * view表示网页类型,
        * click表示点击类型,
        * miniprogram表示小程序类型
    @@ -21,13 +21,13 @@ public class WxMenuButton implements Serializable {
       private String type;
     
       /**
    -   * 菜单标题,不超过16个字节,子菜单不超过60个字节
    +   * 菜单标题,不超过16个字节,子菜单不超过60个字节.
        */
       private String name;
     
       /**
        * 
    -   * 菜单KEY值,用于消息接口推送,不超过128字节
    +   * 菜单KEY值,用于消息接口推送,不超过128字节.
        * click等点击类型必须
        * 
    */ @@ -35,7 +35,8 @@ public class WxMenuButton implements Serializable { /** *
    -   * 网页链接,用户点击菜单可打开链接,不超过1024字节。type为miniprogram时,不支持小程序的老版本客户端将打开本url。
    +   * 网页链接.
    +   * 用户点击菜单可打开链接,不超过1024字节。type为miniprogram时,不支持小程序的老版本客户端将打开本url。
        * view、miniprogram类型必须
        * 
    */ @@ -43,7 +44,7 @@ public class WxMenuButton implements Serializable { /** *
    -   * 调用新增永久素材接口返回的合法media_id
    +   * 调用新增永久素材接口返回的合法media_id.
        * media_id类型和view_limited类型必须
        * 
    */ @@ -52,7 +53,7 @@ public class WxMenuButton implements Serializable { /** *
    -   * 小程序的appid
    +   * 小程序的appid.
        * miniprogram类型必须
        * 
    */ @@ -61,7 +62,7 @@ public class WxMenuButton implements Serializable { /** *
    -   * 小程序的页面路径
    +   * 小程序的页面路径.
        * miniprogram类型必须
        * 
    */ diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java index efc42fbb6b..dffae94887 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java @@ -9,7 +9,7 @@ public class WxMenuRule implements Serializable { private static final long serialVersionUID = -4587181819499286670L; /** - * 变态的微信接口,反序列化时这里反人类的使用和序列化时不一样的名字 + * 变态的微信接口,反序列化时这里反人类的使用和序列化时不一样的名字. */ @SerializedName(value = "tag_id", alternate = "group_id") private String tagId; diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java index 46c0ae89be..809d015ab0 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java @@ -5,7 +5,7 @@ import java.io.Serializable; /** - * 微信错误码说明,请阅读: 全局返回码说明 + * 微信错误码说明,请阅读: 全局返回码说明. * * @author Daniel Qian */ @@ -73,6 +73,9 @@ public Builder setErrorMsg(String errorMsg) { return this; } + /** + * 构造器方法. + */ public WxError build() { WxError wxError = new WxError(); wxError.setErrorCode(this.errorCode); diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpClientBuilder.java index 939b624785..fcd56c48a7 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpClientBuilder.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpClientBuilder.java @@ -4,51 +4,41 @@ import org.apache.http.impl.client.CloseableHttpClient; /** - * httpclient build interface + * httpclient build interface. * * @author kakotor */ public interface ApacheHttpClientBuilder { /** - * 构建httpclient实例 + * 构建httpclient实例. * * @return new instance of CloseableHttpClient */ CloseableHttpClient build(); /** - * 代理服务器地址 - * - * @param httpProxyHost + * 代理服务器地址. */ ApacheHttpClientBuilder httpProxyHost(String httpProxyHost); /** - * 代理服务器端口 - * - * @param httpProxyPort + * 代理服务器端口. */ ApacheHttpClientBuilder httpProxyPort(int httpProxyPort); /** - * 代理服务器用户名 - * - * @param httpProxyUsername + * 代理服务器用户名. */ ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername); /** - * 代理服务器密码 - * - * @param httpProxyPassword + * 代理服务器密码. */ ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword); /** - * ssl连接socket工厂 - * - * @param sslConnectionSocketFactory + * ssl连接socket工厂. */ ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory); } diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java index d3e5a1c167..b99b09fb8f 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheHttpDnsClientBuilder.java @@ -29,9 +29,8 @@ import java.util.concurrent.atomic.AtomicBoolean; /** - * httpclient 连接管理器 自带DNS解析 - *

    - * 大部分代码拷贝自:DefaultApacheHttpClientBuilder + * httpclient 连接管理器 自带DNS解析. + *

    大部分代码拷贝自:DefaultApacheHttpClientBuilder

    * * @author Andy.Huo */ @@ -64,7 +63,7 @@ public boolean retryRequest(IOException exception, int executionCount, HttpConte private String httpProxyPassword; /** - * 闲置连接监控线程 + * 闲置连接监控线程. */ private IdleConnectionMonitorThread idleConnectionMonitorThread; private HttpClientBuilder httpClientBuilder; @@ -162,7 +161,7 @@ public void setCheckWaitTime(int checkWaitTime) { } /** - * 每路的最大链接数,默认10 + * 每路的最大链接数,默认10. * * @param maxConnPerHost 每路的最大链接数,默认10 */ @@ -171,7 +170,7 @@ public void setMaxConnPerHost(int maxConnPerHost) { } /** - * 最大总连接数,默认50 + * 最大总连接数,默认50. * * @param maxTotalConn 最大总连接数,默认50 */ @@ -180,7 +179,7 @@ public void setMaxTotalConn(int maxTotalConn) { } /** - * 自定义httpclient的User Agent + * 自定义httpclient的User Agent. * * @param userAgent User Agent */ @@ -196,9 +195,12 @@ private synchronized void prepare() { if (prepared.get()) { return; } - Registry registry = RegistryBuilder.create() - .register("http", this.plainConnectionSocketFactory).register("https", this.sslConnectionSocketFactory) - .build(); + + Registry registry = + RegistryBuilder.create() + .register("http", this.plainConnectionSocketFactory) + .register("https", this.sslConnectionSocketFactory) + .build(); @SuppressWarnings("resource") PoolingHttpClientConnectionManager connectionManager; @@ -219,8 +221,8 @@ private synchronized void prepare() { connectionManager .setDefaultSocketConfig(SocketConfig.copy(SocketConfig.DEFAULT).setSoTimeout(this.soTimeout).build()); - this.idleConnectionMonitorThread = new IdleConnectionMonitorThread(connectionManager, this.idleConnTimeout, - this.checkWaitTime); + this.idleConnectionMonitorThread = new IdleConnectionMonitorThread( + connectionManager, this.idleConnTimeout, this.checkWaitTime); this.idleConnectionMonitorThread.setDaemon(true); this.idleConnectionMonitorThread.start(); @@ -234,8 +236,8 @@ private synchronized void prepare() { if (StringUtils.isNotBlank(this.httpProxyHost) && StringUtils.isNotBlank(this.httpProxyUsername)) { // 使用代理服务器 需要用户认证的代理服务器 CredentialsProvider provider = new BasicCredentialsProvider(); - provider.setCredentials(new AuthScope(this.httpProxyHost, this.httpProxyPort), - new UsernamePasswordCredentials(this.httpProxyUsername, this.httpProxyPassword)); + provider.setCredentials(new AuthScope(this.httpProxyHost, this.httpProxyPort) + , new UsernamePasswordCredentials(this.httpProxyUsername, this.httpProxyPassword)); this.httpClientBuilder.setDefaultCredentialsProvider(provider); } @@ -267,8 +269,10 @@ public static class IdleConnectionMonitorThread extends Thread { private final int checkWaitTime; private volatile boolean shutdown; - public IdleConnectionMonitorThread(HttpClientConnectionManager connMgr, int idleConnTimeout, - int checkWaitTime) { + /** + * 构造方法. + */ + public IdleConnectionMonitorThread(HttpClientConnectionManager connMgr, int idleConnTimeout, int checkWaitTime) { super("IdleConnectionMonitorThread"); this.connMgr = connMgr; this.idleConnTimeout = idleConnTimeout; @@ -289,12 +293,18 @@ public void run() { } } + /** + * 触发. + */ public void trigger() { synchronized (this) { notifyAll(); } } + /** + * 关闭. + */ public void shutdown() { this.shutdown = true; synchronized (this) { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java index 2eb71b52f1..80f8199296 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMediaDownloadRequestExecutor.java @@ -2,8 +2,8 @@ import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.common.util.http.HttpResponseProxy; import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; +import me.chanjar.weixin.common.util.http.HttpResponseProxy; import me.chanjar.weixin.common.util.http.RequestHttp; import okhttp3.OkHttpClient; import okhttp3.Request; diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java index c86ed1ff67..e08ef4df60 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/xml/XStreamTransformer.java @@ -28,7 +28,7 @@ public static T fromXml(Class clazz, InputStream is) { } /** - * 注册扩展消息的解析器 + * 注册扩展消息的解析器. * * @param clz 类型 * @param xStream xml解析器 diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/AbstractWxMaQrcodeWrapper.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/AbstractWxMaQrcodeWrapper.java index b4ad751791..f329dd30e8 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/AbstractWxMaQrcodeWrapper.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/AbstractWxMaQrcodeWrapper.java @@ -3,7 +3,7 @@ import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; /** - * 微信二维码(小程序码)包装器 + * 微信二维码(小程序码)包装器. * * @author Element */ diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/BaseBuilder.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/BaseBuilder.java index 70d7cf4b7c..c353534c3f 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/BaseBuilder.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/builder/BaseBuilder.java @@ -15,6 +15,9 @@ public T toUser(String toUser) { return (T) this; } + /** + * 构造器方法. + */ public WxMaKefuMessage build() { WxMaKefuMessage m = new WxMaKefuMessage(); m.setMsgType(this.msgType); diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java index 24d9e99b77..9b35df8957 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java @@ -36,11 +36,9 @@ public QrCodeRequestExecutor(RequestHttp requestHttp) { public File execute(String uri, AbstractWxMaQrcodeWrapper ticket) throws WxErrorException, IOException { HttpPost httpPost = new HttpPost(uri); if (requestHttp.getRequestHttpProxy() != null) { - httpPost - .setConfig(RequestConfig.custom() - .setProxy(requestHttp.getRequestHttpProxy()) - .build() - ); + httpPost.setConfig( + RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build() + ); } httpPost.setEntity(new StringEntity(ticket.toString())); @@ -48,8 +46,8 @@ public File execute(String uri, AbstractWxMaQrcodeWrapper ticket) throws WxError InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);) { Header[] contentTypeHeader = response.getHeaders("Content-Type"); if (contentTypeHeader != null && contentTypeHeader.length > 0 - && ContentType.APPLICATION_JSON.getMimeType() - .equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) { + && ContentType.APPLICATION_JSON.getMimeType() + .equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) { String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); throw new WxErrorException(WxError.fromJson(responseContent)); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java index 8c6ec52ad7..578bf68c71 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/xml/XStreamTransformer.java @@ -18,7 +18,7 @@ public class XStreamTransformer { } /** - * xml -> pojo + * xml -> pojo. */ @SuppressWarnings("unchecked") public static T fromXml(Class clazz, String xml) { @@ -33,14 +33,14 @@ public static T fromXml(Class clazz, InputStream is) { } /** - * pojo -> xml + * pojo -> xml. */ public static String toXml(Class clazz, T object) { return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object); } /** - * 注册扩展消息的解析器 + * 注册扩展消息的解析器. * * @param clz 类型 * @param xStream xml解析器 @@ -50,7 +50,7 @@ private static void register(Class clz, XStream xStream) { } /** - * 会自动注册该类及其子类 + * 会自动注册该类及其子类. * * @param clz 要注册的类 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java index 5aaf5ea5eb..d49999c504 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java @@ -5,6 +5,8 @@ import java.io.Serializable; /** + * 设备抽象类. + * * @author keungtung * @date 14/12/2016 */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java index 5298160f35..fe8dc580d7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java @@ -22,9 +22,13 @@ import java.util.Map; /** - * Created by ecoolper on 2017/5/5. + * httpclient 实现的素材请求执行器. + * + * @author ecoolper + * @date 2017/5/5 */ -public class ApacheMaterialNewsInfoRequestExecutor extends MaterialNewsInfoRequestExecutor { +public class ApacheMaterialNewsInfoRequestExecutor + extends MaterialNewsInfoRequestExecutor { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public ApacheMaterialNewsInfoRequestExecutor(RequestHttp requestHttp) { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java index 9928447575..efb9d85604 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/util/SignUtils.java @@ -19,16 +19,17 @@ /** *
    - * 签名相关工具类
    + * 签名相关工具类.
      * Created by Binary Wang on 2017-3-23.
    - * @author binarywang(Binary Wang)
      * 
    + * + * @author binarywang(Binary Wang) */ public class SignUtils { private static final Logger log = LoggerFactory.getLogger(SignUtils.class); /** - * 请参考并使用 {@link #createSign(Object, String, String, boolean)} + * 请参考并使用 {@link #createSign(Object, String, String, boolean)}. */ @Deprecated public static String createSign(Object xmlBean, String signKey) { @@ -36,7 +37,7 @@ public static String createSign(Object xmlBean, String signKey) { } /** - * 请参考并使用 {@link #createSign(Map, String, String, boolean)} + * 请参考并使用 {@link #createSign(Map, String, String, boolean)}. */ @Deprecated public static String createSign(Map params, String signKey) { @@ -44,7 +45,7 @@ public static String createSign(Map params, String signKey) { } /** - * 微信支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3) + * 微信支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3). * * @param xmlBean Bean里的属性如果存在XML注解,则使用其作为key,否则使用变量名 * @param signType 签名类型,如果为空,则默认为MD5 @@ -57,27 +58,25 @@ public static String createSign(Object xmlBean, String signType, String signKey, } /** - * 微信支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3) + * 微信支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3). * - * @param params 参数信息 - * @param signType 签名类型,如果为空,则默认为MD5 - * @param signKey 签名Key - * @param isIgnoreSignType 签名时,是否忽略signType + * @param params 参数信息 + * @param signType 签名类型,如果为空,则默认为MD5 + * @param signKey 签名Key + * @param ignoreSignType 签名时,是否忽略signType * @return 签名字符串 */ - public static String createSign(Map params, String signType, String signKey, boolean isIgnoreSignType) { + public static String createSign(Map params, String signType, String signKey, boolean ignoreSignType) { SortedMap sortedMap = new TreeMap<>(params); StringBuilder toSign = new StringBuilder(); for (String key : sortedMap.keySet()) { String value = params.get(key); boolean shouldSign = false; - if (isIgnoreSignType && "sign_type".equals(key)) { + if (ignoreSignType && "sign_type".equals(key)) { shouldSign = false; } else if (StringUtils.isNotEmpty(value) - && !Lists.newArrayList( - "sign", "key", "xmlString", "xmlDoc", "couponList").contains(key) - ) { + && !Lists.newArrayList("sign", "key", "xmlString", "xmlDoc", "couponList").contains(key)) { shouldSign = true; } @@ -88,18 +87,18 @@ public static String createSign(Map params, String signType, Str toSign.append("key=").append(signKey); if (SignType.HMAC_SHA256.equals(signType)) { - return createHMACSha256Sign(toSign.toString(), signKey); + return createHmacSha256Sign(toSign.toString(), signKey); } else { return DigestUtils.md5Hex(toSign.toString()).toUpperCase(); } } - private static String createHMACSha256Sign(String message, String key) { + private static String createHmacSha256Sign(String message, String key) { try { - Mac hmacSHA256 = Mac.getInstance("HmacSHA256"); + Mac sha256 = Mac.getInstance("HmacSHA256"); SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "HmacSHA256"); - hmacSHA256.init(secretKeySpec); - byte[] bytes = hmacSHA256.doFinal(message.getBytes()); + sha256.init(secretKeySpec); + byte[] bytes = sha256.doFinal(message.getBytes()); return Hex.encodeHexString(bytes).toUpperCase(); } catch (NoSuchAlgorithmException | InvalidKeyException e) { log.error(e.getMessage(), e); @@ -109,7 +108,7 @@ private static String createHMACSha256Sign(String message, String key) { } /** - * 校验签名是否正确 + * 校验签名是否正确. * * @param xmlBean Bean需要标记有XML注解 * @param signType 签名类型,如果为空,则默认为MD5 @@ -121,7 +120,7 @@ public static boolean checkSign(Object xmlBean, String signType, String signKey) } /** - * 校验签名是否正确 + * 校验签名是否正确. * * @param params 需要校验的参数Map * @param signType 签名类型,如果为空,则默认为MD5 diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index 84a9156ba6..9c293103b6 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -2,6 +2,7 @@ import com.github.binarywang.utils.qrcode.QrcodeUtils; import com.github.binarywang.wxpay.bean.coupon.*; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult; import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; @@ -398,9 +399,43 @@ public void testQueryComment() throws Exception { this.logger.info(result); } + /** + * @see {@link com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResultTest} + * @throws Exception + */ @Test public void testParseOrderNotifyResult() throws Exception { - // 请参考com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResultTest里的单元测试 + // 请参考com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResultTest 里的单元测试 + + String xmlString = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 1\n" + + " \n" + + " \n" + + " 2\n" + + " \n" + + " 10000\n" + + " 100\n" + + " \n" + + " 10001\n" + + " 200\n" + + ""; + + WxPayOrderNotifyResult result = this.payService.parseOrderNotifyResult(xmlString); + System.out.println(result); } @Test From e5bd65f2dbc57735bcf78e987699281076cc1be7 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 7 Nov 2017 15:55:42 +0800 Subject: [PATCH 143/165] =?UTF-8?q?#333=20=E4=BF=AE=E5=A4=8D=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E9=AA=8C=E9=87=8D=E9=97=AE=E9=A2=98=EF=BC=88mp?= =?UTF-8?q?=E5=92=8Ccp=E5=90=8C=E6=97=B6=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/message/WxCpMessageRouter.java | 15 +++++++++------ .../chanjar/weixin/mp/api/WxMpMessageRouter.java | 10 ++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java index 3c53d26106..99e4fd4573 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouter.java @@ -11,6 +11,7 @@ import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpXmlMessage; import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -215,17 +216,19 @@ public WxCpXmlOutMessage route(final WxCpXmlMessage wxMessage) { } protected boolean isDuplicateMessage(WxCpXmlMessage wxMessage) { - - String messageId = ""; + String messageId; if (wxMessage.getMsgId() == null) { messageId = String.valueOf(wxMessage.getCreateTime()) - + "-" + String.valueOf(wxMessage.getAgentId() == null ? "" : wxMessage.getAgentId()) + + "-" + StringUtils.trimToEmpty(String.valueOf(wxMessage.getAgentId())) + "-" + wxMessage.getFromUserName() - + "-" + String.valueOf(wxMessage.getEventKey() == null ? "" : wxMessage.getEventKey()) - + "-" + String.valueOf(wxMessage.getEvent() == null ? "" : wxMessage.getEvent()) + + "-" + StringUtils.trimToEmpty(wxMessage.getEventKey()) + + "-" + StringUtils.trimToEmpty(wxMessage.getEvent()) ; } else { - messageId = String.valueOf(wxMessage.getMsgId()); + messageId = new StringBuilder().append(wxMessage.getMsgId()) + .append("-").append(wxMessage.getCreateTime()) + .append("-").append(wxMessage.getFromUserName()) + .toString(); } return this.messageDuplicateChecker.isDuplicate(messageId); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java index 5acf0040aa..6b7ddd08e2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java @@ -10,6 +10,7 @@ import me.chanjar.weixin.common.util.LogExceptionHandler; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -195,16 +196,17 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage) { } protected boolean isMsgDuplicated(WxMpXmlMessage wxMessage) { - StringBuilder messageId = new StringBuilder(); if (wxMessage.getMsgId() == null) { messageId.append(wxMessage.getCreateTime()) .append("-").append(wxMessage.getFromUser()) - .append("-").append(wxMessage.getEventKey() == null ? "" : wxMessage.getEventKey()) - .append("-").append(wxMessage.getEvent() == null ? "" : wxMessage.getEvent()) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getEventKey())) + .append("-").append(StringUtils.trimToEmpty(wxMessage.getEvent())) ; } else { - messageId.append(wxMessage.getMsgId()); + messageId.append(wxMessage.getMsgId()) + .append("-").append(wxMessage.getCreateTime()) + .append("-").append(wxMessage.getFromUser()); } return this.messageDuplicateChecker.isDuplicate(messageId.toString()); From 5ec5ae8bbe242c299d005d9f8318fb3d23ea9e5a Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 9 Nov 2017 11:40:16 +0800 Subject: [PATCH 144/165] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E4=BD=BF=E7=94=A8WxE?= =?UTF-8?q?rrorException?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java | 4 ++-- .../weixin/mp/api/impl/WxMpMassMessageServiceImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java index 6d1f025728..a7aacd544c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMassMessageService.java @@ -94,7 +94,7 @@ public interface WxMpMassMessageService { * * @return wxMpMassSendResult */ - WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception; + WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws WxErrorException; /** *
    @@ -114,6 +114,6 @@ public interface WxMpMassMessageService {
        * @param msgId        发送出去的消息ID
        * @param articleIndex 要删除的文章在图文消息中的位置,第一篇编号为1,该字段不填或填0会删除全部文章
        */
    -  void delete(Integer msgId, Integer articleIndex) throws Exception;
    +  void delete(Integer msgId, Integer articleIndex) throws WxErrorException;
     
     }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java
    index c54fcc768c..779bbc4d9d 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMassMessageServiceImpl.java
    @@ -51,13 +51,13 @@ public WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message)
       }
     
       @Override
    -  public WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception {
    +  public WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws WxErrorException {
         String responseContent = this.wxMpService.post(MESSAGE_MASS_PREVIEW_URL, wxMpMassPreviewMessage.toJson());
         return WxMpMassSendResult.fromJson(responseContent);
       }
     
       @Override
    -  public void delete(Integer msgId, Integer articleIndex) throws Exception {
    +  public void delete(Integer msgId, Integer articleIndex) throws WxErrorException {
         JsonObject jsonObject = new JsonObject();
         jsonObject.addProperty("msg_id", msgId);
         jsonObject.addProperty("article_idx", articleIndex);
    
    From d52a55ff8dacafbf384f93cc6aa98d6bd0dc1784 Mon Sep 17 00:00:00 2001
    From: 007gzs <007gzs@gmail.com>
    Date: Thu, 9 Nov 2017 11:46:07 +0800
    Subject: [PATCH 145/165] =?UTF-8?q?#=20368=20=E5=A2=9E=E5=8A=A0=20?=
     =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=AC=AC=E4=B8=89=E6=96=B9=E5=B9=B3=E5=8F=B0?=
     =?UTF-8?q?=20=E6=A8=A1=E5=9D=97?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    * 增加 微信第三方平台 接口
    
    * WxOpenXmlMessage 消息处理
    ---
     pom.xml                                       | 768 +++++++++---------
     weixin-java-open/README.md                    |  62 ++
     weixin-java-open/pom.xml                      |  97 +++
     .../open/api/WxOpenComponentService.java      |  82 ++
     .../weixin/open/api/WxOpenConfigStorage.java  | 106 +++
     .../weixin/open/api/WxOpenService.java        |  22 +
     .../api/impl/WxOpenComponentServiceImpl.java  | 218 +++++
     .../api/impl/WxOpenInMemoryConfigStorage.java | 386 +++++++++
     .../api/impl/WxOpenInRedisConfigStorage.java  | 164 ++++
     .../open/api/impl/WxOpenMpServiceImpl.java    |  49 ++
     .../api/impl/WxOpenServiceAbstractImpl.java   |  63 ++
     .../WxOpenServiceApacheHttpClientImpl.java    |  44 +
     .../open/api/impl/WxOpenServiceImpl.java      |   8 +
     .../bean/WxOpenAuthorizerAccessToken.java     |  35 +
     .../open/bean/WxOpenComponentAccessToken.java |  35 +
     .../bean/auth/WxOpenAuthorizationInfo.java    |  18 +
     .../open/bean/auth/WxOpenAuthorizerInfo.java  |  22 +
     .../open/bean/message/WxOpenXmlMessage.java   | 100 +++
     .../result/WxOpenAuthorizerInfoResult.java    |  16 +
     .../result/WxOpenAuthorizerOptionResult.java  |  15 +
     .../bean/result/WxOpenQueryAuthResult.java    |  14 +
     .../weixin/open/util/WxOpenCryptUtil.java     |  28 +
     .../WxOpenAuthorizationInfoGsonAdapter.java   |  45 +
     ...xOpenAuthorizerAccessTokenGsonAdapter.java |  21 +
     .../json/WxOpenAuthorizerInfoGsonAdapter.java |  38 +
     ...WxOpenAuthorizerInfoResultGsonAdapter.java |  32 +
     ...OpenAuthorizerOptionResultGsonAdapter.java |  22 +
     ...WxOpenComponentAccessTokenGsonAdapter.java |  21 +
     .../open/util/json/WxOpenGsonBuilder.java     |  36 +
     .../WxOpenQueryAuthResultGsonAdapter.java     |  26 +
     .../open/util/xml/XStreamTransformer.java     |  90 ++
     31 files changed, 2302 insertions(+), 381 deletions(-)
     create mode 100644 weixin-java-open/README.md
     create mode 100644 weixin-java-open/pom.xml
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenConfigStorage.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenService.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceApacheHttpClientImpl.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceImpl.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenAuthorizerAccessToken.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenComponentAccessToken.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizationInfo.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResult.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerOptionResult.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenQueryAuthResult.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizationInfoGsonAdapter.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerAccessTokenGsonAdapter.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoResultGsonAdapter.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerOptionResultGsonAdapter.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenComponentAccessTokenGsonAdapter.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenGsonBuilder.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenQueryAuthResultGsonAdapter.java
     create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/util/xml/XStreamTransformer.java
    
    diff --git a/pom.xml b/pom.xml
    index 7eb78c33ca..38d24fd76c 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -1,381 +1,387 @@
    -
    -
    -  4.0.0
    -  com.github.binarywang
    -  weixin-java-parent
    -  2.8.6.BETA
    -  pom
    -  WeiXin Java Tools - Parent
    -  微信公众号、企业号上级POM
    -  https://github.com/wechat-group/weixin-java-tools
    -
    -  
    -    
    -      The Apache License, Version 2.0
    -      http://www.apache.org/licenses/LICENSE-2.0.txt
    -    
    -  
    -
    -  
    -    
    -      Daniel Qian
    -      chanjarster@gmail.com
    -      https://github.com/chanjarster
    -    
    -    
    -      Binary Wang
    -      binarywang@gmail.com
    -      https://github.com/binarywang
    -    
    -    
    -      gaigeshen
    -      gaigeshen@qq.com
    -      https://github.com/gaigeshen
    -    
    -    
    -      Liu Mingbo
    -      liumingbo2008@gmail.com
    -      https://github.com/FirenzesEagle
    -    
    -    
    -      kakotor
    -      kakotor@gmail.com
    -      https://github.com/kakotor
    -    
    -    
    -      xiong
    -      zhaoxiong.tan@gmail.com
    -      https://github.com/ZhaoxiongTan
    -    
    -    
    -      LiuJunGuang
    -      aimilin@yeah.net
    -      https://github.com/aimilin6688
    -    
    -    
    -      Eric.Tsai
    -      xiaodong.cai.ks@gmail.com
    -      https://github.com/iwareserictsai
    -    
    -    
    -      withinthefog
    -      withinthefog@gmail.com
    -      https://github.com/withinthefog
    -    
    -    
    -      Keung
    -      dongfuqiang1988@163.com
    -      https://github.com/johnnytung
    -    
    -    
    -      Jonk
    -      aimilin@yeah.net
    -      https://github.com/aimilin6688
    -    
    -    
    -      ecoolper
    -      crskyp@gmail.com
    -      https://github.com/crskyp
    -    
    -  
    -
    -  
    -    scm:git:https://github.com/wechat-group/weixin-java-tools.git
    -    scm:git:git@github.com:wechat-group/weixin-java-tools.git
    -    https://github.com/wechat-group/weixin-java-tools
    -  
    -
    -  
    -    weixin-java-common
    -    weixin-java-cp
    -    weixin-java-mp
    -    weixin-java-pay
    -    weixin-java-miniapp
    -    
    -  
    -
    -  
    -    1.7
    -    1.7
    -
    -    UTF-8
    -    true
    -    true
    -    4.5
    -    9.3.0.RC0
    -  
    -
    -  
    -    
    -      
    -        com.github.binarywang
    -        qrcode-utils
    -        1.1
    -      
    -      
    -      
    -        org.jodd
    -        jodd-http
    -        3.7.1
    -        provided
    -      
    -      
    -        com.squareup.okhttp3
    -        okhttp
    -        3.7.0
    -        provided
    -      
    -
    -      
    -        org.apache.httpcomponents
    -        httpclient
    -        ${httpclient.version}
    -      
    -      
    -        org.apache.httpcomponents
    -        httpmime
    -        ${httpclient.version}
    -      
    -      
    -        commons-codec
    -        commons-codec
    -        1.10
    -      
    -      
    -        commons-io
    -        commons-io
    -        2.5
    -      
    -      
    -        org.apache.commons
    -        commons-lang3
    -        3.5
    -      
    -      
    -        org.slf4j
    -        slf4j-api
    -        1.7.24
    -      
    -      
    -        com.thoughtworks.xstream
    -        xstream
    -        1.4.9
    -      
    -      
    -      
    -        com.google.guava
    -        guava
    -        20.0
    -      
    -      
    -        com.google.code.gson
    -        gson
    -        2.8.0
    -      
    -
    -      
    -      
    -        joda-time
    -        joda-time
    -        2.9.7
    -        test
    -      
    -      
    -        ch.qos.logback
    -        logback-classic
    -        1.1.11
    -        test
    -      
    -      
    -        com.google.inject
    -        guice
    -        3.0
    -        test
    -      
    -      
    -        org.testng
    -        testng
    -        6.10
    -        test
    -      
    -      
    -        org.mockito
    -        mockito-all
    -        1.9.5
    -        test
    -      
    -      
    -        org.eclipse.jetty
    -        jetty-server
    -        ${jetty.version}
    -        test
    -      
    -      
    -        org.eclipse.jetty
    -        jetty-servlet
    -        ${jetty.version}
    -        test
    -      
    -      
    -        redis.clients
    -        jedis
    -        2.9.0
    -        provided
    -      
    -      
    -        org.projectlombok
    -        lombok
    -        1.16.18
    -        compile
    -      
    -    
    -  
    -
    -  
    -    
    -      ossrh
    -      https://oss.sonatype.org/content/repositories/snapshots
    -    
    -    
    -      ossrh
    -      https://oss.sonatype.org/service/local/staging/deploy/maven2/
    -    
    -  
    -
    -  
    -    
    -      doclint-java8-disable
    -      
    -        [1.8,)
    -      
    -      
    -        -Xdoclint:none
    -      
    -    
    -
    -    
    -      release
    -      
    -        
    -          
    -            org.apache.maven.plugins
    -            maven-source-plugin
    -            2.2.1
    -            
    -              
    -                attach-sources
    -                
    -                  jar-no-fork
    -                
    -              
    -            
    -          
    -          
    -            org.apache.maven.plugins
    -            maven-javadoc-plugin
    -            2.9.1
    -            
    -              
    -                attach-javadocs
    -                
    -                  jar
    -                
    -              
    -            
    -            
    -              ${javadoc.opts}
    -              UTF-8
    -              zh_CN
    -            
    -          
    -          
    -            org.apache.maven.plugins
    -            maven-gpg-plugin
    -            1.6
    -            
    -              
    -                sign-artifacts
    -                verify
    -                
    -                  sign
    -                
    -              
    -            
    -          
    -        
    -      
    -    
    -  
    -
    -  
    -    
    -      
    -        
    -          org.apache.maven.plugins
    -          maven-surefire-plugin
    -          2.17
    -          
    -            true
    -          
    -        
    -      
    -    
    -
    -    
    -      
    -        org.sonatype.plugins
    -        nexus-staging-maven-plugin
    -        1.6.3
    -        true
    -        
    -          ossrh
    -          https://oss.sonatype.org/
    -          true
    -        
    -      
    -      
    -        org.apache.maven.plugins
    -        maven-release-plugin
    -        2.5.1
    -        
    -          true
    -          false
    -          release
    -          deploy
    -        
    -      
    -      
    -        org.apache.maven.plugins
    -        maven-compiler-plugin
    -        3.6.0
    -        
    -          UTF-8
    -        
    -      
    -
    -      
    -        org.apache.maven.plugins
    -        maven-checkstyle-plugin
    -        2.17
    -        
    -          quality-checks/google_checks.xml
    -          true
    -          true
    -          true
    -        
    -        
    -          
    -            verify
    -            
    -              check
    -            
    -          
    -        
    -      
    -    
    -  
    -
    -
    +
    +
    +  4.0.0
    +  com.github.binarywang
    +  weixin-java-parent
    +  2.8.6.BETA
    +  pom
    +  WeiXin Java Tools - Parent
    +  微信公众号、企业号上级POM
    +  https://github.com/wechat-group/weixin-java-tools
    +
    +  
    +    
    +      The Apache License, Version 2.0
    +      http://www.apache.org/licenses/LICENSE-2.0.txt
    +    
    +  
    +
    +  
    +    
    +      Daniel Qian
    +      chanjarster@gmail.com
    +      https://github.com/chanjarster
    +    
    +    
    +      Binary Wang
    +      binarywang@gmail.com
    +      https://github.com/binarywang
    +    
    +    
    +      gaigeshen
    +      gaigeshen@qq.com
    +      https://github.com/gaigeshen
    +    
    +    
    +      Liu Mingbo
    +      liumingbo2008@gmail.com
    +      https://github.com/FirenzesEagle
    +    
    +    
    +      kakotor
    +      kakotor@gmail.com
    +      https://github.com/kakotor
    +    
    +    
    +      xiong
    +      zhaoxiong.tan@gmail.com
    +      https://github.com/ZhaoxiongTan
    +    
    +    
    +      LiuJunGuang
    +      aimilin@yeah.net
    +      https://github.com/aimilin6688
    +    
    +    
    +      Eric.Tsai
    +      xiaodong.cai.ks@gmail.com
    +      https://github.com/iwareserictsai
    +    
    +    
    +      withinthefog
    +      withinthefog@gmail.com
    +      https://github.com/withinthefog
    +    
    +    
    +      Keung
    +      dongfuqiang1988@163.com
    +      https://github.com/johnnytung
    +    
    +    
    +      Jonk
    +      aimilin@yeah.net
    +      https://github.com/aimilin6688
    +    
    +    
    +      ecoolper
    +      crskyp@gmail.com
    +      https://github.com/crskyp
    +    
    +    
    +      007
    +      007gzs@gmail.com
    +      https://github.com/007gzs
    +    
    +  
    +
    +  
    +    scm:git:https://github.com/wechat-group/weixin-java-tools.git
    +    scm:git:git@github.com:wechat-group/weixin-java-tools.git
    +    https://github.com/wechat-group/weixin-java-tools
    +  
    +
    +  
    +    weixin-java-common
    +    weixin-java-cp
    +    weixin-java-mp
    +    weixin-java-pay
    +    weixin-java-miniapp
    +    weixin-java-open
    +    
    +  
    +
    +  
    +    1.7
    +    1.7
    +
    +    UTF-8
    +    true
    +    true
    +    4.5
    +    9.3.0.RC0
    +  
    +
    +  
    +    
    +      
    +        com.github.binarywang
    +        qrcode-utils
    +        1.1
    +      
    +      
    +      
    +        org.jodd
    +        jodd-http
    +        3.7.1
    +        provided
    +      
    +      
    +        com.squareup.okhttp3
    +        okhttp
    +        3.7.0
    +        provided
    +      
    +
    +      
    +        org.apache.httpcomponents
    +        httpclient
    +        ${httpclient.version}
    +      
    +      
    +        org.apache.httpcomponents
    +        httpmime
    +        ${httpclient.version}
    +      
    +      
    +        commons-codec
    +        commons-codec
    +        1.10
    +      
    +      
    +        commons-io
    +        commons-io
    +        2.5
    +      
    +      
    +        org.apache.commons
    +        commons-lang3
    +        3.5
    +      
    +      
    +        org.slf4j
    +        slf4j-api
    +        1.7.24
    +      
    +      
    +        com.thoughtworks.xstream
    +        xstream
    +        1.4.9
    +      
    +      
    +      
    +        com.google.guava
    +        guava
    +        20.0
    +      
    +      
    +        com.google.code.gson
    +        gson
    +        2.8.0
    +      
    +
    +      
    +      
    +        joda-time
    +        joda-time
    +        2.9.7
    +        test
    +      
    +      
    +        ch.qos.logback
    +        logback-classic
    +        1.1.11
    +        test
    +      
    +      
    +        com.google.inject
    +        guice
    +        3.0
    +        test
    +      
    +      
    +        org.testng
    +        testng
    +        6.10
    +        test
    +      
    +      
    +        org.mockito
    +        mockito-all
    +        1.9.5
    +        test
    +      
    +      
    +        org.eclipse.jetty
    +        jetty-server
    +        ${jetty.version}
    +        test
    +      
    +      
    +        org.eclipse.jetty
    +        jetty-servlet
    +        ${jetty.version}
    +        test
    +      
    +      
    +        redis.clients
    +        jedis
    +        2.9.0
    +        provided
    +      
    +      
    +        org.projectlombok
    +        lombok
    +        1.16.18
    +        compile
    +      
    +    
    +  
    +
    +  
    +    
    +      ossrh
    +      https://oss.sonatype.org/content/repositories/snapshots
    +    
    +    
    +      ossrh
    +      https://oss.sonatype.org/service/local/staging/deploy/maven2/
    +    
    +  
    +
    +  
    +    
    +      doclint-java8-disable
    +      
    +        [1.8,)
    +      
    +      
    +        -Xdoclint:none
    +      
    +    
    +
    +    
    +      release
    +      
    +        
    +          
    +            org.apache.maven.plugins
    +            maven-source-plugin
    +            2.2.1
    +            
    +              
    +                attach-sources
    +                
    +                  jar-no-fork
    +                
    +              
    +            
    +          
    +          
    +            org.apache.maven.plugins
    +            maven-javadoc-plugin
    +            2.9.1
    +            
    +              
    +                attach-javadocs
    +                
    +                  jar
    +                
    +              
    +            
    +            
    +              ${javadoc.opts}
    +              UTF-8
    +              zh_CN
    +            
    +          
    +          
    +            org.apache.maven.plugins
    +            maven-gpg-plugin
    +            1.6
    +            
    +              
    +                sign-artifacts
    +                verify
    +                
    +                  sign
    +                
    +              
    +            
    +          
    +        
    +      
    +    
    +  
    +
    +  
    +    
    +      
    +        
    +          org.apache.maven.plugins
    +          maven-surefire-plugin
    +          2.17
    +          
    +            true
    +          
    +        
    +      
    +    
    +
    +    
    +      
    +        org.sonatype.plugins
    +        nexus-staging-maven-plugin
    +        1.6.3
    +        true
    +        
    +          ossrh
    +          https://oss.sonatype.org/
    +          true
    +        
    +      
    +      
    +        org.apache.maven.plugins
    +        maven-release-plugin
    +        2.5.1
    +        
    +          true
    +          false
    +          release
    +          deploy
    +        
    +      
    +      
    +        org.apache.maven.plugins
    +        maven-compiler-plugin
    +        3.6.0
    +        
    +          UTF-8
    +        
    +      
    +
    +      
    +        org.apache.maven.plugins
    +        maven-checkstyle-plugin
    +        2.17
    +        
    +          quality-checks/google_checks.xml
    +          true
    +          true
    +          true
    +        
    +        
    +          
    +            verify
    +            
    +              check
    +            
    +          
    +        
    +      
    +    
    +  
    +
    +
    diff --git a/weixin-java-open/README.md b/weixin-java-open/README.md
    new file mode 100644
    index 0000000000..d99b770673
    --- /dev/null
    +++ b/weixin-java-open/README.md
    @@ -0,0 +1,62 @@
    +消息机制未实现,下面为通知回调中设置的代码部分
    +```
    +@RestController
    +@RequestMapping("notify")
    +public class NotifyController extends WechatThridBaseController {
    +    @Autowired
    +    protected WxOpenServiceDemo wxOpenService;
    +    @RequestMapping("receive_ticket")
    +    public Object receiveTicket(@RequestBody(required = false) String requestBody, @RequestParam("timestamp") String timestamp,
    +                                @RequestParam("nonce") String nonce, @RequestParam("signature") String signature,
    +                                @RequestParam(name = "encrypt_type", required = false) String encType,
    +                                @RequestParam(name = "msg_signature", required = false) String msgSignature) {
    +        this.logger.info(
    +                "\n接收微信请求:[signature=[{}], encType=[{}], msgSignature=[{}],"
    +                        + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
    +                signature, encType, msgSignature, timestamp, nonce, requestBody);
    +
    +        if (!StringUtils.equalsIgnoreCase("aes", encType) || !wxOpenService.getWxOpenComponentService().checkSignature(timestamp, nonce, signature)) {
    +            throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
    +        }
    +
    +        // aes加密的消息
    +        WxOpenXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedXml(requestBody, wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature);
    +        this.logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString());
    +        String out = null;
    +        try {
    +            out = wxOpenService.getWxOpenComponentService().route(inMessage);
    +        } catch (WxErrorException e) {
    +            throw new ResponseException(ErrorCodeEnum.ERROR, e);
    +        }
    +
    +        this.logger.debug("\n组装回复信息:{}", out);
    +
    +        return out;
    +    }
    +    @RequestMapping("{appId}/callback")
    +    public Object callback(@RequestBody(required = false)String requestBody,
    +                           @PathVariable ("appId") String appId,
    +                           @RequestParam("signature") String signature,
    +                           @RequestParam("timestamp") String timestamp,
    +                           @RequestParam("nonce") String nonce,
    +                           @RequestParam("openid") String openid,
    +                           @RequestParam("encrypt_type") String encType,
    +                           @RequestParam("msg_signature") String msgSignature) {
    +        this.logger.info(
    +                "\n接收微信请求:[appId=[{}], openid=[{}], signature=[{}], encType=[{}], msgSignature=[{}],"
    +                        + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
    +                appId, openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
    +        logger.info("query:"+getHttpServletRequest().getQueryString()+"\nbody:"+requestBody);
    +        if (!StringUtils.equalsIgnoreCase("aes", encType) || !wxOpenService.getWxOpenComponentService().checkSignature(timestamp, nonce, signature)) {
    +            throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
    +        }
    +
    +        String out = "";
    +        // aes加密的消息
    +        WxMpXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedMpXml(requestBody, wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature);
    +        this.logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString());
    +        //wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId);
    +        return out;
    +    }
    +}
    +```
    diff --git a/weixin-java-open/pom.xml b/weixin-java-open/pom.xml
    new file mode 100644
    index 0000000000..d451dce1cd
    --- /dev/null
    +++ b/weixin-java-open/pom.xml
    @@ -0,0 +1,97 @@
    +
    +
    +
    +  4.0.0
    +  
    +    com.github.binarywang
    +    weixin-java-parent
    +    2.8.6.BETA
    +  
    +  weixin-java-open
    +  WeiXin Java Tools - Open
    +  微信开放平台Java SDK
    +  
    +    
    +      007
    +      007gzs@gmail.com
    +      https://github.com/007gzs
    +    
    +  
    +  
    +    
    +      com.github.binarywang
    +      weixin-java-common
    +      ${project.version}
    +    
    +    
    +      com.github.binarywang
    +      weixin-java-mp
    +      ${project.version}
    +    
    +
    +    
    +      org.jodd
    +      jodd-http
    +      provided
    +    
    +    
    +      com.squareup.okhttp3
    +      okhttp
    +      provided
    +    
    +
    +    
    +      org.testng
    +      testng
    +      test
    +    
    +    
    +      com.google.inject
    +      guice
    +      test
    +    
    +    
    +      org.eclipse.jetty
    +      jetty-server
    +      test
    +    
    +    
    +      org.eclipse.jetty
    +      jetty-servlet
    +      test
    +    
    +    
    +      joda-time
    +      joda-time
    +      test
    +    
    +    
    +      redis.clients
    +      jedis
    +    
    +    
    +      ch.qos.logback
    +      logback-classic
    +      test
    +    
    +  
    +
    +  
    +    
    +      
    +        org.apache.maven.plugins
    +        maven-surefire-plugin
    +        
    +          
    +            src/test/resources/testng.xml
    +          
    +        
    +      
    +    
    +  
    +
    +
    +
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java
    new file mode 100644
    index 0000000000..ded17248ed
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java
    @@ -0,0 +1,82 @@
    +package me.chanjar.weixin.open.api;
    +
    +import me.chanjar.weixin.common.bean.result.WxError;
    +import me.chanjar.weixin.common.exception.WxErrorException;
    +import me.chanjar.weixin.mp.api.WxMpService;
    +import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
    +import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
    +import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult;
    +import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerOptionResult;
    +import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult;
    +
    +/**
    + * @author 007
    + */
    +public interface WxOpenComponentService {
    +
    +  String API_COMPONENT_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_component_token";
    +  String API_CREATE_PREAUTHCODE_URL = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode";
    +  String API_QUERY_AUTH_URL = "https://api.weixin.qq.com/cgi-bin/component/api_query_auth";
    +  String API_AUTHORIZER_TOKEN_URL = "https://api.weixin.qq.com /cgi-bin/component/api_authorizer_token";
    +  String API_GET_AUTHORIZER_INFO_URL = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info";
    +  String API_GET_AUTHORIZER_OPTION_URL = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_option";
    +  String API_SET_AUTHORIZER_OPTION_URL = "https://api.weixin.qq.com/cgi-bin/component/ api_set_authorizer_option";
    +
    +
    +  String COMPONENT_LOGIN_PAGE_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s";
    +  String CONNECT_OAUTH2_AUTHORIZE_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s&component_appid=%s#wechat_redirect";
    +
    +  /**
    +   * 用code换取oauth2的access token
    +   */
    +  String OAUTH2_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&code=%s&grant_type=authorization_code&component_appid=%s";
    +  /**
    +   * 刷新oauth2的access token
    +   */
    +  String OAUTH2_REFRESH_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s&component_appid==%s";
    +  WxMpService getWxMpServiceByAppid(String appid);
    +
    +  WxOpenConfigStorage getWxOpenConfigStorage();
    +
    +  boolean checkSignature(String timestamp, String nonce, String signature);
    +
    +  String getComponentAccessToken(boolean forceRefresh) throws WxErrorException;
    +
    +  /**
    +   * 获取用户授权页URL(来路URL和成功跳转URL 的域名都需要为三方平台设置的 登录授权的发起页域名)
    +   */
    +  String getPreAuthUrl(String redirectURI) throws WxErrorException;
    +
    +  String route(WxOpenXmlMessage wxMessage) throws WxErrorException;
    +
    +  /**
    +   * 使用授权码换取公众号或小程序的接口调用凭据和授权信息
    +   */
    +  WxOpenQueryAuthResult getQueryAuth(String authorizationCode) throws WxErrorException;
    +
    +  /**
    +   * 获取授权方的帐号基本信息
    +   */
    +  WxOpenAuthorizerInfoResult getAuthorizerInfo(String authorizerAppid) throws WxErrorException;
    +
    +  /**
    +   * 获取授权方的选项设置信息
    +   */
    +  WxOpenAuthorizerOptionResult getAuthorizerOption(String authorizerAppid, String optionName) throws WxErrorException;
    +
    +  /**
    +   * 设置授权方的选项信息
    +   */
    +  WxError setAuthorizerOption(String authorizerAppid, String optionName, String optionValue) throws WxErrorException;
    +
    +  String getAuthorizerAccessToken(String appid, boolean forceRefresh) throws WxErrorException;
    +
    +  WxMpOAuth2AccessToken oauth2getAccessToken(String appid, String code) throws WxErrorException;
    +
    +  boolean checkSignature(String appId, String timestamp, String nonce, String signature);
    +
    +  WxMpOAuth2AccessToken oauth2refreshAccessToken(String appid, String refreshToken) throws WxErrorException;
    +
    +  String oauth2buildAuthorizationUrl(String appid, String redirectURI, String scope, String state);
    +
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenConfigStorage.java
    new file mode 100644
    index 0000000000..8f6173b798
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenConfigStorage.java
    @@ -0,0 +1,106 @@
    +package me.chanjar.weixin.open.api;
    +
    +import me.chanjar.weixin.mp.api.WxMpConfigStorage;
    +import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken;
    +import me.chanjar.weixin.open.bean.WxOpenComponentAccessToken;
    +
    +/**
    + * @author 007
    + */
    +public interface WxOpenConfigStorage {
    +
    +  void setComponentAppId(String componentAppId);
    +
    +  void setComponentAppSecret(String componentAppSecret);
    +
    +  void setComponentToken(String componentToken);
    +
    +  void setComponentAesKey(String componentAesKey);
    +
    +  String getComponentAppId();
    +  String getComponentAppSecret();
    +  String getComponentToken();
    +  String getComponentAesKey();
    +  String getComponentVerifyTicket();
    +  void setComponentVerifyTicket(String componentVerifyTicket);
    +  String getComponentAccessToken();
    +  boolean isComponentAccessTokenExpired();
    +  void updateComponentAccessTokent(WxOpenComponentAccessToken componentAccessToken);
    +  WxMpConfigStorage getWxMpConfigStorage(String appId);
    +  /**
    +   * 应该是线程安全的
    +   *
    +   * @param componentAccessToken      新的accessToken值
    +   * @param expiresInSeconds 过期时间,以秒为单位
    +   */
    +  void updateComponentAccessTokent(String componentAccessToken, int expiresInSeconds);
    +
    +  /**
    +   * 是否自动刷新token
    +   */
    +  boolean autoRefreshToken();
    +
    +
    +  String getAuthorizerRefreshToken(String appId);
    +  void setAuthorizerRefreshToken(String appId, String authorizerRefreshToken);
    +  String getAuthorizerAccessToken(String appId);
    +
    +
    +  boolean isAuthorizerAccessTokenExpired(String appId);
    +
    +  /**
    +   * 强制将access token过期掉
    +   */
    +  void expireAuthorizerAccessToken(String appId);
    +
    +  /**
    +   * 应该是线程安全的
    +   *
    +   * @param authorizerAccessToken 要更新的WxAccessToken对象
    +   */
    +  void updateAuthorizerAccessToken(String appId, WxOpenAuthorizerAccessToken authorizerAccessToken);
    +
    +  /**
    +   * 应该是线程安全的
    +   *
    +   * @param authorizerAccessToken      新的accessToken值
    +   * @param expiresInSeconds 过期时间,以秒为单位
    +   */
    +  void updateAuthorizerAccessToken(String appId, String authorizerAccessToken, int expiresInSeconds);
    +
    +  String getJsapiTicket(String appId);
    +
    +  boolean isJsapiTicketExpired(String appId);
    +
    +  /**
    +   * 强制将jsapi ticket过期掉
    +   */
    +  void expireJsapiTicket(String appId);
    +
    +  /**
    +   * 应该是线程安全的
    +   *
    +   * @param jsapiTicket      新的jsapi ticket值
    +   * @param expiresInSeconds 过期时间,以秒为单位
    +   */
    +  void updateJsapiTicket(String appId, String jsapiTicket, int expiresInSeconds);
    +
    +  String getCardApiTicket(String appId);
    +
    +
    +  boolean isCardApiTicketExpired(String appId);
    +
    +  /**
    +   * 强制将卡券api ticket过期掉
    +   */
    +  void expireCardApiTicket(String appId);
    +
    +  /**
    +   * 应该是线程安全的
    +   *
    +   * @param cardApiTicket    新的cardApi ticket值
    +   * @param expiresInSeconds 过期时间,以秒为单位
    +   */
    +  void updateCardApiTicket(String appId, String cardApiTicket, int expiresInSeconds);
    +
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenService.java
    new file mode 100644
    index 0000000000..c0214d46ef
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenService.java
    @@ -0,0 +1,22 @@
    +package me.chanjar.weixin.open.api;
    +
    +import me.chanjar.weixin.common.exception.WxErrorException;
    +
    +/**
    + * @author 007
    + */
    +public interface WxOpenService {
    +  WxOpenComponentService getWxOpenComponentService();
    +  WxOpenConfigStorage getWxOpenConfigStorage();
    +  void setWxOpenConfigStorage(WxOpenConfigStorage wxOpenConfigStorage);
    +  /**
    +   * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求
    +   */
    +  String get(String url, String queryParam) throws WxErrorException;
    +
    +  /**
    +   * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求
    +   */
    +  String post(String url, String postData) throws WxErrorException;
    +
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java
    new file mode 100644
    index 0000000000..9f797e2f0f
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java
    @@ -0,0 +1,218 @@
    +package me.chanjar.weixin.open.api.impl;
    +
    +import com.google.gson.JsonObject;
    +import me.chanjar.weixin.common.bean.result.WxError;
    +import me.chanjar.weixin.common.exception.WxErrorException;
    +import me.chanjar.weixin.common.util.crypto.SHA1;
    +import me.chanjar.weixin.common.util.http.URIUtil;
    +import me.chanjar.weixin.common.util.json.WxGsonBuilder;
    +import me.chanjar.weixin.mp.api.WxMpService;
    +import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
    +import me.chanjar.weixin.open.api.WxOpenComponentService;
    +import me.chanjar.weixin.open.api.WxOpenConfigStorage;
    +import me.chanjar.weixin.open.api.WxOpenService;
    +import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken;
    +import me.chanjar.weixin.open.bean.WxOpenComponentAccessToken;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
    +import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
    +import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult;
    +import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerOptionResult;
    +import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult;
    +import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
    +import org.apache.commons.lang3.StringUtils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.Hashtable;
    +import java.util.Map;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenComponentServiceImpl implements WxOpenComponentService {
    +  protected final Logger log = LoggerFactory.getLogger(this.getClass());
    +  private WxOpenService wxOpenService;
    +  private static final Map wxOpenMpServiceMap = new Hashtable<>();
    +
    +  public WxOpenComponentServiceImpl(WxOpenService wxOpenService) {
    +    this.wxOpenService = wxOpenService;
    +  }
    +
    +  @Override
    +  public WxMpService getWxMpServiceByAppid(String appId) {
    +    WxMpService wxMpService = wxOpenMpServiceMap.get(appId);
    +    if (wxMpService == null) {
    +      synchronized (wxOpenMpServiceMap) {
    +        wxMpService = wxOpenMpServiceMap.get(appId);
    +        if (wxMpService == null) {
    +          wxMpService = new WxOpenMpServiceImpl(this, appId, getWxOpenConfigStorage().getWxMpConfigStorage(appId));
    +
    +          wxOpenMpServiceMap.put(appId, wxMpService);
    +        }
    +      }
    +    }
    +    return wxMpService;
    +  }
    +
    +  public WxOpenService getWxOpenService() {
    +    return wxOpenService;
    +  }
    +
    +  @Override
    +  public WxOpenConfigStorage getWxOpenConfigStorage() {
    +    return wxOpenService.getWxOpenConfigStorage();
    +  }
    +  @Override
    +  public boolean checkSignature(String timestamp, String nonce, String signature) {
    +    try {
    +      return SHA1.gen(getWxOpenConfigStorage().getComponentToken(), timestamp, nonce)
    +        .equals(signature);
    +    } catch (Exception e) {
    +      this.log.error("Checking signature failed, and the reason is :" + e.getMessage());
    +      return false;
    +    }
    +  }
    +  @Override
    +  public String getComponentAccessToken(boolean forceRefresh) throws WxErrorException {
    +
    +    if (this.getWxOpenConfigStorage().isComponentAccessTokenExpired() || forceRefresh) {
    +      JsonObject jsonObject = new JsonObject();
    +      jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
    +      jsonObject.addProperty("component_appsecret", getWxOpenConfigStorage().getComponentAppSecret());
    +      jsonObject.addProperty("component_verify_ticket", getWxOpenConfigStorage().getComponentVerifyTicket());
    +
    +      String responseContent = this.getWxOpenService().post(API_COMPONENT_TOKEN_URL, jsonObject.toString());
    +      WxOpenComponentAccessToken componentAccessToken = WxOpenComponentAccessToken.fromJson(responseContent);
    +      getWxOpenConfigStorage().updateComponentAccessTokent(componentAccessToken);
    +    }
    +    return this.getWxOpenConfigStorage().getComponentAccessToken();
    +  }
    +
    +  private String post(String uri, String postData) throws WxErrorException {
    +    String componentAccessToken = getComponentAccessToken(false);
    +    String uriWithComponentAccessToken = uri + (uri.contains("?") ? "&" : "?") + "component_access_token=" + componentAccessToken;
    +    return getWxOpenService().post(uriWithComponentAccessToken, postData);
    +  }
    +
    +  private String get(String uri) throws WxErrorException {
    +    String componentAccessToken = getComponentAccessToken(false);
    +    String uriWithComponentAccessToken = uri + (uri.contains("?") ? "&" : "?") + "component_access_token=" + componentAccessToken;
    +    return getWxOpenService().get(uriWithComponentAccessToken, null);
    +  }
    +
    +  @Override
    +  public String getPreAuthUrl(String redirectURI) throws WxErrorException {
    +
    +    JsonObject jsonObject = new JsonObject();
    +    jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
    +    String responseContent = post(API_CREATE_PREAUTHCODE_URL, jsonObject.toString());
    +    jsonObject = WxGsonBuilder.create().fromJson(responseContent, JsonObject.class);
    +    return String.format(COMPONENT_LOGIN_PAGE_URL, getWxOpenConfigStorage().getComponentAppId(), jsonObject.get("pre_auth_code").getAsString(), URIUtil.encodeURIComponent(redirectURI));
    +  }
    +
    +  @Override
    +  public String route(final WxOpenXmlMessage wxMessage) throws WxErrorException {
    +    if (wxMessage == null) {
    +      throw new NullPointerException("message is empty");
    +    }
    +    if (StringUtils.equalsIgnoreCase(wxMessage.getInfoType(), "component_verify_ticket")) {
    +      getWxOpenConfigStorage().setComponentVerifyTicket(wxMessage.getComponentVerifyTicket());
    +      return "success";
    +    }
    +    //新增、跟新授权
    +    if (StringUtils.equalsAnyIgnoreCase(wxMessage.getInfoType(), "authorized", "updateauthorized")) {
    +      WxOpenQueryAuthResult queryAuth = wxOpenService.getWxOpenComponentService().getQueryAuth(wxMessage.getAuthorizationCode());
    +      if (queryAuth == null || queryAuth.getAuthorizationInfo() == null || queryAuth.getAuthorizationInfo().getAuthorizerAppid() == null) {
    +        throw new NullPointerException("getQueryAuth");
    +      }
    +      WxOpenAuthorizationInfo authorizationInfo = queryAuth.getAuthorizationInfo();
    +      if (authorizationInfo.getAuthorizerAccessToken() != null) {
    +        getWxOpenConfigStorage().updateAuthorizerAccessToken(authorizationInfo.getAuthorizerAppid(),
    +          authorizationInfo.getAuthorizerAccessToken(), authorizationInfo.getExpiresIn());
    +      }
    +      if (authorizationInfo.getAuthorizerRefreshToken() != null) {
    +        getWxOpenConfigStorage().setAuthorizerRefreshToken(authorizationInfo.getAuthorizerAppid(), authorizationInfo.getAuthorizerRefreshToken());
    +      }
    +      return "success";
    +    }
    +    return null;
    +  }
    +  @Override
    +  public WxOpenQueryAuthResult getQueryAuth(String authorizationCode) throws WxErrorException {
    +    JsonObject jsonObject = new JsonObject();
    +    jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
    +    jsonObject.addProperty("authorization_code", authorizationCode);
    +    String responseContent = post(API_QUERY_AUTH_URL, jsonObject.toString());
    +    return WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenQueryAuthResult.class);
    +  }
    +  @Override
    +  public WxOpenAuthorizerInfoResult getAuthorizerInfo(String authorizerAppid) throws WxErrorException {
    +    JsonObject jsonObject = new JsonObject();
    +    jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
    +    jsonObject.addProperty("authorizer_appid", authorizerAppid);
    +    String responseContent = post(API_GET_AUTHORIZER_INFO_URL, jsonObject.toString());
    +    return WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenAuthorizerInfoResult.class);
    +  }
    +
    +  @Override
    +  public WxOpenAuthorizerOptionResult getAuthorizerOption(String authorizerAppid, String optionName) throws WxErrorException {
    +    JsonObject jsonObject = new JsonObject();
    +    jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
    +    jsonObject.addProperty("authorizer_appid", authorizerAppid);
    +    jsonObject.addProperty("option_name", optionName);
    +    String responseContent = post(API_GET_AUTHORIZER_OPTION_URL, jsonObject.toString());
    +    return WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenAuthorizerOptionResult.class);
    +  }
    +  @Override
    +  public WxError setAuthorizerOption(String authorizerAppid, String optionName, String optionValue) throws WxErrorException {
    +    JsonObject jsonObject = new JsonObject();
    +    jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
    +    jsonObject.addProperty("authorizer_appid", authorizerAppid);
    +    jsonObject.addProperty("option_name", optionName);
    +    jsonObject.addProperty("option_value", optionValue);
    +    String responseContent = post(API_SET_AUTHORIZER_OPTION_URL, jsonObject.toString());
    +    return WxGsonBuilder.create().fromJson(responseContent, WxError.class);
    +  }
    +
    +  @Override
    +  public String getAuthorizerAccessToken(String appId, boolean forceRefresh) throws WxErrorException {
    +
    +    if (this.getWxOpenConfigStorage().isAuthorizerAccessTokenExpired(appId) || forceRefresh) {
    +      JsonObject jsonObject = new JsonObject();
    +      jsonObject.addProperty("component_appid", getWxOpenConfigStorage().getComponentAppId());
    +      jsonObject.addProperty("authorizer_appid", appId);
    +      jsonObject.addProperty("authorizer_refresh_token", getWxOpenConfigStorage().getAuthorizerRefreshToken(appId));
    +      String responseContent = post(API_AUTHORIZER_TOKEN_URL, jsonObject.toString());
    +
    +      WxOpenAuthorizerAccessToken wxOpenAuthorizerAccessToken = WxOpenAuthorizerAccessToken.fromJson(responseContent);
    +      getWxOpenConfigStorage().updateAuthorizerAccessToken(appId, wxOpenAuthorizerAccessToken);
    +    }
    +    return this.getWxOpenConfigStorage().getAuthorizerAccessToken(appId);
    +  }
    +
    +  @Override
    +  public WxMpOAuth2AccessToken oauth2getAccessToken(String appId, String code) throws WxErrorException {
    +    String url = String.format(OAUTH2_ACCESS_TOKEN_URL, appId, code, getWxOpenConfigStorage().getComponentAppId());
    +    String responseContent = get(url);
    +    return WxMpOAuth2AccessToken.fromJson(responseContent);
    +  }
    +
    +  @Override
    +  public boolean checkSignature(String appid, String timestamp, String nonce, String signature) {
    +    return false;
    +  }
    +
    +  @Override
    +  public WxMpOAuth2AccessToken oauth2refreshAccessToken(String appId, String refreshToken) throws WxErrorException {
    +    String url = String.format(OAUTH2_REFRESH_TOKEN_URL, appId, refreshToken, getWxOpenConfigStorage().getComponentAppId());
    +    String responseContent = get(url);
    +    return WxMpOAuth2AccessToken.fromJson(responseContent);
    +  }
    +
    +  @Override
    +  public String oauth2buildAuthorizationUrl(String appId, String redirectURI, String scope, String state) {
    +    return String.format(CONNECT_OAUTH2_AUTHORIZE_URL,
    +      appId, URIUtil.encodeURIComponent(redirectURI), scope, StringUtils.trimToEmpty(state), getWxOpenConfigStorage().getComponentAppId());
    +  }
    +
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java
    new file mode 100644
    index 0000000000..dc10ee18a5
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java
    @@ -0,0 +1,386 @@
    +package me.chanjar.weixin.open.api.impl;
    +
    +
    +import me.chanjar.weixin.common.bean.WxAccessToken;
    +import me.chanjar.weixin.common.util.ToStringUtils;
    +import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
    +import me.chanjar.weixin.mp.api.WxMpConfigStorage;
    +import me.chanjar.weixin.open.api.WxOpenConfigStorage;
    +import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken;
    +import me.chanjar.weixin.open.bean.WxOpenComponentAccessToken;
    +
    +import java.io.File;
    +import java.util.Hashtable;
    +import java.util.Map;
    +import java.util.concurrent.locks.Lock;
    +import java.util.concurrent.locks.ReentrantLock;
    +
    +/**
    + * 基于内存的微信配置provider,在实际生产环境中应该将这些配置持久化
    + *
    + * @author 007
    + */
    +public class WxOpenInMemoryConfigStorage implements WxOpenConfigStorage {
    +  private String componentAppId;
    +  private String componentAppSecret;
    +  private String componentToken;
    +  private String componentAesKey;
    +  private String componentVerifyTicket;
    +  private String componentAccessToken;
    +  private long componentExpiresTime;
    +
    +  private Map authorizerRefreshTokens = new Hashtable<>();
    +  private Map authorizerAccessTokens = new Hashtable<>();
    +  private Map jsapiTickets = new Hashtable<>();
    +  private Map cardApiTickets = new Hashtable<>();
    +
    +  @Override
    +  public void setComponentAppId(String componentAppId) {
    +    this.componentAppId = componentAppId;
    +  }
    +  @Override
    +  public void setComponentAppSecret(String componentAppSecret) {
    +    this.componentAppSecret = componentAppSecret;
    +  }
    +  @Override
    +  public void setComponentToken(String componentToken) {
    +    this.componentToken = componentToken;
    +  }
    +  @Override
    +  public void setComponentAesKey(String componentAesKey) {
    +    this.componentAesKey = componentAesKey;
    +  }
    +
    +  @Override
    +  public String getComponentAppId() {
    +    return componentAppId;
    +  }
    +
    +  @Override
    +  public String getComponentAppSecret() {
    +    return componentAppSecret;
    +  }
    +
    +  @Override
    +  public String getComponentToken() {
    +    return componentToken;
    +  }
    +
    +  @Override
    +  public String getComponentAesKey() {
    +    return componentAesKey;
    +  }
    +
    +  @Override
    +  public String getComponentVerifyTicket() {
    +    return componentVerifyTicket;
    +  }
    +
    +  @Override
    +  public void setComponentVerifyTicket(String componentVerifyTicket) {
    +    this.componentVerifyTicket = componentVerifyTicket;
    +  }
    +
    +  @Override
    +  public String getComponentAccessToken() {
    +    return componentAccessToken;
    +  }
    +
    +  @Override
    +  public boolean isComponentAccessTokenExpired() {
    +    return System.currentTimeMillis() > componentExpiresTime;
    +  }
    +
    +  @Override
    +  public void updateComponentAccessTokent(WxOpenComponentAccessToken componentAccessToken) {
    +    updateComponentAccessTokent(componentAccessToken.getComponentAccessToken(), componentAccessToken.getExpiresIn());
    +  }
    +
    +  @Override
    +  public WxMpConfigStorage getWxMpConfigStorage(String appId) {
    +    return new WxOpenMpConfigStorage(this, appId);
    +  }
    +
    +  @Override
    +  public void updateComponentAccessTokent(String componentAccessToken, int expiresInSeconds) {
    +    this.componentAccessToken = componentAccessToken;
    +    this.componentExpiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L;
    +  }
    +
    +  @Override
    +  public boolean autoRefreshToken() {
    +    return true;
    +  }
    +  private String getTokenString(Map map, String key){
    +    Token token = map.get(key);
    +    if(token == null || (token.expiresTime != null && System.currentTimeMillis() > token.expiresTime)){
    +      return null;
    +    }
    +    return token.token;
    +  }
    +  private void expireToken(Map map, String key){
    +    Token token = map.get(key);
    +    if(token != null){
    +      token.expiresTime = 0L;
    +    }
    +  }
    +  private void updateToken(Map map, String key, String tokenString, Integer expiresInSeconds){
    +    Token token = map.get(key);
    +    if(token == null){
    +      token = new Token();
    +      map.put(key, token);
    +    }
    +    token.token = tokenString;
    +    if(expiresInSeconds != null) {
    +      token.expiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L;
    +    }
    +  }
    +  @Override
    +  public String getAuthorizerRefreshToken(String appId) {
    +    return getTokenString(authorizerRefreshTokens, appId);
    +  }
    +
    +  @Override
    +  public void setAuthorizerRefreshToken(String appId, String authorizerRefreshToken) {
    +    updateToken(authorizerRefreshTokens, appId, authorizerRefreshToken, null);
    +  }
    +
    +  @Override
    +  public String getAuthorizerAccessToken(String appId) {
    +    return getTokenString(authorizerAccessTokens, appId);
    +  }
    +
    +
    +  @Override
    +  public boolean isAuthorizerAccessTokenExpired(String appId) {
    +    return getTokenString(authorizerAccessTokens, appId) == null;
    +  }
    +
    +  @Override
    +  public void expireAuthorizerAccessToken(String appId) {
    +    expireToken(authorizerAccessTokens, appId);
    +  }
    +
    +  @Override
    +  public void updateAuthorizerAccessToken(String appId, WxOpenAuthorizerAccessToken authorizerAccessToken) {
    +    updateAuthorizerAccessToken(appId, authorizerAccessToken.getAuthorizerAccessToken(), authorizerAccessToken.getExpiresIn());
    +  }
    +
    +  @Override
    +  public void updateAuthorizerAccessToken(String appId, String authorizerAccessToken, int expiresInSeconds) {
    +    updateToken(authorizerAccessTokens, appId, authorizerAccessToken, expiresInSeconds);
    +  }
    +
    +  @Override
    +  public String getJsapiTicket(String appId) {
    +    return getTokenString(jsapiTickets, appId);
    +  }
    +
    +  @Override
    +  public boolean isJsapiTicketExpired(String appId) {
    +    return getTokenString(jsapiTickets, appId) == null;
    +  }
    +
    +  @Override
    +  public void expireJsapiTicket(String appId) {
    +    expireToken(jsapiTickets, appId);
    +  }
    +
    +  @Override
    +  public void updateJsapiTicket(String appId, String jsapiTicket, int expiresInSeconds) {
    +    updateToken(jsapiTickets, appId, jsapiTicket, expiresInSeconds);
    +  }
    +
    +  @Override
    +  public String getCardApiTicket(String appId) {
    +    return getTokenString(cardApiTickets, appId);
    +  }
    +
    +  @Override
    +  public boolean isCardApiTicketExpired(String appId) {
    +    return getTokenString(cardApiTickets, appId) == null;
    +  }
    +
    +  @Override
    +  public void expireCardApiTicket(String appId) {
    +    expireToken(cardApiTickets, appId);
    +  }
    +
    +  @Override
    +  public void updateCardApiTicket(String appId, String cardApiTicket, int expiresInSeconds) {
    +    updateToken(cardApiTickets, appId, cardApiTicket, expiresInSeconds);
    +  }
    +
    +  private static class Token{
    +    private String token;
    +    private Long expiresTime;
    +  }
    +  private static class WxOpenMpConfigStorage implements WxMpConfigStorage{
    +    private WxOpenConfigStorage wxOpenConfigStorage;
    +    private String appId;
    +    private WxOpenMpConfigStorage(WxOpenConfigStorage wxOpenConfigStorage, String appId){
    +      this.wxOpenConfigStorage = wxOpenConfigStorage;
    +      this.appId = appId;
    +    }
    +
    +    private Lock accessTokenLock = new ReentrantLock();
    +    private Lock jsapiTicketLock = new ReentrantLock();
    +    private Lock cardApiTicketLock = new ReentrantLock();
    +
    +
    +    @Override
    +    public String getAccessToken() {
    +      return wxOpenConfigStorage.getAuthorizerAccessToken(appId);
    +    }
    +
    +    @Override
    +    public Lock getAccessTokenLock() {
    +      return this.accessTokenLock;
    +    }
    +
    +    @Override
    +    public boolean isAccessTokenExpired() {
    +      return wxOpenConfigStorage.isAuthorizerAccessTokenExpired(appId);
    +    }
    +
    +    @Override
    +    public synchronized void updateAccessToken(WxAccessToken accessToken) {
    +      updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn());
    +    }
    +
    +    @Override
    +    public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) {
    +      wxOpenConfigStorage.updateAuthorizerAccessToken(appId, accessToken, expiresInSeconds);
    +    }
    +
    +    @Override
    +    public void expireAccessToken() {
    +      wxOpenConfigStorage.expireAuthorizerAccessToken(appId);
    +    }
    +
    +    @Override
    +    public String getJsapiTicket() {
    +      return wxOpenConfigStorage.getJsapiTicket(appId);
    +    }
    +
    +    @Override
    +    public Lock getJsapiTicketLock() {
    +      return this.jsapiTicketLock;
    +    }
    +
    +    @Override
    +    public boolean isJsapiTicketExpired() {
    +      return wxOpenConfigStorage.isJsapiTicketExpired(appId);
    +    }
    +
    +    @Override
    +    public synchronized void updateJsapiTicket(String jsapiTicket, int expiresInSeconds) {
    +      wxOpenConfigStorage.updateJsapiTicket(appId, jsapiTicket, expiresInSeconds);
    +    }
    +
    +    @Override
    +    public void expireJsapiTicket() {
    +      wxOpenConfigStorage.expireJsapiTicket(appId);
    +    }
    +
    +    /**
    +     * 卡券api_ticket
    +     */
    +    @Override
    +    public String getCardApiTicket() {
    +      return wxOpenConfigStorage.getCardApiTicket(appId);
    +    }
    +
    +    @Override
    +    public Lock getCardApiTicketLock() {
    +      return this.cardApiTicketLock;
    +    }
    +
    +    @Override
    +    public boolean isCardApiTicketExpired() {
    +      return wxOpenConfigStorage.isCardApiTicketExpired(appId);
    +    }
    +
    +    @Override
    +    public synchronized void updateCardApiTicket(String cardApiTicket, int expiresInSeconds) {
    +      wxOpenConfigStorage.updateCardApiTicket(appId, cardApiTicket, expiresInSeconds);
    +    }
    +
    +    @Override
    +    public void expireCardApiTicket() {
    +      wxOpenConfigStorage.expireCardApiTicket(appId);
    +    }
    +
    +    @Override
    +    public String getAppId() {
    +      return this.appId;
    +    }
    +
    +    @Override
    +    public String getSecret() {
    +      return null;
    +    }
    +
    +    @Override
    +    public String getToken() {
    +      return null;
    +    }
    +
    +    @Override
    +    public long getExpiresTime() {
    +      return 0;
    +    }
    +
    +
    +    @Override
    +    public String getAesKey() {
    +      return null;
    +    }
    +
    +    @Override
    +    public String getOauth2redirectUri() {
    +      return null;
    +    }
    +
    +    @Override
    +    public String getHttpProxyHost() {
    +      return null;
    +    }
    +
    +    @Override
    +    public int getHttpProxyPort() {
    +      return 0;
    +    }
    +
    +    @Override
    +    public String getHttpProxyUsername() {
    +      return null;
    +    }
    +
    +    @Override
    +    public String getHttpProxyPassword() {
    +      return null;
    +    }
    +
    +    @Override
    +    public String toString() {
    +      return ToStringUtils.toSimpleString(this);
    +    }
    +
    +    @Override
    +    public File getTmpDirFile() {
    +      return null;
    +    }
    +
    +    @Override
    +    public ApacheHttpClientBuilder getApacheHttpClientBuilder() {
    +      return null;
    +    }
    +
    +
    +    @Override
    +    public boolean autoRefreshToken() {
    +      return true;
    +    }
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java
    new file mode 100644
    index 0000000000..faaa95d84c
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java
    @@ -0,0 +1,164 @@
    +package me.chanjar.weixin.open.api.impl;
    +
    +import redis.clients.jedis.Jedis;
    +import redis.clients.jedis.JedisPool;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenInRedisConfigStorage extends WxOpenInMemoryConfigStorage {
    +
    +  private final static String COMPONENT_VERIFY_TICKET_KEY = "wechat_component_verify_ticket:";
    +  private final static String COMPONENT_ACCESS_TOKEN_KEY = "wechat_component_access_token:";
    +
    +  private final static String AUTHORIZER_REFRESH_TOKEN_KEY = "wechat_authorizer_refresh_token:";
    +  private final static String AUTHORIZER_ACCESS_TOKEN_KEY = "wechat_authorizer_access_token:";
    +  private final static String JSAPI_TICKET_KEY = "wechat_jsapi_ticket:";
    +  private final static String CARD_API_TICKET_KEY = "wechat_card_api_ticket:";
    +
    +
    +  protected final JedisPool jedisPool;
    +  private String componentVerifyTicketKey;
    +  private String componentAccessTokenKey;
    +  private String authorizerRefreshTokenKey;
    +  private String authorizerAccessTokenKey;
    +  private String jsapiTicketKey;
    +  private String cardApiTicket;
    +  public WxOpenInRedisConfigStorage(JedisPool jedisPool) {
    +    this.jedisPool = jedisPool;
    +  }
    +
    +  @Override
    +  public void setComponentAppId(String componentAppId) {
    +    super.setComponentAppId(componentAppId);
    +    componentVerifyTicketKey = COMPONENT_VERIFY_TICKET_KEY.concat(componentAppId);
    +    componentAccessTokenKey = COMPONENT_ACCESS_TOKEN_KEY.concat(componentAppId);
    +    authorizerRefreshTokenKey = AUTHORIZER_REFRESH_TOKEN_KEY.concat(componentAppId);
    +    authorizerAccessTokenKey = AUTHORIZER_ACCESS_TOKEN_KEY.concat(componentAppId);
    +    jsapiTicketKey = JSAPI_TICKET_KEY.concat(componentAppId);
    +    cardApiTicket = CARD_API_TICKET_KEY.concat(componentAppId);
    +  }
    +  @Override
    +  public String getComponentVerifyTicket(){
    +    try(Jedis jedis = jedisPool.getResource()){
    +      return jedis.get(componentVerifyTicketKey);
    +    }
    +  }
    +  @Override
    +  public void setComponentVerifyTicket(String componentVerifyTicket){
    +    try(Jedis jedis = jedisPool.getResource()){
    +      jedis.set(componentVerifyTicketKey, componentVerifyTicket);
    +    }
    +  }
    +  @Override
    +  public String getComponentAccessToken(){
    +    try(Jedis jedis = jedisPool.getResource()){
    +      return jedis.get(componentAccessTokenKey);
    +    }
    +  }
    +  @Override
    +  public boolean isComponentAccessTokenExpired(){
    +    try(Jedis jedis = jedisPool.getResource()){
    +      return jedis.ttl(componentAccessTokenKey) < 2;
    +    }
    +  }
    +  @Override
    +  public void updateComponentAccessTokent(String componentAccessToken, int expiresInSeconds){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      jedis.setex(componentAccessTokenKey, expiresInSeconds - 200, componentAccessToken);
    +    }
    +  }
    +  private String getKey(String prefix, String appId){
    +    return prefix.endsWith(":") ? prefix.concat(appId) : prefix.concat(":").concat(appId);
    +  }
    +
    +  @Override
    +  public String getAuthorizerRefreshToken(String appId){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      return jedis.get(getKey(authorizerRefreshTokenKey, appId));
    +    }
    +  }
    +  @Override
    +  public void setAuthorizerRefreshToken(String appId, String authorizerRefreshToken){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      jedis.set(getKey(authorizerRefreshTokenKey, appId), authorizerRefreshToken);
    +    }
    +  }
    +  @Override
    +  public String getAuthorizerAccessToken(String appId){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      return jedis.get(getKey(authorizerAccessTokenKey, appId));
    +    }
    +  }
    +
    +
    +  @Override
    +  public boolean isAuthorizerAccessTokenExpired(String appId){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      return jedis.ttl(getKey(authorizerAccessTokenKey, appId)) < 2;
    +    }
    +  }
    +  @Override
    +  public void expireAuthorizerAccessToken(String appId){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      jedis.expire(getKey(authorizerAccessTokenKey, appId), 0);
    +    }
    +  }
    +  @Override
    +  public void updateAuthorizerAccessToken(String appId, String authorizerAccessToken, int expiresInSeconds){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      jedis.setex(getKey(authorizerAccessTokenKey, appId), expiresInSeconds - 200, authorizerAccessToken);
    +    }
    +  }
    +
    +  @Override
    +  public String getJsapiTicket(String appId){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      return jedis.get(getKey(jsapiTicketKey, appId));
    +    }
    +  }
    +
    +  @Override
    +  public boolean isJsapiTicketExpired(String appId){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      return jedis.ttl(getKey(jsapiTicketKey, appId)) < 2;
    +    }
    +  }
    +  @Override
    +  public void expireJsapiTicket(String appId){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      jedis.expire(getKey(jsapiTicketKey, appId), 0);
    +    }
    +  }
    +  @Override
    +  public void updateJsapiTicket(String appId, String jsapiTicket, int expiresInSeconds){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      jedis.setex(getKey(jsapiTicketKey, appId), expiresInSeconds - 200, jsapiTicket);
    +    }
    +  }
    +
    +  @Override
    +  public String getCardApiTicket(String appId){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      return jedis.get(getKey(jsapiTicketKey, appId));
    +    }
    +  }
    +  @Override
    +  public boolean isCardApiTicketExpired(String appId){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      return jedis.ttl(getKey(cardApiTicket, appId)) < 2;
    +    }
    +  }
    +  @Override
    +  public void expireCardApiTicket(String appId){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      jedis.expire(getKey(cardApiTicket, appId), 0);
    +    }
    +  }
    +  @Override
    +  public void updateCardApiTicket(String appId, String cardApiTicket, int expiresInSeconds){
    +    try (Jedis jedis = this.jedisPool.getResource()) {
    +      jedis.setex(getKey(cardApiTicket, appId), expiresInSeconds - 200, cardApiTicket);
    +    }
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java
    new file mode 100644
    index 0000000000..b4baf58581
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java
    @@ -0,0 +1,49 @@
    +package me.chanjar.weixin.open.api.impl;
    +
    +import me.chanjar.weixin.common.exception.WxErrorException;
    +import me.chanjar.weixin.mp.api.WxMpConfigStorage;
    +import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
    +import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
    +import me.chanjar.weixin.open.api.WxOpenComponentService;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenMpServiceImpl extends WxMpServiceImpl {
    +  private WxOpenComponentService wxOpenComponentService;
    +  private WxMpConfigStorage wxMpConfigStorage;
    +  private String appId;
    +  public WxOpenMpServiceImpl(WxOpenComponentService wxOpenComponentService, String appId, WxMpConfigStorage wxMpConfigStorage){
    +    this.wxOpenComponentService = wxOpenComponentService;
    +    this.appId = appId;
    +    this.wxMpConfigStorage = wxMpConfigStorage;
    +  }
    +  @Override
    +  public WxMpConfigStorage getWxMpConfigStorage(){
    +    return wxMpConfigStorage;
    +  }
    +  @Override
    +  public String getAccessToken(boolean forceRefresh) throws WxErrorException {
    +    return wxOpenComponentService.getAuthorizerAccessToken(appId, forceRefresh);
    +  }
    +
    +  @Override
    +  public WxMpOAuth2AccessToken oauth2getAccessToken(String code) throws WxErrorException {
    +    return wxOpenComponentService.oauth2getAccessToken(appId, code);
    +  }
    +
    +//  @Override
    +//  public boolean checkSignature(String timestamp, String nonce, String signature) {
    +//    return wxOpenComponentService.checkSignature(appId, timestamp, nonce, signature);
    +//  }
    +
    +  @Override
    +  public WxMpOAuth2AccessToken oauth2refreshAccessToken(String refreshToken) throws WxErrorException {
    +    return wxOpenComponentService.oauth2refreshAccessToken(appId, refreshToken);
    +  }
    +
    +  @Override
    +  public String oauth2buildAuthorizationUrl(String redirectURI, String scope, String state) {
    +    return wxOpenComponentService.oauth2buildAuthorizationUrl(appId, redirectURI, scope, state);
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java
    new file mode 100644
    index 0000000000..5f937dc5cf
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java
    @@ -0,0 +1,63 @@
    +package me.chanjar.weixin.open.api.impl;
    +
    +import me.chanjar.weixin.common.bean.result.WxError;
    +import me.chanjar.weixin.common.exception.WxErrorException;
    +import me.chanjar.weixin.common.util.http.RequestExecutor;
    +import me.chanjar.weixin.common.util.http.RequestHttp;
    +import me.chanjar.weixin.open.api.WxOpenComponentService;
    +import me.chanjar.weixin.open.api.WxOpenConfigStorage;
    +import me.chanjar.weixin.open.api.WxOpenService;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.IOException;
    +
    +/**
    + * @author 007
    + */
    +public abstract class WxOpenServiceAbstractImpl implements WxOpenService, RequestHttp {
    +  protected final Logger log = LoggerFactory.getLogger(this.getClass());
    +  private WxOpenConfigStorage wxOpenConfigStorage;
    +  protected WxOpenComponentService wxOpenComponentService = new WxOpenComponentServiceImpl(this);
    +  @Override
    +  public WxOpenComponentService getWxOpenComponentService() {
    +    return wxOpenComponentService;
    +  }
    +  @Override
    +  public WxOpenConfigStorage getWxOpenConfigStorage(){
    +    return wxOpenConfigStorage;
    +  }
    +  public void setWxOpenConfigStorage(WxOpenConfigStorage wxOpenConfigStorage){
    +    this.wxOpenConfigStorage = wxOpenConfigStorage;
    +  }
    +
    +  protected synchronized  T execute(RequestExecutor executor, String uri, E data) throws WxErrorException {
    +    try {
    +      T result = executor.execute(uri, data);
    +      this.log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uri, data, result);
    +      return result;
    +    } catch (WxErrorException e) {
    +      WxError error = e.getError();
    +//      /*
    +//       * 发生以下情况时尝试刷新access_token
    +//       * 40001 获取access_token时AppSecret错误,或者access_token无效
    +//       * 42001 access_token超时
    +//       * 40014 不合法的access_token,请开发者认真比对access_token的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口
    +//       */
    +//      if (error.getErrorCode() == 42001 || error.getErrorCode() == 40001 || error.getErrorCode() == 40014) {
    +//        // 强制设置wxCpConfigStorage它的access token过期了,这样在下一次请求里就会刷新access token
    +//        this.configStorage.expireAccessToken();
    +//        return execute(executor, uri, data);
    +//      }
    +
    +      if (error.getErrorCode() != 0) {
    +        this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uri, data, error);
    +        throw new WxErrorException(error, e);
    +      }
    +      return null;
    +    } catch (IOException e) {
    +      this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uri, data, e.getMessage());
    +      throw new RuntimeException(e);
    +    }
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceApacheHttpClientImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceApacheHttpClientImpl.java
    new file mode 100644
    index 0000000000..e5b62b3456
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceApacheHttpClientImpl.java
    @@ -0,0 +1,44 @@
    +package me.chanjar.weixin.open.api.impl;
    +
    +import me.chanjar.weixin.common.exception.WxErrorException;
    +import me.chanjar.weixin.common.util.http.HttpType;
    +import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
    +import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
    +import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
    +import org.apache.http.HttpHost;
    +import org.apache.http.impl.client.CloseableHttpClient;
    +
    +/**
    + * apache-http方式实现
    + * @author 007
    + */
    +public  class WxOpenServiceApacheHttpClientImpl extends WxOpenServiceAbstractImpl {
    +  private CloseableHttpClient httpClient = DefaultApacheHttpClientBuilder.get().build();
    +  private HttpHost httpProxy = null;
    +
    +  @Override
    +  public CloseableHttpClient getRequestHttpClient() {
    +    return httpClient;
    +  }
    +
    +  @Override
    +  public HttpHost getRequestHttpProxy() {
    +    return httpProxy;
    +  }
    +
    +  @Override
    +  public HttpType getRequestType() {
    +    return HttpType.APACHE_HTTP;
    +  }
    +
    +  @Override
    +  public String get(String url, String queryParam) throws WxErrorException {
    +    return execute(SimpleGetRequestExecutor.create(this), url, queryParam);
    +  }
    +
    +  @Override
    +  public String post(String url, String postData) throws WxErrorException {
    +    return execute(SimplePostRequestExecutor.create(this), url, postData);
    +  }
    +
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceImpl.java
    new file mode 100644
    index 0000000000..c807ccdf99
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceImpl.java
    @@ -0,0 +1,8 @@
    +package me.chanjar.weixin.open.api.impl;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenServiceImpl extends WxOpenServiceApacheHttpClientImpl {
    +
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenAuthorizerAccessToken.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenAuthorizerAccessToken.java
    new file mode 100644
    index 0000000000..429aad1779
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenAuthorizerAccessToken.java
    @@ -0,0 +1,35 @@
    +package me.chanjar.weixin.open.bean;
    +
    +import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
    +
    +import java.io.Serializable;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenAuthorizerAccessToken implements Serializable{
    +
    +  private String authorizerAccessToken;
    +
    +  private int expiresIn = -1;
    +
    +  public static WxOpenAuthorizerAccessToken fromJson(String json) {
    +    return WxOpenGsonBuilder.create().fromJson(json, WxOpenAuthorizerAccessToken.class);
    +  }
    +
    +  public String getAuthorizerAccessToken() {
    +    return authorizerAccessToken;
    +  }
    +
    +  public void setAuthorizerAccessToken(String authorizerAccessToken) {
    +    this.authorizerAccessToken = authorizerAccessToken;
    +  }
    +
    +  public int getExpiresIn() {
    +    return expiresIn;
    +  }
    +
    +  public void setExpiresIn(int expiresIn) {
    +    this.expiresIn = expiresIn;
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenComponentAccessToken.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenComponentAccessToken.java
    new file mode 100644
    index 0000000000..31f79b752f
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenComponentAccessToken.java
    @@ -0,0 +1,35 @@
    +package me.chanjar.weixin.open.bean;
    +
    +import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
    +
    +import java.io.Serializable;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenComponentAccessToken implements Serializable{
    +
    +  private String componentAccessToken;
    +
    +  private int expiresIn = -1;
    +
    +  public static WxOpenComponentAccessToken fromJson(String json) {
    +    return WxOpenGsonBuilder.create().fromJson(json, WxOpenComponentAccessToken.class);
    +  }
    +
    +  public String getComponentAccessToken() {
    +    return componentAccessToken;
    +  }
    +
    +  public void setComponentAccessToken(String componentAccessToken) {
    +    this.componentAccessToken = componentAccessToken;
    +  }
    +
    +  public int getExpiresIn() {
    +    return expiresIn;
    +  }
    +
    +  public void setExpiresIn(int expiresIn) {
    +    this.expiresIn = expiresIn;
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizationInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizationInfo.java
    new file mode 100644
    index 0000000000..687e31ed6a
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizationInfo.java
    @@ -0,0 +1,18 @@
    +package me.chanjar.weixin.open.bean.auth;
    +
    +import lombok.Data;
    +
    +import java.io.Serializable;
    +import java.util.List;
    +
    +/**
    + * @author 007
    + */
    +@Data
    +public class WxOpenAuthorizationInfo implements Serializable{
    +  private String authorizerAppid;
    +  private String authorizerAccessToken;
    +  private int expiresIn;
    +  private String authorizerRefreshToken;
    +  private List funcInfo;
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java
    new file mode 100644
    index 0000000000..b9f63a3e37
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java
    @@ -0,0 +1,22 @@
    +package me.chanjar.weixin.open.bean.auth;
    +
    +import lombok.Data;
    +
    +import java.io.Serializable;
    +import java.util.Map;
    +
    +/**
    + * @author 007
    + */
    +@Data
    +public class WxOpenAuthorizerInfo implements Serializable{
    +  private String nickName;
    +  private String headImg;
    +  private Integer serviceTypeInfo;
    +  private Integer verifyTypeInfo;
    +  private String userName;
    +  private String principalName;
    +  private Map businessInfo;
    +  private String alias;
    +  private String qrcodeUrl;
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java
    new file mode 100644
    index 0000000000..afcbd5f118
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java
    @@ -0,0 +1,100 @@
    +package me.chanjar.weixin.open.bean.message;
    +
    +import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import com.thoughtworks.xstream.annotations.XStreamConverter;
    +import lombok.Data;
    +import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
    +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
    +import me.chanjar.weixin.open.api.WxOpenConfigStorage;
    +import me.chanjar.weixin.open.util.WxOpenCryptUtil;
    +import me.chanjar.weixin.open.util.xml.XStreamTransformer;
    +import org.apache.commons.io.IOUtils;
    +
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.io.Serializable;
    +
    +/**
    + * @author 007
    + */
    +@XStreamAlias("xml")
    +@Data
    +public class WxOpenXmlMessage implements Serializable{
    +  @XStreamAlias("AppId")
    +  @XStreamConverter(value = XStreamCDataConverter.class)
    +  private String appId;
    +
    +  @XStreamAlias("CreateTime")
    +  private Long createTime;
    +
    +  @XStreamAlias("InfoType")
    +  @XStreamConverter(value = XStreamCDataConverter.class)
    +  private String infoType;
    +
    +  @XStreamAlias("ComponentVerifyTicket")
    +  @XStreamConverter(value = XStreamCDataConverter.class)
    +  private String componentVerifyTicket;
    +
    +  @XStreamAlias("AuthorizerAppid")
    +  @XStreamConverter(value = XStreamCDataConverter.class)
    +  private String authorizerAppid;
    +
    +  @XStreamAlias("AuthorizationCode")
    +  @XStreamConverter(value = XStreamCDataConverter.class)
    +  private String authorizationCode;
    +
    +  @XStreamAlias("AuthorizationCodeExpiredTime")
    +  @XStreamConverter(value = XStreamCDataConverter.class)
    +  private Long authorizationCodeExpiredTime;
    +
    +  @XStreamAlias("PreAuthCode")
    +  @XStreamConverter(value = XStreamCDataConverter.class)
    +  private String preAuthCode;
    +
    +  public static WxOpenXmlMessage fromXml(String xml) {
    +    //修改微信变态的消息内容格式,方便解析
    +    xml = xml.replace("", "");
    +    return XStreamTransformer.fromXml(WxOpenXmlMessage.class, xml);
    +  }
    +
    +  public static WxOpenXmlMessage fromXml(InputStream is) {
    +    return XStreamTransformer.fromXml(WxOpenXmlMessage.class, is);
    +  }
    +
    +  /**
    +   * 从加密字符串转换
    +   *
    +   * @param encryptedXml        密文
    +   * @param wxOpenConfigStorage 配置存储器对象
    +   * @param timestamp           时间戳
    +   * @param nonce               随机串
    +   * @param msgSignature        签名串
    +   */
    +  public static WxOpenXmlMessage fromEncryptedXml(String encryptedXml,
    +                                                  WxOpenConfigStorage wxOpenConfigStorage, String timestamp, String nonce,
    +                                                  String msgSignature) {
    +    WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage);
    +    String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce,
    +      encryptedXml);
    +    return fromXml(plainText);
    +  }
    +  public static WxMpXmlMessage fromEncryptedMpXml(String encryptedXml,
    +                                                  WxOpenConfigStorage wxOpenConfigStorage, String timestamp, String nonce,
    +                                                  String msgSignature) {
    +    WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage);
    +    String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce,
    +      encryptedXml);
    +    return WxMpXmlMessage.fromXml(plainText);
    +  }
    +
    +  public static WxOpenXmlMessage fromEncryptedXml(InputStream is,
    +                                                  WxOpenConfigStorage wxOpenConfigStorage, String timestamp, String nonce,
    +                                                String msgSignature) {
    +    try {
    +      return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), wxOpenConfigStorage,
    +        timestamp, nonce, msgSignature);
    +    } catch (IOException e) {
    +      throw new RuntimeException(e);
    +    }
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResult.java
    new file mode 100644
    index 0000000000..040c9f023d
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResult.java
    @@ -0,0 +1,16 @@
    +package me.chanjar.weixin.open.bean.result;
    +
    +import lombok.Data;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizerInfo;
    +
    +import java.io.Serializable;
    +
    +/**
    + * @author 007
    + */
    +@Data
    +public class WxOpenAuthorizerInfoResult implements Serializable{
    +  private WxOpenAuthorizationInfo authorizationInfo;
    +  private WxOpenAuthorizerInfo authorizerInfo;
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerOptionResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerOptionResult.java
    new file mode 100644
    index 0000000000..d7bf7aa1de
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerOptionResult.java
    @@ -0,0 +1,15 @@
    +package me.chanjar.weixin.open.bean.result;
    +
    +import lombok.Data;
    +
    +import java.io.Serializable;
    +
    +/**
    + * @author 007
    + */
    +@Data
    +public class WxOpenAuthorizerOptionResult implements Serializable{
    +  String authorizerAppid;
    +  String optionName;
    +  String optionValue;
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenQueryAuthResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenQueryAuthResult.java
    new file mode 100644
    index 0000000000..02dab98885
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenQueryAuthResult.java
    @@ -0,0 +1,14 @@
    +package me.chanjar.weixin.open.bean.result;
    +
    +import lombok.Data;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
    +
    +import java.io.Serializable;
    +
    +/**
    + * @author 007
    + */
    +@Data
    +public class WxOpenQueryAuthResult implements Serializable{
    +  private WxOpenAuthorizationInfo authorizationInfo;
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java
    new file mode 100644
    index 0000000000..0adcdbb3ac
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java
    @@ -0,0 +1,28 @@
    +package me.chanjar.weixin.open.util;
    +
    +import me.chanjar.weixin.open.api.WxOpenConfigStorage;
    +import org.apache.commons.codec.binary.Base64;
    +/**
    + * @author 007
    + */
    +public class WxOpenCryptUtil extends me.chanjar.weixin.common.util.crypto.WxCryptUtil {
    +  /**
    +   * 构造函数
    +   *
    +   * @param wxOpenConfigStorage
    +   */
    +  public WxOpenCryptUtil(WxOpenConfigStorage wxOpenConfigStorage) {
    +    /*
    +     * @param token          公众平台上,开发者设置的token
    +     * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey
    +     * @param appId          公众平台appid
    +     */
    +    String encodingAesKey = wxOpenConfigStorage.getComponentAesKey();
    +    String token = wxOpenConfigStorage.getComponentToken();
    +    String appId = wxOpenConfigStorage.getComponentAppId();
    +
    +    this.token = token;
    +    this.appidOrCorpid = appId;
    +    this.aesKey = Base64.decodeBase64(encodingAesKey + "=");
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizationInfoGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizationInfoGsonAdapter.java
    new file mode 100644
    index 0000000000..7aa0c00c5a
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizationInfoGsonAdapter.java
    @@ -0,0 +1,45 @@
    +package me.chanjar.weixin.open.util.json;
    +
    +import com.google.gson.*;
    +import me.chanjar.weixin.common.util.json.GsonHelper;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
    +
    +import java.lang.reflect.Type;
    +import java.util.ArrayList;
    +import java.util.List;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenAuthorizationInfoGsonAdapter implements JsonDeserializer {
    +  @Override
    +  public WxOpenAuthorizationInfo deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
    +    WxOpenAuthorizationInfo authorizationInfo = new WxOpenAuthorizationInfo();
    +    JsonObject jsonObject = jsonElement.getAsJsonObject();
    +    authorizationInfo.setAuthorizerAppid(GsonHelper.getString(jsonObject, "authorizer_appid"));
    +    authorizationInfo.setAuthorizerAccessToken(GsonHelper.getString(jsonObject, "authorizer_access_token"));
    +    authorizationInfo.setExpiresIn(GsonHelper.getPrimitiveInteger(jsonObject, "expires_in"));
    +    authorizationInfo.setAuthorizerRefreshToken(GsonHelper.getString(jsonObject, "authorizer_refresh_token"));
    +    List funcInfo = new ArrayList<>();
    +    JsonArray jsonArray = GsonHelper.getAsJsonArray(jsonObject.get("func_info"));
    +    if(jsonArray != null && !jsonArray.isJsonNull()){
    +      for(int i = 0; i < jsonArray.size(); i++){
    +        jsonObject = jsonArray.get(i).getAsJsonObject();
    +        if(jsonObject == null || jsonObject.isJsonNull()){
    +          continue;
    +        }
    +        jsonObject = jsonObject.getAsJsonObject("funcscope_category");
    +        if(jsonObject == null || jsonObject.isJsonNull()){
    +          continue;
    +        }
    +        Integer id = GsonHelper.getInteger(jsonObject, "id");
    +        if(id == null) {
    +          continue;
    +        }
    +        funcInfo.add(id);
    +      }
    +    }
    +    authorizationInfo.setFuncInfo(funcInfo);
    +    return authorizationInfo;
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerAccessTokenGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerAccessTokenGsonAdapter.java
    new file mode 100644
    index 0000000000..82a04b9ba8
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerAccessTokenGsonAdapter.java
    @@ -0,0 +1,21 @@
    +package me.chanjar.weixin.open.util.json;
    +
    +import com.google.gson.*;
    +import me.chanjar.weixin.common.util.json.GsonHelper;
    +import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken;
    +
    +import java.lang.reflect.Type;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenAuthorizerAccessTokenGsonAdapter implements JsonDeserializer {
    +  @Override
    +  public WxOpenAuthorizerAccessToken deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
    +    WxOpenAuthorizerAccessToken authorizerAccessToken = new WxOpenAuthorizerAccessToken();
    +    JsonObject jsonObject = jsonElement.getAsJsonObject();
    +    authorizerAccessToken.setAuthorizerAccessToken(GsonHelper.getString(jsonObject, "authorizer_access_token"));
    +    authorizerAccessToken.setExpiresIn(GsonHelper.getPrimitiveInteger(jsonObject, "expires_in"));
    +    return authorizerAccessToken;
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java
    new file mode 100644
    index 0000000000..5e1fb6d3e0
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java
    @@ -0,0 +1,38 @@
    +package me.chanjar.weixin.open.util.json;
    +
    +import com.google.gson.*;
    +import com.google.gson.reflect.TypeToken;
    +import me.chanjar.weixin.common.util.json.GsonHelper;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizerInfo;
    +
    +import java.lang.reflect.Type;
    +import java.util.Map;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenAuthorizerInfoGsonAdapter implements JsonDeserializer {
    +  @Override
    +  public WxOpenAuthorizerInfo deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
    +    WxOpenAuthorizerInfo authorizationInfo = new WxOpenAuthorizerInfo();
    +    JsonObject jsonObject = jsonElement.getAsJsonObject();
    +
    +    authorizationInfo.setNickName(GsonHelper.getString(jsonObject, "nick_name"));
    +    authorizationInfo.setHeadImg(GsonHelper.getString(jsonObject, "head_img"));
    +    authorizationInfo.setUserName(GsonHelper.getString(jsonObject, "user_name"));
    +    authorizationInfo.setPrincipalName(GsonHelper.getString(jsonObject, "principal_name"));
    +    authorizationInfo.setAlias(GsonHelper.getString(jsonObject, "alias"));
    +    authorizationInfo.setQrcodeUrl(GsonHelper.getString(jsonObject, "qrcode_url"));
    +    if(jsonObject.has("service_type_info")) {
    +      authorizationInfo.setServiceTypeInfo(GsonHelper.getInteger(jsonObject.getAsJsonObject("service_type_info"), "id"));
    +    }
    +    if(jsonObject.has("verify_type_info")) {
    +      authorizationInfo.setVerifyTypeInfo(GsonHelper.getInteger(jsonObject.getAsJsonObject("verify_type_info"), "id"));
    +    }
    +    Map businessInfo = WxOpenGsonBuilder.create().fromJson(jsonObject.get("business_info"),
    +      new TypeToken>() {
    +      }.getType());
    +    authorizationInfo.setBusinessInfo(businessInfo);
    +    return authorizationInfo;
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoResultGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoResultGsonAdapter.java
    new file mode 100644
    index 0000000000..1cef0ff411
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoResultGsonAdapter.java
    @@ -0,0 +1,32 @@
    +package me.chanjar.weixin.open.util.json;
    +
    +import com.google.gson.*;
    +import com.google.gson.reflect.TypeToken;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizerInfo;
    +import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult;
    +
    +import java.lang.reflect.Type;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenAuthorizerInfoResultGsonAdapter implements JsonDeserializer {
    +  @Override
    +  public WxOpenAuthorizerInfoResult deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
    +    WxOpenAuthorizerInfoResult authorizerInfoResult = new WxOpenAuthorizerInfoResult();
    +    JsonObject jsonObject = jsonElement.getAsJsonObject();
    +
    +    WxOpenAuthorizationInfo authorizationInfo = WxOpenGsonBuilder.INSTANCE.create().fromJson(jsonObject.get("authorization_info"),
    +      new TypeToken() {
    +      }.getType());
    +
    +    authorizerInfoResult.setAuthorizationInfo(authorizationInfo);
    +    WxOpenAuthorizerInfo authorizerInfo = WxOpenGsonBuilder.INSTANCE.create().fromJson(jsonObject.get("authorizer_info"),
    +      new TypeToken() {
    +      }.getType());
    +
    +    authorizerInfoResult.setAuthorizerInfo(authorizerInfo);
    +    return authorizerInfoResult;
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerOptionResultGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerOptionResultGsonAdapter.java
    new file mode 100644
    index 0000000000..8a2d379c31
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerOptionResultGsonAdapter.java
    @@ -0,0 +1,22 @@
    +package me.chanjar.weixin.open.util.json;
    +
    +import com.google.gson.*;
    +import me.chanjar.weixin.common.util.json.GsonHelper;
    +import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerOptionResult;
    +
    +import java.lang.reflect.Type;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenAuthorizerOptionResultGsonAdapter implements JsonDeserializer {
    +  @Override
    +  public WxOpenAuthorizerOptionResult deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
    +    WxOpenAuthorizerOptionResult authorizerOptionResult = new WxOpenAuthorizerOptionResult();
    +    JsonObject jsonObject = jsonElement.getAsJsonObject();
    +    authorizerOptionResult.setAuthorizerAppid(GsonHelper.getString(jsonObject, "authorizer_appid"));
    +    authorizerOptionResult.setOptionName(GsonHelper.getString(jsonObject, "option_name"));
    +    authorizerOptionResult.setOptionValue(GsonHelper.getString(jsonObject, "option_value"));
    +    return authorizerOptionResult;
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenComponentAccessTokenGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenComponentAccessTokenGsonAdapter.java
    new file mode 100644
    index 0000000000..10ed85083c
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenComponentAccessTokenGsonAdapter.java
    @@ -0,0 +1,21 @@
    +package me.chanjar.weixin.open.util.json;
    +
    +import com.google.gson.*;
    +import me.chanjar.weixin.common.util.json.GsonHelper;
    +import me.chanjar.weixin.open.bean.WxOpenComponentAccessToken;
    +
    +import java.lang.reflect.Type;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenComponentAccessTokenGsonAdapter implements JsonDeserializer {
    +  @Override
    +  public WxOpenComponentAccessToken deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
    +    WxOpenComponentAccessToken componentAccessToken = new WxOpenComponentAccessToken();
    +    JsonObject jsonObject = jsonElement.getAsJsonObject();
    +    componentAccessToken.setComponentAccessToken(GsonHelper.getString(jsonObject, "component_access_token"));
    +    componentAccessToken.setExpiresIn(GsonHelper.getPrimitiveInteger(jsonObject, "expires_in"));
    +    return componentAccessToken;
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenGsonBuilder.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenGsonBuilder.java
    new file mode 100644
    index 0000000000..2b390adef3
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenGsonBuilder.java
    @@ -0,0 +1,36 @@
    +package me.chanjar.weixin.open.util.json;
    +
    +import com.google.gson.Gson;
    +import com.google.gson.GsonBuilder;
    +import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken;
    +import me.chanjar.weixin.open.bean.WxOpenComponentAccessToken;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizerInfo;
    +import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult;
    +import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerOptionResult;
    +import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenGsonBuilder {
    +
    +  public static final GsonBuilder INSTANCE = new GsonBuilder();
    +
    +  static {
    +    INSTANCE.disableHtmlEscaping();
    +    INSTANCE.registerTypeAdapter(WxOpenComponentAccessToken.class, new WxOpenComponentAccessTokenGsonAdapter());
    +    INSTANCE.registerTypeAdapter(WxOpenAuthorizerAccessToken.class, new WxOpenAuthorizerAccessTokenGsonAdapter());
    +    INSTANCE.registerTypeAdapter(WxOpenAuthorizationInfo.class, new WxOpenAuthorizationInfoGsonAdapter());
    +    INSTANCE.registerTypeAdapter(WxOpenAuthorizerInfo.class, new WxOpenAuthorizerInfoGsonAdapter());
    +    INSTANCE.registerTypeAdapter(WxOpenQueryAuthResult.class, new WxOpenQueryAuthResultGsonAdapter());
    +    INSTANCE.registerTypeAdapter(WxOpenAuthorizerInfoResult.class, new WxOpenAuthorizerInfoResultGsonAdapter());
    +    INSTANCE.registerTypeAdapter(WxOpenAuthorizerOptionResult.class, new WxOpenAuthorizerOptionResultGsonAdapter());
    +
    +  }
    +
    +  public static Gson create() {
    +    return INSTANCE.create();
    +  }
    +
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenQueryAuthResultGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenQueryAuthResultGsonAdapter.java
    new file mode 100644
    index 0000000000..8868d0fef7
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenQueryAuthResultGsonAdapter.java
    @@ -0,0 +1,26 @@
    +package me.chanjar.weixin.open.util.json;
    +
    +import com.google.gson.*;
    +import com.google.gson.reflect.TypeToken;
    +import me.chanjar.weixin.open.bean.auth.WxOpenAuthorizationInfo;
    +import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult;
    +
    +import java.lang.reflect.Type;
    +
    +/**
    + * @author 007
    + */
    +public class WxOpenQueryAuthResultGsonAdapter implements JsonDeserializer {
    +  @Override
    +  public WxOpenQueryAuthResult deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
    +    WxOpenQueryAuthResult queryAuthResult = new WxOpenQueryAuthResult();
    +    JsonObject jsonObject = jsonElement.getAsJsonObject();
    +
    +    WxOpenAuthorizationInfo authorizationInfo = WxOpenGsonBuilder.INSTANCE.create().fromJson(jsonObject.get("authorization_info"),
    +      new TypeToken() {
    +      }.getType());
    +
    +    queryAuthResult.setAuthorizationInfo(authorizationInfo);
    +    return queryAuthResult;
    +  }
    +}
    diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/xml/XStreamTransformer.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/xml/XStreamTransformer.java
    new file mode 100644
    index 0000000000..515c90def0
    --- /dev/null
    +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/xml/XStreamTransformer.java
    @@ -0,0 +1,90 @@
    +package me.chanjar.weixin.open.util.xml;
    +
    +import com.thoughtworks.xstream.XStream;
    +import me.chanjar.weixin.common.util.xml.XStreamInitializer;
    +import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
    +
    +import java.io.InputStream;
    +import java.util.*;
    +
    +/**
    + * @author 007
    + */
    +public class XStreamTransformer {
    +  private static final Map, XStream> CLASS_2_XSTREAM_INSTANCE = new HashMap<>();
    +
    +  static {
    +    registerClass(WxOpenXmlMessage.class);
    +  }
    +
    +  /**
    +   * xml -> pojo
    +   */
    +  @SuppressWarnings("unchecked")
    +  public static  T fromXml(Class clazz, String xml) {
    +    T object = (T) CLASS_2_XSTREAM_INSTANCE.get(clazz).fromXML(xml);
    +    return object;
    +  }
    +
    +  @SuppressWarnings("unchecked")
    +  public static  T fromXml(Class clazz, InputStream is) {
    +    T object = (T) CLASS_2_XSTREAM_INSTANCE.get(clazz).fromXML(is);
    +    return object;
    +  }
    +
    +  /**
    +   * pojo -> xml
    +   */
    +  public static  String toXml(Class clazz, T object) {
    +    return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object);
    +  }
    +
    +  /**
    +   * 注册扩展消息的解析器
    +   *
    +   * @param clz     类型
    +   * @param xStream xml解析器
    +   */
    +  private static void register(Class clz, XStream xStream) {
    +    CLASS_2_XSTREAM_INSTANCE.put(clz, xStream);
    +  }
    +
    +  /**
    +   * 会自动注册该类及其子类
    +   *
    +   * @param clz 要注册的类
    +   */
    +  private static void registerClass(Class clz) {
    +    XStream xstream = XStreamInitializer.getInstance();
    +    xstream.setClassLoader(Thread.currentThread().getContextClassLoader());
    +
    +    xstream.processAnnotations(clz);
    +    xstream.processAnnotations(getInnerClasses(clz));
    +    if (clz.equals(WxOpenXmlMessage.class)) {
    +      // 操蛋的微信,模板消息推送成功的消息是MsgID,其他消息推送过来是MsgId
    +      xstream.aliasField("MsgID", WxOpenXmlMessage.class, "msgId");
    +    }
    +
    +    register(clz, xstream);
    +  }
    +
    +  private static Class[] getInnerClasses(Class clz) {
    +    Class[] innerClasses = clz.getClasses();
    +    if (innerClasses == null) {
    +      return null;
    +    }
    +
    +    List> result = new ArrayList<>();
    +    result.addAll(Arrays.asList(innerClasses));
    +    for (Class inner : innerClasses) {
    +      Class[] innerClz = getInnerClasses(inner);
    +      if (innerClz == null) {
    +        continue;
    +      }
    +
    +      result.addAll(Arrays.asList(innerClz));
    +    }
    +
    +    return result.toArray(new Class[0]);
    +  }
    +}
    
    From a2cf1f66e5be26a9024a10b42b2f44fe12098673 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Thu, 9 Nov 2017 16:47:20 +0800
    Subject: [PATCH 146/165] =?UTF-8?q?#370=20WxMpServiceOkHttpImpl=E6=94=B9?=
     =?UTF-8?q?=E7=94=A8httpProxy?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java    | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
    index cab1dfc606..19e799b469 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
    @@ -67,7 +67,7 @@ public void initHttp() {
         WxMpConfigStorage configStorage = this.getWxMpConfigStorage();
     
         if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {
    -      httpProxy = OkHttpProxyInfo.socks5Proxy(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword());
    +      httpProxy = OkHttpProxyInfo.httpProxy(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword());
         }
         OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
         //设置代理
    
    From 802f9e8a286abe628c8bb0b04b67655926a1ea60 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Thu, 9 Nov 2017 17:02:48 +0800
    Subject: [PATCH 147/165] =?UTF-8?q?#370=20WxMpServiceOkHttpImpl=E6=94=B9?=
     =?UTF-8?q?=E7=94=A8httpProxy?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../weixin/cp/api/impl/WxCpServiceOkHttpImpl.java    |  9 ++++++++-
     .../weixin/mp/api/impl/WxMpServiceAbstractImpl.java  |  2 +-
     .../weixin/mp/api/impl/WxMpServiceOkHttpImpl.java    | 12 +++++++-----
     3 files changed, 16 insertions(+), 7 deletions(-)
    
    diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java
    index d3580fe8a0..af9219cfe8 100644
    --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java
    +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceOkHttpImpl.java
    @@ -67,8 +67,15 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
       @Override
       public void initHttp() {
         this.log.debug("WxCpServiceOkHttpImpl initHttp");
    -    OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
         //设置代理
    +    if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {
    +      httpProxy = OkHttpProxyInfo.httpProxy(configStorage.getHttpProxyHost(),
    +        configStorage.getHttpProxyPort(),
    +        configStorage.getHttpProxyUsername(),
    +        configStorage.getHttpProxyPassword());
    +    }
    +
    +    OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
         if (httpProxy != null) {
           clientBuilder.proxy(getRequestHttpProxy().getProxy());
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java
    index 7b571ed197..420cb25249 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java
    @@ -28,7 +28,7 @@ public abstract class WxMpServiceAbstractImpl implements WxMpService, Requ
     
       protected final Logger log = LoggerFactory.getLogger(this.getClass());
       protected WxSessionManager sessionManager = new StandardSessionManager();
    -  private WxMpConfigStorage wxMpConfigStorage;
    +  protected WxMpConfigStorage wxMpConfigStorage;
       private WxMpKefuService kefuService = new WxMpKefuServiceImpl(this);
       private WxMpMaterialService materialService = new WxMpMaterialServiceImpl(this);
       private WxMpMenuService menuService = new WxMpMenuServiceImpl(this);
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
    index 19e799b469..b5135cebcb 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
    @@ -5,7 +5,6 @@
     import me.chanjar.weixin.common.exception.WxErrorException;
     import me.chanjar.weixin.common.util.http.HttpType;
     import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
    -import me.chanjar.weixin.mp.api.WxMpConfigStorage;
     import me.chanjar.weixin.mp.api.WxMpService;
     import okhttp3.*;
     
    @@ -64,13 +63,16 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
       @Override
       public void initHttp() {
         this.log.debug("WxMpServiceOkHttpImpl initHttp");
    -    WxMpConfigStorage configStorage = this.getWxMpConfigStorage();
     
    -    if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {
    -      httpProxy = OkHttpProxyInfo.httpProxy(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword());
    +    //设置代理
    +    if (wxMpConfigStorage.getHttpProxyHost() != null && wxMpConfigStorage.getHttpProxyPort() > 0) {
    +      httpProxy = OkHttpProxyInfo.httpProxy(wxMpConfigStorage.getHttpProxyHost(),
    +        wxMpConfigStorage.getHttpProxyPort(),
    +        wxMpConfigStorage.getHttpProxyUsername(),
    +        wxMpConfigStorage.getHttpProxyPassword());
         }
    +
         OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
    -    //设置代理
         if (httpProxy != null) {
           clientBuilder.proxy(getRequestHttpProxy().getProxy());
     
    
    From e9ef9eb1521e33f85185975a04dfcda2eafc085d Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Fri, 10 Nov 2017 12:03:21 +0800
    Subject: [PATCH 148/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?=
     =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.8.7.BETA?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     pom.xml                     | 2 +-
     weixin-java-common/pom.xml  | 2 +-
     weixin-java-cp/pom.xml      | 2 +-
     weixin-java-miniapp/pom.xml | 2 +-
     weixin-java-mp/pom.xml      | 2 +-
     weixin-java-open/pom.xml    | 2 +-
     weixin-java-pay/pom.xml     | 2 +-
     7 files changed, 7 insertions(+), 7 deletions(-)
    
    diff --git a/pom.xml b/pom.xml
    index 38d24fd76c..bb540a48e2 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -6,7 +6,7 @@
       4.0.0
       com.github.binarywang
       weixin-java-parent
    -  2.8.6.BETA
    +  2.8.7.BETA
       pom
       WeiXin Java Tools - Parent
       微信公众号、企业号上级POM
    diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml
    index 61839da214..b970c23dfd 100644
    --- a/weixin-java-common/pom.xml
    +++ b/weixin-java-common/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.6.BETA
    +    2.8.7.BETA
       
     
       weixin-java-common
    diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml
    index 64dfe320a6..e0074830f2 100644
    --- a/weixin-java-cp/pom.xml
    +++ b/weixin-java-cp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.6.BETA
    +    2.8.7.BETA
       
     
       weixin-java-cp
    diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml
    index 5b1a2772fa..47459836d1 100644
    --- a/weixin-java-miniapp/pom.xml
    +++ b/weixin-java-miniapp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.6.BETA
    +    2.8.7.BETA
       
       weixin-java-miniapp
       WeiXin Java Tools - MiniApp
    diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml
    index 3405388824..3888075e8e 100644
    --- a/weixin-java-mp/pom.xml
    +++ b/weixin-java-mp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.6.BETA
    +    2.8.7.BETA
       
       weixin-java-mp
       WeiXin Java Tools - MP
    diff --git a/weixin-java-open/pom.xml b/weixin-java-open/pom.xml
    index d451dce1cd..f61e56988d 100644
    --- a/weixin-java-open/pom.xml
    +++ b/weixin-java-open/pom.xml
    @@ -8,7 +8,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.6.BETA
    +    2.8.7.BETA
       
       weixin-java-open
       WeiXin Java Tools - Open
    diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml
    index b4940b2712..3fa728fc91 100644
    --- a/weixin-java-pay/pom.xml
    +++ b/weixin-java-pay/pom.xml
    @@ -5,7 +5,7 @@
       
         weixin-java-parent
         com.github.binarywang
    -    2.8.6.BETA
    +    2.8.7.BETA
       
       4.0.0
     
    
    From e007a13df6aa6578ff4b4529f8573a64a7f4b319 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Tue, 14 Nov 2017 10:43:52 +0800
    Subject: [PATCH 149/165] =?UTF-8?q?=E4=BD=BF=E7=94=A8lombok=E7=9A=84@Data?=
     =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E7=AE=80=E5=8C=96miniapp=E6=A8=A1=E5=9D=97?=
     =?UTF-8?q?=E7=9A=84=E6=89=80=E6=9C=89bean=E7=B1=BB?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../wx/miniapp/bean/WxMaCodeLineColor.java    |  35 +---
     .../bean/WxMaJscode2SessionResult.java        |  36 +----
     .../wx/miniapp/bean/WxMaKefuMessage.java      |  58 +------
     .../wx/miniapp/bean/WxMaMessage.java          |  89 +---------
     .../wx/miniapp/bean/WxMaQrcode.java           |  20 +--
     .../wx/miniapp/bean/WxMaTemplateMessage.java  | 153 +-----------------
     .../wx/miniapp/bean/WxMaUserInfo.java         | 106 +-----------
     .../wx/miniapp/bean/WxMaWxcode.java           |  42 +----
     .../wx/miniapp/bean/WxMaWxcodeLimit.java      |  43 +----
     .../api/impl/WxMaMsgServiceImplTest.java      |   2 +-
     .../miniapp/bean/WxMaTemplateMessageTest.java |   2 +-
     .../wx/miniapp/demo/WxMaDemoServer.java       |   2 +-
     12 files changed, 39 insertions(+), 549 deletions(-)
    
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
    index 850da06d7a..2afb4c073e 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaCodeLineColor.java
    @@ -1,5 +1,8 @@
     package cn.binarywang.wx.miniapp.bean;
     
    +import lombok.AllArgsConstructor;
    +import lombok.Data;
    +
     /**
      * 
      * lineColor 包装类
    @@ -8,36 +11,8 @@
      * 
    * @author Element */ +@Data +@AllArgsConstructor public class WxMaCodeLineColor { private String r = "0", g = "0", b = "0"; - - public WxMaCodeLineColor(String r, String g, String b) { - this.r = r; - this.g = g; - this.b = b; - } - - public String getR() { - return r; - } - - public void setR(String r) { - this.r = r; - } - - public String getG() { - return g; - } - - public void setG(String g) { - this.g = g; - } - - public String getB() { - return b; - } - - public void setB(String b) { - this.b = b; - } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java index 98d090ac74..7d3e2d8de6 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaJscode2SessionResult.java @@ -2,6 +2,8 @@ import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; import java.io.Serializable; @@ -10,6 +12,8 @@ * * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = false) public class WxMaJscode2SessionResult implements Serializable { private static final long serialVersionUID = -1060216618475607933L; @@ -29,36 +33,4 @@ public static WxMaJscode2SessionResult fromJson(String json) { return WxMaGsonBuilder.create().fromJson(json, WxMaJscode2SessionResult.class); } - public String getSessionKey() { - return sessionKey; - } - - public void setSessionKey(String sessionKey) { - this.sessionKey = sessionKey; - } - - public Integer getExpiresin() { - return expiresin; - } - - public void setExpiresin(Integer expiresin) { - this.expiresin = expiresin; - } - - public String getOpenid() { - return openid; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public String getUnionid() { - return unionid; - } - - public void setUnionid(String unionid) { - this.unionid = unionid; - } - } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java index 680eeb65a4..ec1728db60 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaKefuMessage.java @@ -3,6 +3,7 @@ import cn.binarywang.wx.miniapp.builder.ImageBuilder; import cn.binarywang.wx.miniapp.builder.TextBuilder; import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; +import lombok.Data; import java.io.Serializable; @@ -11,6 +12,7 @@ * * @author Binary Wang */ +@Data public class WxMaKefuMessage implements Serializable { private static final long serialVersionUID = -9196732086954365246L; @@ -36,62 +38,6 @@ public static ImageBuilder newImageBuilder() { return new ImageBuilder(); } - public String getToUser() { - return this.toUser; - } - - public void setToUser(String toUser) { - this.toUser = toUser; - } - - public String getMsgType() { - return this.msgType; - } - - public void setMsgType(String msgType) { - this.msgType = msgType; - } - - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getThumbMediaId() { - return this.thumbMediaId; - } - - public void setThumbMediaId(String thumbMediaId) { - this.thumbMediaId = thumbMediaId; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - public String toJson() { return WxMaGsonBuilder.create().toJson(this); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java index 4b201da1cd..cb1fed6923 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java @@ -7,6 +7,7 @@ import com.google.gson.annotations.SerializedName; import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import org.apache.commons.io.IOUtils; @@ -20,6 +21,7 @@ * @author Binary Wang */ @XStreamAlias("xml") +@Data public class WxMaMessage implements Serializable { private static final long serialVersionUID = -3586245291677274914L; @@ -146,91 +148,4 @@ public String toJson() { return WxMaGsonBuilder.create().toJson(this); } - public String getToUser() { - return toUser; - } - - public void setToUser(String toUser) { - this.toUser = toUser; - } - - public String getFromUser() { - return fromUser; - } - - public void setFromUser(String fromUser) { - this.fromUser = fromUser; - } - - public Integer getCreateTime() { - return createTime; - } - - public void setCreateTime(Integer createTime) { - this.createTime = createTime; - } - - public String getMsgType() { - return msgType; - } - - public void setMsgType(String msgType) { - this.msgType = msgType; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public Long getMsgId() { - return msgId; - } - - public void setMsgId(Long msgId) { - this.msgId = msgId; - } - - public String getPicUrl() { - return picUrl; - } - - public void setPicUrl(String picUrl) { - this.picUrl = picUrl; - } - - public String getMediaId() { - return mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getEvent() { - return event; - } - - public void setEvent(String event) { - this.event = event; - } - - public String getSessionFrom() { - return sessionFrom; - } - - public void setSessionFrom(String sessionFrom) { - this.sessionFrom = sessionFrom; - } - - public String getEncrypt() { - return encrypt; - } - - public void setEncrypt(String encrypt) { - this.encrypt = encrypt; - } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java index 39b870fbea..5c17cd1e58 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaQrcode.java @@ -1,12 +1,16 @@ package cn.binarywang.wx.miniapp.bean; import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; +import lombok.Data; +import lombok.EqualsAndHashCode; import java.io.Serializable; /** * @author Binary Wang */ +@Data +@EqualsAndHashCode(callSuper = false) public class WxMaQrcode extends AbstractWxMaQrcodeWrapper implements Serializable { private static final long serialVersionUID = 5777119669111011584L; private String path; @@ -21,22 +25,6 @@ public static WxMaQrcode fromJson(String json) { return WxMaGsonBuilder.create().fromJson(json, WxMaQrcode.class); } - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - @Override public String toString() { return WxMaGsonBuilder.create().toJson(this); diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java index 79f955c6d2..32268b4c4b 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessage.java @@ -1,6 +1,8 @@ package cn.binarywang.wx.miniapp.bean; import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; +import lombok.Builder; +import lombok.Data; import java.io.Serializable; import java.util.ArrayList; @@ -11,6 +13,8 @@ * * @author Binary Wang */ +@Data +@Builder public class WxMaTemplateMessage implements Serializable { private static final long serialVersionUID = 5063374783759519418L; @@ -57,7 +61,8 @@ public class WxMaTemplateMessage implements Serializable { * 描述: 模板内容,不填则下发空模板 *
    */ - private List data = new ArrayList<>(); + @Builder.Default + private final List data = new ArrayList<>(); /** *
    @@ -77,80 +82,11 @@ public class WxMaTemplateMessage implements Serializable {
        */
       private String emphasisKeyword;
     
    -  private WxMaTemplateMessage(Builder builder) {
    -    setToUser(builder.toUser);
    -    setTemplateId(builder.templateId);
    -    setPage(builder.page);
    -    setFormId(builder.formId);
    -    setData(builder.data);
    -    setColor(builder.color);
    -    setEmphasisKeyword(builder.emphasisKeyword);
    -  }
    -
    -  public static Builder newBuilder() {
    -    return new Builder();
    -  }
    -
       public String toJson() {
         return WxMaGsonBuilder.create().toJson(this);
       }
     
    -  public String getToUser() {
    -    return toUser;
    -  }
    -
    -  public void setToUser(String toUser) {
    -    this.toUser = toUser;
    -  }
    -
    -  public String getTemplateId() {
    -    return templateId;
    -  }
    -
    -  public void setTemplateId(String templateId) {
    -    this.templateId = templateId;
    -  }
    -
    -  public String getPage() {
    -    return page;
    -  }
    -
    -  public void setPage(String page) {
    -    this.page = page;
    -  }
    -
    -  public String getFormId() {
    -    return formId;
    -  }
    -
    -  public void setFormId(String formId) {
    -    this.formId = formId;
    -  }
    -
    -  public List getData() {
    -    return data;
    -  }
    -
    -  public void setData(List data) {
    -    this.data = data;
    -  }
    -
    -  public String getColor() {
    -    return color;
    -  }
    -
    -  public void setColor(String color) {
    -    this.color = color;
    -  }
    -
    -  public String getEmphasisKeyword() {
    -    return emphasisKeyword;
    -  }
    -
    -  public void setEmphasisKeyword(String emphasisKeyword) {
    -    this.emphasisKeyword = emphasisKeyword;
    -  }
    -
    +  @lombok.Data
       public static class Data {
         private String name;
         private String value;
    @@ -167,81 +103,6 @@ public Data(String name, String value, String color) {
           this.color = color;
         }
     
    -    public String getName() {
    -      return this.name;
    -    }
    -
    -    public void setName(String name) {
    -      this.name = name;
    -    }
    -
    -    public String getValue() {
    -      return this.value;
    -    }
    -
    -    public void setValue(String value) {
    -      this.value = value;
    -    }
    -
    -    public String getColor() {
    -      return this.color;
    -    }
    -
    -    public void setColor(String color) {
    -      this.color = color;
    -    }
    -
       }
     
    -  public static final class Builder {
    -    private String toUser;
    -    private String templateId;
    -    private String page;
    -    private String formId;
    -    private List data;
    -    private String color;
    -    private String emphasisKeyword;
    -
    -    private Builder() {
    -    }
    -
    -    public Builder toUser(String toUser) {
    -      this.toUser = toUser;
    -      return this;
    -    }
    -
    -    public Builder templateId(String templateId) {
    -      this.templateId = templateId;
    -      return this;
    -    }
    -
    -    public Builder page(String page) {
    -      this.page = page;
    -      return this;
    -    }
    -
    -    public Builder formId(String formId) {
    -      this.formId = formId;
    -      return this;
    -    }
    -
    -    public Builder data(List data) {
    -      this.data = data;
    -      return this;
    -    }
    -
    -    public Builder color(String color) {
    -      this.color = color;
    -      return this;
    -    }
    -
    -    public Builder emphasisKeyword(String emphasisKeyword) {
    -      this.emphasisKeyword = emphasisKeyword;
    -      return this;
    -    }
    -
    -    public WxMaTemplateMessage build() {
    -      return new WxMaTemplateMessage(this);
    -    }
    -  }
     }
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java
    index 5114d1b112..8b0ed8fe6a 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaUserInfo.java
    @@ -1,14 +1,14 @@
     package cn.binarywang.wx.miniapp.bean;
     
     import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
    -import org.apache.commons.lang3.builder.ToStringBuilder;
    -import org.apache.commons.lang3.builder.ToStringStyle;
    +import lombok.Data;
     
     import java.io.Serializable;
     
     /**
      * @author Binary Wang
      */
    +@Data
     public class WxMaUserInfo implements Serializable {
       private static final long serialVersionUID = 6719822331555402137L;
     
    @@ -27,109 +27,9 @@ public static WxMaUserInfo fromJson(String json) {
         return WxMaGsonBuilder.create().fromJson(json, WxMaUserInfo.class);
       }
     
    -  @Override
    -  public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    -  }
    -
    -  public String getOpenId() {
    -    return openId;
    -  }
    -
    -  public void setOpenId(String openId) {
    -    this.openId = openId;
    -  }
    -
    -  public String getNickName() {
    -    return nickName;
    -  }
    -
    -  public void setNickName(String nickName) {
    -    this.nickName = nickName;
    -  }
    -
    -  public String getGender() {
    -    return gender;
    -  }
    -
    -  public void setGender(String gender) {
    -    this.gender = gender;
    -  }
    -
    -  public String getLanguage() {
    -    return language;
    -  }
    -
    -  public void setLanguage(String language) {
    -    this.language = language;
    -  }
    -
    -  public String getCity() {
    -    return city;
    -  }
    -
    -  public void setCity(String city) {
    -    this.city = city;
    -  }
    -
    -  public String getProvince() {
    -    return province;
    -  }
    -
    -  public void setProvince(String province) {
    -    this.province = province;
    -  }
    -
    -  public String getCountry() {
    -    return country;
    -  }
    -
    -  public void setCountry(String country) {
    -    this.country = country;
    -  }
    -
    -  public String getAvatarUrl() {
    -    return avatarUrl;
    -  }
    -
    -  public void setAvatarUrl(String avatarUrl) {
    -    this.avatarUrl = avatarUrl;
    -  }
    -
    -  public String getUnionId() {
    -    return unionId;
    -  }
    -
    -  public void setUnionId(String unionId) {
    -    this.unionId = unionId;
    -  }
    -
    -  public Watermark getWatermark() {
    -    return watermark;
    -  }
    -
    -  public void setWatermark(Watermark watermark) {
    -    this.watermark = watermark;
    -  }
    -
    +  @Data
       public static class Watermark {
         private String timestamp;
         private String appid;
    -
    -    public String getTimestamp() {
    -      return timestamp;
    -    }
    -
    -    public void setTimestamp(String timestamp) {
    -      this.timestamp = timestamp;
    -    }
    -
    -    public String getAppid() {
    -      return appid;
    -    }
    -
    -    public void setAppid(String appid) {
    -      this.appid = appid;
    -    }
       }
     }
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java
    index 8654ed9991..8e629096c6 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcode.java
    @@ -2,6 +2,8 @@
     
     import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
     import com.google.gson.annotations.SerializedName;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
     
     import java.io.Serializable;
     
    @@ -10,9 +12,11 @@
      * @author Element
      * @date 2017/7/27
      */
    +@Data
    +@EqualsAndHashCode(callSuper = false)
     public class WxMaWxcode extends AbstractWxMaQrcodeWrapper implements Serializable {
    -
       private static final long serialVersionUID = 1287399621649210322L;
    +
       private String path;
       private int width = 430;
     
    @@ -26,40 +30,4 @@ public static WxMaWxcode fromJson(String json) {
         return WxMaGsonBuilder.create().fromJson(json, WxMaWxcode.class);
       }
     
    -  public static long getSerialVersionUID() {
    -    return serialVersionUID;
    -  }
    -
    -  public String getPath() {
    -    return path;
    -  }
    -
    -  public void setPath(String path) {
    -    this.path = path;
    -  }
    -
    -  public int getWidth() {
    -    return width;
    -  }
    -
    -  public void setWidth(int width) {
    -    this.width = width;
    -  }
    -
    -  public boolean isAutoColor() {
    -    return autoColor;
    -  }
    -
    -  public void setAutoColor(boolean autoColor) {
    -    this.autoColor = autoColor;
    -  }
    -
    -  public WxMaCodeLineColor getLineColor() {
    -    return lineColor;
    -  }
    -
    -  public void setLineColor(WxMaCodeLineColor lineColor) {
    -    this.lineColor = lineColor;
    -  }
    -
     }
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java
    index 92f6837af2..5f76273b54 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaWxcodeLimit.java
    @@ -2,6 +2,8 @@
     
     import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
     import com.google.gson.annotations.SerializedName;
    +import lombok.Data;
    +import lombok.EqualsAndHashCode;
     
     import java.io.Serializable;
     
    @@ -10,6 +12,8 @@
      * @author Element
      * @date 2017/7/27
      */
    +@Data
    +@EqualsAndHashCode(callSuper = false)
     public class WxMaWxcodeLimit extends AbstractWxMaQrcodeWrapper implements Serializable {
       private static final long serialVersionUID = 4782193774524960401L;
       private String scene;
    @@ -27,43 +31,4 @@ public static WxMaWxcodeLimit fromJson(String json) {
         return WxMaGsonBuilder.create().fromJson(json, WxMaWxcodeLimit.class);
       }
     
    -  public String getPage() {
    -    return page;
    -  }
    -
    -  public void setPage(String page) {
    -    this.page = page;
    -  }
    -
    -  public String getScene() {
    -    return scene;
    -  }
    -
    -  public void setScene(String scene) {
    -    this.scene = scene;
    -  }
    -
    -  public int getWidth() {
    -    return width;
    -  }
    -
    -  public void setWidth(int width) {
    -    this.width = width;
    -  }
    -
    -  public boolean isAutoColor() {
    -    return autoColor;
    -  }
    -
    -  public void setAutoColor(boolean autoColor) {
    -    this.autoColor = autoColor;
    -  }
    -
    -  public WxMaCodeLineColor getLineColor() {
    -    return lineColor;
    -  }
    -
    -  public void setLineColor(WxMaCodeLineColor lineColor) {
    -    this.lineColor = lineColor;
    -  }
     }
    diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java
    index f07481ffbf..d6aa31a71f 100644
    --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java
    +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaMsgServiceImplTest.java
    @@ -54,7 +54,7 @@ public void testSendTemplateMsg() throws WxErrorException {
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
         TestConfig config = (TestConfig) this.wxService.getWxMaConfig();
     
    -    WxMaTemplateMessage templateMessage = WxMaTemplateMessage.newBuilder()
    +    WxMaTemplateMessage templateMessage = WxMaTemplateMessage.builder()
           .toUser(config.getOpenid())
           .formId("FORMID")
           .page("index")
    diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessageTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessageTest.java
    index ad6e62c2ca..d4464312eb 100644
    --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessageTest.java
    +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaTemplateMessageTest.java
    @@ -11,7 +11,7 @@
     public class WxMaTemplateMessageTest {
       @Test
       public void testToJson() throws Exception {
    -    WxMaTemplateMessage tm = WxMaTemplateMessage.newBuilder()
    +    WxMaTemplateMessage tm = WxMaTemplateMessage.builder()
           .toUser("OPENID")
           //.color("aaaaa")
           .formId("FORMID")
    diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java
    index 9c4493f0c4..8d14b261ff 100644
    --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java
    +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/demo/WxMaDemoServer.java
    @@ -94,7 +94,7 @@ public void handle(WxMaMessage wxMessage, Map context,
         public void handle(WxMaMessage wxMessage, Map context,
                            WxMaService service, WxSessionManager sessionManager)
           throws WxErrorException {
    -      service.getMsgService().sendTemplateMsg(WxMaTemplateMessage.newBuilder()
    +      service.getMsgService().sendTemplateMsg(WxMaTemplateMessage.builder()
             .templateId(templateId).data(Lists.newArrayList(
               new WxMaTemplateMessage.Data("keyword1", "339208499", "#173177")))
             .toUser(wxMessage.getFromUser())
    
    From 993999735b941115e0ecb285d5f96a5ea6f0ce46 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Tue, 14 Nov 2017 11:05:18 +0800
    Subject: [PATCH 150/165] =?UTF-8?q?=E4=BD=BF=E7=94=A8lombok=E7=9A=84@Data?=
     =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E7=AE=80=E5=8C=96common=E6=A8=A1=E5=9D=97?=
     =?UTF-8?q?=E7=9A=84=E6=89=80=E6=9C=89bean=E7=B1=BB?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../weixin/common/bean/WxAccessToken.java     | 18 +----
     .../common/bean/WxCardApiSignature.java       | 76 +------------------
     .../weixin/common/bean/WxJsapiSignature.java  | 44 +----------
     .../weixin/common/bean/menu/WxMenu.java       | 19 +----
     .../weixin/common/bean/menu/WxMenuButton.java | 65 +---------------
     .../weixin/common/bean/menu/WxMenuRule.java   | 58 +-------------
     .../weixin/common/bean/result/WxError.java    | 57 +-------------
     .../bean/result/WxMediaUploadResult.java      | 34 +--------
     .../chanjar/weixin/common/util/BeanUtils.java |  2 +-
     .../common/util/http/HttpResponseProxy.java   | 12 +--
     .../ApacheSimplePostRequestExecutor.java      |  4 +-
     .../JoddHttpSimplePostRequestExecutor.java    |  6 +-
     .../common/util/json/WxErrorAdapter.java      | 17 +++--
     .../weixin/common/bean/WxErrorTest.java       |  1 -
     .../weixin/cp/api/WxCpBusyRetryTest.java      |  4 +-
     .../mp/api/impl/WxMpCardServiceImpl.java      |  7 +-
     .../mp/api/impl/WxMpKefuServiceImpl.java      |  4 +-
     .../mp/api/impl/WxMpMaterialServiceImpl.java  |  2 +-
     .../mp/api/impl/WxMpQrcodeServiceImpl.java    | 20 ++---
     .../datacube/WxDataCubeArticleResult.java     |  2 +
     .../bean/datacube/WxDataCubeArticleTotal.java | 11 +--
     .../bean/datacube/WxDataCubeBaseResult.java   |  4 +-
     .../datacube/WxDataCubeInterfaceResult.java   |  2 +
     .../mp/bean/datacube/WxDataCubeMsgResult.java | 17 +++--
     .../weixin/mp/bean/device/BaseResp.java       |  4 +-
     .../weixin/mp/bean/device/RespMsg.java        |  4 +-
     .../weixin/mp/bean/device/TransMsgResp.java   |  4 +-
     .../mp/bean/device/WxDeviceAuthorize.java     |  2 +
     .../bean/device/WxDeviceAuthorizeResult.java  |  4 +-
     .../weixin/mp/bean/device/WxDeviceBind.java   |  4 +-
     .../bean/device/WxDeviceBindDeviceResult.java |  4 +-
     .../mp/bean/device/WxDeviceBindResult.java    |  4 +-
     .../weixin/mp/bean/device/WxDeviceMsg.java    |  4 +-
     .../mp/bean/device/WxDeviceOpenIdResult.java  |  4 +-
     .../mp/bean/device/WxDeviceQrCodeResult.java  |  4 +-
     .../bean/message/WxMpXmlOutImageMessage.java  |  2 +
     .../bean/message/WxMpXmlOutNewsMessage.java   |  2 +
     .../bean/message/WxMpXmlOutTextMessage.java   |  2 +
     .../WxMpXmlOutTransferKefuMessage.java        |  2 +
     .../bean/message/WxMpXmlOutVoiceMessage.java  |  2 +
     ...lVoiceAndImageDownloadRequestExecutor.java |  3 +-
     .../mp/util/http/QrCodeRequestExecutor.java   |  2 +-
     .../ApacheMaterialUploadRequestExecutor.java  |  2 +-
     .../ApacheMediaImgUploadRequestExecutor.java  |  2 +-
     .../JoddMaterialUploadRequestExecutor.java    |  2 +-
     .../JoddMediaImgUploadRequestExecutor.java    |  2 +-
     .../OkhttpMaterialUploadRequestExecutor.java  |  2 +-
     .../weixin/mp/api/WxMpBusyRetryTest.java      |  4 +-
     48 files changed, 131 insertions(+), 426 deletions(-)
    
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessToken.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessToken.java
    index 6476205a54..6327965152 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessToken.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessToken.java
    @@ -1,9 +1,11 @@
     package me.chanjar.weixin.common.bean;
     
    +import lombok.Data;
     import me.chanjar.weixin.common.util.json.WxGsonBuilder;
     
     import java.io.Serializable;
     
    +@Data
     public class WxAccessToken implements Serializable {
       private static final long serialVersionUID = 8709719312922168909L;
     
    @@ -15,20 +17,4 @@ public static WxAccessToken fromJson(String json) {
         return WxGsonBuilder.create().fromJson(json, WxAccessToken.class);
       }
     
    -  public String getAccessToken() {
    -    return this.accessToken;
    -  }
    -
    -  public void setAccessToken(String accessToken) {
    -    this.accessToken = accessToken;
    -  }
    -
    -  public int getExpiresIn() {
    -    return this.expiresIn;
    -  }
    -
    -  public void setExpiresIn(int expiresIn) {
    -    this.expiresIn = expiresIn;
    -  }
    -
     }
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxCardApiSignature.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxCardApiSignature.java
    index df272318e7..9d5d7a06dd 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxCardApiSignature.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxCardApiSignature.java
    @@ -1,17 +1,18 @@
     package me.chanjar.weixin.common.bean;
     
    +import lombok.Data;
     import me.chanjar.weixin.common.util.ToStringUtils;
     
     import java.io.Serializable;
     
     /**
    - * 卡券Api签名
    + * 卡券Api签名.
      *
      * @author YuJian
      * @version 15/11/8
      */
    +@Data
     public class WxCardApiSignature implements Serializable {
    -
       private static final long serialVersionUID = 158176707226975979L;
     
       private String appId;
    @@ -37,75 +38,4 @@ public String toString() {
         return ToStringUtils.toSimpleString(this);
       }
     
    -  public String getAppId() {
    -    return this.appId;
    -  }
    -
    -  public void setAppId(String appId) {
    -    this.appId = appId;
    -  }
    -
    -  public String getCardId() {
    -    return this.cardId;
    -  }
    -
    -  public void setCardId(String cardId) {
    -    this.cardId = cardId;
    -  }
    -
    -  public String getCardType() {
    -    return this.cardType;
    -  }
    -
    -  public void setCardType(String cardType) {
    -    this.cardType = cardType;
    -  }
    -
    -  public String getLocationId() {
    -    return this.locationId;
    -  }
    -
    -  public void setLocationId(String locationId) {
    -    this.locationId = locationId;
    -  }
    -
    -  public String getCode() {
    -    return this.code;
    -  }
    -
    -  public void setCode(String code) {
    -    this.code = code;
    -  }
    -
    -  public String getOpenId() {
    -    return this.openId;
    -  }
    -
    -  public void setOpenId(String openId) {
    -    this.openId = openId;
    -  }
    -
    -  public Long getTimestamp() {
    -    return this.timestamp;
    -  }
    -
    -  public void setTimestamp(Long timestamp) {
    -    this.timestamp = timestamp;
    -  }
    -
    -  public String getNonceStr() {
    -    return this.nonceStr;
    -  }
    -
    -  public void setNonceStr(String nonceStr) {
    -    this.nonceStr = nonceStr;
    -  }
    -
    -  public String getSignature() {
    -    return this.signature;
    -  }
    -
    -  public void setSignature(String signature) {
    -    this.signature = signature;
    -  }
     }
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxJsapiSignature.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxJsapiSignature.java
    index 7837158361..619f0a7504 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxJsapiSignature.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxJsapiSignature.java
    @@ -1,10 +1,13 @@
     package me.chanjar.weixin.common.bean;
     
    +import lombok.Data;
    +
     import java.io.Serializable;
     
     /**
    - * jspai signature
    + * jspai signature.
      */
    +@Data
     public class WxJsapiSignature implements Serializable {
       private static final long serialVersionUID = -1116808193154384804L;
     
    @@ -18,43 +21,4 @@ public class WxJsapiSignature implements Serializable {
     
       private String signature;
     
    -  public String getSignature() {
    -    return this.signature;
    -  }
    -
    -  public void setSignature(String signature) {
    -    this.signature = signature;
    -  }
    -
    -  public String getNonceStr() {
    -    return nonceStr;
    -  }
    -
    -  public void setNonceStr(String nonceStr) {
    -    this.nonceStr = nonceStr;
    -  }
    -
    -  public long getTimestamp() {
    -    return this.timestamp;
    -  }
    -
    -  public void setTimestamp(long timestamp) {
    -    this.timestamp = timestamp;
    -  }
    -
    -  public String getUrl() {
    -    return this.url;
    -  }
    -
    -  public void setUrl(String url) {
    -    this.url = url;
    -  }
    -
    -  public String getAppId() {
    -    return appId;
    -  }
    -
    -  public void setAppId(String appId) {
    -    this.appId = appId;
    -  }
     }
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenu.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenu.java
    index d82431c96a..4d349acb25 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenu.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenu.java
    @@ -1,5 +1,6 @@
     package me.chanjar.weixin.common.bean.menu;
     
    +import lombok.Data;
     import me.chanjar.weixin.common.util.ToStringUtils;
     import me.chanjar.weixin.common.util.json.WxGsonBuilder;
     
    @@ -15,8 +16,8 @@
      *
      * @author Daniel Qian
      */
    +@Data
     public class WxMenu implements Serializable {
    -
       private static final long serialVersionUID = -7083914585539687746L;
     
       private List buttons = new ArrayList<>();
    @@ -40,22 +41,6 @@ public static WxMenu fromJson(InputStream is) {
           .fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), WxMenu.class);
       }
     
    -  public List getButtons() {
    -    return this.buttons;
    -  }
    -
    -  public void setButtons(List buttons) {
    -    this.buttons = buttons;
    -  }
    -
    -  public WxMenuRule getMatchRule() {
    -    return this.matchRule;
    -  }
    -
    -  public void setMatchRule(WxMenuRule matchRule) {
    -    this.matchRule = matchRule;
    -  }
    -
       public String toJson() {
         return WxGsonBuilder.create().toJson(this);
       }
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java
    index 1c32ef104a..2f9276b025 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java
    @@ -1,12 +1,14 @@
     package me.chanjar.weixin.common.bean.menu;
     
     import com.google.gson.annotations.SerializedName;
    +import lombok.Data;
     import me.chanjar.weixin.common.util.ToStringUtils;
     
     import java.io.Serializable;
     import java.util.ArrayList;
     import java.util.List;
     
    +@Data
     public class WxMenuButton implements Serializable {
       private static final long serialVersionUID = -1070939403109776555L;
     
    @@ -77,67 +79,4 @@ public String toString() {
         return ToStringUtils.toSimpleString(this);
       }
     
    -  public String getType() {
    -    return this.type;
    -  }
    -
    -  public void setType(String type) {
    -    this.type = type;
    -  }
    -
    -  public String getName() {
    -    return this.name;
    -  }
    -
    -  public void setName(String name) {
    -    this.name = name;
    -  }
    -
    -  public String getKey() {
    -    return this.key;
    -  }
    -
    -  public void setKey(String key) {
    -    this.key = key;
    -  }
    -
    -  public String getUrl() {
    -    return this.url;
    -  }
    -
    -  public void setUrl(String url) {
    -    this.url = url;
    -  }
    -
    -  public List getSubButtons() {
    -    return this.subButtons;
    -  }
    -
    -  public void setSubButtons(List subButtons) {
    -    this.subButtons = subButtons;
    -  }
    -
    -  public String getMediaId() {
    -    return this.mediaId;
    -  }
    -
    -  public void setMediaId(String mediaId) {
    -    this.mediaId = mediaId;
    -  }
    -
    -  public String getAppId() {
    -    return appId;
    -  }
    -
    -  public void setAppId(String appId) {
    -    this.appId = appId;
    -  }
    -
    -  public String getPagePath() {
    -    return pagePath;
    -  }
    -
    -  public void setPagePath(String pagePath) {
    -    this.pagePath = pagePath;
    -  }
     }
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java
    index dffae94887..16542dec69 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java
    @@ -1,10 +1,12 @@
     package me.chanjar.weixin.common.bean.menu;
     
     import com.google.gson.annotations.SerializedName;
    +import lombok.Data;
     import me.chanjar.weixin.common.util.ToStringUtils;
     
     import java.io.Serializable;
     
    +@Data
     public class WxMenuRule implements Serializable {
       private static final long serialVersionUID = -4587181819499286670L;
     
    @@ -20,62 +22,6 @@ public class WxMenuRule implements Serializable {
       private String clientPlatformType;
       private String language;
     
    -  public String getTagId() {
    -    return this.tagId;
    -  }
    -
    -  public void setTagId(String tagId) {
    -    this.tagId = tagId;
    -  }
    -
    -  public String getSex() {
    -    return this.sex;
    -  }
    -
    -  public void setSex(String sex) {
    -    this.sex = sex;
    -  }
    -
    -  public String getCountry() {
    -    return this.country;
    -  }
    -
    -  public void setCountry(String country) {
    -    this.country = country;
    -  }
    -
    -  public String getProvince() {
    -    return this.province;
    -  }
    -
    -  public void setProvince(String province) {
    -    this.province = province;
    -  }
    -
    -  public String getCity() {
    -    return this.city;
    -  }
    -
    -  public void setCity(String city) {
    -    this.city = city;
    -  }
    -
    -  public String getClientPlatformType() {
    -    return this.clientPlatformType;
    -  }
    -
    -  public void setClientPlatformType(String clientPlatformType) {
    -    this.clientPlatformType = clientPlatformType;
    -  }
    -
    -  public String getLanguage() {
    -    return this.language;
    -  }
    -
    -  public void setLanguage(String language) {
    -    this.language = language;
    -  }
    -
       @Override
       public String toString() {
         return ToStringUtils.toSimpleString(this);
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java
    index 809d015ab0..25a06f4785 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java
    @@ -1,5 +1,7 @@
     package me.chanjar.weixin.common.bean.result;
     
    +import lombok.Builder;
    +import lombok.Data;
     import me.chanjar.weixin.common.util.json.WxGsonBuilder;
     
     import java.io.Serializable;
    @@ -9,6 +11,8 @@
      *
      * @author Daniel Qian
      */
    +@Data
    +@Builder
     public class WxError implements Serializable {
     
       private static final long serialVersionUID = 7869786563361406291L;
    @@ -23,34 +27,6 @@ public static WxError fromJson(String json) {
         return WxGsonBuilder.create().fromJson(json, WxError.class);
       }
     
    -  public static Builder newBuilder() {
    -    return new Builder();
    -  }
    -
    -  public int getErrorCode() {
    -    return this.errorCode;
    -  }
    -
    -  public void setErrorCode(int errorCode) {
    -    this.errorCode = errorCode;
    -  }
    -
    -  public String getErrorMsg() {
    -    return this.errorMsg;
    -  }
    -
    -  public void setErrorMsg(String errorMsg) {
    -    this.errorMsg = errorMsg;
    -  }
    -
    -  public String getJson() {
    -    return this.json;
    -  }
    -
    -  public void setJson(String json) {
    -    this.json = json;
    -  }
    -
       @Override
       public String toString() {
         if (this.json != null) {
    @@ -59,29 +35,4 @@ public String toString() {
         return "错误: Code=" + this.errorCode + ", Msg=" + this.errorMsg;
       }
     
    -  public static class Builder {
    -    private int errorCode;
    -    private String errorMsg;
    -
    -    public Builder setErrorCode(int errorCode) {
    -      this.errorCode = errorCode;
    -      return this;
    -    }
    -
    -    public Builder setErrorMsg(String errorMsg) {
    -      this.errorMsg = errorMsg;
    -      return this;
    -    }
    -
    -    /**
    -     * 构造器方法.
    -     */
    -    public WxError build() {
    -      WxError wxError = new WxError();
    -      wxError.setErrorCode(this.errorCode);
    -      wxError.setErrorMsg(this.errorMsg);
    -      return wxError;
    -    }
    -
    -  }
     }
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java
    index 2c83d85c5f..a50018aaef 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java
    @@ -1,10 +1,12 @@
     package me.chanjar.weixin.common.bean.result;
     
    +import lombok.Data;
     import me.chanjar.weixin.common.util.ToStringUtils;
     import me.chanjar.weixin.common.util.json.WxGsonBuilder;
     
     import java.io.Serializable;
     
    +@Data
     public class WxMediaUploadResult implements Serializable {
       private static final long serialVersionUID = 330834334738622341L;
     
    @@ -17,38 +19,6 @@ public static WxMediaUploadResult fromJson(String json) {
         return WxGsonBuilder.create().fromJson(json, WxMediaUploadResult.class);
       }
     
    -  public String getType() {
    -    return this.type;
    -  }
    -
    -  public void setType(String type) {
    -    this.type = type;
    -  }
    -
    -  public String getMediaId() {
    -    return this.mediaId;
    -  }
    -
    -  public void setMediaId(String mediaId) {
    -    this.mediaId = mediaId;
    -  }
    -
    -  public long getCreatedAt() {
    -    return this.createdAt;
    -  }
    -
    -  public void setCreatedAt(long createdAt) {
    -    this.createdAt = createdAt;
    -  }
    -
    -  public String getThumbMediaId() {
    -    return this.thumbMediaId;
    -  }
    -
    -  public void setThumbMediaId(String thumbMediaId) {
    -    this.thumbMediaId = thumbMediaId;
    -  }
    -
       @Override
       public String toString() {
         return ToStringUtils.toSimpleString(this);
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java
    index b9a22600b7..12ce3a4e13 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java
    @@ -64,7 +64,7 @@ public static void checkRequiredFields(Object bean) throws WxErrorException {
         if (!requiredFields.isEmpty()) {
           String msg = "必填字段 " + requiredFields + " 必须提供值";
           log.debug(msg);
    -      throw new WxErrorException(WxError.newBuilder().setErrorMsg(msg).build());
    +      throw new WxErrorException(WxError.builder().errorMsg(msg).build());
         }
       }
     
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java
    index a75aa963e0..37efdaaf38 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java
    @@ -19,6 +19,8 @@
      * @author Binary Wang
      */
     public class HttpResponseProxy {
    +  private static final Pattern PATTERN = Pattern.compile(".*filename=\"(.*)\"");
    +
       private CloseableHttpResponse apacheHttpResponse;
       private HttpResponse joddHttpResponse;
       private Response okHttpResponse;
    @@ -56,7 +58,7 @@ public String getFileName() throws WxErrorException {
       private String getFileName(CloseableHttpResponse response) throws WxErrorException {
         Header[] contentDispositionHeader = response.getHeaders("Content-disposition");
         if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
    -      throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build());
    +      throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
         }
     
         return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
    @@ -74,15 +76,15 @@ private String getFileName(Response response) throws WxErrorException {
     
       private String extractFileNameFromContentString(String content) throws WxErrorException {
         if (content == null || content.length() == 0) {
    -      throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build());
    +      throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
         }
     
    -    Pattern p = Pattern.compile(".*filename=\"(.*)\"");
    -    Matcher m = p.matcher(content);
    +    Matcher m = PATTERN.matcher(content);
         if (m.matches()) {
           return m.group(1);
         }
    -    throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build());
    +
    +    throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
       }
     
     }
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java
    index cc85fa76d7..1a8a292b9f 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheSimplePostRequestExecutor.java
    @@ -39,9 +39,7 @@ public String execute(String uri, String postEntity) throws WxErrorException, IO
         try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) {
           String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
           if (responseContent.isEmpty()) {
    -        throw new WxErrorException(
    -          WxError.newBuilder().setErrorCode(9999).setErrorMsg("无响应内容")
    -            .build());
    +        throw new WxErrorException(WxError.builder().errorCode(9999).errorMsg("无响应内容").build());
           }
     
           if (responseContent.startsWith("")) {
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java
    index 8fa349c67a..57207f1b3e 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpSimplePostRequestExecutor.java
    @@ -5,7 +5,6 @@
     import jodd.http.HttpResponse;
     import jodd.http.ProxyInfo;
     import jodd.util.StringPool;
    -
     import me.chanjar.weixin.common.bean.result.WxError;
     import me.chanjar.weixin.common.exception.WxErrorException;
     import me.chanjar.weixin.common.util.http.RequestHttp;
    @@ -40,9 +39,8 @@ public String execute(String uri, String postEntity) throws WxErrorException, IO
     
         String responseContent = response.bodyText();
         if (responseContent.isEmpty()) {
    -      throw new WxErrorException(
    -        WxError.newBuilder().setErrorCode(9999).setErrorMsg("无响应内容")
    -          .build());
    +      throw new WxErrorException(WxError.builder().errorCode(9999).errorMsg("无响应内容")
    +        .build());
         }
     
         if (responseContent.startsWith("")) {
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java
    index cc426bc8ca..abd0da6052 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/WxErrorAdapter.java
    @@ -14,23 +14,26 @@
     import java.lang.reflect.Type;
     
     /**
    - * @author Daniel Qian
    + * @author Daniel Qian.
      */
     public class WxErrorAdapter implements JsonDeserializer {
     
       @Override
    -  public WxError deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    -    WxError wxError = new WxError();
    +  public WxError deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
    +    throws JsonParseException {
    +    WxError.WxErrorBuilder errorBuilder = WxError.builder();
         JsonObject wxErrorJsonObject = json.getAsJsonObject();
     
         if (wxErrorJsonObject.get("errcode") != null && !wxErrorJsonObject.get("errcode").isJsonNull()) {
    -      wxError.setErrorCode(GsonHelper.getAsPrimitiveInt(wxErrorJsonObject.get("errcode")));
    +      errorBuilder.errorCode(GsonHelper.getAsPrimitiveInt(wxErrorJsonObject.get("errcode")));
         }
         if (wxErrorJsonObject.get("errmsg") != null && !wxErrorJsonObject.get("errmsg").isJsonNull()) {
    -      wxError.setErrorMsg(GsonHelper.getAsString(wxErrorJsonObject.get("errmsg")));
    +      errorBuilder.errorMsg(GsonHelper.getAsString(wxErrorJsonObject.get("errmsg")));
         }
    -    wxError.setJson(json.toString());
    -    return wxError;
    +
    +    errorBuilder.json(json.toString());
    +
    +    return errorBuilder.build();
       }
     
     }
    diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxErrorTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxErrorTest.java
    index 477fcdabc0..1c05ea731e 100644
    --- a/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxErrorTest.java
    +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/bean/WxErrorTest.java
    @@ -8,7 +8,6 @@
     public class WxErrorTest {
     
       public void testFromJson() {
    -
         String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\" }";
         WxError wxError = WxError.fromJson(json);
         Assert.assertTrue(wxError.getErrorCode() == 40003);
    diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java
    index 2c964d309c..6d4e8ce893 100644
    --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java
    +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java
    @@ -24,9 +24,7 @@ public synchronized  T executeInternal(
             RequestExecutor executor, String uri, E data)
             throws WxErrorException {
             this.log.info("Executed");
    -        WxError error = new WxError();
    -        error.setErrorCode(-1);
    -        throw new WxErrorException(error);
    +        throw new WxErrorException(WxError.builder().errorCode(-1).build());
           }
         };
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImpl.java
    index 8ec5945f7b..49ed7589f3 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpCardServiceImpl.java
    @@ -229,10 +229,9 @@ public String getCardDetail(String cardId) throws WxErrorException {
         String errcode = json.get("errcode").getAsString();
         if (!"0".equals(errcode)) {
           String errmsg = json.get("errmsg").getAsString();
    -      WxError error = new WxError();
    -      error.setErrorCode(Integer.valueOf(errcode));
    -      error.setErrorMsg(errmsg);
    -      throw new WxErrorException(error);
    +      throw new WxErrorException(WxError.builder()
    +        .errorCode(Integer.valueOf(errcode)).errorMsg(errmsg)
    +        .build());
         }
     
         return responseContent;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java
    index 8d98a07a32..6bda9e5caf 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java
    @@ -112,11 +112,11 @@ public WxMpKfSessionWaitCaseList kfSessionGetWaitCase() throws WxErrorException
       @Override
       public WxMpKfMsgList kfMsgList(Date startTime, Date endTime, Long msgId, Integer number) throws WxErrorException {
         if (number > 10000) {
    -      throw new WxErrorException(WxError.newBuilder().setErrorMsg("非法参数请求,每次最多查询10000条记录!").build());
    +      throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法参数请求,每次最多查询10000条记录!").build());
         }
     
         if (startTime.after(endTime)) {
    -      throw new WxErrorException(WxError.newBuilder().setErrorMsg("起始时间不能晚于结束时间!").build());
    +      throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("起始时间不能晚于结束时间!").build());
         }
     
         JsonObject param = new JsonObject();
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
    index 3683bb7f53..520f69ea0d 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMaterialServiceImpl.java
    @@ -37,7 +37,7 @@ public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputS
         try {
           return this.mediaUpload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType));
         } catch (IOException e) {
    -      throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e);
    +      throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg(e.getMessage()).build(), e);
         }
       }
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java
    index 5f6c3ad54f..f6af96e5f8 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java
    @@ -28,13 +28,13 @@ public WxMpQrcodeServiceImpl(WxMpService wxMpService) {
       @Override
       public WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds) throws WxErrorException {
         if (sceneId == 0) {
    -      throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("临时二维码场景值不能为0!").build());
    +      throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("临时二维码场景值不能为0!").build());
         }
     
         //expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。
         if (expireSeconds != null && expireSeconds > 2592000) {
    -      throw new WxErrorException(WxError.newBuilder().setErrorCode(-1)
    -        .setErrorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build());
    +      throw new WxErrorException(WxError.builder().errorCode(-1)
    +        .errorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build());
         }
     
         if (expireSeconds == null) {
    @@ -59,13 +59,13 @@ public WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds
       @Override
       public WxMpQrCodeTicket qrCodeCreateTmpTicket(String sceneStr, Integer expireSeconds) throws WxErrorException {
         if (StringUtils.isBlank(sceneStr)) {
    -      throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("临时二维码场景值不能为空!").build());
    +      throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("临时二维码场景值不能为空!").build());
         }
     
         //expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。
         if (expireSeconds != null && expireSeconds > 2592000) {
    -      throw new WxErrorException(WxError.newBuilder().setErrorCode(-1)
    -        .setErrorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build());
    +      throw new WxErrorException(WxError.builder().errorCode(-1)
    +        .errorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build());
         }
     
         if (expireSeconds == null) {
    @@ -90,7 +90,9 @@ public WxMpQrCodeTicket qrCodeCreateTmpTicket(String sceneStr, Integer expireSec
       @Override
       public WxMpQrCodeTicket qrCodeCreateLastTicket(int sceneId) throws WxErrorException {
         if (sceneId < 1 || sceneId > 100000) {
    -      throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("永久二维码的场景值目前只支持1--100000!").build());
    +      throw new WxErrorException(WxError.builder().errorCode(-1)
    +        .errorMsg("永久二维码的场景值目前只支持1--100000!")
    +        .build());
         }
     
         String url = API_URL_PREFIX + "/create";
    @@ -137,9 +139,7 @@ public String qrCodePictureUrl(String ticket, boolean needShortUrl) throws WxErr
     
           return resultUrl;
         } catch (UnsupportedEncodingException e) {
    -      WxError error = WxError.newBuilder().setErrorCode(-1)
    -        .setErrorMsg(e.getMessage()).build();
    -      throw new WxErrorException(error);
    +      throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg(e.getMessage()).build());
         }
       }
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java
    index 8fa3065136..3901c61fbc 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleResult.java
    @@ -3,6 +3,7 @@
     import com.google.gson.annotations.SerializedName;
     import com.google.gson.reflect.TypeToken;
     import lombok.Data;
    +import lombok.EqualsAndHashCode;
     import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
     
     import java.util.List;
    @@ -15,6 +16,7 @@
      * @author Binary Wang
      */
     @Data
    +@EqualsAndHashCode(callSuper = true)
     public class WxDataCubeArticleResult extends WxDataCubeBaseResult {
       private static final long serialVersionUID = -9222452497954511765L;
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java
    index f1c982963b..bef0e66d15 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeArticleTotal.java
    @@ -3,37 +3,38 @@
     import com.google.gson.annotations.SerializedName;
     import com.google.gson.reflect.TypeToken;
     import lombok.Data;
    +import lombok.EqualsAndHashCode;
     import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
     
     import java.util.List;
     
     /**
    - * 图文分析数据接口返回结果对象
    - * 

    + * 图文分析数据接口返回结果对象. * Created by Binary Wang on 2016/8/24. * * @author Binary Wang */ @Data +@EqualsAndHashCode(callSuper = true) public class WxDataCubeArticleTotal extends WxDataCubeBaseResult { private static final long serialVersionUID = -7634365687303052699L; /** - * msgid + * msgid. * 请注意:这里的msgid实际上是由msgid(图文消息id,这也就是群发接口调用后返回的msg_data_id)和index(消息次序索引)组成, 例如12003_3, 其中12003是msgid,即一次群发的消息的id; 3为index,假设该次群发的图文消息共5个文章(因为可能为多图文),3表示5个中的第3个 */ @SerializedName("msgid") private String msgId; /** - * title + * title. * 图文消息的标题 */ @SerializedName("title") private String title; /** - * details + * details. * 详细信息 */ @SerializedName("details") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java index f12b52b1c6..df86ab4e15 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java @@ -9,7 +9,7 @@ /** *

    - *  统计接口的共用属性类
    + *  统计接口的共用属性类.
      *  Created by Binary Wang on 2016/8/25.
      * 
    * @@ -21,7 +21,7 @@ public abstract class WxDataCubeBaseResult implements Serializable { protected static final JsonParser JSON_PARSER = new JsonParser(); /** - * ref_date + * ref_date. * 数据的日期,需在begin_date和end_date之间 */ @SerializedName("ref_date") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java index 2ffd7f9961..b151c0089f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java @@ -3,6 +3,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.util.List; @@ -15,6 +16,7 @@ * @author Binary Wang */ @Data +@EqualsAndHashCode(callSuper = true) public class WxDataCubeInterfaceResult extends WxDataCubeBaseResult { private static final long serialVersionUID = 597734329161281398L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java index 27afd7bf64..1e7e1f58c2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java @@ -3,51 +3,52 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.util.List; /** - * 消息分析数据接口返回结果对象 - *

    + * 消息分析数据接口返回结果对象. * Created by Binary Wang on 2016/8/29. * * @author Binary Wang */ @Data +@EqualsAndHashCode(callSuper = true) public class WxDataCubeMsgResult extends WxDataCubeBaseResult { private static final long serialVersionUID = 6932121822150573659L; /** - * ref_hour + * ref_hour. * 数据的小时,包括从000到2300,分别代表的是[000,100)到[2300,2400),即每日的第1小时和最后1小时 */ @SerializedName("ref_hour") private Integer refHour; /** - * msg_type + * msg_type. * 消息类型,代表含义如下:1代表文字 2代表图片 3代表语音 4代表视频 6代表第三方应用消息(链接消息) */ @SerializedName("msg_type") private Integer msgType; /** - * msg_user + * msg_user. * 上行发送了(向公众号发送了)消息的用户数 */ @SerializedName("msg_user") private Integer msgUser; /** - * msg_count + * msg_count. * 上行发送了消息的消息总数 */ @SerializedName("msg_count") private Integer msgCount; /** - * count_interval + * count_interval. * 当日发送消息量分布的区间,0代表 “0”,1代表“1-5”,2代表“6-10”,3代表“10次以上” */ @SerializedName("count_interval") @@ -61,7 +62,7 @@ public class WxDataCubeMsgResult extends WxDataCubeBaseResult { private Integer intPageReadCount; /** - * ori_page_read_user + * ori_page_read_user. * 原文页(点击图文页“阅读原文”进入的页面)的阅读人数,无原文页时此处数据为0 */ @SerializedName("ori_page_read_user") diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java index 077f5189a1..5c66b0cd60 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java @@ -2,12 +2,14 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; /** - * @author keungtung + * @author keungtung. * @date 10/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class BaseResp extends AbstractDeviceBean { private static final long serialVersionUID = 4252655933699659073L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java index b618cdaf30..601f848223 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java @@ -2,13 +2,15 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; /** * - * @author keungtung + * @author keungtung. * @date 10/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class RespMsg extends AbstractDeviceBean { private static final long serialVersionUID = -4241272701707684136L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java index 644a81326a..f2b35da5ea 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java @@ -2,14 +2,16 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.util.json.WxGsonBuilder; /** * - * @author keungtung + * @author keungtung. * @date 14/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class TransMsgResp extends AbstractDeviceBean { private static final long serialVersionUID = 5386954916622816491L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java index 454628c886..5e00c4faea 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.Arrays; import java.util.LinkedList; @@ -12,6 +13,7 @@ * @date 10/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class WxDeviceAuthorize extends AbstractDeviceBean { private static final long serialVersionUID = 8786321356569903887L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java index 6cf01f4dfe..9608452ce1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java @@ -1,15 +1,17 @@ package me.chanjar.weixin.mp.bean.device; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.util.List; /** - * @author keungtung + * @author keungtung. * @date 10/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class WxDeviceAuthorizeResult extends AbstractDeviceBean { private static final long serialVersionUID = 9105294570912249811L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java index 7a3c639944..aeb7f819ce 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java @@ -2,12 +2,14 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; /** - * @author keungtung + * @author keungtung. * @date 10/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class WxDeviceBind extends AbstractDeviceBean { private static final long serialVersionUID = 467559769037590880L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java index 06786087dc..ec032e8617 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindDeviceResult.java @@ -2,15 +2,17 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.util.List; /** - * @author keungtung + * @author keungtung. * @date 16/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class WxDeviceBindDeviceResult extends AbstractDeviceBean { private static final long serialVersionUID = 725870295905935355L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java index 1b04942b49..f6c702aa29 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java @@ -2,13 +2,15 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** - * @author keungtung + * @author keungtung. * @date 10/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class WxDeviceBindResult extends AbstractDeviceBean { private static final long serialVersionUID = 4687725146279339359L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java index be9239b09d..4128a9f82b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java @@ -2,13 +2,15 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.util.ToStringUtils; /** - * @author keungtung + * @author keungtung. * @date 10/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class WxDeviceMsg extends AbstractDeviceBean { private static final long serialVersionUID = -5567110858455277963L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java index 8e3327e519..95cf2a94ff 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceOpenIdResult.java @@ -2,15 +2,17 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.util.List; /** - * @author keungtung + * @author keungtung. * @date 16/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class WxDeviceOpenIdResult extends AbstractDeviceBean { private static final long serialVersionUID = 4980885167833836220L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java index f8b6309ea0..0e0d96f419 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java @@ -2,13 +2,15 @@ import com.google.gson.annotations.SerializedName; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** - * @author keungtung + * @author keungtung. * @date 10/12/2016 */ @Data +@EqualsAndHashCode(callSuper = false) public class WxDeviceQrCodeResult extends AbstractDeviceBean { private static final long serialVersionUID = -4312858303060918266L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java index 9947de1806..dbb0ab90f9 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutImageMessage.java @@ -3,11 +3,13 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter; @XStreamAlias("xml") @Data +@EqualsAndHashCode(callSuper = true) public class WxMpXmlOutImageMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = -2684778597067990723L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java index 7ec26a6ea3..f7405600ef 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutNewsMessage.java @@ -3,6 +3,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @@ -12,6 +13,7 @@ @XStreamAlias("xml") @Data +@EqualsAndHashCode(callSuper = true) public class WxMpXmlOutNewsMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = -4604402850905714772L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java index 208367b4cb..cbaa05abc3 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTextMessage.java @@ -3,11 +3,13 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @XStreamAlias("xml") @Data +@EqualsAndHashCode(callSuper = true) public class WxMpXmlOutTextMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = -3972786455288763361L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java index aae4512bf1..5b0857830e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutTransferKefuMessage.java @@ -3,6 +3,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @@ -10,6 +11,7 @@ @XStreamAlias("xml") @Data +@EqualsAndHashCode(callSuper = true) public class WxMpXmlOutTransferKefuMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = 1850903037285841322L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java index 51ff53758a..bd91b861ee 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlOutVoiceMessage.java @@ -3,11 +3,13 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.Data; +import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter; @XStreamAlias("xml") @Data +@EqualsAndHashCode(callSuper = true) public class WxMpXmlOutVoiceMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = 240367390249860551L; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java index 09cb70d0f5..8a4f7462f7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/MaterialVoiceAndImageDownloadRequestExecutor.java @@ -9,7 +9,8 @@ import java.io.File; import java.io.InputStream; -public abstract class MaterialVoiceAndImageDownloadRequestExecutor implements RequestExecutor { +public abstract class MaterialVoiceAndImageDownloadRequestExecutor + implements RequestExecutor { protected RequestHttp requestHttp; protected File tmpDirFile; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java index 406eec01f9..af2e025796 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/QrCodeRequestExecutor.java @@ -32,7 +32,7 @@ public static RequestExecutor create(RequestHttp request case OK_HTTP: return new OkhttpQrCodeRequestExecutor(requestHttp); default: - throw new WxErrorException(WxError.newBuilder().setErrorMsg("不支持的http框架").build()); + throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("不支持的http框架").build()); } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialUploadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialUploadRequestExecutor.java index 445ff2736e..9ddd61f9a9 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialUploadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialUploadRequestExecutor.java @@ -41,7 +41,7 @@ public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material) throw } if (material == null) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg("非法请求,material参数为空").build()); + throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法请求,material参数为空").build()); } File file = material.getFile(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMediaImgUploadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMediaImgUploadRequestExecutor.java index 63e278e43c..d001876d6d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMediaImgUploadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMediaImgUploadRequestExecutor.java @@ -30,7 +30,7 @@ public ApacheMediaImgUploadRequestExecutor(RequestHttp requestHttp) { @Override public WxMediaImgUploadResult execute(String uri, File data) throws WxErrorException, IOException { if (data == null) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg("文件对象为空").build()); + throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build()); } HttpPost httpPost = new HttpPost(uri); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialUploadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialUploadRequestExecutor.java index ce30323695..a7a5509c08 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialUploadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialUploadRequestExecutor.java @@ -36,7 +36,7 @@ public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material) throw request.withConnectionProvider(requestHttp.getRequestHttpClient()); if (material == null) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg("非法请求,material参数为空").build()); + throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法请求,material参数为空").build()); } File file = material.getFile(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMediaImgUploadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMediaImgUploadRequestExecutor.java index d0fdbfb856..b66a793365 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMediaImgUploadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMediaImgUploadRequestExecutor.java @@ -26,7 +26,7 @@ public JoddMediaImgUploadRequestExecutor(RequestHttp requestHttp) { @Override public WxMediaImgUploadResult execute(String uri, File data) throws WxErrorException, IOException { if (data == null) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg("文件对象为空").build()); + throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build()); } HttpRequest request = HttpRequest.post(uri); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java index ef4bcbb299..766d239565 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialUploadRequestExecutor.java @@ -31,7 +31,7 @@ public OkhttpMaterialUploadRequestExecutor(RequestHttp requestHttp) { public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material) throws WxErrorException, IOException { logger.debug("OkhttpMaterialUploadRequestExecutor is running"); if (material == null) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg("非法请求,material参数为空").build()); + throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法请求,material参数为空").build()); } File file = material.getFile(); if (file == null || !file.exists()) { diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java index fc0f70b776..e8630dbc5a 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java @@ -23,9 +23,7 @@ public synchronized T executeInternal( RequestExecutor executor, String uri, E data) throws WxErrorException { this.log.info("Executed"); - WxError error = new WxError(); - error.setErrorCode(-1); - throw new WxErrorException(error); + throw new WxErrorException(WxError.builder().errorCode(-1).build()); } }; From e00e7bb0cab3853ae7f5e6a13fca82768879a033 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 14 Nov 2017 11:07:31 +0800 Subject: [PATCH 151/165] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=BC=80?= =?UTF-8?q?=E6=94=BE=E5=B9=B3=E5=8F=B0=E6=A8=A1=E5=9D=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/api/WxOpenComponentService.java | 1 + .../weixin/open/api/WxOpenConfigStorage.java | 28 +++++--- .../weixin/open/api/WxOpenService.java | 3 + .../api/impl/WxOpenComponentServiceImpl.java | 7 +- .../api/impl/WxOpenInMemoryConfigStorage.java | 68 ++++++++++--------- .../api/impl/WxOpenInRedisConfigStorage.java | 64 ++++++++++------- .../open/api/impl/WxOpenMpServiceImpl.java | 7 +- .../api/impl/WxOpenServiceAbstractImpl.java | 9 ++- .../WxOpenServiceApacheHttpClientImpl.java | 3 +- .../bean/WxOpenAuthorizerAccessToken.java | 3 +- .../open/bean/WxOpenComponentAccessToken.java | 3 +- .../bean/auth/WxOpenAuthorizationInfo.java | 4 +- .../open/bean/auth/WxOpenAuthorizerInfo.java | 4 +- .../open/bean/message/WxOpenXmlMessage.java | 7 +- .../result/WxOpenAuthorizerInfoResult.java | 4 +- .../result/WxOpenAuthorizerOptionResult.java | 4 +- .../bean/result/WxOpenQueryAuthResult.java | 4 +- .../weixin/open/util/WxOpenCryptUtil.java | 1 + .../WxOpenAuthorizationInfoGsonAdapter.java | 10 +-- .../json/WxOpenAuthorizerInfoGsonAdapter.java | 4 +- 20 files changed, 152 insertions(+), 86 deletions(-) diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java index ded17248ed..c3c402c5af 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java @@ -34,6 +34,7 @@ public interface WxOpenComponentService { * 刷新oauth2的access token */ String OAUTH2_REFRESH_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s&component_appid==%s"; + WxMpService getWxMpServiceByAppid(String appid); WxOpenConfigStorage getWxOpenConfigStorage(); diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenConfigStorage.java index 8f6173b798..7e548253e8 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenConfigStorage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenConfigStorage.java @@ -9,29 +9,39 @@ */ public interface WxOpenConfigStorage { + String getComponentAppId(); + void setComponentAppId(String componentAppId); + String getComponentAppSecret(); + void setComponentAppSecret(String componentAppSecret); + String getComponentToken(); + void setComponentToken(String componentToken); + String getComponentAesKey(); + void setComponentAesKey(String componentAesKey); - String getComponentAppId(); - String getComponentAppSecret(); - String getComponentToken(); - String getComponentAesKey(); String getComponentVerifyTicket(); + void setComponentVerifyTicket(String componentVerifyTicket); + String getComponentAccessToken(); + boolean isComponentAccessTokenExpired(); + void updateComponentAccessTokent(WxOpenComponentAccessToken componentAccessToken); + WxMpConfigStorage getWxMpConfigStorage(String appId); + /** * 应该是线程安全的 * - * @param componentAccessToken 新的accessToken值 - * @param expiresInSeconds 过期时间,以秒为单位 + * @param componentAccessToken 新的accessToken值 + * @param expiresInSeconds 过期时间,以秒为单位 */ void updateComponentAccessTokent(String componentAccessToken, int expiresInSeconds); @@ -42,7 +52,9 @@ public interface WxOpenConfigStorage { String getAuthorizerRefreshToken(String appId); + void setAuthorizerRefreshToken(String appId, String authorizerRefreshToken); + String getAuthorizerAccessToken(String appId); @@ -63,8 +75,8 @@ public interface WxOpenConfigStorage { /** * 应该是线程安全的 * - * @param authorizerAccessToken 新的accessToken值 - * @param expiresInSeconds 过期时间,以秒为单位 + * @param authorizerAccessToken 新的accessToken值 + * @param expiresInSeconds 过期时间,以秒为单位 */ void updateAuthorizerAccessToken(String appId, String authorizerAccessToken, int expiresInSeconds); diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenService.java index c0214d46ef..e11296e6c8 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenService.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenService.java @@ -7,8 +7,11 @@ */ public interface WxOpenService { WxOpenComponentService getWxOpenComponentService(); + WxOpenConfigStorage getWxOpenConfigStorage(); + void setWxOpenConfigStorage(WxOpenConfigStorage wxOpenConfigStorage); + /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求 */ diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java index 9f797e2f0f..45de69b1e6 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java @@ -30,9 +30,9 @@ * @author 007 */ public class WxOpenComponentServiceImpl implements WxOpenComponentService { + private static final Map wxOpenMpServiceMap = new Hashtable<>(); protected final Logger log = LoggerFactory.getLogger(this.getClass()); private WxOpenService wxOpenService; - private static final Map wxOpenMpServiceMap = new Hashtable<>(); public WxOpenComponentServiceImpl(WxOpenService wxOpenService) { this.wxOpenService = wxOpenService; @@ -62,6 +62,7 @@ public WxOpenService getWxOpenService() { public WxOpenConfigStorage getWxOpenConfigStorage() { return wxOpenService.getWxOpenConfigStorage(); } + @Override public boolean checkSignature(String timestamp, String nonce, String signature) { try { @@ -72,6 +73,7 @@ public boolean checkSignature(String timestamp, String nonce, String signature) return false; } } + @Override public String getComponentAccessToken(boolean forceRefresh) throws WxErrorException { @@ -137,6 +139,7 @@ public String route(final WxOpenXmlMessage wxMessage) throws WxErrorException { } return null; } + @Override public WxOpenQueryAuthResult getQueryAuth(String authorizationCode) throws WxErrorException { JsonObject jsonObject = new JsonObject(); @@ -145,6 +148,7 @@ public WxOpenQueryAuthResult getQueryAuth(String authorizationCode) throws WxErr String responseContent = post(API_QUERY_AUTH_URL, jsonObject.toString()); return WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenQueryAuthResult.class); } + @Override public WxOpenAuthorizerInfoResult getAuthorizerInfo(String authorizerAppid) throws WxErrorException { JsonObject jsonObject = new JsonObject(); @@ -163,6 +167,7 @@ public WxOpenAuthorizerOptionResult getAuthorizerOption(String authorizerAppid, String responseContent = post(API_GET_AUTHORIZER_OPTION_URL, jsonObject.toString()); return WxOpenGsonBuilder.create().fromJson(responseContent, WxOpenAuthorizerOptionResult.class); } + @Override public WxError setAuthorizerOption(String authorizerAppid, String optionName, String optionValue) throws WxErrorException { JsonObject jsonObject = new JsonObject(); diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java index dc10ee18a5..687a57d774 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java @@ -35,25 +35,13 @@ public class WxOpenInMemoryConfigStorage implements WxOpenConfigStorage { private Map cardApiTickets = new Hashtable<>(); @Override - public void setComponentAppId(String componentAppId) { - this.componentAppId = componentAppId; - } - @Override - public void setComponentAppSecret(String componentAppSecret) { - this.componentAppSecret = componentAppSecret; - } - @Override - public void setComponentToken(String componentToken) { - this.componentToken = componentToken; - } - @Override - public void setComponentAesKey(String componentAesKey) { - this.componentAesKey = componentAesKey; + public String getComponentAppId() { + return componentAppId; } @Override - public String getComponentAppId() { - return componentAppId; + public void setComponentAppId(String componentAppId) { + this.componentAppId = componentAppId; } @Override @@ -61,16 +49,31 @@ public String getComponentAppSecret() { return componentAppSecret; } + @Override + public void setComponentAppSecret(String componentAppSecret) { + this.componentAppSecret = componentAppSecret; + } + @Override public String getComponentToken() { return componentToken; } + @Override + public void setComponentToken(String componentToken) { + this.componentToken = componentToken; + } + @Override public String getComponentAesKey() { return componentAesKey; } + @Override + public void setComponentAesKey(String componentAesKey) { + this.componentAesKey = componentAesKey; + } + @Override public String getComponentVerifyTicket() { return componentVerifyTicket; @@ -111,30 +114,34 @@ public void updateComponentAccessTokent(String componentAccessToken, int expires public boolean autoRefreshToken() { return true; } - private String getTokenString(Map map, String key){ + + private String getTokenString(Map map, String key) { Token token = map.get(key); - if(token == null || (token.expiresTime != null && System.currentTimeMillis() > token.expiresTime)){ + if (token == null || (token.expiresTime != null && System.currentTimeMillis() > token.expiresTime)) { return null; } return token.token; } - private void expireToken(Map map, String key){ + + private void expireToken(Map map, String key) { Token token = map.get(key); - if(token != null){ + if (token != null) { token.expiresTime = 0L; } } - private void updateToken(Map map, String key, String tokenString, Integer expiresInSeconds){ + + private void updateToken(Map map, String key, String tokenString, Integer expiresInSeconds) { Token token = map.get(key); - if(token == null){ + if (token == null) { token = new Token(); map.put(key, token); } token.token = tokenString; - if(expiresInSeconds != null) { + if (expiresInSeconds != null) { token.expiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; } } + @Override public String getAuthorizerRefreshToken(String appId) { return getTokenString(authorizerRefreshTokens, appId); @@ -211,22 +218,21 @@ public void updateCardApiTicket(String appId, String cardApiTicket, int expiresI updateToken(cardApiTickets, appId, cardApiTicket, expiresInSeconds); } - private static class Token{ + private static class Token { private String token; private Long expiresTime; } - private static class WxOpenMpConfigStorage implements WxMpConfigStorage{ + + private static class WxOpenMpConfigStorage implements WxMpConfigStorage { private WxOpenConfigStorage wxOpenConfigStorage; private String appId; - private WxOpenMpConfigStorage(WxOpenConfigStorage wxOpenConfigStorage, String appId){ - this.wxOpenConfigStorage = wxOpenConfigStorage; - this.appId = appId; - } - private Lock accessTokenLock = new ReentrantLock(); private Lock jsapiTicketLock = new ReentrantLock(); private Lock cardApiTicketLock = new ReentrantLock(); - + private WxOpenMpConfigStorage(WxOpenConfigStorage wxOpenConfigStorage, String appId) { + this.wxOpenConfigStorage = wxOpenConfigStorage; + this.appId = appId; + } @Override public String getAccessToken() { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java index faaa95d84c..c3bd6a2b6f 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInRedisConfigStorage.java @@ -24,6 +24,7 @@ public class WxOpenInRedisConfigStorage extends WxOpenInMemoryConfigStorage { private String authorizerAccessTokenKey; private String jsapiTicketKey; private String cardApiTicket; + public WxOpenInRedisConfigStorage(JedisPool jedisPool) { this.jedisPool = jedisPool; } @@ -38,54 +39,62 @@ public void setComponentAppId(String componentAppId) { jsapiTicketKey = JSAPI_TICKET_KEY.concat(componentAppId); cardApiTicket = CARD_API_TICKET_KEY.concat(componentAppId); } + @Override - public String getComponentVerifyTicket(){ - try(Jedis jedis = jedisPool.getResource()){ + public String getComponentVerifyTicket() { + try (Jedis jedis = jedisPool.getResource()) { return jedis.get(componentVerifyTicketKey); } } + @Override - public void setComponentVerifyTicket(String componentVerifyTicket){ - try(Jedis jedis = jedisPool.getResource()){ + public void setComponentVerifyTicket(String componentVerifyTicket) { + try (Jedis jedis = jedisPool.getResource()) { jedis.set(componentVerifyTicketKey, componentVerifyTicket); } } + @Override - public String getComponentAccessToken(){ - try(Jedis jedis = jedisPool.getResource()){ + public String getComponentAccessToken() { + try (Jedis jedis = jedisPool.getResource()) { return jedis.get(componentAccessTokenKey); } } + @Override - public boolean isComponentAccessTokenExpired(){ - try(Jedis jedis = jedisPool.getResource()){ + public boolean isComponentAccessTokenExpired() { + try (Jedis jedis = jedisPool.getResource()) { return jedis.ttl(componentAccessTokenKey) < 2; } } + @Override - public void updateComponentAccessTokent(String componentAccessToken, int expiresInSeconds){ + public void updateComponentAccessTokent(String componentAccessToken, int expiresInSeconds) { try (Jedis jedis = this.jedisPool.getResource()) { jedis.setex(componentAccessTokenKey, expiresInSeconds - 200, componentAccessToken); } } - private String getKey(String prefix, String appId){ + + private String getKey(String prefix, String appId) { return prefix.endsWith(":") ? prefix.concat(appId) : prefix.concat(":").concat(appId); } @Override - public String getAuthorizerRefreshToken(String appId){ + public String getAuthorizerRefreshToken(String appId) { try (Jedis jedis = this.jedisPool.getResource()) { return jedis.get(getKey(authorizerRefreshTokenKey, appId)); } } + @Override - public void setAuthorizerRefreshToken(String appId, String authorizerRefreshToken){ + public void setAuthorizerRefreshToken(String appId, String authorizerRefreshToken) { try (Jedis jedis = this.jedisPool.getResource()) { jedis.set(getKey(authorizerRefreshTokenKey, appId), authorizerRefreshToken); } } + @Override - public String getAuthorizerAccessToken(String appId){ + public String getAuthorizerAccessToken(String appId) { try (Jedis jedis = this.jedisPool.getResource()) { return jedis.get(getKey(authorizerAccessTokenKey, appId)); } @@ -93,70 +102,77 @@ public String getAuthorizerAccessToken(String appId){ @Override - public boolean isAuthorizerAccessTokenExpired(String appId){ + public boolean isAuthorizerAccessTokenExpired(String appId) { try (Jedis jedis = this.jedisPool.getResource()) { return jedis.ttl(getKey(authorizerAccessTokenKey, appId)) < 2; } } + @Override - public void expireAuthorizerAccessToken(String appId){ + public void expireAuthorizerAccessToken(String appId) { try (Jedis jedis = this.jedisPool.getResource()) { jedis.expire(getKey(authorizerAccessTokenKey, appId), 0); } } + @Override - public void updateAuthorizerAccessToken(String appId, String authorizerAccessToken, int expiresInSeconds){ + public void updateAuthorizerAccessToken(String appId, String authorizerAccessToken, int expiresInSeconds) { try (Jedis jedis = this.jedisPool.getResource()) { jedis.setex(getKey(authorizerAccessTokenKey, appId), expiresInSeconds - 200, authorizerAccessToken); } } @Override - public String getJsapiTicket(String appId){ + public String getJsapiTicket(String appId) { try (Jedis jedis = this.jedisPool.getResource()) { return jedis.get(getKey(jsapiTicketKey, appId)); } } @Override - public boolean isJsapiTicketExpired(String appId){ + public boolean isJsapiTicketExpired(String appId) { try (Jedis jedis = this.jedisPool.getResource()) { return jedis.ttl(getKey(jsapiTicketKey, appId)) < 2; } } + @Override - public void expireJsapiTicket(String appId){ + public void expireJsapiTicket(String appId) { try (Jedis jedis = this.jedisPool.getResource()) { jedis.expire(getKey(jsapiTicketKey, appId), 0); } } + @Override - public void updateJsapiTicket(String appId, String jsapiTicket, int expiresInSeconds){ + public void updateJsapiTicket(String appId, String jsapiTicket, int expiresInSeconds) { try (Jedis jedis = this.jedisPool.getResource()) { jedis.setex(getKey(jsapiTicketKey, appId), expiresInSeconds - 200, jsapiTicket); } } @Override - public String getCardApiTicket(String appId){ + public String getCardApiTicket(String appId) { try (Jedis jedis = this.jedisPool.getResource()) { return jedis.get(getKey(jsapiTicketKey, appId)); } } + @Override - public boolean isCardApiTicketExpired(String appId){ + public boolean isCardApiTicketExpired(String appId) { try (Jedis jedis = this.jedisPool.getResource()) { return jedis.ttl(getKey(cardApiTicket, appId)) < 2; } } + @Override - public void expireCardApiTicket(String appId){ + public void expireCardApiTicket(String appId) { try (Jedis jedis = this.jedisPool.getResource()) { jedis.expire(getKey(cardApiTicket, appId), 0); } } + @Override - public void updateCardApiTicket(String appId, String cardApiTicket, int expiresInSeconds){ + public void updateCardApiTicket(String appId, String cardApiTicket, int expiresInSeconds) { try (Jedis jedis = this.jedisPool.getResource()) { jedis.setex(getKey(cardApiTicket, appId), expiresInSeconds - 200, cardApiTicket); } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java index b4baf58581..1f4a465f3a 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java @@ -13,15 +13,18 @@ public class WxOpenMpServiceImpl extends WxMpServiceImpl { private WxOpenComponentService wxOpenComponentService; private WxMpConfigStorage wxMpConfigStorage; private String appId; - public WxOpenMpServiceImpl(WxOpenComponentService wxOpenComponentService, String appId, WxMpConfigStorage wxMpConfigStorage){ + + public WxOpenMpServiceImpl(WxOpenComponentService wxOpenComponentService, String appId, WxMpConfigStorage wxMpConfigStorage) { this.wxOpenComponentService = wxOpenComponentService; this.appId = appId; this.wxMpConfigStorage = wxMpConfigStorage; } + @Override - public WxMpConfigStorage getWxMpConfigStorage(){ + public WxMpConfigStorage getWxMpConfigStorage() { return wxMpConfigStorage; } + @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { return wxOpenComponentService.getAuthorizerAccessToken(appId, forceRefresh); diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java index 5f937dc5cf..3276c429b4 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java @@ -17,17 +17,20 @@ */ public abstract class WxOpenServiceAbstractImpl implements WxOpenService, RequestHttp { protected final Logger log = LoggerFactory.getLogger(this.getClass()); - private WxOpenConfigStorage wxOpenConfigStorage; protected WxOpenComponentService wxOpenComponentService = new WxOpenComponentServiceImpl(this); + private WxOpenConfigStorage wxOpenConfigStorage; + @Override public WxOpenComponentService getWxOpenComponentService() { return wxOpenComponentService; } + @Override - public WxOpenConfigStorage getWxOpenConfigStorage(){ + public WxOpenConfigStorage getWxOpenConfigStorage() { return wxOpenConfigStorage; } - public void setWxOpenConfigStorage(WxOpenConfigStorage wxOpenConfigStorage){ + + public void setWxOpenConfigStorage(WxOpenConfigStorage wxOpenConfigStorage) { this.wxOpenConfigStorage = wxOpenConfigStorage; } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceApacheHttpClientImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceApacheHttpClientImpl.java index e5b62b3456..58921e6957 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceApacheHttpClientImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceApacheHttpClientImpl.java @@ -10,9 +10,10 @@ /** * apache-http方式实现 + * * @author 007 */ -public class WxOpenServiceApacheHttpClientImpl extends WxOpenServiceAbstractImpl { +public class WxOpenServiceApacheHttpClientImpl extends WxOpenServiceAbstractImpl { private CloseableHttpClient httpClient = DefaultApacheHttpClientBuilder.get().build(); private HttpHost httpProxy = null; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenAuthorizerAccessToken.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenAuthorizerAccessToken.java index 429aad1779..9b86412bb3 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenAuthorizerAccessToken.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenAuthorizerAccessToken.java @@ -7,7 +7,8 @@ /** * @author 007 */ -public class WxOpenAuthorizerAccessToken implements Serializable{ +public class WxOpenAuthorizerAccessToken implements Serializable { + private static final long serialVersionUID = -4069745419280727420L; private String authorizerAccessToken; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenComponentAccessToken.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenComponentAccessToken.java index 31f79b752f..8a97c24dfb 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenComponentAccessToken.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/WxOpenComponentAccessToken.java @@ -7,7 +7,8 @@ /** * @author 007 */ -public class WxOpenComponentAccessToken implements Serializable{ +public class WxOpenComponentAccessToken implements Serializable { + private static final long serialVersionUID = 2134550135400443725L; private String componentAccessToken; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizationInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizationInfo.java index 687e31ed6a..23e8f1497e 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizationInfo.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizationInfo.java @@ -9,7 +9,9 @@ * @author 007 */ @Data -public class WxOpenAuthorizationInfo implements Serializable{ +public class WxOpenAuthorizationInfo implements Serializable { + private static final long serialVersionUID = -8713680081354754208L; + private String authorizerAppid; private String authorizerAccessToken; private int expiresIn; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java index b9f63a3e37..864724035d 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/auth/WxOpenAuthorizerInfo.java @@ -9,7 +9,9 @@ * @author 007 */ @Data -public class WxOpenAuthorizerInfo implements Serializable{ +public class WxOpenAuthorizerInfo implements Serializable { + private static final long serialVersionUID = -5327886953416394738L; + private String nickName; private String headImg; private Integer serviceTypeInfo; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java index afcbd5f118..6b2e04fde7 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java @@ -19,7 +19,9 @@ */ @XStreamAlias("xml") @Data -public class WxOpenXmlMessage implements Serializable{ +public class WxOpenXmlMessage implements Serializable { + private static final long serialVersionUID = -5641769554709507771L; + @XStreamAlias("AppId") @XStreamConverter(value = XStreamCDataConverter.class) private String appId; @@ -78,6 +80,7 @@ public static WxOpenXmlMessage fromEncryptedXml(String encryptedXml, encryptedXml); return fromXml(plainText); } + public static WxMpXmlMessage fromEncryptedMpXml(String encryptedXml, WxOpenConfigStorage wxOpenConfigStorage, String timestamp, String nonce, String msgSignature) { @@ -89,7 +92,7 @@ public static WxMpXmlMessage fromEncryptedMpXml(String encryptedXml, public static WxOpenXmlMessage fromEncryptedXml(InputStream is, WxOpenConfigStorage wxOpenConfigStorage, String timestamp, String nonce, - String msgSignature) { + String msgSignature) { try { return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), wxOpenConfigStorage, timestamp, nonce, msgSignature); diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResult.java index 040c9f023d..7bccff5c3c 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerInfoResult.java @@ -10,7 +10,9 @@ * @author 007 */ @Data -public class WxOpenAuthorizerInfoResult implements Serializable{ +public class WxOpenAuthorizerInfoResult implements Serializable { + private static final long serialVersionUID = 3166298050833019785L; + private WxOpenAuthorizationInfo authorizationInfo; private WxOpenAuthorizerInfo authorizerInfo; } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerOptionResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerOptionResult.java index d7bf7aa1de..c0ccf008ad 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerOptionResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenAuthorizerOptionResult.java @@ -8,7 +8,9 @@ * @author 007 */ @Data -public class WxOpenAuthorizerOptionResult implements Serializable{ +public class WxOpenAuthorizerOptionResult implements Serializable { + private static final long serialVersionUID = 4477837353654658179L; + String authorizerAppid; String optionName; String optionValue; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenQueryAuthResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenQueryAuthResult.java index 02dab98885..5da7b6e6cf 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenQueryAuthResult.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenQueryAuthResult.java @@ -9,6 +9,8 @@ * @author 007 */ @Data -public class WxOpenQueryAuthResult implements Serializable{ +public class WxOpenQueryAuthResult implements Serializable { + private static final long serialVersionUID = 2394736235020206855L; + private WxOpenAuthorizationInfo authorizationInfo; } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java index 0adcdbb3ac..a27b6fe636 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/WxOpenCryptUtil.java @@ -2,6 +2,7 @@ import me.chanjar.weixin.open.api.WxOpenConfigStorage; import org.apache.commons.codec.binary.Base64; + /** * @author 007 */ diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizationInfoGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizationInfoGsonAdapter.java index 7aa0c00c5a..69df0647c8 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizationInfoGsonAdapter.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizationInfoGsonAdapter.java @@ -22,18 +22,18 @@ public WxOpenAuthorizationInfo deserialize(JsonElement jsonElement, Type type, J authorizationInfo.setAuthorizerRefreshToken(GsonHelper.getString(jsonObject, "authorizer_refresh_token")); List funcInfo = new ArrayList<>(); JsonArray jsonArray = GsonHelper.getAsJsonArray(jsonObject.get("func_info")); - if(jsonArray != null && !jsonArray.isJsonNull()){ - for(int i = 0; i < jsonArray.size(); i++){ + if (jsonArray != null && !jsonArray.isJsonNull()) { + for (int i = 0; i < jsonArray.size(); i++) { jsonObject = jsonArray.get(i).getAsJsonObject(); - if(jsonObject == null || jsonObject.isJsonNull()){ + if (jsonObject == null || jsonObject.isJsonNull()) { continue; } jsonObject = jsonObject.getAsJsonObject("funcscope_category"); - if(jsonObject == null || jsonObject.isJsonNull()){ + if (jsonObject == null || jsonObject.isJsonNull()) { continue; } Integer id = GsonHelper.getInteger(jsonObject, "id"); - if(id == null) { + if (id == null) { continue; } funcInfo.add(id); diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java index 5e1fb6d3e0..cc03a82e1c 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/util/json/WxOpenAuthorizerInfoGsonAdapter.java @@ -23,10 +23,10 @@ public WxOpenAuthorizerInfo deserialize(JsonElement jsonElement, Type type, Json authorizationInfo.setPrincipalName(GsonHelper.getString(jsonObject, "principal_name")); authorizationInfo.setAlias(GsonHelper.getString(jsonObject, "alias")); authorizationInfo.setQrcodeUrl(GsonHelper.getString(jsonObject, "qrcode_url")); - if(jsonObject.has("service_type_info")) { + if (jsonObject.has("service_type_info")) { authorizationInfo.setServiceTypeInfo(GsonHelper.getInteger(jsonObject.getAsJsonObject("service_type_info"), "id")); } - if(jsonObject.has("verify_type_info")) { + if (jsonObject.has("verify_type_info")) { authorizationInfo.setVerifyTypeInfo(GsonHelper.getInteger(jsonObject.getAsJsonObject("verify_type_info"), "id")); } Map businessInfo = WxOpenGsonBuilder.create().fromJson(jsonObject.get("business_info"), From 22261499257eef36c4f7b607df533afa188f3b0e Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 14 Nov 2017 11:23:18 +0800 Subject: [PATCH 152/165] =?UTF-8?q?=E4=BD=BF=E7=94=A8lombok=E7=9A=84@Data?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E7=AE=80=E5=8C=96cp=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E6=89=80=E6=9C=89bean=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/cp/bean/WxCpDepart.java | 45 +-- .../chanjar/weixin/cp/bean/WxCpMessage.java | 144 +------ .../weixin/cp/bean/WxCpMessageSendResult.java | 53 +-- .../me/chanjar/weixin/cp/bean/WxCpTag.java | 34 +- .../bean/WxCpTagAddOrRemoveUsersResult.java | 46 +-- .../me/chanjar/weixin/cp/bean/WxCpUser.java | 150 +------ .../weixin/cp/bean/WxCpXmlMessage.java | 372 ++---------------- .../cp/bean/WxCpXmlOutImageMessage.java | 10 +- .../weixin/cp/bean/WxCpXmlOutMessage.java | 47 +-- .../weixin/cp/bean/WxCpXmlOutNewsMessage.java | 53 +-- .../weixin/cp/bean/WxCpXmlOutTextMessage.java | 11 +- .../cp/bean/WxCpXmlOutVideoMessage.java | 28 +- .../cp/bean/WxCpXmlOutVoiceMessage.java | 10 +- .../weixin/cp/bean/article/MpnewsArticle.java | 126 +----- .../weixin/cp/bean/article/NewArticle.java | 35 +- .../weixin/cp/bean/WxCpXmlMessageTest.java | 2 +- 16 files changed, 104 insertions(+), 1062 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java index 25042eb0b8..2890ce61eb 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpDepart.java @@ -1,14 +1,16 @@ package me.chanjar.weixin.cp.bean; +import lombok.Data; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.io.Serializable; /** - * 微信部门 + * 微信部门. * * @author Daniel Qian */ +@Data public class WxCpDepart implements Serializable { private static final long serialVersionUID = -5028321625140879571L; @@ -21,49 +23,8 @@ public static WxCpDepart fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpDepart.class); } - public Integer getId() { - return this.id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getParentId() { - return this.parentId; - } - - public void setParentId(Integer parentId) { - this.parentId = parentId; - } - - public Long getOrder() { - return this.order; - } - - public void setOrder(Long order) { - this.order = order; - } - public String toJson() { return WxCpGsonBuilder.create().toJson(this); } - @Override - public String toString() { - return "WxCpDepart{" + - "id=" + this.id + - ", name='" + this.name + '\'' + - ", parentId=" + this.parentId + - ", order=" + this.order + - '}'; - } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java index 53e82edf63..403e9dc365 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessage.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.cp.bean; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.cp.bean.article.MpnewsArticle; import me.chanjar.weixin.cp.bean.article.NewArticle; @@ -11,13 +12,14 @@ import java.util.List; /** - * 消息 + * 消息. * * @author Daniel Qian */ +@Data public class WxCpMessage implements Serializable { - private static final long serialVersionUID = -2082278303476631708L; + private String toUser; private String toParty; private String toTag; @@ -36,104 +38,61 @@ public class WxCpMessage implements Serializable { private List mpnewsArticles = new ArrayList<>(); /** - * 获得文本消息builder + * 获得文本消息builder. */ public static TextBuilder TEXT() { return new TextBuilder(); } /** - * 获得文本卡片消息builder + * 获得文本卡片消息builder. */ public static TextCardBuilder TEXTCARD() { return new TextCardBuilder(); } /** - * 获得图片消息builder + * 获得图片消息builder. */ public static ImageBuilder IMAGE() { return new ImageBuilder(); } /** - * 获得语音消息builder + * 获得语音消息builder. */ public static VoiceBuilder VOICE() { return new VoiceBuilder(); } /** - * 获得视频消息builder + * 获得视频消息builder. */ public static VideoBuilder VIDEO() { return new VideoBuilder(); } /** - * 获得图文消息builder + * 获得图文消息builder. */ public static NewsBuilder NEWS() { return new NewsBuilder(); } /** - * 获得mpnews图文消息builder + * 获得mpnews图文消息builder. */ public static MpnewsBuilder MPNEWS() { return new MpnewsBuilder(); } /** - * 获得文件消息builder + * 获得文件消息builder. */ public static FileBuilder FILE() { return new FileBuilder(); } - public List getMpnewsArticles() { - return mpnewsArticles; - } - - public void setMpnewsArticles(List mpnewsArticles) { - this.mpnewsArticles = mpnewsArticles; - } - - public String getToUser() { - return this.toUser; - } - - public void setToUser(String toUser) { - this.toUser = toUser; - } - - public String getToParty() { - return this.toParty; - } - - public void setToParty(String toParty) { - this.toParty = toParty; - } - - public String getToTag() { - return this.toTag; - } - - public void setToTag(String toTag) { - this.toTag = toTag; - } - - public Integer getAgentId() { - return this.agentId; - } - - public void setAgentId(Integer agentId) { - this.agentId = agentId; - } - - public String getMsgType() { - return this.msgType; - } /** *

    @@ -153,87 +112,8 @@ public void setMsgType(String msgType) {
         this.msgType = msgType;
       }
     
    -  public String getSafe() {
    -    return this.safe;
    -  }
    -
    -  public void setSafe(String safe) {
    -    this.safe = safe;
    -  }
    -
    -  public String getContent() {
    -    return this.content;
    -  }
    -
    -  public void setContent(String content) {
    -    this.content = content;
    -  }
    -
    -  public String getMediaId() {
    -    return this.mediaId;
    -  }
    -
    -  public void setMediaId(String mediaId) {
    -    this.mediaId = mediaId;
    -  }
    -
    -  public String getThumbMediaId() {
    -    return this.thumbMediaId;
    -  }
    -
    -  public void setThumbMediaId(String thumbMediaId) {
    -    this.thumbMediaId = thumbMediaId;
    -  }
    -
    -  public String getTitle() {
    -    return this.title;
    -  }
    -
    -  public void setTitle(String title) {
    -    this.title = title;
    -  }
    -
    -  public String getDescription() {
    -    return this.description;
    -  }
    -
    -  public void setDescription(String description) {
    -    this.description = description;
    -  }
    -
    -  public String getMusicUrl() {
    -    return this.musicUrl;
    -  }
    -
    -  public void setMusicUrl(String musicUrl) {
    -    this.musicUrl = musicUrl;
    -  }
    -
    -  public String getHqMusicUrl() {
    -    return this.hqMusicUrl;
    -  }
    -
    -  public void setHqMusicUrl(String hqMusicUrl) {
    -    this.hqMusicUrl = hqMusicUrl;
    -  }
    -
    -  public List getArticles() {
    -    return this.articles;
    -  }
    -
    -  public void setArticles(List articles) {
    -    this.articles = articles;
    -  }
    -
       public String toJson() {
         return WxCpGsonBuilder.INSTANCE.create().toJson(this);
       }
     
    -  public String getUrl() {
    -    return this.url;
    -  }
    -
    -  public void setUrl(String url) {
    -    this.url = url;
    -  }
     }
    diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessageSendResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessageSendResult.java
    index 6989c4988f..e54a01eccd 100644
    --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessageSendResult.java
    +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpMessageSendResult.java
    @@ -2,21 +2,25 @@
     
     import com.google.common.base.Splitter;
     import com.google.gson.annotations.SerializedName;
    +import lombok.Data;
     import me.chanjar.weixin.common.util.ToStringUtils;
     import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
     import org.apache.commons.lang3.StringUtils;
     
    +import java.io.Serializable;
     import java.util.Collections;
     import java.util.List;
     
     /**
    - * 
    - * 消息发送结果对象类
    + * 消息发送结果对象类.
      * Created by Binary Wang on 2017-6-22.
    + *
      * @author Binary Wang
    - * 
    */ -public class WxCpMessageSendResult { +@Data +public class WxCpMessageSendResult implements Serializable { + private static final long serialVersionUID = 916455987193190004L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -41,52 +45,13 @@ public static WxCpMessageSendResult fromJson(String json) { @SerializedName("invalidtag") private String invalidTag; - public Integer getErrCode() { - return this.errCode; - } - - public void setErrCode(Integer errCode) { - this.errCode = errCode; - } - - public String getErrMsg() { - return this.errMsg; - } - - public void setErrMsg(String errMsg) { - this.errMsg = errMsg; - } - - public String getInvalidUser() { - return this.invalidUser; - } - - public void setInvalidUser(String invalidUser) { - this.invalidUser = invalidUser; - } - - public String getInvalidParty() { - return this.invalidParty; - } - - public void setInvalidParty(String invalidParty) { - this.invalidParty = invalidParty; - } - - public String getInvalidTag() { - return this.invalidTag; - } - - public void setInvalidTag(String invalidTag) { - this.invalidTag = invalidTag; - } public List getInvalidUserList() { return this.content2List(this.invalidUser); } private List content2List(String content) { - if(StringUtils.isBlank(content)){ + if (StringUtils.isBlank(content)) { return Collections.emptyList(); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTag.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTag.java index 79ec3f1321..360ddd28be 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTag.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTag.java @@ -1,50 +1,30 @@ package me.chanjar.weixin.cp.bean; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.io.Serializable; /** - * Created by Daniel Qian + * Created by Daniel Qian. */ +@Data +@AllArgsConstructor +@NoArgsConstructor public class WxCpTag implements Serializable { - private static final long serialVersionUID = -7243320279646928402L; private String id; private String name; - public WxCpTag() { - super(); - } - - public WxCpTag(String id, String name) { - super(); - this.id = id; - this.name = name; - } public static WxCpTag fromJson(String json) { return WxCpGsonBuilder.create().fromJson(json, WxCpTag.class); } - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } - public String toJson() { return WxCpGsonBuilder.create().toJson(this); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagAddOrRemoveUsersResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagAddOrRemoveUsersResult.java index c216ae46a6..3d89c073fc 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagAddOrRemoveUsersResult.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTagAddOrRemoveUsersResult.java @@ -2,21 +2,25 @@ import com.google.common.base.Splitter; import com.google.gson.annotations.SerializedName; +import lombok.Data; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import org.apache.commons.lang3.StringUtils; +import java.io.Serializable; import java.util.Collections; import java.util.List; /** - *
    - * 为标签添加或移除用户结果对象类
    + * 为标签添加或移除用户结果对象类.
      * Created by Binary Wang on 2017-6-22.
    + *
      * @author Binary Wang
    - * 
    */ -public class WxCpTagAddOrRemoveUsersResult { +@Data +public class WxCpTagAddOrRemoveUsersResult implements Serializable { + private static final long serialVersionUID = 1420065684270213578L; + @Override public String toString() { return ToStringUtils.toSimpleString(this); @@ -38,44 +42,12 @@ public static WxCpTagAddOrRemoveUsersResult fromJson(String json) { @SerializedName("invalidparty") private String[] invalidParty; - public Integer getErrCode() { - return this.errCode; - } - - public void setErrCode(Integer errCode) { - this.errCode = errCode; - } - - public String getErrMsg() { - return this.errMsg; - } - - public void setErrMsg(String errMsg) { - this.errMsg = errMsg; - } - - public String getInvalidUser() { - return this.invalidUsers; - } - - public void setInvalidUser(String invalidUser) { - this.invalidUsers = invalidUser; - } - - public String[] getInvalidParty() { - return this.invalidParty; - } - - public void setInvalidParty(String[] invalidParty) { - this.invalidParty = invalidParty; - } - public List getInvalidUserList() { return this.content2List(this.invalidUsers); } private List content2List(String content) { - if(StringUtils.isBlank(content)){ + if (StringUtils.isBlank(content)) { return Collections.emptyList(); } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUser.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUser.java index 647a4e6ba2..0a3aaeb7a7 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUser.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpUser.java @@ -1,5 +1,7 @@ package me.chanjar.weixin.cp.bean; +import lombok.AllArgsConstructor; +import lombok.Data; import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; import java.io.Serializable; @@ -7,12 +9,12 @@ import java.util.List; /** - * 微信用户信息 + * 微信用户信息. * * @author Daniel Qian */ +@Data public class WxCpUser implements Serializable { - public enum Gender { MALE("男", "1"), FEMAIL("女", "2"); @@ -62,159 +64,23 @@ public static Gender fromCode(String code) { private String englishName; private String telephone; - public static WxCpUser fromJson(String json) { - return WxCpGsonBuilder.INSTANCE.create().fromJson(json, WxCpUser.class); - } - - public String getUserId() { - return this.userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer[] getDepartIds() { - return this.departIds; - } - - public void setDepartIds(Integer[] departIds) { - this.departIds = departIds; - } - - public Gender getGender() { - return this.gender; - } - - public void setGender(Gender gender) { - this.gender = gender; - } - - public String getPosition() { - return this.position; - } - - public void setPosition(String position) { - this.position = position; - } - - public String getMobile() { - return this.mobile; - } - - public void setMobile(String mobile) { - this.mobile = mobile; - } - - public String getTelephone() { - return this.telephone; - } - - public void setTelephone(String telephone) { - this.telephone = telephone; - } - - public String getEmail() { - return this.email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getAvatar() { - return this.avatar; - } - - public void setAvatar(String avatar) { - this.avatar = avatar; - } - - public Integer getStatus() { - return this.status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public Integer getEnable() { - return this.enable; - } - - public void setEnable(Integer enable) { - this.enable = enable; - } - public void addExtAttr(String name, String value) { this.extAttrs.add(new Attr(name, value)); } - public List getExtAttrs() { - return this.extAttrs; - } - - public Integer getIsLeader() { - return isLeader; - } - - public void setIsLeader(Integer isLeader) { - this.isLeader = isLeader; - } - - public Integer getHideMobile() { - return hideMobile; - } - - public void setHideMobile(Integer hideMobile) { - this.hideMobile = hideMobile; - } - - public String getEnglishName() { - return englishName; - } - - public void setEnglishName(String englishName) { - this.englishName = englishName; + public static WxCpUser fromJson(String json) { + return WxCpGsonBuilder.INSTANCE.create().fromJson(json, WxCpUser.class); } public String toJson() { return WxCpGsonBuilder.INSTANCE.create().toJson(this); } + @Data + @AllArgsConstructor public static class Attr { private String name; private String value; - - public Attr(String name, String value) { - this.name = name; - this.value = value; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } - } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java index 0beb53eef9..785884a174 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlMessage.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.ToStringUtils; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @@ -28,6 +29,7 @@ * @author Daniel Qian */ @XStreamAlias("xml") +@Data public class WxCpXmlMessage implements Serializable { private static final long serialVersionUID = -1042994982179476410L; @@ -130,28 +132,29 @@ public class WxCpXmlMessage implements Serializable { // 群发消息返回的结果 /////////////////////////////////////// /** - * 群发的结果 + * 群发的结果. */ @XStreamAlias("Status") @XStreamConverter(value = XStreamCDataConverter.class) private String status; /** - * group_id下粉丝数;或者openid_list中的粉丝数 + * group_id下粉丝数;或者openid_list中的粉丝数. */ @XStreamAlias("TotalCount") private Integer totalCount; /** - * 过滤(过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数,原则上,filterCount = sentCount + errorCount + * 过滤. + * (过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数,原则上,filterCount = sentCount + errorCount */ @XStreamAlias("FilterCount") private Integer filterCount; /** - * 发送成功的粉丝数 + * 发送成功的粉丝数. */ @XStreamAlias("SentCount") private Integer sentCount; /** - * 发送失败的粉丝数 + * 发送失败的粉丝数. */ @XStreamAlias("ErrorCount") private Integer errorCount; @@ -176,7 +179,7 @@ protected static WxCpXmlMessage fromXml(InputStream is) { } /** - * 从加密字符串转换 + * 从加密字符串转换. */ public static WxCpXmlMessage fromEncryptedXml( String encryptedXml, @@ -198,30 +201,6 @@ public static WxCpXmlMessage fromEncryptedXml( } } - public Integer getAgentId() { - return this.agentId; - } - - public void setAgentId(Integer agentId) { - this.agentId = agentId; - } - - public String getToUserName() { - return this.toUserName; - } - - public void setToUserName(String toUserName) { - this.toUserName = toUserName; - } - - public Long getCreateTime() { - return this.createTime; - } - - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } - /** *
        * 当接受用户消息时,可能会获得以下值:
    @@ -247,322 +226,54 @@ public String getMsgType() {
        * {@link WxConsts.XmlMsgType#VIDEO}
        * {@link WxConsts.XmlMsgType#NEWS}
        * 
    - * - * @param msgType */ public void setMsgType(String msgType) { this.msgType = msgType; } - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - public Long getMsgId() { - return this.msgId; - } - - public void setMsgId(Long msgId) { - this.msgId = msgId; - } - - public String getPicUrl() { - return this.picUrl; - } - - public void setPicUrl(String picUrl) { - this.picUrl = picUrl; - } - - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getFormat() { - return this.format; - } - - public void setFormat(String format) { - this.format = format; - } - - public String getThumbMediaId() { - return this.thumbMediaId; - } - - public void setThumbMediaId(String thumbMediaId) { - this.thumbMediaId = thumbMediaId; - } - - public Double getLocationX() { - return this.locationX; - } - - public void setLocationX(Double locationX) { - this.locationX = locationX; - } - - public Double getLocationY() { - return this.locationY; - } - - public void setLocationY(Double locationY) { - this.locationY = locationY; - } - - public Double getScale() { - return this.scale; - } - - public void setScale(Double scale) { - this.scale = scale; - } - - public String getLabel() { - return this.label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getEvent() { - return this.event; - } - - public void setEvent(String event) { - this.event = event; - } - - public String getEventKey() { - return this.eventKey; - } - - public void setEventKey(String eventKey) { - this.eventKey = eventKey; - } - - public String getTicket() { - return this.ticket; - } - - public void setTicket(String ticket) { - this.ticket = ticket; - } - - public Double getLatitude() { - return this.latitude; - } - - public void setLatitude(Double latitude) { - this.latitude = latitude; - } - - public Double getLongitude() { - return this.longitude; - } - - public void setLongitude(Double longitude) { - this.longitude = longitude; - } - - public Double getPrecision() { - return this.precision; - } - - public void setPrecision(Double precision) { - this.precision = precision; - } - - public String getRecognition() { - return this.recognition; - } - - public void setRecognition(String recognition) { - this.recognition = recognition; - } - - public String getFromUserName() { - return this.fromUserName; - } - - public void setFromUserName(String fromUserName) { - this.fromUserName = fromUserName; - } - - public String getStatus() { - return this.status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Integer getTotalCount() { - return this.totalCount; - } - - public void setTotalCount(Integer totalCount) { - this.totalCount = totalCount; - } - - public Integer getFilterCount() { - return this.filterCount; - } - - public void setFilterCount(Integer filterCount) { - this.filterCount = filterCount; - } - - public Integer getSentCount() { - return this.sentCount; - } - - public void setSentCount(Integer sentCount) { - this.sentCount = sentCount; - } - - public Integer getErrorCount() { - return this.errorCount; - } - - public void setErrorCount(Integer errorCount) { - this.errorCount = errorCount; - } - - public WxCpXmlMessage.ScanCodeInfo getScanCodeInfo() { - return this.scanCodeInfo; - } - - public void setScanCodeInfo(WxCpXmlMessage.ScanCodeInfo scanCodeInfo) { - this.scanCodeInfo = scanCodeInfo; - } - - public WxCpXmlMessage.SendPicsInfo getSendPicsInfo() { - return this.sendPicsInfo; - } - - public void setSendPicsInfo(WxCpXmlMessage.SendPicsInfo sendPicsInfo) { - this.sendPicsInfo = sendPicsInfo; - } - - public WxCpXmlMessage.SendLocationInfo getSendLocationInfo() { - return this.sendLocationInfo; - } - - public void setSendLocationInfo(WxCpXmlMessage.SendLocationInfo sendLocationInfo) { - this.sendLocationInfo = sendLocationInfo; - } - @Override public String toString() { return ToStringUtils.toSimpleString(this); } + @Data @XStreamAlias("ScanCodeInfo") public static class ScanCodeInfo { + /** + * 扫描类型,一般是qrcode. + */ @XStreamAlias("ScanType") @XStreamConverter(value = XStreamCDataConverter.class) private String scanType; + /** + * 扫描结果,即二维码对应的字符串信息. + */ @XStreamAlias("ScanResult") @XStreamConverter(value = XStreamCDataConverter.class) private String scanResult; - - /** - * 扫描类型,一般是qrcode - */ - public String getScanType() { - - return this.scanType; - } - - public void setScanType(String scanType) { - this.scanType = scanType; - } - - /** - * 扫描结果,即二维码对应的字符串信息 - */ - public String getScanResult() { - return this.scanResult; - } - - public void setScanResult(String scanResult) { - this.scanResult = scanResult; - } - } + @Data @XStreamAlias("SendPicsInfo") public static class SendPicsInfo { @XStreamAlias("PicList") protected final List picList = new ArrayList<>(); + @XStreamAlias("Count") private Long count; - public Long getCount() { - return this.count; - } - - public void setCount(Long count) { - this.count = count; - } - - public List getPicList() { - return this.picList; - } - @XStreamAlias("item") + @Data public static class Item { - @XStreamAlias("PicMd5Sum") @XStreamConverter(value = XStreamCDataConverter.class) - private String PicMd5Sum; - - public String getPicMd5Sum() { - return this.PicMd5Sum; - } - - public void setPicMd5Sum(String picMd5Sum) { - this.PicMd5Sum = picMd5Sum; - } + private String picMd5Sum; } } + @Data @XStreamAlias("SendLocationInfo") public static class SendLocationInfo { @@ -584,47 +295,8 @@ public static class SendLocationInfo { @XStreamAlias("Poiname") @XStreamConverter(value = XStreamCDataConverter.class) - private String poiname; - - public String getLocationX() { - return this.locationX; - } - - public void setLocationX(String locationX) { - this.locationX = locationX; - } + private String poiName; - public String getLocationY() { - return this.locationY; - } - - public void setLocationY(String locationY) { - this.locationY = locationY; - } - - public String getScale() { - return this.scale; - } - - public void setScale(String scale) { - this.scale = scale; - } - - public String getLabel() { - return this.label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getPoiname() { - return this.poiname; - } - - public void setPoiname(String poiname) { - this.poiname = poiname; - } } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutImageMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutImageMessage.java index 1d3b3e4ebc..dc77875e7e 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutImageMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutImageMessage.java @@ -2,10 +2,12 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter; @XStreamAlias("xml") +@Data public class WxCpXmlOutImageMessage extends WxCpXmlOutMessage { private static final long serialVersionUID = -1099446240667237313L; @@ -17,12 +19,4 @@ public WxCpXmlOutImageMessage() { this.msgType = WxConsts.XmlMsgType.IMAGE; } - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutMessage.java index d69703502f..34c5499f06 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutMessage.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.bean.outxmlbuilder.*; @@ -11,8 +12,8 @@ import java.io.Serializable; @XStreamAlias("xml") +@Data public abstract class WxCpXmlOutMessage implements Serializable { - private static final long serialVersionUID = 1418629839964153110L; @XStreamAlias("ToUserName") @@ -31,78 +32,46 @@ public abstract class WxCpXmlOutMessage implements Serializable { protected String msgType; /** - * 获得文本消息builder + * 获得文本消息builder. */ public static TextBuilder TEXT() { return new TextBuilder(); } /** - * 获得图片消息builder + * 获得图片消息builder. */ public static ImageBuilder IMAGE() { return new ImageBuilder(); } /** - * 获得语音消息builder + * 获得语音消息builder. */ public static VoiceBuilder VOICE() { return new VoiceBuilder(); } /** - * 获得视频消息builder + * 获得视频消息builder. */ public static VideoBuilder VIDEO() { return new VideoBuilder(); } /** - * 获得图文消息builder + * 获得图文消息builder. */ public static NewsBuilder NEWS() { return new NewsBuilder(); } - public String getToUserName() { - return this.toUserName; - } - - public void setToUserName(String toUserName) { - this.toUserName = toUserName; - } - - public String getFromUserName() { - return this.fromUserName; - } - - public void setFromUserName(String fromUserName) { - this.fromUserName = fromUserName; - } - - public Long getCreateTime() { - return this.createTime; - } - - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } - - public String getMsgType() { - return this.msgType; - } - - public void setMsgType(String msgType) { - this.msgType = msgType; - } - protected String toXml() { return XStreamTransformer.toXml((Class) this.getClass(), this); } /** - * 转换成加密的xml格式 + * 转换成加密的xml格式. */ public String toEncryptedXml(WxCpConfigStorage wxCpConfigStorage) { String plainXml = toXml(); diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessage.java index 9e23aefe7e..992397981f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessage.java @@ -2,6 +2,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @@ -9,11 +10,13 @@ import java.util.List; @XStreamAlias("xml") +@Data public class WxCpXmlOutNewsMessage extends WxCpXmlOutMessage { private static final long serialVersionUID = -5796178637883178826L; @XStreamAlias("Articles") protected final List articles = new ArrayList<>(); + @XStreamAlias("ArticleCount") protected int articleCount; @@ -21,72 +24,32 @@ public WxCpXmlOutNewsMessage() { this.msgType = WxConsts.XmlMsgType.NEWS; } - public int getArticleCount() { - return this.articleCount; - } public void addArticle(Item item) { this.articles.add(item); this.articleCount = this.articles.size(); } - public List getArticles() { - return this.articles; - } - - @XStreamAlias("item") + @Data public static class Item { @XStreamAlias("Title") @XStreamConverter(value = XStreamCDataConverter.class) - private String Title; + private String title; @XStreamAlias("Description") @XStreamConverter(value = XStreamCDataConverter.class) - private String Description; + private String description; @XStreamAlias("PicUrl") @XStreamConverter(value = XStreamCDataConverter.class) - private String PicUrl; + private String picUrl; @XStreamAlias("Url") @XStreamConverter(value = XStreamCDataConverter.class) - private String Url; - - public String getTitle() { - return this.Title; - } - - public void setTitle(String title) { - this.Title = title; - } - - public String getDescription() { - return this.Description; - } - - public void setDescription(String description) { - this.Description = description; - } - - public String getPicUrl() { - return this.PicUrl; - } - - public void setPicUrl(String picUrl) { - this.PicUrl = picUrl; - } - - public String getUrl() { - return this.Url; - } - - public void setUrl(String url) { - this.Url = url; - } + private String url; } - } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutTextMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutTextMessage.java index ca1382b004..1c354a12d4 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutTextMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutTextMessage.java @@ -2,10 +2,12 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @XStreamAlias("xml") +@Data public class WxCpXmlOutTextMessage extends WxCpXmlOutMessage { private static final long serialVersionUID = 2569239617185930232L; @@ -17,13 +19,4 @@ public WxCpXmlOutTextMessage() { this.msgType = WxConsts.XmlMsgType.TEXT; } - public String getContent() { - return this.content; - } - - public void setContent(String content) { - this.content = content; - } - - } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVideoMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVideoMessage.java index 44a447e2ca..6d3bd0b4d1 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVideoMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVideoMessage.java @@ -2,10 +2,12 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @XStreamAlias("xml") +@Data public class WxCpXmlOutVideoMessage extends WxCpXmlOutMessage { private static final long serialVersionUID = -8672761162722733622L; @@ -40,7 +42,7 @@ public void setDescription(String description) { this.video.setDescription(description); } - + @Data @XStreamAlias("Video") public static class Video { @@ -56,30 +58,6 @@ public static class Video { @XStreamConverter(value = XStreamCDataConverter.class) private String description; - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVoiceMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVoiceMessage.java index 4b91fcf4bc..c880bccfff 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVoiceMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpXmlOutVoiceMessage.java @@ -2,10 +2,12 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; +import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamMediaIdConverter; @XStreamAlias("xml") +@Data public class WxCpXmlOutVoiceMessage extends WxCpXmlOutMessage { private static final long serialVersionUID = -7947384031546099340L; @@ -17,12 +19,4 @@ public WxCpXmlOutVoiceMessage() { this.msgType = WxConsts.XmlMsgType.VOICE; } - public String getMediaId() { - return this.mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } - } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/MpnewsArticle.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/MpnewsArticle.java index b3f4acf402..af622fefd8 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/MpnewsArticle.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/MpnewsArticle.java @@ -1,5 +1,8 @@ package me.chanjar.weixin.cp.bean.article; +import lombok.Builder; +import lombok.Data; + import java.io.Serializable; /** @@ -9,6 +12,8 @@ * * @author Binary Wang */ +@Data +@Builder(builderMethodName = "newBuilder") public class MpnewsArticle implements Serializable { private static final long serialVersionUID = 6985871812170756481L; @@ -20,125 +25,4 @@ public class MpnewsArticle implements Serializable { private String digest; private String showCoverPic; - private MpnewsArticle(Builder builder) { - setTitle(builder.title); - setThumbMediaId(builder.thumbMediaId); - setAuthor(builder.author); - setContentSourceUrl(builder.contentSourceUrl); - setContent(builder.content); - setDigest(builder.digest); - setShowCoverPic(builder.showCoverPic); - } - - public static Builder newBuilder() { - return new Builder(); - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getThumbMediaId() { - return thumbMediaId; - } - - public void setThumbMediaId(String thumbMediaId) { - this.thumbMediaId = thumbMediaId; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public String getContentSourceUrl() { - return contentSourceUrl; - } - - public void setContentSourceUrl(String contentSourceUrl) { - this.contentSourceUrl = contentSourceUrl; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getDigest() { - return digest; - } - - public void setDigest(String digest) { - this.digest = digest; - } - - public String getShowCoverPic() { - return showCoverPic; - } - - public void setShowCoverPic(String showCoverPic) { - this.showCoverPic = showCoverPic; - } - - public static final class Builder { - private String title; - private String thumbMediaId; - private String author; - private String contentSourceUrl; - private String content; - private String digest; - private String showCoverPic; - - private Builder() { - } - - public Builder title(String title) { - this.title = title; - return this; - } - - public Builder thumbMediaId(String thumbMediaId) { - this.thumbMediaId = thumbMediaId; - return this; - } - - public Builder author(String author) { - this.author = author; - return this; - } - - public Builder contentSourceUrl(String contentSourceUrl) { - this.contentSourceUrl = contentSourceUrl; - return this; - } - - public Builder content(String content) { - this.content = content; - return this; - } - - public Builder digest(String digest) { - this.digest = digest; - return this; - } - - public Builder showCoverPic(String showCoverPic) { - this.showCoverPic = showCoverPic; - return this; - } - - public MpnewsArticle build() { - return new MpnewsArticle(this); - } - } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java index 02b0b1086f..7f10d363b4 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/article/NewArticle.java @@ -1,5 +1,7 @@ package me.chanjar.weixin.cp.bean.article; +import lombok.Data; + import java.io.Serializable; /** @@ -9,6 +11,7 @@ * * @author Binary Wang */ +@Data public class NewArticle implements Serializable { private static final long serialVersionUID = 4087852055781140659L; @@ -17,36 +20,4 @@ public class NewArticle implements Serializable { private String url; private String picUrl; - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getPicUrl() { - return this.picUrl; - } - - public void setPicUrl(String picUrl) { - this.picUrl = picUrl; - } - } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java index f9be8c1534..e320d8cb2e 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlMessageTest.java @@ -86,7 +86,7 @@ public void testFromXml() { assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); assertEquals(wxMessage.getSendLocationInfo().getScale(), "15"); assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号"); - assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi"); + assertEquals(wxMessage.getSendLocationInfo().getPoiName(), "wo de poi"); } public void testSendPicsInfo() { From 13e1c4b628a36c1df1739a37ad60b6a99f77aae4 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 14 Nov 2017 11:29:07 +0800 Subject: [PATCH 153/165] fix error code --- .../binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java index b00a20a143..b198fc7a07 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaMediaServiceImpl.java @@ -31,7 +31,7 @@ public WxMediaUploadResult uploadMedia(String mediaType, String fileType, InputS try { return this.uploadMedia(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType)); } catch (IOException e) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e); + throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e); } } @@ -48,7 +48,7 @@ public File getMedia(String mediaId) throws WxErrorException { .create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("wxma").toFile()); return this.wxMaService.execute(executor, MEDIA_GET_URL, "media_id=" + mediaId); } catch (IOException e) { - throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e); + throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e); } } From 9eda612db3aa3f0ceb4f03c63fe60f5035f14757 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 14 Nov 2017 11:33:16 +0800 Subject: [PATCH 154/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.8.8.BETA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-miniapp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- weixin-java-open/pom.xml | 2 +- weixin-java-pay/pom.xml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index bb540a48e2..2beb44880d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.8.7.BETA + 2.8.8.BETA pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index b970c23dfd..25dc5bd1fa 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.7.BETA + 2.8.8.BETA weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index e0074830f2..96dba9c9d6 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.7.BETA + 2.8.8.BETA weixin-java-cp diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml index 47459836d1..b7e2f1cb9c 100644 --- a/weixin-java-miniapp/pom.xml +++ b/weixin-java-miniapp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.7.BETA + 2.8.8.BETA weixin-java-miniapp WeiXin Java Tools - MiniApp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 3888075e8e..81bf0008c5 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -7,7 +7,7 @@ com.github.binarywang weixin-java-parent - 2.8.7.BETA + 2.8.8.BETA weixin-java-mp WeiXin Java Tools - MP diff --git a/weixin-java-open/pom.xml b/weixin-java-open/pom.xml index f61e56988d..b52c578175 100644 --- a/weixin-java-open/pom.xml +++ b/weixin-java-open/pom.xml @@ -8,7 +8,7 @@ com.github.binarywang weixin-java-parent - 2.8.7.BETA + 2.8.8.BETA weixin-java-open WeiXin Java Tools - Open diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml index 3fa728fc91..47b3f4da16 100644 --- a/weixin-java-pay/pom.xml +++ b/weixin-java-pay/pom.xml @@ -5,7 +5,7 @@ weixin-java-parent com.github.binarywang - 2.8.7.BETA + 2.8.8.BETA 4.0.0 From d32cf99b6d315cc65d72f1337ab30c23b8149fff Mon Sep 17 00:00:00 2001 From: 007gzs <007gzs@gmail.com> Date: Tue, 14 Nov 2017 17:02:13 +0800 Subject: [PATCH 155/165] =?UTF-8?q?#376=20=E5=A2=9E=E5=8A=A0=E6=91=87?= =?UTF-8?q?=E4=B8=80=E6=91=87=E5=91=A8=E8=BE=B9=E7=9A=84=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 774 +++++++++--------- .../weixin/common/util/crypto/ByteGroup.java | 52 +- .../common/util/crypto/PKCS7Encoder.java | 136 +-- .../weixin/mp/api/WxMpShakeService.java | 34 + .../mp/api/impl/WxMpShakeServiceImpl.java | 29 +- .../mp/bean/shake/WxMpDeviceIdentifier.java | 23 + .../WxMpShakeAroundDeviceBindPageQuery.java | 23 + .../shake/WxMpShakeAroundPageAddQuery.java | 23 + .../shake/WxMpShakeAroundPageAddResult.java | 26 + .../WxMpShakeAroundRelationSearchQuery.java | 32 + .../WxMpShakeAroundRelationSearchResult.java | 22 + 11 files changed, 692 insertions(+), 482 deletions(-) create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpDeviceIdentifier.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundDeviceBindPageQuery.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundPageAddQuery.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundPageAddResult.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundRelationSearchQuery.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundRelationSearchResult.java diff --git a/pom.xml b/pom.xml index 2beb44880d..54f52b021e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,387 +1,387 @@ - - - 4.0.0 - com.github.binarywang - weixin-java-parent - 2.8.8.BETA - pom - WeiXin Java Tools - Parent - 微信公众号、企业号上级POM - https://github.com/wechat-group/weixin-java-tools - - - - The Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - - Daniel Qian - chanjarster@gmail.com - https://github.com/chanjarster - - - Binary Wang - binarywang@gmail.com - https://github.com/binarywang - - - gaigeshen - gaigeshen@qq.com - https://github.com/gaigeshen - - - Liu Mingbo - liumingbo2008@gmail.com - https://github.com/FirenzesEagle - - - kakotor - kakotor@gmail.com - https://github.com/kakotor - - - xiong - zhaoxiong.tan@gmail.com - https://github.com/ZhaoxiongTan - - - LiuJunGuang - aimilin@yeah.net - https://github.com/aimilin6688 - - - Eric.Tsai - xiaodong.cai.ks@gmail.com - https://github.com/iwareserictsai - - - withinthefog - withinthefog@gmail.com - https://github.com/withinthefog - - - Keung - dongfuqiang1988@163.com - https://github.com/johnnytung - - - Jonk - aimilin@yeah.net - https://github.com/aimilin6688 - - - ecoolper - crskyp@gmail.com - https://github.com/crskyp - - - 007 - 007gzs@gmail.com - https://github.com/007gzs - - - - - scm:git:https://github.com/wechat-group/weixin-java-tools.git - scm:git:git@github.com:wechat-group/weixin-java-tools.git - https://github.com/wechat-group/weixin-java-tools - - - - weixin-java-common - weixin-java-cp - weixin-java-mp - weixin-java-pay - weixin-java-miniapp - weixin-java-open - - - - - 1.7 - 1.7 - - UTF-8 - true - true - 4.5 - 9.3.0.RC0 - - - - - - com.github.binarywang - qrcode-utils - 1.1 - - - - org.jodd - jodd-http - 3.7.1 - provided - - - com.squareup.okhttp3 - okhttp - 3.7.0 - provided - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - org.apache.httpcomponents - httpmime - ${httpclient.version} - - - commons-codec - commons-codec - 1.10 - - - commons-io - commons-io - 2.5 - - - org.apache.commons - commons-lang3 - 3.5 - - - org.slf4j - slf4j-api - 1.7.24 - - - com.thoughtworks.xstream - xstream - 1.4.9 - - - - com.google.guava - guava - 20.0 - - - com.google.code.gson - gson - 2.8.0 - - - - - joda-time - joda-time - 2.9.7 - test - - - ch.qos.logback - logback-classic - 1.1.11 - test - - - com.google.inject - guice - 3.0 - test - - - org.testng - testng - 6.10 - test - - - org.mockito - mockito-all - 1.9.5 - test - - - org.eclipse.jetty - jetty-server - ${jetty.version} - test - - - org.eclipse.jetty - jetty-servlet - ${jetty.version} - test - - - redis.clients - jedis - 2.9.0 - provided - - - org.projectlombok - lombok - 1.16.18 - compile - - - - - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - - doclint-java8-disable - - [1.8,) - - - -Xdoclint:none - - - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - - attach-javadocs - - jar - - - - - ${javadoc.opts} - UTF-8 - zh_CN - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - - - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.17 - - true - - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.3 - true - - ossrh - https://oss.sonatype.org/ - true - - - - org.apache.maven.plugins - maven-release-plugin - 2.5.1 - - true - false - release - deploy - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.6.0 - - UTF-8 - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.17 - - quality-checks/google_checks.xml - true - true - true - - - - verify - - check - - - - - - - - + + + 4.0.0 + com.github.binarywang + weixin-java-parent + 2.8.8.BETA + pom + WeiXin Java Tools - Parent + 微信公众号、企业号上级POM + https://github.com/wechat-group/weixin-java-tools + + + + The Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + + Daniel Qian + chanjarster@gmail.com + https://github.com/chanjarster + + + Binary Wang + binarywang@gmail.com + https://github.com/binarywang + + + gaigeshen + gaigeshen@qq.com + https://github.com/gaigeshen + + + Liu Mingbo + liumingbo2008@gmail.com + https://github.com/FirenzesEagle + + + kakotor + kakotor@gmail.com + https://github.com/kakotor + + + xiong + zhaoxiong.tan@gmail.com + https://github.com/ZhaoxiongTan + + + LiuJunGuang + aimilin@yeah.net + https://github.com/aimilin6688 + + + Eric.Tsai + xiaodong.cai.ks@gmail.com + https://github.com/iwareserictsai + + + withinthefog + withinthefog@gmail.com + https://github.com/withinthefog + + + Keung + dongfuqiang1988@163.com + https://github.com/johnnytung + + + Jonk + aimilin@yeah.net + https://github.com/aimilin6688 + + + ecoolper + crskyp@gmail.com + https://github.com/crskyp + + + 007 + 007gzs@gmail.com + https://github.com/007gzs + + + + + scm:git:https://github.com/wechat-group/weixin-java-tools.git + scm:git:git@github.com:wechat-group/weixin-java-tools.git + https://github.com/wechat-group/weixin-java-tools + + + + weixin-java-common + weixin-java-cp + weixin-java-mp + weixin-java-pay + weixin-java-miniapp + weixin-java-open + + + + + 1.7 + 1.7 + + UTF-8 + true + true + 4.5 + 9.3.0.RC0 + + + + + + com.github.binarywang + qrcode-utils + 1.1 + + + + org.jodd + jodd-http + 3.7.1 + provided + + + com.squareup.okhttp3 + okhttp + 3.7.0 + provided + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + org.apache.httpcomponents + httpmime + ${httpclient.version} + + + commons-codec + commons-codec + 1.10 + + + commons-io + commons-io + 2.5 + + + org.apache.commons + commons-lang3 + 3.5 + + + org.slf4j + slf4j-api + 1.7.24 + + + com.thoughtworks.xstream + xstream + 1.4.9 + + + + com.google.guava + guava + 20.0 + + + com.google.code.gson + gson + 2.8.0 + + + + + joda-time + joda-time + 2.9.7 + test + + + ch.qos.logback + logback-classic + 1.1.11 + test + + + com.google.inject + guice + 3.0 + test + + + org.testng + testng + 6.10 + test + + + org.mockito + mockito-all + 1.9.5 + test + + + org.eclipse.jetty + jetty-server + ${jetty.version} + test + + + org.eclipse.jetty + jetty-servlet + ${jetty.version} + test + + + redis.clients + jedis + 2.9.0 + provided + + + org.projectlombok + lombok + 1.16.18 + compile + + + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + doclint-java8-disable + + [1.8,) + + + -Xdoclint:none + + + + + release + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + ${javadoc.opts} + UTF-8 + zh_CN + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.17 + + true + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.3 + true + + ossrh + https://oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.1 + + true + false + release + deploy + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + UTF-8 + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.17 + + quality-checks/google_checks.xml + true + true + true + + + + verify + + check + + + + + + + + diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/ByteGroup.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/ByteGroup.java index b12ec65555..bff08d680d 100755 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/ByteGroup.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/ByteGroup.java @@ -1,26 +1,26 @@ -package me.chanjar.weixin.common.util.crypto; - -import java.util.ArrayList; - -public class ByteGroup { - ArrayList byteContainer = new ArrayList<>(); - - public byte[] toBytes() { - byte[] bytes = new byte[this.byteContainer.size()]; - for (int i = 0; i < this.byteContainer.size(); i++) { - bytes[i] = this.byteContainer.get(i); - } - return bytes; - } - - public ByteGroup addBytes(byte[] bytes) { - for (byte b : bytes) { - this.byteContainer.add(b); - } - return this; - } - - public int size() { - return this.byteContainer.size(); - } -} +package me.chanjar.weixin.common.util.crypto; + +import java.util.ArrayList; + +public class ByteGroup { + ArrayList byteContainer = new ArrayList<>(); + + public byte[] toBytes() { + byte[] bytes = new byte[this.byteContainer.size()]; + for (int i = 0; i < this.byteContainer.size(); i++) { + bytes[i] = this.byteContainer.get(i); + } + return bytes; + } + + public ByteGroup addBytes(byte[] bytes) { + for (byte b : bytes) { + this.byteContainer.add(b); + } + return this; + } + + public int size() { + return this.byteContainer.size(); + } +} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/PKCS7Encoder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/PKCS7Encoder.java index 145896a577..8ce94cbac0 100755 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/PKCS7Encoder.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/PKCS7Encoder.java @@ -1,68 +1,68 @@ -/** - * 对公众平台发送给公众账号的消息加解密示例代码. - * - * @copyright Copyright (c) 1998-2014 Tencent Inc. - */ - -// ------------------------------------------------------------------------ - -package me.chanjar.weixin.common.util.crypto; - -import java.nio.charset.Charset; -import java.util.Arrays; - -/** - * 提供基于PKCS7算法的加解 - */ -public class PKCS7Encoder { - - private static final Charset CHARSET = Charset.forName("utf-8"); - private static final int BLOCK_SIZE = 32; - - /** - * 获得对明文进行补位填充的字节. - * - * @param count 需要进行填充补位操作的明文字节个数 - * @return 补齐用的字节数组 - */ - public static byte[] encode(int count) { - // 计算需要填充的位数 - int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE); - if (amountToPad == 0) { - amountToPad = BLOCK_SIZE; - } - // 获得补位所用的字符 - char padChr = chr(amountToPad); - String tmp = new String(); - for (int index = 0; index < amountToPad; index++) { - tmp += padChr; - } - return tmp.getBytes(CHARSET); - } - - /** - * 删除解密后明文的补位字符 - * - * @param decrypted 解密后的明文 - * @return 删除补位字符后的明文 - */ - public static byte[] decode(byte[] decrypted) { - int pad = decrypted[decrypted.length - 1]; - if (pad < 1 || pad > 32) { - pad = 0; - } - return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad); - } - - /** - * 将数字转化成ASCII码对应的字符,用于对明文进行补码 - * - * @param a 需要转化的数字 - * @return 转化得到的字符 - */ - public static char chr(int a) { - byte target = (byte) (a & 0xFF); - return (char) target; - } - -} +/** + * 对公众平台发送给公众账号的消息加解密示例代码. + * + * @copyright Copyright (c) 1998-2014 Tencent Inc. + */ + +// ------------------------------------------------------------------------ + +package me.chanjar.weixin.common.util.crypto; + +import java.nio.charset.Charset; +import java.util.Arrays; + +/** + * 提供基于PKCS7算法的加解 + */ +public class PKCS7Encoder { + + private static final Charset CHARSET = Charset.forName("utf-8"); + private static final int BLOCK_SIZE = 32; + + /** + * 获得对明文进行补位填充的字节. + * + * @param count 需要进行填充补位操作的明文字节个数 + * @return 补齐用的字节数组 + */ + public static byte[] encode(int count) { + // 计算需要填充的位数 + int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE); + if (amountToPad == 0) { + amountToPad = BLOCK_SIZE; + } + // 获得补位所用的字符 + char padChr = chr(amountToPad); + String tmp = new String(); + for (int index = 0; index < amountToPad; index++) { + tmp += padChr; + } + return tmp.getBytes(CHARSET); + } + + /** + * 删除解密后明文的补位字符 + * + * @param decrypted 解密后的明文 + * @return 删除补位字符后的明文 + */ + public static byte[] decode(byte[] decrypted) { + int pad = decrypted[decrypted.length - 1]; + if (pad < 1 || pad > 32) { + pad = 0; + } + return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad); + } + + /** + * 将数字转化成ASCII码对应的字符,用于对明文进行补码 + * + * @param a 需要转化的数字 + * @return 转化得到的字符 + */ + public static char chr(int a) { + byte target = (byte) (a & 0xFF); + return (char) target; + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java index 87a6747af5..697bfe899d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpShakeService.java @@ -1,8 +1,10 @@ package me.chanjar.weixin.mp.api; +import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.bean.WxMpShakeInfoResult; import me.chanjar.weixin.mp.bean.WxMpShakeQuery; +import me.chanjar.weixin.mp.bean.shake.*; /** * 摇一摇周边的相关接口 @@ -24,4 +26,36 @@ public interface WxMpShakeService { */ WxMpShakeInfoResult getShakeInfo(WxMpShakeQuery wxMpShakeQuery) throws WxErrorException; + /** + *
    +   * 页面管理
    + * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1459246752 + *
    + * @param shakeAroundPageAddQuery + * @return + * @throws WxErrorException + */ + WxMpShakeAroundPageAddResult pageAdd(WxMpShakeAroundPageAddQuery shakeAroundPageAddQuery) throws WxErrorException; + + /** + *
    +   * 配置设备与页面的关联关系
    + * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1459301931 + *
    + * @param shakeAroundDeviceBindPageQuery + * @return + * @throws WxErrorException + */ + WxError deviceBindPageQuery(WxMpShakeAroundDeviceBindPageQuery shakeAroundDeviceBindPageQuery) throws WxErrorException; + + /** + *
    +   * 查询设备与页面的关联关系
    + * 详情请见: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1443447914 + *
    + * @param shakeAroundRelationSearchQuery + * @return + * @throws WxErrorException + */ + WxMpShakeAroundRelationSearchResult relationSearch(WxMpShakeAroundRelationSearchQuery shakeAroundRelationSearchQuery) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpShakeServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpShakeServiceImpl.java index bee636fd54..2c90f70e2b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpShakeServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpShakeServiceImpl.java @@ -1,13 +1,16 @@ package me.chanjar.weixin.mp.api.impl; +import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpShakeService; import me.chanjar.weixin.mp.bean.WxMpShakeInfoResult; import me.chanjar.weixin.mp.bean.WxMpShakeQuery; +import me.chanjar.weixin.mp.bean.shake.*; /** * Created by rememberber on 2017/6/5. + * * @author rememberber */ public class WxMpShakeServiceImpl implements WxMpShakeService { @@ -27,7 +30,7 @@ public WxMpShakeServiceImpl(WxMpService wxMpService) { * 接口地址:https://api.weixin.qq.com/shakearound/user/getshakeinfo?access_token=ACCESS_TOKE *
    * - * @param wxMpShakeQuery 查询参数 + * @param wxMpShakeQuery 查询参数 */ @Override public WxMpShakeInfoResult getShakeInfo(WxMpShakeQuery wxMpShakeQuery) throws WxErrorException { @@ -36,4 +39,28 @@ public WxMpShakeInfoResult getShakeInfo(WxMpShakeQuery wxMpShakeQuery) throws Wx String responseContent = this.wxMpService.post(url, postData); return WxMpShakeInfoResult.fromJson(responseContent); } + + @Override + public WxMpShakeAroundPageAddResult pageAdd(WxMpShakeAroundPageAddQuery shakeAroundPageAddQuery) throws WxErrorException { + String url = "https://api.weixin.qq.com/shakearound/page/add"; + String postData = shakeAroundPageAddQuery.toJsonString(); + String responseContent = this.wxMpService.post(url, postData); + return WxMpShakeAroundPageAddResult.fromJson(responseContent); + } + + @Override + public WxError deviceBindPageQuery(WxMpShakeAroundDeviceBindPageQuery shakeAroundDeviceBindPageQuery) throws WxErrorException { + String url = "https://api.weixin.qq.com/shakearound/device/bindpage"; + String postData = shakeAroundDeviceBindPageQuery.toJsonString(); + String responseContent = this.wxMpService.post(url, postData); + return WxError.fromJson(responseContent); + } + + @Override + public WxMpShakeAroundRelationSearchResult relationSearch(WxMpShakeAroundRelationSearchQuery shakeAroundRelationSearchQuery) throws WxErrorException { + String url = "https://api.weixin.qq.com/shakearound/relation/search"; + String postData = shakeAroundRelationSearchQuery.toJsonString(); + String responseContent = this.wxMpService.post(url, postData); + return WxMpShakeAroundRelationSearchResult.fromJson(responseContent); + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpDeviceIdentifier.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpDeviceIdentifier.java new file mode 100644 index 0000000000..e93bf75cf9 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpDeviceIdentifier.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.mp.bean.shake; + +import com.google.gson.JsonObject; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class WxMpDeviceIdentifier implements Serializable { + private Integer device_id; + private String uuid; + private Integer page_id; + private Integer major; + private Integer minor; + public JsonObject toJsonObject(){ + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("device_id", device_id); + jsonObject.addProperty("uuid", uuid); + jsonObject.addProperty("major", major); + jsonObject.addProperty("minor", minor); + return jsonObject; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundDeviceBindPageQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundDeviceBindPageQuery.java new file mode 100644 index 0000000000..71da0b1c65 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundDeviceBindPageQuery.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.mp.bean.shake; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import lombok.Data; + +import java.util.Collection; + +@Data +public class WxMpShakeAroundDeviceBindPageQuery { + private WxMpDeviceIdentifier deviceIdentifier; + private Collection pageIds; + public String toJsonString(){ + JsonObject jsonObject = new JsonObject(); + jsonObject.add("device_identifier", deviceIdentifier.toJsonObject()); + JsonArray jsonArray = new JsonArray(); + for(Integer pageid: pageIds){ + jsonArray.add(pageid); + } + jsonObject.add("page_ids", jsonArray); + return jsonObject.toString(); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundPageAddQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundPageAddQuery.java new file mode 100644 index 0000000000..b04ced93bd --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundPageAddQuery.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.mp.bean.shake; + +import com.google.gson.JsonObject; +import lombok.Data; + +import java.io.Serializable; +@Data +public class WxMpShakeAroundPageAddQuery implements Serializable { + private String title; + private String description; + private String pageUrl; + private String comment; + private String iconUrl; + public String toJsonString(){ + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("title", title); + jsonObject.addProperty("description", description); + jsonObject.addProperty("page_url", pageUrl); + jsonObject.addProperty("comment", comment); + jsonObject.addProperty("icon_url", iconUrl); + return jsonObject.toString(); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundPageAddResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundPageAddResult.java new file mode 100644 index 0000000000..632fe4f351 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundPageAddResult.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.mp.bean.shake; + +import com.google.gson.JsonObject; +import lombok.Data; +import me.chanjar.weixin.common.util.json.GsonHelper; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + +import java.io.Serializable; + +@Data +public class WxMpShakeAroundPageAddResult implements Serializable { + private Integer errorCode; + private String errorMsg; + private Integer pageId; + public static WxMpShakeAroundPageAddResult fromJson(String json) { + JsonObject jsonObject = WxMpGsonBuilder.INSTANCE.create().fromJson(json, JsonObject.class); + WxMpShakeAroundPageAddResult result = new WxMpShakeAroundPageAddResult(); + result.setErrorCode(GsonHelper.getInteger(jsonObject, "errcode")); + result.setErrorMsg(GsonHelper.getString(jsonObject, "errmsg")); + jsonObject = jsonObject.getAsJsonObject("data"); + if(jsonObject != null){ + result.setPageId(GsonHelper.getInteger(jsonObject, "page_id")); + } + return result; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundRelationSearchQuery.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundRelationSearchQuery.java new file mode 100644 index 0000000000..390fe50964 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundRelationSearchQuery.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.mp.bean.shake; + +import com.google.gson.JsonObject; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class WxMpShakeAroundRelationSearchQuery implements Serializable { + private int type; + private Integer pageId; + private Integer begin; + private Integer count; + private WxMpDeviceIdentifier deviceIdentifier; + public String toJsonString(){ + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("type", type); + switch (type){ + case 1: + jsonObject.add("device_identifier", deviceIdentifier.toJsonObject()); + break; + case 2: + jsonObject.addProperty("page_id", pageId); + jsonObject.addProperty("begin", begin); + jsonObject.addProperty("count", count); + break; + default: + throw new IllegalArgumentException("type error"); + } + return jsonObject.toString(); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundRelationSearchResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundRelationSearchResult.java new file mode 100644 index 0000000000..2b7269e572 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/shake/WxMpShakeAroundRelationSearchResult.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.mp.bean.shake; + +import lombok.Data; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +@Data +public class WxMpShakeAroundRelationSearchResult implements Serializable { + private Integer errcode; + private String errmsg; + private WxMpShakeAcoundRelationSearch data; + public static WxMpShakeAroundRelationSearchResult fromJson(String json) { + return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpShakeAroundRelationSearchResult.class); + } + @Data + public static class WxMpShakeAcoundRelationSearch implements Serializable{ + private List relations; + private Integer total_count; + } +} From 556487078c6fed354fb9dea8d57099c2108f29c4 Mon Sep 17 00:00:00 2001 From: 007gzs <007gzs@gmail.com> Date: Tue, 21 Nov 2017 13:59:46 +0800 Subject: [PATCH 156/165] =?UTF-8?q?#378=20=E4=BF=AE=E5=A4=8D=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E5=B9=B3=E5=8F=B0=E6=8E=A5=E5=8F=A3BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 增加 微信第三方平台 接口 * WxOpenXmlMessage 消息处理 * 增加 摇周边部分接口 * fix * fix * rebase * 增加 摇周边部分接口 * fix * fix * unix 换行符 * fix 三方接口BUG --- .../me/chanjar/weixin/open/api/WxOpenComponentService.java | 4 ++-- .../me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java | 1 + .../me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java index c3c402c5af..966a89835e 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java @@ -17,10 +17,10 @@ public interface WxOpenComponentService { String API_COMPONENT_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_component_token"; String API_CREATE_PREAUTHCODE_URL = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode"; String API_QUERY_AUTH_URL = "https://api.weixin.qq.com/cgi-bin/component/api_query_auth"; - String API_AUTHORIZER_TOKEN_URL = "https://api.weixin.qq.com /cgi-bin/component/api_authorizer_token"; + String API_AUTHORIZER_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token"; String API_GET_AUTHORIZER_INFO_URL = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info"; String API_GET_AUTHORIZER_OPTION_URL = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_option"; - String API_SET_AUTHORIZER_OPTION_URL = "https://api.weixin.qq.com/cgi-bin/component/ api_set_authorizer_option"; + String API_SET_AUTHORIZER_OPTION_URL = "https://api.weixin.qq.com/cgi-bin/component/api_set_authorizer_option"; String COMPONENT_LOGIN_PAGE_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s"; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java index 1f4a465f3a..0123e389c6 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java @@ -18,6 +18,7 @@ public WxOpenMpServiceImpl(WxOpenComponentService wxOpenComponentService, String this.wxOpenComponentService = wxOpenComponentService; this.appId = appId; this.wxMpConfigStorage = wxMpConfigStorage; + initHttp(); } @Override diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java index 6b2e04fde7..26c1791cda 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java @@ -46,7 +46,6 @@ public class WxOpenXmlMessage implements Serializable { private String authorizationCode; @XStreamAlias("AuthorizationCodeExpiredTime") - @XStreamConverter(value = XStreamCDataConverter.class) private Long authorizationCodeExpiredTime; @XStreamAlias("PreAuthCode") From 5c9ec87bb8361ba023d8cd1be6241060f3528511 Mon Sep 17 00:00:00 2001 From: 007gzs <007gzs@gmail.com> Date: Tue, 21 Nov 2017 20:55:17 +0800 Subject: [PATCH 157/165] =?UTF-8?q?#379=20WxOpenXmlMessage=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20=E5=8A=A0=E5=AF=86=20WxMpXmlOutMessage=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20MpConfigStorage=20=E8=BF=94=E5=9B=9Eaeskey=E5=92=8C?= =?UTF-8?q?token=20MpService=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5=E5=8A=A0?= =?UTF-8?q?=E5=AF=86=20=20=E5=A2=9E=E5=8A=A0=20=E5=85=A8=E7=BD=91=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 增加 微信第三方平台 接口 * WxOpenXmlMessage 消息处理 * 增加 摇周边部分接口 * fix * fix * rebase * 增加 摇周边部分接口 * fix * fix * unix 换行符 * fix 三方接口BUG * fix URL 错误 * WxOpenMpServiceImpl 修改为包可见,防止用户混淆 WxOpenXmlMessage 增加 加密 WxMpXmlOutMessage接口 MpConfigStorage 返回aeskey和token MpService可以直接加密 增加 全网发布用例 --- weixin-java-open/README.md | 28 ++++++++++++++++++- .../open/api/WxOpenComponentService.java | 4 +-- .../api/impl/WxOpenInMemoryConfigStorage.java | 4 +-- .../open/api/impl/WxOpenMpServiceImpl.java | 2 +- .../open/bean/message/WxOpenXmlMessage.java | 7 +++++ 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/weixin-java-open/README.md b/weixin-java-open/README.md index d99b770673..1f935a9713 100644 --- a/weixin-java-open/README.md +++ b/weixin-java-open/README.md @@ -1,4 +1,6 @@ 消息机制未实现,下面为通知回调中设置的代码部分 + +以下代码可通过腾讯全网发布测试用例 ``` @RestController @RequestMapping("notify") @@ -55,7 +57,31 @@ public class NotifyController extends WechatThridBaseController { // aes加密的消息 WxMpXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedMpXml(requestBody, wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature); this.logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString()); - //wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId); + // 全网发布测试用例 + if (StringUtils.equalsAnyIgnoreCase(appId, "wxd101a85aa106f53e", "wx570bc396a51b8ff8")) { + try { + if (StringUtils.equals(inMessage.getMsgType(), "text")) { + if (StringUtils.equals(inMessage.getContent(), "TESTCOMPONENT_MSG_TYPE_TEXT")) { + out = new WxOpenCryptUtil(wxOpenService.getWxOpenConfigStorage()).encrypt( + WxMpXmlOutMessage.TEXT().content("TESTCOMPONENT_MSG_TYPE_TEXT_callback") + .fromUser(inMessage.getToUser()) + .toUser(inMessage.getFromUser()) + .build() + .toXml() + ); + } else if (StringUtils.startsWith(inMessage.getContent(), "QUERY_AUTH_CODE:")) { + String msg = inMessage.getContent().replace("QUERY_AUTH_CODE:", "") + "_from_api"; + WxMpKefuMessage kefuMessage = WxMpKefuMessage.TEXT().content(msg).toUser(inMessage.getFromUser()).build(); + wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getKefuService().sendKefuMessage(kefuMessage); + } + } else if (StringUtils.equals(inMessage.getMsgType(), "event")) { + WxMpKefuMessage kefuMessage = WxMpKefuMessage.TEXT().content(inMessage.getEvent() + "from_callback").toUser(inMessage.getFromUser()).build(); + wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getKefuService().sendKefuMessage(kefuMessage); + } + } catch (WxErrorException e) { + logger.error("callback", e); + } + } return out; } } diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java index 966a89835e..9dc5a6d3d1 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java @@ -29,11 +29,11 @@ public interface WxOpenComponentService { /** * 用code换取oauth2的access token */ - String OAUTH2_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&code=%s&grant_type=authorization_code&component_appid=%s"; + String OAUTH2_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/component/access_token?appid=%s&code=%s&grant_type=authorization_code&component_appid=%s"; /** * 刷新oauth2的access token */ - String OAUTH2_REFRESH_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s&component_appid==%s"; + String OAUTH2_REFRESH_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/component/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s&component_appid==%s"; WxMpService getWxMpServiceByAppid(String appid); diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java index 687a57d774..50cf8b6e74 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenInMemoryConfigStorage.java @@ -329,7 +329,7 @@ public String getSecret() { @Override public String getToken() { - return null; + return wxOpenConfigStorage.getComponentToken(); } @Override @@ -340,7 +340,7 @@ public long getExpiresTime() { @Override public String getAesKey() { - return null; + return wxOpenConfigStorage.getComponentAesKey(); } @Override diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java index 0123e389c6..9c537bc93e 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java @@ -9,7 +9,7 @@ /** * @author 007 */ -public class WxOpenMpServiceImpl extends WxMpServiceImpl { +/* package */ class WxOpenMpServiceImpl extends WxMpServiceImpl { private WxOpenComponentService wxOpenComponentService; private WxMpConfigStorage wxMpConfigStorage; private String appId; diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java index 26c1791cda..8cb245ba3e 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java @@ -5,6 +5,7 @@ import lombok.Data; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; import me.chanjar.weixin.open.api.WxOpenConfigStorage; import me.chanjar.weixin.open.util.WxOpenCryptUtil; import me.chanjar.weixin.open.util.xml.XStreamTransformer; @@ -52,6 +53,12 @@ public class WxOpenXmlMessage implements Serializable { @XStreamConverter(value = XStreamCDataConverter.class) private String preAuthCode; + public static String wxMpOutXmlMessageToEncryptedXml(WxMpXmlOutMessage message, WxOpenConfigStorage wxOpenConfigStorage){ + String plainXml = message.toXml(); + WxOpenCryptUtil pc = new WxOpenCryptUtil(wxOpenConfigStorage); + return pc.encrypt(plainXml); + } + public static WxOpenXmlMessage fromXml(String xml) { //修改微信变态的消息内容格式,方便解析 xml = xml.replace("", ""); From 81ebe1a085ddaecfdf1d8aa0602450d8f5445b84 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 22 Nov 2017 23:10:53 +0800 Subject: [PATCH 158/165] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/service/impl/WxPayServiceAbstractImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index 07c3627998..0eccb7272a 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -422,9 +422,9 @@ public WxPayBillResult downloadBill(String billDate, String billType, String tar String responseContent = this.post(url, request.toXML(), false); if (responseContent.startsWith("<")) { throw WxPayException.from(WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class)); - } else { - return this.handleBillInformation(responseContent); } + + return this.handleBillInformation(responseContent); } private WxPayBillResult handleBillInformation(String responseContent) { From 20825922ce42788896546d4e0385dbadc48423c5 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 22 Nov 2017 23:15:18 +0800 Subject: [PATCH 159/165] =?UTF-8?q?#367=20=E5=A2=9E=E5=8A=A0=E5=AF=B9api?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=AC=A1=E6=95=B0=E6=B8=85=E9=9B=B6=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/api/WxMpService.java | 25 +++- .../mp/api/impl/WxMpServiceAbstractImpl.java | 7 + .../mp/api/impl/WxMpServiceImplTest.java | 125 +----------------- 3 files changed, 32 insertions(+), 125 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java index 914c902d44..0dd5a66bd3 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java @@ -5,8 +5,11 @@ import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; -import me.chanjar.weixin.mp.bean.*; -import me.chanjar.weixin.mp.bean.result.*; +import me.chanjar.weixin.mp.bean.WxMpSemanticQuery; +import me.chanjar.weixin.mp.bean.result.WxMpCurrentAutoReplyInfo; +import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken; +import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult; +import me.chanjar.weixin.mp.bean.result.WxMpUser; /** * 微信API的Service @@ -62,6 +65,11 @@ public interface WxMpService { */ String GET_CURRENT_AUTOREPLY_INFO_URL = "https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info"; + /** + * 公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零 + */ + String CLEAR_QUOTA_URL = "https://api.weixin.qq.com/cgi-bin/clear_quota"; + /** *
        * 验证消息的确来自微信服务器
    @@ -219,6 +227,18 @@ public interface WxMpService {
        */
       WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException;
     
    +  /**
    +   * 
    +   *  公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零:
    +   *  HTTP调用:https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN
    +   *  接口文档地址:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433744592
    +   *
    +   * 
    + * + * @param appid 公众号的APPID + */ + void clearQuota(String appid) throws WxErrorException; + /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求 */ @@ -376,6 +396,7 @@ public interface WxMpService { /** * 返回群发消息相关接口方法的实现类对象,以方便调用其各个接口 + * * @return WxMpMassMessageService */ WxMpMassMessageService getMassMessageService(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java index 420cb25249..54b4c36096 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java @@ -207,6 +207,13 @@ public WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorExceptio return WxMpCurrentAutoReplyInfo.fromJson(this.get(GET_CURRENT_AUTOREPLY_INFO_URL, null)); } + @Override + public void clearQuota(String appid) throws WxErrorException { + JsonObject o = new JsonObject(); + o.addProperty("appid", appid); + this.post(CLEAR_QUOTA_URL, o.toString()); + } + @Override public String get(String url, String queryParam) throws WxErrorException { return execute(SimpleGetRequestExecutor.create(this), url, queryParam); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java index 9cb9e1d115..89060a6ef1 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImplTest.java @@ -15,7 +15,6 @@ @Test @Guice(modules = ApiTestModule.class) public class WxMpServiceImplTest { - @Inject private WxMpService wxService; @@ -28,88 +27,8 @@ public void testGetCurrentAutoReplyInfo() throws WxErrorException { } @Test - public void testCheckSignature() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testGetAccessToken() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testGetAccessTokenBoolean() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testGetJsapiTicket() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testGetJsapiTicketBoolean() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testCreateJsapiSignature() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testCustomMessageSend() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testMassNewsUpload() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testMassVideoUpload() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testMassGroupMessageSend() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testMassOpenIdsMessageSend() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testMassMessagePreview() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testShortUrl() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testSetIndustry() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testGetIndustry() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testSemanticQuery() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testOauth2buildAuthorizationUrl() { - Assert.fail("Not yet implemented"); + public void testClearQuota() throws WxErrorException { + this.wxService.clearQuota(wxService.getWxMpConfigStorage().getAppId()); } @Test @@ -121,44 +40,4 @@ public void testBuildQrConnectUrl() { System.out.println(qrConnectUrl); } - @Test - public void testOauth2getAccessToken() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testOauth2refreshAccessToken() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testOauth2getUserInfo() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testOauth2validateAccessToken() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testGetCallbackIP() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testGet() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testPost() { - Assert.fail("Not yet implemented"); - } - - @Test - public void testExecute() { - Assert.fail("Not yet implemented"); - } - } From 6180577f65c0935385fb52517775a366e22e4f5b Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 22 Nov 2017 23:22:10 +0800 Subject: [PATCH 160/165] =?UTF-8?q?=E5=A2=9E=E5=8A=A0redis=E7=9A=84configS?= =?UTF-8?q?torage=E5=AE=9E=E7=8E=B0=E7=9A=84=E6=B3=A8=E9=87=8A=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/cp/config/WxCpJedisConfigStorage.java | 6 +++++- .../me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpJedisConfigStorage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpJedisConfigStorage.java index 39b2ae5023..5ef99a3ca8 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpJedisConfigStorage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpJedisConfigStorage.java @@ -9,7 +9,11 @@ import java.io.File; /** - * Jedis client implementor for wechat config storage + * Jedis client implementor for wechat config storage. + *
    + *    使用说明:本实现仅供参考,并不完整,
    + *    比如为减少项目依赖,未加入redis分布式锁的实现,如有需要请自行实现。
    + * 
    * * @author gaigeshen */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java index 3254972c26..6974221c10 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInRedisConfigStorage.java @@ -5,7 +5,10 @@ /** * 基于Redis的微信配置provider - * + *
    + *    使用说明:本实现仅供参考,并不完整,
    + *    比如为减少项目依赖,未加入redis分布式锁的实现,如有需要请自行实现。
    + * 
    * @author nickwong */ @SuppressWarnings("hiding") From fa4cc5a9fd72d365bca1adfde74acd450b1cc536 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 22 Nov 2017 23:48:59 +0800 Subject: [PATCH 161/165] =?UTF-8?q?#380=20=E4=BF=AE=E5=A4=8Dokhttp?= =?UTF-8?q?=E5=92=8Cjodd-http=E5=AE=9E=E7=8E=B0=E7=9A=84=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=B0=B8=E4=B9=85=E7=B4=A0=E6=9D=90=E6=8E=A5=E5=8F=A3=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apache/ApacheMaterialNewsInfoRequestExecutor.java | 5 ++--- .../http/jodd/JoddMaterialNewsInfoRequestExecutor.java | 8 +++++--- .../okhttp/OkhttpMaterialNewsInfoRequestExecutor.java | 5 ++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java index fe8dc580d7..baab51b591 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/apache/ApacheMaterialNewsInfoRequestExecutor.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.util.http.apache; +import com.google.common.collect.ImmutableMap; import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.http.RequestHttp; @@ -43,9 +44,7 @@ public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorExc httpPost.setConfig(config); } - Map params = new HashMap<>(); - params.put("media_id", materialId); - httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(params))); + httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId)))); try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); this.logger.debug("响应原始数据:{}", responseContent); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialNewsInfoRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialNewsInfoRequestExecutor.java index 181a640787..2bce6ee4f6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialNewsInfoRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/jodd/JoddMaterialNewsInfoRequestExecutor.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.util.http.jodd; +import com.google.common.collect.ImmutableMap; import jodd.http.HttpConnectionProvider; import jodd.http.HttpRequest; import jodd.http.HttpResponse; @@ -9,6 +10,7 @@ import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.http.RequestHttp; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -28,13 +30,13 @@ public JoddMaterialNewsInfoRequestExecutor(RequestHttp requestHttp) { @Override public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorException, IOException { - HttpRequest request = HttpRequest.post(uri); if (requestHttp.getRequestHttpProxy() != null) { requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); } - request.withConnectionProvider(requestHttp.getRequestHttpClient()); - request.query("media_id", materialId); + HttpRequest request = HttpRequest.post(uri) + .withConnectionProvider(requestHttp.getRequestHttpClient()) + .body(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId))); HttpResponse response = request.send(); response.charset(StringPool.UTF_8); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java index 3f46ab7880..e8bd9beea6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpMaterialNewsInfoRequestExecutor.java @@ -1,9 +1,11 @@ package me.chanjar.weixin.mp.util.http.okhttp; +import com.google.common.collect.ImmutableMap; import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -28,7 +30,8 @@ public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorExc //得到httpClient OkHttpClient client = requestHttp.getRequestHttpClient(); - RequestBody requestBody = new FormBody.Builder().add("media_id", materialId).build(); + RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), + WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId))); Request request = new Request.Builder().url(uri).post(requestBody).build(); Response response = client.newCall(request).execute(); From 1875c1b374233ab792b7a2f7ed7078a957e4bb53 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 23 Nov 2017 12:08:40 +0800 Subject: [PATCH 162/165] =?UTF-8?q?#383=20=E4=BF=AE=E5=A4=8D=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=94=AF=E4=BB=98=E6=9F=A5=E8=AF=A2=E4=BB=A3=E9=87=91?= =?UTF-8?q?=E5=88=B8=E4=BF=A1=E6=81=AF=E8=BF=94=E5=9B=9E=E7=9A=84coupon=5F?= =?UTF-8?q?state=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coupon/WxPayCouponInfoQueryResult.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java index ad9aceb45e..f7d9138392 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/coupon/WxPayCouponInfoQueryResult.java @@ -21,7 +21,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult { /** *
    -   * 字段名:设备号
    +   * 字段名:设备号.
        * 变量名:device_info
        * 是否必填:否
        * 示例值:123456sb
    @@ -34,7 +34,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:批次ID
    +   * 字段名:批次ID.
        * 变量名:coupon_stock_id
        * 是否必填:是
        * 示例值:1567
    @@ -47,7 +47,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:代金券id
    +   * 字段名:代金券id.
        * 变量名:coupon_id
        * 是否必填:是
        * 示例值:4242
    @@ -60,7 +60,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:代金券面额
    +   * 字段名:代金券面额.
        * 变量名:coupon_value
        * 是否必填:是
        * 示例值:4
    @@ -73,7 +73,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:代金券使用门槛
    +   * 字段名:代金券使用门槛.
        * 变量名:coupon_mininum
        * 是否必填:是
        * 示例值:10
    @@ -86,7 +86,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:代金券名称
    +   * 字段名:代金券名称.
        * 变量名:coupon_name
        * 是否必填:是
        * 示例值:测试代金券
    @@ -99,20 +99,20 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:代金券状态
    +   * 字段名:代金券状态.
        * 变量名:coupon_state
        * 是否必填:是
        * 示例值:SENDED
    -   * 类型:int
    +   * 类型:String
        * 说明:代金券状态:SENDED-可用,USED-已实扣,EXPIRED-已过期
        * 
    */ @XStreamAlias("coupon_state") - private Integer couponState; + private String couponState; /** *
    -   * 字段名:代金券描述
    +   * 字段名:代金券描述.
        * 变量名:coupon_desc
        * 是否必填:是
        * 示例值:微信支付-代金券
    @@ -125,7 +125,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:实际优惠金额
    +   * 字段名:实际优惠金额.
        * 变量名:coupon_use_value
        * 是否必填:是
        * 示例值:0
    @@ -138,7 +138,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:优惠剩余可用额
    +   * 字段名:优惠剩余可用额.
        * 变量名:coupon_remain_value
        * 是否必填:是
        * 示例值:4
    @@ -151,7 +151,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:生效开始时间
    +   * 字段名:生效开始时间.
        * 变量名:begin_time
        * 是否必填:是
        * 示例值:1943787483
    @@ -164,7 +164,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:生效结束时间
    +   * 字段名:生效结束时间.
        * 变量名:end_time
        * 是否必填:是
        * 示例值:1943787484
    @@ -177,7 +177,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:发放时间
    +   * 字段名:发放时间.
        * 变量名:send_time
        * 是否必填:是
        * 示例值:1943787420
    @@ -190,7 +190,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:消耗方商户id
    +   * 字段名:消耗方商户id.
        * 变量名:consumer_mch_id
        * 是否必填:否
        * 示例值:10000098
    @@ -203,7 +203,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:发放来源
    +   * 字段名:发放来源.
        * 变量名:send_source
        * 是否必填:是
        * 示例值:FULL_SEND
    @@ -216,7 +216,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
     
       /**
        * 
    -   * 字段名:是否允许部分使用
    +   * 字段名:是否允许部分使用.
        * 变量名:is_partial_use
        * 是否必填:否
        * 示例值:1
    
    From 6d566ced44a352e4ecb5ad7dbacc80536d67ca21 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Thu, 23 Nov 2017 12:16:34 +0800
    Subject: [PATCH 163/165] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=B8=B4=E6=97=B6?=
     =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E6=9C=AC2.8.9.BETA?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     pom.xml                     | 2 +-
     weixin-java-common/pom.xml  | 2 +-
     weixin-java-cp/pom.xml      | 2 +-
     weixin-java-miniapp/pom.xml | 2 +-
     weixin-java-mp/pom.xml      | 2 +-
     weixin-java-open/pom.xml    | 2 +-
     weixin-java-pay/pom.xml     | 2 +-
     7 files changed, 7 insertions(+), 7 deletions(-)
    
    diff --git a/pom.xml b/pom.xml
    index 54f52b021e..c640173530 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -6,7 +6,7 @@
       4.0.0
       com.github.binarywang
       weixin-java-parent
    -  2.8.8.BETA
    +  2.8.9.BETA
       pom
       WeiXin Java Tools - Parent
       微信公众号、企业号上级POM
    diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml
    index 25dc5bd1fa..aa1e4c3578 100644
    --- a/weixin-java-common/pom.xml
    +++ b/weixin-java-common/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.8.BETA
    +    2.8.9.BETA
       
     
       weixin-java-common
    diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml
    index 96dba9c9d6..4dbab6b6f0 100644
    --- a/weixin-java-cp/pom.xml
    +++ b/weixin-java-cp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.8.BETA
    +    2.8.9.BETA
       
     
       weixin-java-cp
    diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml
    index b7e2f1cb9c..8638ea3b11 100644
    --- a/weixin-java-miniapp/pom.xml
    +++ b/weixin-java-miniapp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.8.BETA
    +    2.8.9.BETA
       
       weixin-java-miniapp
       WeiXin Java Tools - MiniApp
    diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml
    index 81bf0008c5..876386fb1b 100644
    --- a/weixin-java-mp/pom.xml
    +++ b/weixin-java-mp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.8.BETA
    +    2.8.9.BETA
       
       weixin-java-mp
       WeiXin Java Tools - MP
    diff --git a/weixin-java-open/pom.xml b/weixin-java-open/pom.xml
    index b52c578175..1eb63805ea 100644
    --- a/weixin-java-open/pom.xml
    +++ b/weixin-java-open/pom.xml
    @@ -8,7 +8,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.8.BETA
    +    2.8.9.BETA
       
       weixin-java-open
       WeiXin Java Tools - Open
    diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml
    index 47b3f4da16..d120876353 100644
    --- a/weixin-java-pay/pom.xml
    +++ b/weixin-java-pay/pom.xml
    @@ -5,7 +5,7 @@
       
         weixin-java-parent
         com.github.binarywang
    -    2.8.8.BETA
    +    2.8.9.BETA
       
       4.0.0
     
    
    From 920a2f7e13db0d2e23d7695085bbbd4c09a3a4a2 Mon Sep 17 00:00:00 2001
    From: axeon <23231269@qq.com>
    Date: Fri, 24 Nov 2017 12:25:20 +0800
    Subject: [PATCH 164/165] =?UTF-8?q?#384=20=E5=8E=BB=E6=8E=89executeInterna?=
     =?UTF-8?q?l=E4=B8=8A=E4=BC=9A=E5=AF=BC=E8=87=B4=E6=80=A7=E8=83=BD?=
     =?UTF-8?q?=E9=97=AE=E9=A2=98=E7=9A=84=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?=
     =?UTF-8?q?synchronized?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java  | 2 +-
     .../java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java | 2 +-
     .../me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java  | 2 +-
     3 files changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java
    index 83bc5e13c6..aac09e342b 100644
    --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java
    +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpServiceAbstractImpl.java
    @@ -381,7 +381,7 @@ public  T execute(RequestExecutor executor, String uri, E data) thro
         throw new RuntimeException("微信服务端异常,超出重试次数");
       }
     
    -  protected synchronized  T executeInternal(RequestExecutor executor, String uri, E data) throws WxErrorException {
    +  protected  T executeInternal(RequestExecutor executor, String uri, E data) throws WxErrorException {
         if (uri.contains("access_token=")) {
           throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri);
         }
    diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java
    index 9cfa7efaa9..df3fad8efb 100644
    --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java
    +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java
    @@ -181,7 +181,7 @@ public  T execute(RequestExecutor executor, String uri, E data) thro
         throw new RuntimeException("微信服务端异常,超出重试次数");
       }
     
    -  public synchronized  T executeInternal(RequestExecutor executor, String uri, E data) throws WxErrorException {
    +  public  T executeInternal(RequestExecutor executor, String uri, E data) throws WxErrorException {
         if (uri.contains("access_token=")) {
           throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri);
         }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java
    index 54b4c36096..d81018daa5 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceAbstractImpl.java
    @@ -259,7 +259,7 @@ public  T execute(RequestExecutor executor, String uri, E data) thro
         throw new RuntimeException("微信服务端异常,超出重试次数");
       }
     
    -  public synchronized  T executeInternal(RequestExecutor executor, String uri, E data) throws WxErrorException {
    +  public  T executeInternal(RequestExecutor executor, String uri, E data) throws WxErrorException {
         if (uri.contains("access_token=")) {
           throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri);
         }
    
    From 919a534962756a0d1447ddeb4bf84f22e4e3da0f Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Fri, 1 Dec 2017 19:01:35 +0800
    Subject: [PATCH 165/165] =?UTF-8?q?=E5=8F=91=E5=B8=832.9.0=E6=AD=A3?=
     =?UTF-8?q?=E5=BC=8F=E7=89=88=E6=9C=AC?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     pom.xml                     | 2 +-
     weixin-java-common/pom.xml  | 2 +-
     weixin-java-cp/pom.xml      | 2 +-
     weixin-java-miniapp/pom.xml | 2 +-
     weixin-java-mp/pom.xml      | 2 +-
     weixin-java-open/pom.xml    | 2 +-
     weixin-java-pay/pom.xml     | 2 +-
     7 files changed, 7 insertions(+), 7 deletions(-)
    
    diff --git a/pom.xml b/pom.xml
    index c640173530..6a683db1a0 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -6,7 +6,7 @@
       4.0.0
       com.github.binarywang
       weixin-java-parent
    -  2.8.9.BETA
    +  2.9.0
       pom
       WeiXin Java Tools - Parent
       微信公众号、企业号上级POM
    diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml
    index aa1e4c3578..7dcff6ad6c 100644
    --- a/weixin-java-common/pom.xml
    +++ b/weixin-java-common/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.9.BETA
    +    2.9.0
       
     
       weixin-java-common
    diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml
    index 4dbab6b6f0..f589bbe003 100644
    --- a/weixin-java-cp/pom.xml
    +++ b/weixin-java-cp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.9.BETA
    +    2.9.0
       
     
       weixin-java-cp
    diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml
    index 8638ea3b11..d10de23659 100644
    --- a/weixin-java-miniapp/pom.xml
    +++ b/weixin-java-miniapp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.9.BETA
    +    2.9.0
       
       weixin-java-miniapp
       WeiXin Java Tools - MiniApp
    diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml
    index 876386fb1b..a135b6dda6 100644
    --- a/weixin-java-mp/pom.xml
    +++ b/weixin-java-mp/pom.xml
    @@ -7,7 +7,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.9.BETA
    +    2.9.0
       
       weixin-java-mp
       WeiXin Java Tools - MP
    diff --git a/weixin-java-open/pom.xml b/weixin-java-open/pom.xml
    index 1eb63805ea..5dfd4308e9 100644
    --- a/weixin-java-open/pom.xml
    +++ b/weixin-java-open/pom.xml
    @@ -8,7 +8,7 @@
       
         com.github.binarywang
         weixin-java-parent
    -    2.8.9.BETA
    +    2.9.0
       
       weixin-java-open
       WeiXin Java Tools - Open
    diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml
    index d120876353..f245bff227 100644
    --- a/weixin-java-pay/pom.xml
    +++ b/weixin-java-pay/pom.xml
    @@ -5,7 +5,7 @@
       
         weixin-java-parent
         com.github.binarywang
    -    2.8.9.BETA
    +    2.9.0
       
       4.0.0