From db896f158e5d815253651557ca63fbe02544795d Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 21 Sep 2016 11:17:22 +0800 Subject: [PATCH 01/76] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a546f16d..f061f5b0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Weixin Java Tools 微信公众号/企业号开发Java SDK -## [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badge/) ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) [![Build Status](https://travis-ci.org/binarywang/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/binarywang/weixin-java-tools) +## [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badge/) ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) [![Build Status](https://travis-ci.org/wechat-group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/wechat-group/weixin-java-tools) ### 声明:本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。 From 73b38ab7853f6ed53db5e030038dd6cfeb035e60 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 26 Sep 2016 18:43:58 +0800 Subject: [PATCH 02/76] Update README.md --- README.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f061f5b0..4c090930 100644 --- a/README.md +++ b/README.md @@ -20,16 +20,16 @@ =========== ## 版本说明 -* 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.0.0,2.1.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request。 -* BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版)。 -* 目前最新版本号为 ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) ,也可以通过访问如下地址查看所有最新的版本: -- [【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) -- [【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22) - +* 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.0.0,2.1.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request; +* BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版); +* 目前最新版本号为 ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) ,也可以通过访问链接[【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) [【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22) +分别查看所有最新的版本。 ## Maven & Gradle * 公众号(订阅号、服务号): + +maven: ```xml com.github.binarywang @@ -37,12 +37,14 @@ 2.1.0 ``` - +gradle: ```groovy compile 'com.github.binarywang:weixin-java-mp:2.1.0' ``` * 企业号: + +maven: ```xml com.github.binarywang @@ -50,7 +52,7 @@ compile 'com.github.binarywang:weixin-java-mp:2.1.0' 2.1.0 ``` - +gradle: ```groovy compile 'com.github.binarywang:weixin-java-cp:2.1.0' ``` @@ -63,16 +65,14 @@ compile 'com.github.binarywang:weixin-java-cp:2.1.0' * https://git.coding.net/binarywang/weixin-java-tools.git -## 目前可参考的Demo项目: -* https://github.com/wechat-group/weixin-java-tools-springmvc -* https://github.com/wechat-group/weixin-mp-demo -* ===========以下为备份仓库,会保持跟主仓库同步 -* http://git.oschina.net/binary/weixin-mp-demo -* https://bitbucket.org/binarywang/weixin-mp-demo +## 目前可参考的Demo项目有两个: +1. https://github.com/wechat-group/weixin-mp-demo +1. https://github.com/wechat-group/weixin-java-tools-springmvc ## 关于代码贡献 +* 非常欢迎和感谢对本项目发起Pull Request的同学,本项目代码风格为使用2个空格代表一个Tab,因此在提交代码时请注意一下,否则很容易在IDE格式化代码后与原代码产生大量diff,这样会给其他人阅读代码带来极大的困扰。 +* 为了便于设置,本项目引入editorconfig插件,请使用eclipse的同学在贡献代码前安装相关插件,IntelliJ IDEA则自带支持,无需额外安装插件。 +* 本项目可以采用两种方式接受代码贡献: -* 非常欢迎和感谢对本项目发起Pull Request的同学,本项目可以采用两种方式接受代码贡献: -* 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支。 -* 另外一种贡献代码的方式就是加入SDK Developers开发组,如果对自己的代码足够自信,可以随时提交代码,注意要随时进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询管理员。 -* 本项目代码风格为使用2个空格代表一个Tab,因此在提交代码时请注意一下,否则很容易在IDE格式化代码后与原代码产生大量diff,这样会给其他人阅读代码带来极大的困扰。 +1. 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支。 +1. 另外一种贡献代码的方式就是加入SDK Developers开发组,如果对自己的代码足够自信,可以随时提交代码,注意要随时进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询管理员。 From af924030d79346e31f8e5b004fb4fe3901b17edf Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 28 Sep 2016 10:11:49 +0800 Subject: [PATCH 03/76] Update README.md --- README.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 4c090930..93da5c67 100644 --- a/README.md +++ b/README.md @@ -2,27 +2,26 @@ ## [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badge/) ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) [![Build Status](https://travis-ci.org/wechat-group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/wechat-group/weixin-java-tools) -### 声明:本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。 +### 注意: +1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。*** +1. ***自2.0.0版本以来,主要是公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。*** +1. 最新更新:2016-08-31 发布2.1.0正式版! -### 最新更新:2.1.0版发布!!! on 2016-08-31 +=========== -#### ***自2.0.0版本以来,接口调整比较大,主要是公众号的调整,企业号无过多调整,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。所以如果习惯于1.X.X版本的同学不想做过多更改的话,请慎重考虑升级到2.X.X版本.*** ---- +## 开发交流方式: +1. ***入群须知:为保证入群成员质量,请申请入群前,先Star本项目,然后在申请入群时,输入您的Github帐号ID,以便管理员核对,ID即你的github主页地址https://github.com/XXXX 中最后的部分XXXX的内容,或者在github网页右上角点击头像后查看Signed in as后方内容。*** +1. QQ群:343954419 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=078f7a153d243853e24cf2b542e7a6ccbf2a592bc138080f84d11297f736ec46) +1. 微信群: 因二维码有时间限制,如有想加入微信群的,请入QQ群后咨询获取最新入群二维码; +1. 有功能需求或由于微信官方接口调整导致的代码问题,可以直接提出issue,便于讨论追踪问题; +1. 详细开发文档请看 [Wiki](https://github.com/wechat-group/weixin-java-tools/wiki)。 -### 详细开发文档请看 [wiki](https://github.com/chanjarster/weixin-java-tools/wiki)。 -=========== -## 开发交流工具: -* 微信群: 因二维码有时间限制,如有想加入微信群的,请入QQ群后咨询获取最新入群二维码。 -* QQ群:343954419 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=078f7a153d243853e24cf2b542e7a6ccbf2a592bc138080f84d11297f736ec46) -* ***注意:为保证入群成员质量,请申请入群前,先Star本项目,然后在申请入群时,输入您的Github帐号ID,以便管理员核对,ID即你的github主页地址https://github.com/XXXX 中最后的部分XXXX的内容,或者在github网页右上角点击头像查看,如下图Signed in as下方黄色标识内容即是:*** -* ![github_id](https://raw.githubusercontent.com/wechat-group/weixin-java-tools/develop/res/github_id.png) - =========== ## 版本说明 * 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.0.0,2.1.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request; * BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版); -* 目前最新版本号为 ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) ,也可以通过访问链接[【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) [【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22) +* 目前最新版本号为 ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) ,也可以通过访问链接[【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) 、[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22) 分别查看所有最新的版本。 ## Maven & Gradle From 742c74d850da0ed7dd1d747f1c8ef61d705ce6d6 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Wed, 28 Sep 2016 13:19:36 +0800 Subject: [PATCH 04/76] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=A2=9E=E7=9A=84tagid=5Flist?= =?UTF-8?q?=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/common/util/json/GsonHelper.java | 21 +++++ .../mp/api/impl/WxMpUserServiceImpl.java | 3 +- .../chanjar/weixin/mp/bean/WxMpUserQuery.java | 41 ++++----- .../weixin/mp/bean/result/WxMpUser.java | 88 ++++++++++++------- .../weixin/mp/bean/store/WxMpStoreInfo.java | 4 - .../mp/util/json/WxMpUserGsonAdapter.java | 12 ++- .../mp/api/WxXmlMpInMemoryConfigStorage.java | 4 - .../mp/api/impl/WxMpStoreServiceImplTest.java | 4 - .../mp/api/impl/WxMpUserServiceImplTest.java | 42 +++++---- 9 files changed, 131 insertions(+), 88 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/GsonHelper.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/GsonHelper.java index 3c106fbf..ec30c6b0 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/GsonHelper.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/GsonHelper.java @@ -9,6 +9,10 @@ package me.chanjar.weixin.common.util.json; +import java.util.List; + +import com.google.common.collect.Lists; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -112,4 +116,21 @@ public class GsonHelper { return r == null ? 0f : r; } + public static Integer[] getIntArray(JsonObject o, String string) { + JsonArray jsonArray = getAsJsonArray(o.getAsJsonArray(string)); + if (jsonArray == null) { + return null; + } + + List result = Lists.newArrayList(); + for (int i = 0; i < jsonArray.size(); i++) { + result.add(jsonArray.get(i).getAsInt()); + } + + return result.toArray(new Integer[0]); + } + + public static JsonArray getAsJsonArray(JsonElement element) { + return element == null ? null : element.getAsJsonArray(); + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java index 6af109e7..09557ed2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java @@ -56,7 +56,8 @@ public class WxMpUserServiceImpl implements WxMpUserService { @Override public List userInfoList(WxMpUserQuery userQuery) throws WxErrorException { String url = API_URL_PREFIX + "/info/batchget"; - String responseContent = this.wxMpService.execute(new SimplePostRequestExecutor(), url, userQuery.toJsonString()); + String responseContent = this.wxMpService.post(url, + userQuery.toJsonString()); return WxMpUser.fromJsonList(responseContent); } 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 f16c004c..e97389b8 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 @@ -24,22 +24,22 @@ public class WxMpUserQuery { /** * 语言使用默认(zh_CN) * - * @param openIdList + * @param openids */ - public WxMpUserQuery(List openIdList) { + public WxMpUserQuery(List openids) { super(); - add(openIdList); + add(openids); } /** * 添加OpenId列表,语言使用默认(zh_CN) * - * @param openIdList + * @param openids * @return {@link WxMpUserQuery} */ - public WxMpUserQuery add(List openIdList) { - for (String openId : openIdList) { - this.add(openId); + public WxMpUserQuery add(List openids) { + for (String openid : openids) { + this.add(openid); } return this; } @@ -47,12 +47,12 @@ public class WxMpUserQuery { /** * 添加一个OpenId * - * @param openId + * @param openid * @param lang 国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语 * @return {@link WxMpUserQuery} */ - public WxMpUserQuery add(String openId, String lang) { - this.queryParamList.add(new WxMpUserQueryParam(openId, lang)); + public WxMpUserQuery add(String openid, String lang) { + this.queryParamList.add(new WxMpUserQueryParam(openid, lang)); return this; } @@ -63,34 +63,34 @@ public class WxMpUserQuery { * 该方法默认lang = zh_CN * * - * @param openId + * @param openid * @return {@link WxMpUserQuery} */ - public WxMpUserQuery add(String openId) { - this.queryParamList.add(new WxMpUserQueryParam(openId)); + public WxMpUserQuery add(String openid) { + this.queryParamList.add(new WxMpUserQueryParam(openid)); return this; } /** * 删除指定的OpenId,语言使用默认(zh_CN) * - * @param openId + * @param openid * @return {@link WxMpUserQuery} */ - public WxMpUserQuery remove(String openId) { - this.queryParamList.remove(new WxMpUserQueryParam(openId)); + public WxMpUserQuery remove(String openid) { + this.queryParamList.remove(new WxMpUserQueryParam(openid)); return this; } /** * 删除指定的OpenId * - * @param openId + * @param openid * @param lang 国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语 * @return {@link WxMpUserQuery} */ - public WxMpUserQuery remove(String openId, String lang) { - this.queryParamList.remove(new WxMpUserQueryParam(openId, lang)); + public WxMpUserQuery remove(String openid, String lang) { + this.queryParamList.remove(new WxMpUserQueryParam(openid, lang)); return this; } @@ -110,9 +110,6 @@ public class WxMpUserQuery { // 查询参数封装 public class WxMpUserQueryParam implements Serializable { - /** - * @fields serialVersionUID - */ private static final long serialVersionUID = -6863571795702385319L; private String openid; private String lang; 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 76670f02..19d03abf 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 @@ -4,6 +4,9 @@ import java.io.Serializable; import java.lang.reflect.Type; import java.util.List; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; @@ -17,91 +20,111 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; */ public class WxMpUser implements Serializable { - /** - * @fields serialVersionUID - */ private static final long serialVersionUID = 5788154322646488738L; - protected Boolean subscribe; - protected String openId; - protected String nickname; - protected String sex; - protected String language; - protected String city; - protected String province; - protected String country; - protected String headImgUrl; - protected Long subscribeTime; - protected String unionId; - protected Integer sexId; - protected String remark; - protected Integer groupId; + private Boolean subscribe; + private String openId; + private String nickname; + private String sex; + private String language; + private String city; + private String province; + private String country; + private String headImgUrl; + private Long subscribeTime; + private String unionId; + private Integer sexId; + private String remark; + private Integer groupId; + private Integer[] tagIds; public Boolean getSubscribe() { return this.subscribe; } + public Boolean isSubscribe() { 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; } @@ -118,22 +141,34 @@ public class WxMpUser implements Serializable { 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 Integer[] getTagIds() { + return this.tagIds; + } + + public void setTagIds(Integer[] tagIds) { + this.tagIds = tagIds; + } + public static WxMpUser fromJson(String json) { return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxMpUser.class); } public static List fromJsonList(String json) { - Type collectionType = new TypeToken>() {}.getType(); + Type collectionType = new TypeToken>() { + }.getType(); Gson gson = WxMpGsonBuilder.INSTANCE.create(); JsonObject jsonObject = gson.fromJson(json, JsonObject.class); return gson.fromJson(jsonObject.get("user_info_list"), collectionType); @@ -141,20 +176,7 @@ public class WxMpUser implements Serializable { @Override public String toString() { - return "WxMpUser{" + - "subscribe=" + this.subscribe + - ", openId='" + this.openId + '\'' + - ", nickname='" + this.nickname + '\'' + - ", sex='" + this.sex + '\'' + - ", language='" + this.language + '\'' + - ", city='" + this.city + '\'' + - ", province='" + this.province + '\'' + - ", country='" + this.country + '\'' + - ", headImgUrl='" + this.headImgUrl + '\'' + - ", subscribeTime=" + this.subscribeTime + - ", unionId='" + this.unionId + '\'' + - ", remark='" + this.remark + '\'' + - ", groupId='" + this.groupId + '\'' + - '}'; + return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); } + } 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 eae6dc6e..48b01822 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,7 +1,3 @@ -/** - * Copyright(c) 2011-2016 by UCredit Inc. - * All Rights Reserved - */ package me.chanjar.weixin.mp.bean.store; import org.apache.commons.lang3.builder.ToStringBuilder; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpUserGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpUserGsonAdapter.java index f580a470..7bd1ed80 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpUserGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpUserGsonAdapter.java @@ -8,12 +8,17 @@ */ package me.chanjar.weixin.mp.util.json; -import com.google.gson.*; +import java.lang.reflect.Type; + +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.result.WxMpUser; -import java.lang.reflect.Type; - public class WxMpUserGsonAdapter implements JsonDeserializer { @Override @@ -36,6 +41,7 @@ public class WxMpUserGsonAdapter implements JsonDeserializer { Integer sexId = GsonHelper.getInteger(o, "sex"); wxMpUser.setRemark(GsonHelper.getString(o, "remark")); wxMpUser.setGroupId(GsonHelper.getInteger(o, "groupid")); + wxMpUser.setTagIds(GsonHelper.getIntArray(o, "tagid_list")); wxMpUser.setSexId(sexId); if(new Integer(1).equals(sexId)) { wxMpUser.setSex("男"); diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxXmlMpInMemoryConfigStorage.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxXmlMpInMemoryConfigStorage.java index 6b28f196..c9835a0a 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxXmlMpInMemoryConfigStorage.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxXmlMpInMemoryConfigStorage.java @@ -1,7 +1,3 @@ -/** - * Copyright(c) 2011-2016 by UCredit Inc. - * All Rights Reserved - */ package me.chanjar.weixin.mp.api; import org.apache.commons.lang3.builder.ToStringBuilder; 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 9c01c431..9c28dfa7 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 @@ -1,7 +1,3 @@ -/** - * Copyright(c) 2011-2016 by UCredit Inc. - * All Rights Reserved - */ package me.chanjar.weixin.mp.api.impl; import static org.junit.Assert.assertNotNull; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java index 4133d3a3..4242df10 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImplTest.java @@ -1,10 +1,11 @@ - + package me.chanjar.weixin.mp.api.impl; import java.util.ArrayList; import java.util.List; import org.testng.Assert; +import org.testng.annotations.BeforeTest; import org.testng.annotations.Guice; import org.testng.annotations.Test; @@ -28,34 +29,42 @@ import me.chanjar.weixin.mp.bean.result.WxMpUserList; public class WxMpUserServiceImplTest { @Inject - protected WxMpServiceImpl wxService; + private WxMpServiceImpl wxService; + + private WxXmlMpInMemoryConfigStorage configProvider; + + @BeforeTest + public void setup() { + this.configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService + .getWxMpConfigStorage(); + } public void testUserUpdateRemark() throws WxErrorException { - WxXmlMpInMemoryConfigStorage configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); - this.wxService.getUserService().userUpdateRemark(configProvider.getOpenid(), "测试备注名"); + this.wxService.getUserService() + .userUpdateRemark(this.configProvider.getOpenid(), "测试备注名"); } public void testUserInfo() throws WxErrorException { - WxXmlMpInMemoryConfigStorage configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); - WxMpUser user = this.wxService.getUserService().userInfo(configProvider.getOpenid(), null); + WxMpUser user = this.wxService.getUserService() + .userInfo(this.configProvider.getOpenid(), null); Assert.assertNotNull(user); System.out.println(user); } - + public void testUserInfoList() throws WxErrorException { - WxXmlMpInMemoryConfigStorage configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); - List openIdList = new ArrayList<>(); - openIdList.add(configProvider.getOpenid()); - List userList = this.wxService.getUserService().userInfoList(openIdList); + List openids = new ArrayList<>(); + openids.add(this.configProvider.getOpenid()); + List userList = this.wxService.getUserService() + .userInfoList(openids); Assert.assertEquals(userList.size(), 1); - System.out.println(userList); + System.out.println(userList); } - + public void testUserInfoListByWxMpUserQuery() throws WxErrorException { - WxXmlMpInMemoryConfigStorage configProvider = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); WxMpUserQuery query = new WxMpUserQuery(); - query.add(configProvider.getOpenid(), "zh_CN"); - List userList = this.wxService.getUserService().userInfoList(query); + query.add(this.configProvider.getOpenid(), "zh_CN"); + List userList = this.wxService.getUserService() + .userInfoList(query); Assert.assertEquals(userList.size(), 1); System.out.println(userList); } @@ -68,6 +77,5 @@ public class WxMpUserServiceImplTest { Assert.assertFalse(wxMpUserList.getOpenIds().size() == -1); System.out.println(wxMpUserList); } - } From 815ea188e70fb1fe53f755fdd8765c473fe82d7f Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Wed, 28 Sep 2016 14:00:07 +0800 Subject: [PATCH 05/76] =?UTF-8?q?=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/impl/WxMpUserServiceImpl.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java index 09557ed2..9267407c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpUserServiceImpl.java @@ -5,8 +5,6 @@ import java.util.List; import com.google.gson.JsonObject; import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; -import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpUserService; import me.chanjar.weixin.mp.bean.WxMpUserQuery; @@ -30,27 +28,30 @@ public class WxMpUserServiceImpl implements WxMpUserService { JsonObject json = new JsonObject(); json.addProperty("openid", openid); json.addProperty("remark", remark); - this.wxMpService.execute(new SimplePostRequestExecutor(), url, json.toString()); + this.wxMpService.post(url, json.toString()); } @Override public WxMpUser userInfo(String openid, String lang) throws WxErrorException { String url = API_URL_PREFIX + "/info"; lang = lang == null ? "zh_CN" : lang; - String responseContent = this.wxMpService.execute(new SimpleGetRequestExecutor(), url, "openid=" + openid + "&lang=" + lang); + String responseContent = this.wxMpService.get(url, + "openid=" + openid + "&lang=" + lang); return WxMpUser.fromJson(responseContent); } @Override public WxMpUserList userList(String next_openid) throws WxErrorException { String url = API_URL_PREFIX + "/get"; - String responseContent = this.wxMpService.execute(new SimpleGetRequestExecutor(), url, next_openid == null ? null : "next_openid=" + next_openid); + String responseContent = this.wxMpService.get(url, + next_openid == null ? null : "next_openid=" + next_openid); return WxMpUserList.fromJson(responseContent); } @Override - public List userInfoList(List openidList) throws WxErrorException { - return userInfoList(new WxMpUserQuery(openidList)); + public List userInfoList(List openids) + throws WxErrorException { + return this.userInfoList(new WxMpUserQuery(openids)); } @Override From 74a0ada3f11f3685965165159c0d2378ceb4ed6b Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Wed, 28 Sep 2016 15:57:43 +0800 Subject: [PATCH 06/76] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E4=BD=9C=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/chanjar/weixin/mp/api/WxMpCardService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCardService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCardService.java index 80bf38a6..d4a36c65 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCardService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpCardService.java @@ -6,8 +6,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpCardResult; /** * 卡券相关接口 - * Created by Binary Wang on 2016/7/27. - * @author binarywang(https://github.com/binarywang) + * @author YuJian(mgcnrx11@hotmail.com) on 01/11/2016 */ public interface WxMpCardService { From 1352385328f133796d1a56d163c51ef493ab1009 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Wed, 28 Sep 2016 18:47:03 +0800 Subject: [PATCH 07/76] =?UTF-8?q?=E7=A7=BB=E9=99=A4Group=E7=9B=B8=E5=85=B3?= =?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/WxMpGroupService.java | 71 ---------------- .../me/chanjar/weixin/mp/api/WxMpService.java | 8 -- .../mp/api/impl/WxMpGroupServiceImpl.java | 84 ------------------- .../weixin/mp/api/impl/WxMpServiceImpl.java | 70 ++++------------ .../mp/api/impl/WxMpGroupServiceImplTest.java | 62 -------------- weixin-java-mp/src/test/resources/testng.xml | 3 - 6 files changed, 16 insertions(+), 282 deletions(-) delete mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGroupService.java delete mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGroupServiceImpl.java delete mode 100644 weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGroupServiceImplTest.java diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGroupService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGroupService.java deleted file mode 100644 index 22255d36..00000000 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGroupService.java +++ /dev/null @@ -1,71 +0,0 @@ -package me.chanjar.weixin.mp.api; - -import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.bean.WxMpGroup; - -import java.util.List; - -/** - * 用户分组相关操作接口 - * @author Binary Wang - * 分组接口属于老接口,不知道啥时候被替换成用户标签接口 - * - */ -@Deprecated -public interface WxMpGroupService { - - - /** - *
-   * 分组管理接口 - 创建分组
-   * 最多支持创建500个分组
-   * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=分组管理接口
-   * 
- * - * @param name 分组名字(30个字符以内) - */ - WxMpGroup groupCreate(String name) throws WxErrorException; - - /** - *
-   * 分组管理接口 - 查询所有分组
-   * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=分组管理接口
-   * 
- */ - List groupGet() throws WxErrorException; - - /** - *
-   * 分组管理接口 - 查询用户所在分组
-   * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=分组管理接口
-   * 
- * - * @param openid 微信用户的openid - */ - long userGetGroup(String openid) throws WxErrorException; - - /** - *
-   * 分组管理接口 - 修改分组名
-   * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=分组管理接口
-   *
-   * 如果id为0(未分组),1(黑名单),2(星标组),或者不存在的id,微信会返回系统繁忙的错误
-   * 
- * - * @param group 要更新的group,group的id,name必须设置 - */ - void groupUpdate(WxMpGroup group) throws WxErrorException; - - /** - *
-   * 分组管理接口 - 移动用户分组
-   * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=分组管理接口
-   *
-   * 如果to_groupid为0(未分组),1(黑名单),2(星标组),或者不存在的id,微信会返回系统繁忙的错误
-   * 
- * - * @param openid 用户openid - * @param to_groupid 移动到的分组id - */ - void userUpdateGroup(String openid, long to_groupid) 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 3b7f2125..5eca1192 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 @@ -322,14 +322,6 @@ public interface WxMpService { */ WxMpUserService getUserService(); - /** - * 返回用户分组相关接口方法的实现类对象,以方便调用个其各种接口 - * - * @return WxMpGroupService - */ - - WxMpGroupService getGroupService(); - /** * 返回用户标签相关接口方法的实现类对象,以方便调用个其各种接口 * diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGroupServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGroupServiceImpl.java deleted file mode 100644 index bfceff61..00000000 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGroupServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package me.chanjar.weixin.mp.api.impl; - -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.common.util.http.SimpleGetRequestExecutor; -import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; -import me.chanjar.weixin.common.util.json.GsonHelper; -import me.chanjar.weixin.mp.api.WxMpGroupService; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.WxMpGroup; -import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; - -import java.util.List; - -/** - * Created by Binary Wang on 2016/7/21. - */ -@Deprecated -public class WxMpGroupServiceImpl implements WxMpGroupService { - private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/groups"; - private WxMpService wxMpService; - - public WxMpGroupServiceImpl(WxMpService wxMpService) { - this.wxMpService = wxMpService; - } - - @Override - public WxMpGroup groupCreate(String name) throws WxErrorException { - String url = API_URL_PREFIX + "/create"; - JsonObject json = new JsonObject(); - JsonObject groupJson = new JsonObject(); - json.add("group", groupJson); - groupJson.addProperty("name", name); - - String responseContent = this.wxMpService.execute( - new SimplePostRequestExecutor(), - url, - json.toString()); - return WxMpGroup.fromJson(responseContent); - } - - @Override - public List groupGet() throws WxErrorException { - String url = API_URL_PREFIX + "/get"; - String responseContent = this.wxMpService.execute(new SimpleGetRequestExecutor(), url, null); - /* - * 操蛋的微信API,创建时返回的是 { group : { id : ..., name : ...} } - * 查询时返回的是 { groups : [ { id : ..., name : ..., count : ... }, ... ] } - */ - JsonElement tmpJsonElement = new JsonParser().parse(responseContent); - return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement.getAsJsonObject().get("groups"), - new TypeToken>() { - }.getType()); - } - - @Override - public long userGetGroup(String openid) throws WxErrorException { - String url = API_URL_PREFIX + "/getid"; - JsonObject o = new JsonObject(); - o.addProperty("openid", openid); - String responseContent = this.wxMpService.execute(new SimplePostRequestExecutor(), url, o.toString()); - JsonElement tmpJsonElement = new JsonParser().parse(responseContent); - return GsonHelper.getAsLong(tmpJsonElement.getAsJsonObject().get("groupid")); - } - - @Override - public void groupUpdate(WxMpGroup group) throws WxErrorException { - String url = API_URL_PREFIX + "/update"; - this.wxMpService.execute(new SimplePostRequestExecutor(), url, group.toJson()); - } - - @Override - public void userUpdateGroup(String openid, long to_groupid) throws WxErrorException { - String url = API_URL_PREFIX + "/members/update"; - JsonObject json = new JsonObject(); - json.addProperty("openid", openid); - json.addProperty("to_groupid", to_groupid); - this.wxMpService.execute(new SimplePostRequestExecutor(), url, json.toString()); - } - -} 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 ba3fcdfc..ef1f8e87 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 @@ -1,23 +1,9 @@ package me.chanjar.weixin.mp.api.impl; -import java.io.IOException; - -import org.apache.http.HttpHost; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.conn.ssl.DefaultHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.impl.client.BasicResponseHandler; -import org.apache.http.impl.client.CloseableHttpClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; - import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.bean.result.WxError; @@ -26,39 +12,22 @@ import me.chanjar.weixin.common.session.StandardSessionManager; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.common.util.RandomUtils; import me.chanjar.weixin.common.util.crypto.SHA1; -import me.chanjar.weixin.common.util.http.ApacheHttpClientBuilder; -import me.chanjar.weixin.common.util.http.DefaultApacheHttpClientBuilder; -import me.chanjar.weixin.common.util.http.RequestExecutor; -import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; -import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; -import me.chanjar.weixin.common.util.http.URIUtil; -import me.chanjar.weixin.mp.api.WxMpCardService; -import me.chanjar.weixin.mp.api.WxMpConfigStorage; -import me.chanjar.weixin.mp.api.WxMpDataCubeService; -import me.chanjar.weixin.mp.api.WxMpGroupService; -import me.chanjar.weixin.mp.api.WxMpKefuService; -import me.chanjar.weixin.mp.api.WxMpMaterialService; -import me.chanjar.weixin.mp.api.WxMpMenuService; -import me.chanjar.weixin.mp.api.WxMpPayService; -import me.chanjar.weixin.mp.api.WxMpQrcodeService; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.WxMpStoreService; -import me.chanjar.weixin.mp.api.WxMpUserBlacklistService; -import me.chanjar.weixin.mp.api.WxMpUserService; -import me.chanjar.weixin.mp.api.WxMpUserTagService; -import me.chanjar.weixin.mp.bean.WxMpIndustry; -import me.chanjar.weixin.mp.bean.WxMpMassGroupMessage; -import me.chanjar.weixin.mp.bean.WxMpMassNews; -import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage; -import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage; -import me.chanjar.weixin.mp.bean.WxMpMassVideo; -import me.chanjar.weixin.mp.bean.WxMpSemanticQuery; -import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; -import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; -import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult; -import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken; -import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult; -import me.chanjar.weixin.mp.bean.result.WxMpUser; +import me.chanjar.weixin.common.util.http.*; +import me.chanjar.weixin.mp.api.*; +import me.chanjar.weixin.mp.bean.*; +import me.chanjar.weixin.mp.bean.result.*; +import org.apache.http.HttpHost; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.conn.ssl.DefaultHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.CloseableHttpClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; public class WxMpServiceImpl implements WxMpService { @@ -86,8 +55,6 @@ public class WxMpServiceImpl implements WxMpService { private WxMpUserService userService = new WxMpUserServiceImpl(this); - private WxMpGroupService groupService = new WxMpGroupServiceImpl(this); - private WxMpUserTagService tagService = new WxMpUserTagServiceImpl(this); private WxMpQrcodeService qrCodeService = new WxMpQrcodeServiceImpl(this); @@ -559,11 +526,6 @@ public class WxMpServiceImpl implements WxMpService { return this.userService; } - @Override - public WxMpGroupService getGroupService() { - return this.groupService; - } - @Override public WxMpUserTagService getUserTagService() { return this.tagService; diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGroupServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGroupServiceImplTest.java deleted file mode 100644 index 2216e553..00000000 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpGroupServiceImplTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package me.chanjar.weixin.mp.api.impl; - -import com.google.inject.Inject; -import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.api.ApiTestModule; -import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; -import me.chanjar.weixin.mp.bean.WxMpGroup; -import org.testng.Assert; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import java.util.List; - -/** - * 测试分组接口 - * - * @author chanjarster - */ -@Deprecated -@Test(groups = "groupAPI") -@Guice(modules = ApiTestModule.class) -public class WxMpGroupServiceImplTest { - - @Inject - protected WxMpServiceImpl wxService; - - protected WxMpGroup group; - - public void testGroupCreate() throws WxErrorException { - WxMpGroup res = this.wxService.getGroupService().groupCreate("测试分组1"); - Assert.assertEquals(res.getName(), "测试分组1"); - } - - @Test(dependsOnMethods="testGroupCreate") - public void testGroupGet() throws WxErrorException { - List groupList = this.wxService.getGroupService().groupGet(); - Assert.assertNotNull(groupList); - Assert.assertTrue(groupList.size() > 0); - for (WxMpGroup g : groupList) { - this.group = g; - Assert.assertNotNull(g.getName()); - } - } - - @Test(dependsOnMethods={"testGroupGet", "testGroupCreate"}) - public void getGroupUpdate() throws WxErrorException { - this.group.setName("分组改名"); - this.wxService.getGroupService().groupUpdate(this.group); - } - - public void testGroupQueryUserGroup() throws WxErrorException { - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); - long groupid = this.wxService.getGroupService().userGetGroup(configStorage.getOpenid()); - Assert.assertTrue(groupid != -1l); - } - - public void testGroupMoveUser() throws WxErrorException { - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage(); - this.wxService.getGroupService().userUpdateGroup(configStorage.getOpenid(), this.wxService.getGroupService().groupGet().get(3).getId()); - } - -} diff --git a/weixin-java-mp/src/test/resources/testng.xml b/weixin-java-mp/src/test/resources/testng.xml index d821e398..6d5310ce 100644 --- a/weixin-java-mp/src/test/resources/testng.xml +++ b/weixin-java-mp/src/test/resources/testng.xml @@ -5,9 +5,6 @@ - - - From f2a858db7a53a46bf0cdcd55e0eabee452e5a0f6 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Wed, 28 Sep 2016 19:00:46 +0800 Subject: [PATCH 08/76] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=A7=BB=E9=99=A4group?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E5=90=8E=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/api/WxMpService.java | 8 +-- .../weixin/mp/api/WxMpUserTagService.java | 15 +++--- .../weixin/mp/api/impl/WxMpServiceImpl.java | 2 +- .../mp/api/impl/WxMpUserTagServiceImpl.java | 25 +++++---- .../me/chanjar/weixin/mp/bean/WxMpGroup.java | 52 ------------------- ...upMessage.java => WxMpMassTagMessage.java} | 25 ++++----- .../chanjar/weixin/mp/bean/tag/WxUserTag.java | 6 +-- .../mp/util/json/WxMpGroupGsonAdapter.java | 49 ----------------- .../weixin/mp/util/json/WxMpGsonBuilder.java | 32 ++++++++++-- ...ava => WxMpMassTagMessageGsonAdapter.java} | 10 ++-- .../weixin/mp/api/WxMpMassMessageAPITest.java | 10 ++-- .../api/impl/WxMpUserTagServiceImplTest.java | 14 ++--- 12 files changed, 88 insertions(+), 160 deletions(-) delete mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpGroup.java rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/{WxMpMassGroupMessage.java => WxMpMassTagMessage.java} (82%) delete mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGroupGsonAdapter.java rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/{WxMpMassGroupMessageGsonAdapter.java => WxMpMassTagMessageGsonAdapter.java} (85%) 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 5eca1192..292c5645 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 @@ -4,7 +4,7 @@ import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.mp.bean.WxMpIndustry; -import me.chanjar.weixin.mp.bean.WxMpMassGroupMessage; +import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; import me.chanjar.weixin.mp.bean.WxMpMassNews; import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage; import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage; @@ -88,7 +88,7 @@ public interface WxMpService { * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 * * - * @see #massGroupMessageSend(me.chanjar.weixin.mp.bean.WxMpMassGroupMessage) + * @see #massGroupMessageSend(me.chanjar.weixin.mp.bean.WxMpMassTagMessage) * @see #massOpenIdsMessageSend(me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage) */ WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException; @@ -99,7 +99,7 @@ public interface WxMpService { * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 * * - * @see #massGroupMessageSend(me.chanjar.weixin.mp.bean.WxMpMassGroupMessage) + * @see #massGroupMessageSend(me.chanjar.weixin.mp.bean.WxMpMassTagMessage) * @see #massOpenIdsMessageSend(me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage) */ WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException; @@ -112,7 +112,7 @@ public interface WxMpService { * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口 * */ - WxMpMassSendResult massGroupMessageSend(WxMpMassGroupMessage message) throws WxErrorException; + WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException; /** *
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 406842db..0fcfb40f 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
@@ -1,11 +1,11 @@
 package me.chanjar.weixin.mp.api;
 
+import java.util.List;
+
 import me.chanjar.weixin.common.exception.WxErrorException;
 import me.chanjar.weixin.mp.bean.tag.WxTagListUser;
 import me.chanjar.weixin.mp.bean.tag.WxUserTag;
 
-import java.util.List;
-
 /**
  * 用户标签管理相关接口
  * Created by Binary Wang on 2016/9/2.
@@ -44,7 +44,7 @@ public interface WxMpUserTagService {
    * 
* */ - Boolean tagUpdate(Integer id, String name) throws WxErrorException; + Boolean tagUpdate(Long tagId, String name) throws WxErrorException; /** *
@@ -54,7 +54,7 @@ public interface WxMpUserTagService {
    * 
* */ - Boolean tagDelete(Integer id) throws WxErrorException; + Boolean tagDelete(Long tagId) throws WxErrorException; /** *
@@ -64,7 +64,8 @@ public interface WxMpUserTagService {
    * 
* */ - WxTagListUser tagListUser(Integer tagId, String nextOpenid) throws WxErrorException; + WxTagListUser tagListUser(Long tagId, String nextOpenid) + throws WxErrorException; /** *
@@ -74,7 +75,7 @@ public interface WxMpUserTagService {
    * 
* */ - boolean batchTagging(Integer tagId, String[] openids) throws WxErrorException; + boolean batchTagging(Long tagId, String[] openids) throws WxErrorException; /** *
@@ -84,7 +85,7 @@ public interface WxMpUserTagService {
    * 
* */ - boolean batchUntagging(Integer tagId, String[] openids) throws WxErrorException; + boolean batchUntagging(Long tagId, String[] openids) throws WxErrorException; /** 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 ef1f8e87..0a28ce17 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 @@ -190,7 +190,7 @@ public class WxMpServiceImpl implements WxMpService { } @Override - public WxMpMassSendResult massGroupMessageSend(WxMpMassGroupMessage message) throws WxErrorException { + public WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall"; String responseContent = execute(new SimplePostRequestExecutor(), url, message.toJson()); return WxMpMassSendResult.fromJson(responseContent); 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 d2bb3213..3f6a4dba 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 @@ -1,9 +1,16 @@ package me.chanjar.weixin.mp.api.impl; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; + import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; @@ -11,11 +18,6 @@ import me.chanjar.weixin.mp.api.WxMpUserTagService; import me.chanjar.weixin.mp.bean.tag.WxTagListUser; import me.chanjar.weixin.mp.bean.tag.WxUserTag; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; /** * @@ -58,7 +60,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { } @Override - public Boolean tagUpdate(Integer id, String name) throws WxErrorException { + public Boolean tagUpdate(Long id, String name) throws WxErrorException { String url = API_URL_PREFIX + "/update"; JsonObject json = new JsonObject(); @@ -78,7 +80,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { } @Override - public Boolean tagDelete(Integer id) throws WxErrorException { + public Boolean tagDelete(Long id) throws WxErrorException { String url = API_URL_PREFIX + "/delete"; JsonObject json = new JsonObject(); @@ -98,7 +100,8 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { } @Override - public WxTagListUser tagListUser(Integer tagId, String nextOpenid) throws WxErrorException { + public WxTagListUser tagListUser(Long tagId, String nextOpenid) + throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/user/tag/get"; JsonObject json = new JsonObject(); @@ -112,7 +115,8 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { } @Override - public boolean batchTagging(Integer tagId, String[] openids) throws WxErrorException { + public boolean batchTagging(Long tagId, String[] openids) + throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging"; JsonObject json = new JsonObject(); @@ -135,7 +139,8 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { } @Override - public boolean batchUntagging(Integer tagId, String[] openids) throws WxErrorException { + public boolean batchUntagging(Long tagId, String[] openids) + throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging"; JsonObject json = new JsonObject(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpGroup.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpGroup.java deleted file mode 100644 index 7dfd4ccc..00000000 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpGroup.java +++ /dev/null @@ -1,52 +0,0 @@ -package me.chanjar.weixin.mp.bean; - -import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; - -import java.io.Serializable; - -/** - * 微信用户分组 - * @author chanjarster - * - */ -public class WxMpGroup implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1554709708638735270L; - private long id = -1; - private String name; - private long count; - public long getId() { - return this.id; - } - public void setId(long id) { - this.id = id; - } - public String getName() { - return this.name; - } - public void setName(String name) { - this.name = name; - } - public long getCount() { - return this.count; - } - public void setCount(long count) { - this.count = count; - } - - public static WxMpGroup fromJson(String json) { - return WxMpGsonBuilder.create().fromJson(json, WxMpGroup.class); - } - - public String toJson() { - return WxMpGsonBuilder.create().toJson(this); - } - @Override - public String toString() { - return "WxMpGroup [id=" + this.id + ", name=" + this.name + ", count=" + this.count + "]"; - } - -} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassGroupMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java similarity index 82% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassGroupMessage.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java index d77605a6..300b4f90 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassGroupMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMassTagMessage.java @@ -1,26 +1,23 @@ package me.chanjar.weixin.mp.bean; -import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; - import java.io.Serializable; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + /** - * 分组群发的消息 + * 按标签群发的消息 * * @author chanjarster */ -public class WxMpMassGroupMessage implements Serializable { +public class WxMpMassTagMessage implements Serializable { - /** - * - */ private static final long serialVersionUID = -6625914040986749286L; - private Long groupId; + private Long tagId; private String msgtype; private String content; private String mediaId; - public WxMpMassGroupMessage() { + public WxMpMassTagMessage() { super(); } @@ -64,16 +61,16 @@ public class WxMpMassGroupMessage implements Serializable { return WxMpGsonBuilder.INSTANCE.create().toJson(this); } - public Long getGroupId() { - return this.groupId; + public Long getTagId() { + return this.tagId; } /** * 如果不设置则就意味着发给所有用户 - * @param groupId + * @param tagId */ - public void setGroupId(Long groupId) { - this.groupId = groupId; + public void setTagId(Long tagId) { + this.tagId = tagId; } } 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 d9e07d04..53e247a7 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 @@ -19,7 +19,7 @@ public class WxUserTag { /** * id 标签id,由微信分配 */ - private Integer id; + private Long id; /** * name 标签名,UTF8编码 @@ -47,11 +47,11 @@ public class WxUserTag { this.count = count; } - public Integer getId() { + public Long getId() { return this.id; } - public void setId(Integer id) { + public void setId(Long id) { this.id = id; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGroupGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGroupGsonAdapter.java deleted file mode 100644 index a6a48ed7..00000000 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGroupGsonAdapter.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved. - * - * This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended - * only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction - * arose from modification of the original source, or other redistribution of this source - * is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD. - */ -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.WxMpGroup; - -import java.lang.reflect.Type; - -public class WxMpGroupGsonAdapter implements JsonSerializer, JsonDeserializer { - - @Override - public JsonElement serialize(WxMpGroup group, Type typeOfSrc, JsonSerializationContext context) { - JsonObject json = new JsonObject(); - JsonObject groupJson = new JsonObject(); - groupJson.addProperty("name", group.getName()); - groupJson.addProperty("id", group.getId()); - groupJson.addProperty("count", group.getCount()); - json.add("group", groupJson); - return json; - } - - @Override - public WxMpGroup deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - WxMpGroup group = new WxMpGroup(); - JsonObject groupJson = json.getAsJsonObject(); - if (json.getAsJsonObject().get("group") != null) { - groupJson = json.getAsJsonObject().get("group").getAsJsonObject(); - } - if (groupJson.get("name") != null && !groupJson.get("name").isJsonNull()) { - group.setName(GsonHelper.getAsString(groupJson.get("name"))); - } - if (groupJson.get("id") != null && !groupJson.get("id").isJsonNull()) { - group.setId(GsonHelper.getAsPrimitiveLong(groupJson.get("id"))); - } - if (groupJson.get("count") != null && !groupJson.get("count").isJsonNull()) { - group.setCount(GsonHelper.getAsPrimitiveLong(groupJson.get("count"))); - } - return group; - } - -} 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 ab3d5769..df63ac64 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 @@ -2,10 +2,35 @@ package me.chanjar.weixin.mp.util.json; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import me.chanjar.weixin.mp.bean.*; + +import me.chanjar.weixin.mp.bean.WxMpCard; +import me.chanjar.weixin.mp.bean.WxMpCustomMessage; +import me.chanjar.weixin.mp.bean.WxMpIndustry; +import me.chanjar.weixin.mp.bean.WxMpMassNews; +import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage; +import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage; +import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; +import me.chanjar.weixin.mp.bean.WxMpMassVideo; +import me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate; +import me.chanjar.weixin.mp.bean.WxMpMaterialNews; +import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; -import me.chanjar.weixin.mp.bean.result.*; +import me.chanjar.weixin.mp.bean.result.WxMediaImgUploadResult; +import me.chanjar.weixin.mp.bean.result.WxMpCardResult; +import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; +import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult; +import me.chanjar.weixin.mp.bean.result.WxMpMaterialCountResult; +import me.chanjar.weixin.mp.bean.result.WxMpMaterialFileBatchGetResult; +import me.chanjar.weixin.mp.bean.result.WxMpMaterialNewsBatchGetResult; +import me.chanjar.weixin.mp.bean.result.WxMpMaterialUploadResult; +import me.chanjar.weixin.mp.bean.result.WxMpMaterialVideoInfoResult; +import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken; +import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; +import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult; +import me.chanjar.weixin.mp.bean.result.WxMpUser; +import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult; +import me.chanjar.weixin.mp.bean.result.WxMpUserList; public class WxMpGsonBuilder { @@ -15,9 +40,8 @@ public class WxMpGsonBuilder { INSTANCE.disableHtmlEscaping(); INSTANCE.registerTypeAdapter(WxMpCustomMessage.class, new WxMpCustomMessageGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpMassNews.class, new WxMpMassNewsGsonAdapter()); - INSTANCE.registerTypeAdapter(WxMpMassGroupMessage.class, new WxMpMassGroupMessageGsonAdapter()); + INSTANCE.registerTypeAdapter(WxMpMassTagMessage.class, new WxMpMassTagMessageGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpMassOpenIdsMessage.class, new WxMpMassOpenIdsMessageGsonAdapter()); - INSTANCE.registerTypeAdapter(WxMpGroup.class, new WxMpGroupGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpUser.class, new WxMpUserGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpUserList.class, new WxUserListGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpMassVideo.class, new WxMpMassVideoAdapter()); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassGroupMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java similarity index 85% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassGroupMessageGsonAdapter.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java index 4ad45848..c32fa9f8 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassGroupMessageGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java @@ -13,22 +13,22 @@ import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.WxMpMassGroupMessage; +import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; import java.lang.reflect.Type; -public class WxMpMassGroupMessageGsonAdapter implements JsonSerializer { +public class WxMpMassTagMessageGsonAdapter implements JsonSerializer { @Override - public JsonElement serialize(WxMpMassGroupMessage message, Type typeOfSrc, JsonSerializationContext context) { + public JsonElement serialize(WxMpMassTagMessage message, Type typeOfSrc, JsonSerializationContext context) { JsonObject messageJson = new JsonObject(); JsonObject filter = new JsonObject(); - if(null == message.getGroupId()) { + if(null == message.getTagId()) { filter.addProperty("is_to_all", true); } else { filter.addProperty("is_to_all", false); - filter.addProperty("group_id", message.getGroupId()); + filter.addProperty("group_id", message.getTagId()); } messageJson.add("filter", filter); 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/WxMpMassMessageAPITest.java index 3f2c28b8..e093d575 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/WxMpMassMessageAPITest.java @@ -14,9 +14,9 @@ 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.impl.WxMpServiceImpl; -import me.chanjar.weixin.mp.bean.WxMpMassGroupMessage; import me.chanjar.weixin.mp.bean.WxMpMassNews; import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage; +import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; import me.chanjar.weixin.mp.bean.WxMpMassVideo; import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult; @@ -68,11 +68,11 @@ public class WxMpMassMessageAPITest { @Test public void testTextMassGroupMessageSend() throws WxErrorException { - WxMpMassGroupMessage massMessage = new WxMpMassGroupMessage(); + WxMpMassTagMessage massMessage = new WxMpMassTagMessage(); massMessage.setMsgtype(WxConsts.MASS_MSG_TEXT); massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World"); massMessage - .setGroupId(this.wxService.getGroupService().groupGet().get(0).getId()); + .setTagId(this.wxService.getUserTagService().tagGet().get(0).getId()); WxMpMassSendResult massResult = this.wxService .massGroupMessageSend(massMessage); @@ -83,11 +83,11 @@ public class WxMpMassMessageAPITest { @Test(dataProvider="massMessages") public void testMediaMassGroupMessageSend(String massMsgType, String mediaId) throws WxErrorException { - WxMpMassGroupMessage massMessage = new WxMpMassGroupMessage(); + WxMpMassTagMessage massMessage = new WxMpMassTagMessage(); massMessage.setMsgtype(massMsgType); massMessage.setMediaId(mediaId); massMessage - .setGroupId(this.wxService.getGroupService().groupGet().get(0).getId()); + .setTagId(this.wxService.getUserTagService().tagGet().get(0).getId()); WxMpMassSendResult massResult = this.wxService .massGroupMessageSend(massMessage); 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 74a6cfc4..9fc579c9 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 @@ -1,15 +1,17 @@ package me.chanjar.weixin.mp.api.impl; +import java.util.List; + +import org.testng.Assert; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + import com.google.inject.Inject; + import me.chanjar.weixin.mp.api.ApiTestModule; import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; import me.chanjar.weixin.mp.bean.tag.WxTagListUser; import me.chanjar.weixin.mp.bean.tag.WxUserTag; -import org.testng.Assert; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import java.util.List; /** * @@ -22,7 +24,7 @@ public class WxMpUserTagServiceImplTest { @Inject protected WxMpServiceImpl wxService; - private Integer tagId = 2; + private Long tagId = 2L; @Test public void testTagCreate() throws Exception { From d7e35a1c5630f3e357a727ffec4f568b3ef7ff2b Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Wed, 28 Sep 2016 19:01:28 +0800 Subject: [PATCH 09/76] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/util/json/WxMpMassTagMessageGsonAdapter.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 c32fa9f8..6514ed59 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 @@ -8,15 +8,16 @@ */ package me.chanjar.weixin.mp.util.json; +import java.lang.reflect.Type; + import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; + import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; -import java.lang.reflect.Type; - public class WxMpMassTagMessageGsonAdapter implements JsonSerializer { @Override @@ -28,7 +29,7 @@ public class WxMpMassTagMessageGsonAdapter implements JsonSerializer Date: Wed, 28 Sep 2016 19:15:38 +0800 Subject: [PATCH 10/76] =?UTF-8?q?=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/impl/WxMpServiceImpl.java | 80 +++++++++++++------ 1 file changed, 55 insertions(+), 25 deletions(-) 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 0a28ce17..1a7ffe84 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 @@ -1,9 +1,23 @@ package me.chanjar.weixin.mp.api.impl; +import java.io.IOException; + +import org.apache.http.HttpHost; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.conn.ssl.DefaultHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.CloseableHttpClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; + import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.bean.result.WxError; @@ -12,22 +26,38 @@ import me.chanjar.weixin.common.session.StandardSessionManager; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.common.util.RandomUtils; import me.chanjar.weixin.common.util.crypto.SHA1; -import me.chanjar.weixin.common.util.http.*; -import me.chanjar.weixin.mp.api.*; -import me.chanjar.weixin.mp.bean.*; -import me.chanjar.weixin.mp.bean.result.*; -import org.apache.http.HttpHost; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.conn.ssl.DefaultHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.impl.client.BasicResponseHandler; -import org.apache.http.impl.client.CloseableHttpClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; +import me.chanjar.weixin.common.util.http.ApacheHttpClientBuilder; +import me.chanjar.weixin.common.util.http.DefaultApacheHttpClientBuilder; +import me.chanjar.weixin.common.util.http.RequestExecutor; +import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; +import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; +import me.chanjar.weixin.common.util.http.URIUtil; +import me.chanjar.weixin.mp.api.WxMpCardService; +import me.chanjar.weixin.mp.api.WxMpConfigStorage; +import me.chanjar.weixin.mp.api.WxMpDataCubeService; +import me.chanjar.weixin.mp.api.WxMpKefuService; +import me.chanjar.weixin.mp.api.WxMpMaterialService; +import me.chanjar.weixin.mp.api.WxMpMenuService; +import me.chanjar.weixin.mp.api.WxMpPayService; +import me.chanjar.weixin.mp.api.WxMpQrcodeService; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.api.WxMpStoreService; +import me.chanjar.weixin.mp.api.WxMpUserBlacklistService; +import me.chanjar.weixin.mp.api.WxMpUserService; +import me.chanjar.weixin.mp.api.WxMpUserTagService; +import me.chanjar.weixin.mp.bean.WxMpIndustry; +import me.chanjar.weixin.mp.bean.WxMpMassNews; +import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage; +import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage; +import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; +import me.chanjar.weixin.mp.bean.WxMpMassVideo; +import me.chanjar.weixin.mp.bean.WxMpSemanticQuery; +import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; +import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; +import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult; +import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken; +import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult; +import me.chanjar.weixin.mp.bean.result.WxMpUser; public class WxMpServiceImpl implements WxMpService { @@ -178,35 +208,35 @@ public class WxMpServiceImpl implements WxMpService { @Override public WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/media/uploadnews"; - String responseContent = execute(new SimplePostRequestExecutor(), url, news.toJson()); + String responseContent = this.post(url, news.toJson()); return WxMpMassUploadResult.fromJson(responseContent); } @Override public WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/media/uploadvideo"; - String responseContent = execute(new SimplePostRequestExecutor(), url, video.toJson()); + String responseContent = this.post(url, video.toJson()); return WxMpMassUploadResult.fromJson(responseContent); } @Override public WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall"; - String responseContent = execute(new SimplePostRequestExecutor(), url, message.toJson()); + String responseContent = this.post(url, message.toJson()); return WxMpMassSendResult.fromJson(responseContent); } @Override public WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/message/mass/send"; - String responseContent = execute(new SimplePostRequestExecutor(), url, message.toJson()); + String responseContent = this.post(url, message.toJson()); return WxMpMassSendResult.fromJson(responseContent); } @Override public WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception { String url = "https://api.weixin.qq.com/cgi-bin/message/mass/preview"; - String responseContent = execute(new SimplePostRequestExecutor(), url, wxMpMassPreviewMessage.toJson()); + String responseContent = this.post(url, wxMpMassPreviewMessage.toJson()); return WxMpMassSendResult.fromJson(responseContent); } @@ -216,7 +246,7 @@ public class WxMpServiceImpl implements WxMpService { JsonObject o = new JsonObject(); o.addProperty("action", "long2short"); o.addProperty("long_url", long_url); - String responseContent = execute(new SimplePostRequestExecutor(), url, o.toString()); + String responseContent = this.post(url, o.toString()); JsonElement tmpJsonElement = JSON_PARSER.parse(responseContent); return tmpJsonElement.getAsJsonObject().get("short_url").getAsString(); } @@ -240,20 +270,20 @@ public class WxMpServiceImpl implements WxMpService { throw new IllegalArgumentException("industry id is empty"); } String url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry"; - return execute(new SimplePostRequestExecutor(), url, wxMpIndustry.toJson()); + return this.post(url, wxMpIndustry.toJson()); } @Override public WxMpIndustry getIndustry() throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/template/get_industry"; - String responseContent = execute(new SimpleGetRequestExecutor(), url, null); + String responseContent = this.get(url, null); return WxMpIndustry.fromJson(responseContent); } @Override public WxMpSemanticQueryResult semanticQuery(WxMpSemanticQuery semanticQuery) throws WxErrorException { String url = "https://api.weixin.qq.com/semantic/semproxy/search"; - String responseContent = execute(new SimplePostRequestExecutor(), url, semanticQuery.toJson()); + String responseContent = this.post(url, semanticQuery.toJson()); return WxMpSemanticQueryResult.fromJson(responseContent); } From 74783618247914b4eb515f22c4b9a603a109c26f Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Wed, 28 Sep 2016 19:45:07 +0800 Subject: [PATCH 11/76] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=9A=84=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 --- .../mp/api/impl/WxMpDataCubeServiceImpl.java | 40 +++---------------- .../mp/api/impl/WxMpUserTagServiceImpl.java | 27 ++----------- 2 files changed, 9 insertions(+), 58 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDataCubeServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDataCubeServiceImpl.java index b82b7eaa..2dbee076 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDataCubeServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDataCubeServiceImpl.java @@ -1,32 +1,21 @@ package me.chanjar.weixin.mp.api.impl; -import java.text.Format; -import java.util.Date; -import java.util.List; - -import org.apache.commons.lang3.time.FastDateFormat; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.google.gson.JsonObject; - import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.WxMpDataCubeService; import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeArticleTotal; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; +import me.chanjar.weixin.mp.bean.datacube.*; +import org.apache.commons.lang3.time.FastDateFormat; + +import java.text.Format; +import java.util.Date; +import java.util.List; /** * Created by Binary Wang on 2016/8/23. * @author binarywang (https://github.com/binarywang) */ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { - protected final Logger log = LoggerFactory.getLogger(WxMpDataCubeServiceImpl.class); - private static final String API_URL_PREFIX = "https://api.weixin.qq.com/datacube"; private final Format dateFormat = FastDateFormat.getInstance("yyyy-MM-dd"); @@ -44,7 +33,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeUserSummary.fromJson(responseContent); } @@ -55,7 +43,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeUserCumulate.fromJson(responseContent); } @@ -66,7 +53,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeArticleResult.fromJson(responseContent); } @@ -77,7 +63,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeArticleTotal.fromJson(responseContent); } @@ -88,7 +73,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeArticleResult.fromJson(responseContent); } @@ -99,7 +83,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeArticleResult.fromJson(responseContent); } @@ -110,7 +93,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeArticleResult.fromJson(responseContent); } @@ -121,7 +103,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeArticleResult.fromJson(responseContent); } @@ -133,7 +114,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeMsgResult.fromJson(responseContent); } @@ -145,7 +125,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeMsgResult.fromJson(responseContent); } @@ -157,7 +136,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeMsgResult.fromJson(responseContent); } @@ -169,7 +147,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeMsgResult.fromJson(responseContent); } @@ -181,7 +158,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeMsgResult.fromJson(responseContent); } @@ -193,7 +169,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeMsgResult.fromJson(responseContent); } @@ -205,7 +180,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeMsgResult.fromJson(responseContent); } @@ -217,7 +191,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeInterfaceResult.fromJson(responseContent); } @@ -229,7 +202,6 @@ public class WxMpDataCubeServiceImpl implements WxMpDataCubeService { param.addProperty("begin_date", this.dateFormat.format(beginDate)); param.addProperty("end_date", this.dateFormat.format(endDate)); String responseContent = this.wxMpService.post(url, param.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}",url, param, responseContent); return WxDataCubeInterfaceResult.fromJson(responseContent); } } 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 3f6a4dba..4d3639c8 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 @@ -1,16 +1,9 @@ package me.chanjar.weixin.mp.api.impl; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; - import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; @@ -18,6 +11,9 @@ import me.chanjar.weixin.mp.api.WxMpUserTagService; import me.chanjar.weixin.mp.bean.tag.WxTagListUser; import me.chanjar.weixin.mp.bean.tag.WxUserTag; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; /** * @@ -25,8 +21,6 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; * Created by Binary Wang on 2016/9/2. */ public class WxMpUserTagServiceImpl implements WxMpUserTagService { - protected final Logger log = LoggerFactory - .getLogger(WxMpDataCubeServiceImpl.class); private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/tags"; private WxMpService wxMpService; @@ -44,8 +38,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { json.add("tag", tagJson); String responseContent = this.wxMpService.post(url, json.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(), - responseContent); return WxUserTag.fromJson(responseContent); } @@ -54,8 +46,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { String url = API_URL_PREFIX + "/get"; String responseContent = this.wxMpService.get(url, null); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, "[empty]", - responseContent); return WxUserTag.listFromJson(responseContent); } @@ -70,7 +60,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { json.add("tag", tagJson); String responseContent = this.wxMpService.post(url, json.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(), responseContent); WxError wxError = WxError.fromJson(responseContent); if (wxError.getErrorCode() == 0) { return true; @@ -89,8 +78,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { json.add("tag", tagJson); String responseContent = this.wxMpService.post(url, json.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(), - responseContent); WxError wxError = WxError.fromJson(responseContent); if (wxError.getErrorCode() == 0) { return true; @@ -109,8 +96,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { json.addProperty("next_openid", StringUtils.trimToEmpty(nextOpenid)); String responseContent = this.wxMpService.post(url, json.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(), - responseContent); return WxTagListUser.fromJson(responseContent); } @@ -128,8 +113,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { json.add("openid_list", openidArrayJson); String responseContent = this.wxMpService.post(url, json.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(), - responseContent); WxError wxError = WxError.fromJson(responseContent); if (wxError.getErrorCode() == 0) { return true; @@ -152,8 +135,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { json.add("openid_list", openidArrayJson); String responseContent = this.wxMpService.post(url, json.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(), - responseContent); WxError wxError = WxError.fromJson(responseContent); if (wxError.getErrorCode() == 0) { return true; @@ -170,8 +151,6 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { json.addProperty("openid", openid); String responseContent = this.wxMpService.post(url, json.toString()); - this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(), - responseContent); return WxMpGsonBuilder.create().fromJson( new JsonParser().parse(responseContent).getAsJsonObject().get("tagid_list"), From 6889e3d95e9eeb96d1a891096159faa6ce0bed71 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Wed, 28 Sep 2016 19:45:43 +0800 Subject: [PATCH 12/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9F=A5=E7=9C=8B=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=20for=20issue=20#17?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/WxMpStoreService.java | 19 +++++++++++-- .../mp/api/impl/WxMpStoreServiceImpl.java | 27 ++++++++++++++----- .../mp/bean/store/WxMpStoreBaseInfo.java | 16 ++++++----- .../weixin/mp/bean/store/WxMpStoreInfo.java | 3 ++- .../mp/api/impl/WxMpStoreServiceImplTest.java | 27 ++++++++++--------- 5 files changed, 63 insertions(+), 29 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 f4f3ccb6..e9adbf4c 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 @@ -1,12 +1,12 @@ package me.chanjar.weixin.mp.api; -import java.util.List; - import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo; import me.chanjar.weixin.mp.bean.store.WxMpStoreInfo; import me.chanjar.weixin.mp.bean.store.WxMpStoreListResult; +import java.util.List; + /** * 门店管理的相关接口代码 * @author binarywang(https://github.com/binarywang) @@ -27,6 +27,21 @@ public interface WxMpStoreService { */ void add(WxMpStoreBaseInfo request) throws WxErrorException; + + /** + *
+   * 查询门店信息
+   * 创建门店后获取poi_id 后,商户可以利用poi_id,查询具体某条门店的信息。
+   * 若在查询时,update_status 字段为1,表明在5 个工作日内曾用update 接口修改过门店扩展字段,该扩展字段为最新的修改字段,尚未经过审核采纳,因此不是最终结果。
+   * 最终结果会在5 个工作日内,最终确认是否采纳,并前端生效(但该扩展字段的采纳过程不影响门店的可用性,即available_state仍为审核通过状态)
+   * 注:扩展字段为公共编辑信息(大家都可修改),修改将会审核,并决定是否对修改建议进行采纳,但不会影响该门店的生效可用状态。
+   * 详情请见: 微信门店接口
+   * 
+ * @param poiId 门店poiId + * @throws WxErrorException + */ + WxMpStoreBaseInfo get(String poiId) 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 99740d45..d5f50b14 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
@@ -1,14 +1,8 @@
 package me.chanjar.weixin.mp.api.impl;
 
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.Map.Entry;
-
-import org.joor.Reflect;
-
 import com.google.common.collect.Lists;
 import com.google.gson.JsonObject;
-
+import com.google.gson.JsonParser;
 import me.chanjar.weixin.common.annotation.Required;
 import me.chanjar.weixin.common.bean.result.WxError;
 import me.chanjar.weixin.common.exception.WxErrorException;
@@ -17,6 +11,11 @@ import me.chanjar.weixin.mp.api.WxMpStoreService;
 import me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo;
 import me.chanjar.weixin.mp.bean.store.WxMpStoreInfo;
 import me.chanjar.weixin.mp.bean.store.WxMpStoreListResult;
+import org.joor.Reflect;
+
+import java.lang.reflect.Field;
+import java.util.List;
+import java.util.Map.Entry;
 
 /**
  *  Created by Binary Wang on 2016/9/26.
@@ -44,6 +43,20 @@ public class WxMpStoreServiceImpl implements WxMpStoreService {
     }
   }
 
+  @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());
+    WxError wxError = WxError.fromJson(response);
+    if (wxError.getErrorCode() != 0) {
+      throw new WxErrorException(wxError);
+    }
+    return WxMpStoreBaseInfo.fromJson(new JsonParser().parse(response).getAsJsonObject()
+        .get("business").getAsJsonObject().get("base_info").toString());
+  }
+
   private void checkParameters(WxMpStoreBaseInfo request) {
     List nullFields = Lists.newArrayList();
     for (Entry entry : Reflect.on(request).fields()
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 06a5b178..dcfd3153 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
@@ -1,17 +1,15 @@
 package me.chanjar.weixin.mp.bean.store;
 
-import java.math.BigDecimal;
-import java.util.List;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.annotations.SerializedName;
-
 import me.chanjar.weixin.common.annotation.Required;
 import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 门店基础信息
@@ -24,6 +22,10 @@ public class WxMpStoreBaseInfo {
     return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
   }
 
+  public static WxMpStoreBaseInfo fromJson(String json) {
+    return WxMpGsonBuilder.create().fromJson(json, WxMpStoreBaseInfo.class);
+  }
+
   public String toJson() {
     JsonElement base_info = WxMpGsonBuilder.create().toJsonTree(this);
     JsonObject jsonObject = new JsonObject();
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 48b01822..5b44b860 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,5 +1,6 @@
 package me.chanjar.weixin.mp.bean.store;
 
+import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
@@ -22,4 +23,4 @@ public class WxMpStoreInfo {
     this.baseInfo = baseInfo;
   }
 
-}
\ No newline at end of file
+}
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 9c28dfa7..3efaf8de 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
@@ -1,20 +1,18 @@
 package me.chanjar.weixin.mp.api.impl;
 
-import static org.junit.Assert.assertNotNull;
-
-import java.math.BigDecimal;
-import java.util.List;
-
-import org.testng.annotations.Guice;
-import org.testng.annotations.Test;
-
 import com.google.inject.Inject;
-
 import me.chanjar.weixin.common.exception.WxErrorException;
 import me.chanjar.weixin.mp.api.ApiTestModule;
 import me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo;
 import me.chanjar.weixin.mp.bean.store.WxMpStoreInfo;
 import me.chanjar.weixin.mp.bean.store.WxMpStoreListResult;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+import static org.junit.Assert.assertNotNull;
 
 /**
  * @author 王彬 (Binary Wang)
@@ -28,18 +26,23 @@ public class WxMpStoreServiceImplTest {
 
   /**
    * Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpStoreServiceImpl#add(me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo)}.
-   * @throws WxErrorException 
+   * @throws WxErrorException
    */
   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[] { "美食,江浙菜" })
+            .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());
   }
 
+  public void testGet() throws WxErrorException {
+    WxMpStoreBaseInfo result = this.wxMpService.getStoreService().get("291503654");
+    assertNotNull(result);
+    System.err.println(result);
+  }
+
   public void testList() throws WxErrorException {
     WxMpStoreListResult result = this.wxMpService.getStoreService().list(0, 10);
     assertNotNull(result);

From 091aefe4e150e4788004861bf61fc0cef45e96a8 Mon Sep 17 00:00:00 2001
From: BinaryWang 
Date: Wed, 28 Sep 2016 19:53:35 +0800
Subject: [PATCH 13/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=97=A8=E5=BA=97?=
 =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BF=A1=E6=81=AF=E4=BF=AE=E6=94=B9=E7=9A=84?=
 =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=20for=20issue=20#17?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../me/chanjar/weixin/mp/api/WxMpStoreService.java   | 12 +++++++++++-
 .../weixin/mp/api/impl/WxMpStoreServiceImpl.java     | 10 ++++++++++
 .../weixin/mp/api/impl/WxMpStoreServiceImplTest.java | 11 ++++++++++-
 3 files changed, 31 insertions(+), 2 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 e9adbf4c..127954aa 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
@@ -27,7 +27,6 @@ public interface WxMpStoreService {
    */
   void add(WxMpStoreBaseInfo request) throws WxErrorException;
 
-
   /**
    * 
    * 查询门店信息
@@ -63,4 +62,15 @@ public interface WxMpStoreService {
    * @throws WxErrorException
    */
   List listAll() throws WxErrorException;
+
+  /**
+   * 
+   * 修改门店服务信息
+   * 商户可以通过该接口,修改门店的服务信息,包括:sid、图片列表、营业时间、推荐、特色服务、简介、人均价格、电话8个字段(名称、坐标、地址等不可修改)修改后需要人工审核。
+   * 详情请见: 微信门店接口
+   * 
+ * @throws WxErrorException + */ + void update(WxMpStoreBaseInfo info) 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 d5f50b14..4a808f27 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 @@ -117,4 +117,14 @@ public class WxMpStoreServiceImpl implements WxMpStoreService { return stores; } + @Override + public void update(WxMpStoreBaseInfo request) throws WxErrorException { + String url = API_BASE_URL + "/updatepoi"; + String response = this.wxMpService.post(url, request.toJson()); + 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 3efaf8de..f994f68f 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 @@ -15,7 +15,8 @@ import java.util.List; import static org.junit.Assert.assertNotNull; /** - * @author 王彬 (Binary Wang) + * @author binarywang(https://github.com/binarywang) + * Created by Binary Wang on 2016-09-23. * */ @Test @@ -37,6 +38,14 @@ public class WxMpStoreServiceImplTest { .build()); } + 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) + .build()); + } + public void testGet() throws WxErrorException { WxMpStoreBaseInfo result = this.wxMpService.getStoreService().get("291503654"); assertNotNull(result); From 460a52be108f9459b06a49c26e2b6a8a4da19f68 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Wed, 28 Sep 2016 20:00:55 +0800 Subject: [PATCH 14/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=97=A8=E5=BA=97=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C=20for=20?= =?UTF-8?q?issue=20#17?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/api/WxMpStoreService.java | 13 ++++++++++++- .../weixin/mp/api/impl/WxMpStoreServiceImpl.java | 12 ++++++++++++ .../mp/api/impl/WxMpStoreServiceImplTest.java | 4 ++++ 3 files changed, 28 insertions(+), 1 deletion(-) 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 127954aa..a8394db3 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 @@ -36,11 +36,22 @@ public interface WxMpStoreService { * 注:扩展字段为公共编辑信息(大家都可修改),修改将会审核,并决定是否对修改建议进行采纳,但不会影响该门店的生效可用状态。 * 详情请见: 微信门店接口 *
- * @param poiId 门店poiId + * @param poiId 门店Id * @throws WxErrorException */ WxMpStoreBaseInfo get(String poiId) throws WxErrorException; + /** + *
+   * 删除门店
+   * 商户可以通过该接口,删除已经成功创建的门店。请商户慎重调用该接口。
+   * 详情请见: 微信门店接口
+   * 
+ * @param poiId 门店Id + * @throws WxErrorException + */ + void delete(String poiId) 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 4a808f27..7cfce11d 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
@@ -57,6 +57,18 @@ public class WxMpStoreServiceImpl implements WxMpStoreService {
         .get("business").getAsJsonObject().get("base_info").toString());
   }
 
+  @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());
+    WxError wxError = WxError.fromJson(response);
+    if (wxError.getErrorCode() != 0) {
+      throw new WxErrorException(wxError);
+    }
+  }
+
   private void checkParameters(WxMpStoreBaseInfo request) {
     List nullFields = Lists.newArrayList();
     for (Entry entry : Reflect.on(request).fields()
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 f994f68f..b6ca8d08 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
@@ -52,6 +52,10 @@ public class WxMpStoreServiceImplTest {
     System.err.println(result);
   }
 
+  public void testDelete() throws WxErrorException {
+    this.wxMpService.getStoreService().delete("463558057");
+  }
+
   public void testList() throws WxErrorException {
     WxMpStoreListResult result = this.wxMpService.getStoreService().list(0, 10);
     assertNotNull(result);

From 8a5fdb171730b0ca9b8425741a45d28b556ff270 Mon Sep 17 00:00:00 2001
From: BinaryWang 
Date: Wed, 28 Sep 2016 20:20:17 +0800
Subject: [PATCH 15/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9F=A5=E8=AF=A2?=
 =?UTF-8?q?=E9=97=A8=E5=BA=97=E7=B1=BB=E7=9B=AE=E5=88=97=E8=A1=A8=E7=9A=84?=
 =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=20for=20issue=20#17?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../chanjar/weixin/mp/api/WxMpStoreService.java  | 16 ++++++++++++++++
 .../weixin/mp/api/impl/WxMpStoreServiceImpl.java | 16 ++++++++++++++++
 .../mp/api/impl/WxMpStoreServiceImplTest.java    |  6 ++++++
 3 files changed, 38 insertions(+)

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 a8394db3..0ce7cc03 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
@@ -35,6 +35,7 @@ public interface WxMpStoreService {
    * 最终结果会在5 个工作日内,最终确认是否采纳,并前端生效(但该扩展字段的采纳过程不影响门店的可用性,即available_state仍为审核通过状态)
    * 注:扩展字段为公共编辑信息(大家都可修改),修改将会审核,并决定是否对修改建议进行采纳,但不会影响该门店的生效可用状态。
    * 详情请见: 微信门店接口
+   * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/getpoi?access_token=TOKEN
    * 
* @param poiId 门店Id * @throws WxErrorException @@ -46,6 +47,7 @@ public interface WxMpStoreService { * 删除门店 * 商户可以通过该接口,删除已经成功创建的门店。请商户慎重调用该接口。 * 详情请见: 微信门店接口 + * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/delpoi?access_token=TOKEN *
* @param poiId 门店Id * @throws WxErrorException @@ -57,6 +59,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 * * @param begin 开始位置,0 即为从第一条开始查询 * @param limit 返回数据条数,最大允许50,默认为20 @@ -69,6 +72,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 * * @throws WxErrorException */ @@ -79,9 +83,21 @@ public interface WxMpStoreService { * 修改门店服务信息 * 商户可以通过该接口,修改门店的服务信息,包括:sid、图片列表、营业时间、推荐、特色服务、简介、人均价格、电话8个字段(名称、坐标、地址等不可修改)修改后需要人工审核。 * 详情请见: 微信门店接口 + * 接口格式:http://api.weixin.qq.com/cgi-bin/poi/updatepoi?access_token=TOKEN * * @throws WxErrorException */ void update(WxMpStoreBaseInfo info) throws WxErrorException; + /** + *
+   * 门店类目表
+   * 类目名称接口是为商户提供自己门店类型信息的接口。门店类目定位的越规范,能够精准的吸引更多用户,提高曝光率。
+   * 详情请见: 微信门店接口
+   * 接口格式: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 7cfce11d..39c7f729 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 @@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api.impl; import com.google.common.collect.Lists; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; import me.chanjar.weixin.common.annotation.Required; import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; @@ -11,6 +12,7 @@ import me.chanjar.weixin.mp.api.WxMpStoreService; import me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo; import me.chanjar.weixin.mp.bean.store.WxMpStoreInfo; import me.chanjar.weixin.mp.bean.store.WxMpStoreListResult; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import org.joor.Reflect; import java.lang.reflect.Field; @@ -139,4 +141,18 @@ public class WxMpStoreServiceImpl implements WxMpStoreService { } } + @Override + public List listCategories() throws WxErrorException { + String url = API_BASE_URL + "/getwxcategory"; + String response = this.wxMpService.get(url, null); + WxError wxError = WxError.fromJson(response); + if (wxError.getErrorCode() != 0) { + throw new WxErrorException(wxError); + } + + return WxMpGsonBuilder.create().fromJson( + new JsonParser().parse(response).getAsJsonObject().get("category_list"), + new TypeToken>(){}.getType()); + } + } 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 b6ca8d08..76685470 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 @@ -56,6 +56,12 @@ public class WxMpStoreServiceImplTest { this.wxMpService.getStoreService().delete("463558057"); } + public void testListCategories() throws WxErrorException { + List result = this.wxMpService.getStoreService().listCategories(); + assertNotNull(result); + System.err.println(result); + } + public void testList() throws WxErrorException { WxMpStoreListResult result = this.wxMpService.getStoreService().list(0, 10); assertNotNull(result); From d9e8fe6d1467d238b3b5469bafede335c2ef83fd Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Wed, 28 Sep 2016 20:30:25 +0800 Subject: [PATCH 16/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E4=BA=8B=E4=BB=B6=E6=8E=A8=E9=80=81=E7=9A=84?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=B6=88=E6=81=AF=E5=8F=98=E9=87=8F=E5=92=8C?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=B8=B8=E9=87=8F=EF=BC=8C=20for=20issue=20#?= =?UTF-8?q?17?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/common/api/WxConsts.java | 2 + .../weixin/mp/bean/WxMpXmlMessage.java | 83 ++++++++++++++++--- 2 files changed, 74 insertions(+), 11 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 eae90d97..6a1e4380 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 @@ -93,6 +93,8 @@ public class WxConsts { public static final String EVT_KF_CREATE_SESSION = "kf_create_session"; // 客服接入会话 public static final String EVT_KF_CLOSE_SESSION = "kf_close_session"; // 客服关闭会话 public static final String EVT_KF_SWITCH_SESSION = "kf_switch_session"; // 客服转接会话 + public static final String EVT_POI_CHECK_NOTIFY = "poi_check_notify"; //门店审核事件推送 + /////////////////////// // 上传多媒体文件的类型 /////////////////////// diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java index 047961ea..c0240648 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java @@ -1,22 +1,20 @@ package me.chanjar.weixin.mp.bean; -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; - import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.mp.api.WxMpConfigStorage; import me.chanjar.weixin.mp.util.crypto.WxMpCryptUtil; import me.chanjar.weixin.mp.util.xml.XStreamTransformer; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** *
@@ -209,6 +207,69 @@ public class WxMpXmlMessage implements Serializable {
   @XStreamAlias("SendLocationInfo")
   private SendLocationInfo sendLocationInfo = new SendLocationInfo();
 
+  ///////////////////////////////////////
+  // 门店审核事件推送
+  ///////////////////////////////////////
+  /**
+   * UniqId
+   * 商户自己内部ID,即字段中的sid
+   */
+  @XStreamAlias("UniqId")
+  private String storeUniqId;
+
+  /**
+   * PoiId
+   * 微信的门店ID,微信内门店唯一标示ID
+   */
+  @XStreamAlias("PoiId")
+  private String poiId;
+
+  /**
+   * Result
+   * 审核结果,成功succ 或失败fail
+   */
+  @XStreamAlias("Result")
+  private String result;
+
+  /**
+   * msg
+   * 成功的通知信息,或审核失败的驳回理由
+   */
+  @XStreamAlias("msg")
+  private String msg;
+
+  public String getStoreUniqId() {
+    return storeUniqId;
+  }
+
+  public void setStoreUniqId(String storeUniqId) {
+    this.storeUniqId = storeUniqId;
+  }
+
+  public String getPoiId() {
+    return poiId;
+  }
+
+  public void setPoiId(String poiId) {
+    this.poiId = poiId;
+  }
+
+  public String getResult() {
+    return result;
+  }
+
+  public void setResult(String result) {
+    this.result = result;
+  }
+
+  public String getMsg() {
+    return msg;
+  }
+
+  public void setMsg(String msg) {
+    this.msg = msg;
+  }
+
   public String getToUserName() {
     return this.toUserName;
   }

From 87ab934a1ccfef6da6710b01f94073f5b34a0bc9 Mon Sep 17 00:00:00 2001
From: BinaryWang 
Date: Thu, 29 Sep 2016 13:54:40 +0800
Subject: [PATCH 17/76] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E9=83=A8?=
 =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../mp/api/impl/WxMpPayServiceImpl.java       |  3 +-
 .../weixin/mp/bean/WxMpXmlMessage.java        | 28 ++++++++++---------
 .../weixin/mp/bean/tag/WxTagListUser.java     | 16 ++++++-----
 3 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
index 475f5406..dcb1e89f 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
@@ -28,7 +28,6 @@ import me.chanjar.weixin.mp.api.WxMpService;
 import me.chanjar.weixin.mp.bean.pay.WxMpPayCallback;
 import me.chanjar.weixin.mp.bean.pay.WxMpPayRefundResult;
 import me.chanjar.weixin.mp.bean.pay.WxMpPayResult;
-import me.chanjar.weixin.mp.bean.pay.WxMpPrepayIdResult;
 import me.chanjar.weixin.mp.bean.pay.WxRedpackResult;
 import me.chanjar.weixin.mp.bean.pay.WxSendRedpackRequest;
 import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest;
@@ -287,7 +286,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
 
     if (!TRADE_TYPES.contains(request.getTradeType())) {
       throw new IllegalArgumentException(
-"trade_type目前必须为" + TRADE_TYPES + "其中之一");
+          "trade_type目前必须为" + TRADE_TYPES + "其中之一");
 
     }
 
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
index c0240648..460e7ce6 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
@@ -1,20 +1,22 @@
 package me.chanjar.weixin.mp.bean;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import com.thoughtworks.xstream.annotations.XStreamConverter;
+
 import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
 import me.chanjar.weixin.mp.api.WxMpConfigStorage;
 import me.chanjar.weixin.mp.util.crypto.WxMpCryptUtil;
 import me.chanjar.weixin.mp.util.xml.XStreamTransformer;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
 
 /**
  * 
@@ -239,7 +241,7 @@ public class WxMpXmlMessage implements Serializable {
   private String msg;
 
   public String getStoreUniqId() {
-    return storeUniqId;
+    return this.storeUniqId;
   }
 
   public void setStoreUniqId(String storeUniqId) {
@@ -247,7 +249,7 @@ public class WxMpXmlMessage implements Serializable {
   }
 
   public String getPoiId() {
-    return poiId;
+    return this.poiId;
   }
 
   public void setPoiId(String poiId) {
@@ -255,7 +257,7 @@ public class WxMpXmlMessage implements Serializable {
   }
 
   public String getResult() {
-    return result;
+    return this.result;
   }
 
   public void setResult(String result) {
@@ -263,7 +265,7 @@ public class WxMpXmlMessage implements Serializable {
   }
 
   public String getMsg() {
-    return msg;
+    return this.msg;
   }
 
   public void setMsg(String msg) {
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 0ba48edc..b07314ba 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,11 +1,13 @@
 package me.chanjar.weixin.mp.bean.tag;
 
-import com.google.gson.annotations.SerializedName;
-import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
+import java.util.List;
+
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
-import java.util.List;
+import com.google.gson.annotations.SerializedName;
+
+import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
 
 /**
  * 获取标签下粉丝列表的结果对象
@@ -46,7 +48,7 @@ public class WxTagListUser {
   private String nextOpenid;
 
   public Integer getCount() {
-    return count;
+    return this.count;
   }
 
   public void setCount(Integer count) {
@@ -54,7 +56,7 @@ public class WxTagListUser {
   }
 
   public WxTagListUserData getData() {
-    return data;
+    return this.data;
   }
 
   public void setData(WxTagListUserData data) {
@@ -62,7 +64,7 @@ public class WxTagListUser {
   }
 
   public String getNextOpenid() {
-    return nextOpenid;
+    return this.nextOpenid;
   }
 
   public void setNextOpenid(String nextOpenid) {
@@ -82,7 +84,7 @@ public class WxTagListUser {
     private List openidList;
 
     public List getOpenidList() {
-      return openidList;
+      return this.openidList;
     }
 
     public void setOpenidList(List openidList) {

From 5345a6d1f15df7182bce6c1b4bacc8b750cf41d3 Mon Sep 17 00:00:00 2001
From: BinaryWang 
Date: Fri, 30 Sep 2016 16:41:50 +0800
Subject: [PATCH 18/76] =?UTF-8?q?=E9=87=8D=E6=9E=84WxMpXmlMessage=EF=BC=8C?=
 =?UTF-8?q?=E4=BF=AE=E6=94=B9fromUserName=E4=B8=BAfromUser=EF=BC=8CtoUserN?=
 =?UTF-8?q?ame=E4=B8=BAtoUser=EF=BC=8C=E9=81=BF=E5=85=8D=E4=B8=8D=E5=BF=85?=
 =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=AD=A7=E4=B9=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../weixin/mp/api/WxMpMessageRouter.java      |  8 ++++----
 .../weixin/mp/api/WxMpMessageRouterRule.java  |  2 +-
 .../weixin/mp/bean/WxMpXmlMessage.java        | 20 +++++++++----------
 .../weixin/mp/api/WxMpMessageRouterTest.java  | 14 ++++++-------
 .../mp/api/impl/WxMpPayServiceImplTest.java   | 19 ++----------------
 .../weixin/mp/bean/WxMpXmlMessageTest.java    |  8 ++++----
 .../mp/demo/DemoGuessNumberHandler.java       | 14 ++++++-------
 .../weixin/mp/demo/DemoImageHandler.java      |  4 ++--
 .../weixin/mp/demo/DemoOAuth2Handler.java     |  2 +-
 .../weixin/mp/demo/DemoTextHandler.java       |  4 ++--
 10 files changed, 40 insertions(+), 55 deletions(-)

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 0c7a7105..7db50e79 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
@@ -171,7 +171,7 @@ public class WxMpMessageRouter {
       } else {
         res = rule.service(wxMessage, this.wxMpService, this.sessionManager, this.exceptionHandler);
         // 在同步操作结束,session访问结束
-        this.log.debug("End session access: async=false, sessionId={}", wxMessage.getFromUserName());
+        this.log.debug("End session access: async=false, sessionId={}", wxMessage.getFromUser());
         sessionEndAccess(wxMessage);
       }
     }
@@ -183,7 +183,7 @@ public class WxMpMessageRouter {
           for (Future future : futures) {
             try {
               future.get();
-              WxMpMessageRouter.this.log.debug("End session access: async=true, sessionId={}", wxMessage.getFromUserName());
+              WxMpMessageRouter.this.log.debug("End session access: async=true, sessionId={}", wxMessage.getFromUser());
               // 异步操作结束,session访问结束
               sessionEndAccess(wxMessage);
             } catch (InterruptedException e) {
@@ -203,7 +203,7 @@ public class WxMpMessageRouter {
     StringBuffer messageId = new StringBuffer();
     if (wxMessage.getMsgId() == null) {
       messageId.append(wxMessage.getCreateTime())
-        .append("-").append(wxMessage.getFromUserName())
+        .append("-").append(wxMessage.getFromUser())
         .append("-").append(wxMessage.getEventKey() == null ? "" : wxMessage.getEventKey())
         .append("-").append(wxMessage.getEvent() == null ? "" : wxMessage.getEvent())
       ;
@@ -221,7 +221,7 @@ public class WxMpMessageRouter {
    */
   protected void sessionEndAccess(WxMpXmlMessage wxMessage) {
 
-    InternalSession session = ((InternalSessionManager)this.sessionManager).findSession(wxMessage.getFromUserName());
+    InternalSession session = ((InternalSessionManager)this.sessionManager).findSession(wxMessage.getFromUser());
     if (session != null) {
       session.endAccess();
     }
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 eb02c641..317303b8 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
@@ -168,7 +168,7 @@ public class WxMpMessageRouterRule {
    */
   protected boolean test(WxMpXmlMessage wxMessage) {
     return
-        (this.fromUser == null || this.fromUser.equals(wxMessage.getFromUserName()))
+        (this.fromUser == null || this.fromUser.equals(wxMessage.getFromUser()))
             &&
             (this.msgType == null || this.msgType.toLowerCase().equals((wxMessage.getMsgType()==null?null:wxMessage.getMsgType().toLowerCase())))
             &&
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
index 460e7ce6..b1997f92 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
@@ -40,11 +40,11 @@ public class WxMpXmlMessage implements Serializable {
 
   @XStreamAlias("ToUserName")
   @XStreamConverter(value = XStreamCDataConverter.class)
-  private String toUserName;
+  private String toUser;
 
   @XStreamAlias("FromUserName")
   @XStreamConverter(value = XStreamCDataConverter.class)
-  private String fromUserName;
+  private String fromUser;
 
   @XStreamAlias("CreateTime")
   private Long createTime;
@@ -272,12 +272,12 @@ public class WxMpXmlMessage implements Serializable {
     this.msg = msg;
   }
 
-  public String getToUserName() {
-    return this.toUserName;
+  public String getToUser() {
+    return this.toUser;
   }
 
-  public void setToUserName(String toUserName) {
-    this.toUserName = toUserName;
+  public void setToUser(String toUser) {
+    this.toUser = toUser;
   }
 
   public Long getCreateTime() {
@@ -482,12 +482,12 @@ public class WxMpXmlMessage implements Serializable {
     this.recognition = recognition;
   }
 
-  public String getFromUserName() {
-    return this.fromUserName;
+  public String getFromUser() {
+    return this.fromUser;
   }
 
-  public void setFromUserName(String fromUserName) {
-    this.fromUserName = fromUserName;
+  public void setFromUser(String fromUser) {
+    this.fromUser = fromUser;
   }
 
   public static WxMpXmlMessage fromXml(String xml) {
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 07a1b75a..fdc90744 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
@@ -195,7 +195,7 @@ public class WxMpMessageRouterTest {
         .rule().async(false).handler(new WxSessionMessageHandler()).end();
 
     WxMpXmlMessage msg = new WxMpXmlMessage();
-    msg.setFromUserName("abc");
+    msg.setFromUser("abc");
     router.route(msg);
 
     Thread.sleep(2000l);
@@ -215,7 +215,7 @@ public class WxMpMessageRouterTest {
           .rule().async(true).handler(new WxSessionMessageHandler()).end();
 
       WxMpXmlMessage msg = new WxMpXmlMessage();
-      msg.setFromUserName("abc");
+      msg.setFromUser("abc");
       router.route(msg);
 
       Thread.sleep(2000l);
@@ -229,7 +229,7 @@ public class WxMpMessageRouterTest {
           .rule().async(false).handler(new WxSessionMessageHandler()).end();
 
       WxMpXmlMessage msg = new WxMpXmlMessage();
-      msg.setFromUserName("abc");
+      msg.setFromUser("abc");
       router.route(msg);
 
       Thread.sleep(2000l);
@@ -249,7 +249,7 @@ public class WxMpMessageRouterTest {
         .rule().async(true).handler(new WxSessionMessageHandler()).end();
 
     WxMpXmlMessage msg = new WxMpXmlMessage();
-    msg.setFromUserName("abc");
+    msg.setFromUser("abc");
     router.route(msg);
 
     Thread.sleep(2000l);
@@ -268,7 +268,7 @@ public class WxMpMessageRouterTest {
           .rule().async(false).handler(new WxSessionMessageHandler()).end();
 
       WxMpXmlMessage msg = new WxMpXmlMessage();
-      msg.setFromUserName("abc");
+      msg.setFromUser("abc");
       router.route(msg);
 
       Thread.sleep(2000l);
@@ -282,7 +282,7 @@ public class WxMpMessageRouterTest {
           .rule().async(true).handler(new WxSessionMessageHandler()).end();
 
       WxMpXmlMessage msg = new WxMpXmlMessage();
-      msg.setFromUserName("abc");
+      msg.setFromUser("abc");
       router.route(msg);
 
       Thread.sleep(2000l);
@@ -295,7 +295,7 @@ public class WxMpMessageRouterTest {
     @Override
     public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService wxMpService,
         WxSessionManager sessionManager) {
-      sessionManager.getSession(wxMessage.getFromUserName());
+      sessionManager.getSession(wxMessage.getFromUser());
       return null;
     }
 
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java
index 1982f948..092be38a 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java
@@ -25,21 +25,6 @@ public class WxMpPayServiceImplTest {
   @Inject
   protected WxMpServiceImpl wxService;
 
-  @Test
-  public void testGetPrepayId() throws Exception {
-
-  }
-
-  @Test
-  public void testGetJsapiPayInfo() throws Exception {
-
-  }
-
-  @Test
-  public void testGetNativePayInfo() throws Exception {
-
-  }
-
   @Test
   public void testGetPayInfo() throws Exception {
 
@@ -79,7 +64,7 @@ public class WxMpPayServiceImplTest {
 
   /**
    * Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#unifiedOrder(me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest)}.
-   * @throws WxErrorException 
+   * @throws WxErrorException
    */
   @Test
   public void testUnifiedOrder() throws WxErrorException {
@@ -89,4 +74,4 @@ public class WxMpPayServiceImplTest {
             .tradeType("JSAPI").openid("122").outTradeNo("111111").build());
     System.err.println(result);
   }
-}
\ No newline at end of file
+}
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpXmlMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpXmlMessageTest.java
index 3885ec32..87d8428b 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpXmlMessageTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpXmlMessageTest.java
@@ -54,8 +54,8 @@ public class WxMpXmlMessageTest {
                 + ""
                 + "";
     WxMpXmlMessage wxMessage = WxMpXmlMessage.fromXml(xml);
-    Assert.assertEquals(wxMessage.getToUserName(), "toUser");
-    Assert.assertEquals(wxMessage.getFromUserName(), "fromUser");
+    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");
@@ -135,8 +135,8 @@ public class WxMpXmlMessageTest {
         + ""
         + "";
     WxMpXmlMessage wxMessage = WxMpXmlMessage.fromXml(xml);
-    Assert.assertEquals(wxMessage.getToUserName(), "toUser");
-    Assert.assertEquals(wxMessage.getFromUserName(), "fromUser");
+    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");
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoGuessNumberHandler.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoGuessNumberHandler.java
index a6fb1e53..f35b3b87 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoGuessNumberHandler.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoGuessNumberHandler.java
@@ -50,18 +50,18 @@ public class DemoGuessNumberHandler implements WxMpMessageHandler, WxMpMessageMa
   }
 
   protected void letsGo(WxMpXmlMessage wxMessage, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
-    WxSession session = sessionManager.getSession(wxMessage.getFromUserName());
+    WxSession session = sessionManager.getSession(wxMessage.getFromUser());
     if (session.getAttribute("guessing") == null) {
       WxMpCustomMessage m = WxMpCustomMessage
           .TEXT()
-          .toUser(wxMessage.getFromUserName())
+          .toUser(wxMessage.getFromUser())
           .content("请猜一个100以内的数字")
           .build();
       wxMpService.getKefuService().customMessageSend(m);
     } else {
       WxMpCustomMessage m = WxMpCustomMessage
           .TEXT()
-          .toUser(wxMessage.getFromUserName())
+          .toUser(wxMessage.getFromUser())
           .content("放弃了吗?那请重新猜一个100以内的数字")
           .build();
       wxMpService.getKefuService().customMessageSend(m);
@@ -74,7 +74,7 @@ public class DemoGuessNumberHandler implements WxMpMessageHandler, WxMpMessageMa
 
   protected void giveHint(WxMpXmlMessage wxMessage, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
 
-    WxSession session = sessionManager.getSession(wxMessage.getFromUserName());
+    WxSession session = sessionManager.getSession(wxMessage.getFromUser());
 
     if (session.getAttribute("guessing") == null) {
       return;
@@ -89,7 +89,7 @@ public class DemoGuessNumberHandler implements WxMpMessageHandler, WxMpMessageMa
     if (guessNumber < answer) {
       WxMpCustomMessage m = WxMpCustomMessage
           .TEXT()
-          .toUser(wxMessage.getFromUserName())
+          .toUser(wxMessage.getFromUser())
           .content("小了")
           .build();
       wxMpService.getKefuService().customMessageSend(m);
@@ -97,14 +97,14 @@ public class DemoGuessNumberHandler implements WxMpMessageHandler, WxMpMessageMa
     } else if (guessNumber > answer) {
       WxMpCustomMessage m = WxMpCustomMessage
           .TEXT()
-          .toUser(wxMessage.getFromUserName())
+          .toUser(wxMessage.getFromUser())
           .content("大了")
           .build();
       wxMpService.getKefuService().customMessageSend(m);
     } else {
       WxMpCustomMessage m = WxMpCustomMessage
           .TEXT()
-          .toUser(wxMessage.getFromUserName())
+          .toUser(wxMessage.getFromUser())
           .content("Bingo!")
           .build();
       session.removeAttribute("guessing");
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 a22f28d7..cd733210 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
@@ -24,8 +24,8 @@ public class DemoImageHandler implements WxMpMessageHandler {
           = WxMpXmlOutMessage
           .IMAGE()
           .mediaId(wxMediaUploadResult.getMediaId())
-          .fromUser(wxMessage.getToUserName())
-          .toUser(wxMessage.getFromUserName())
+          .fromUser(wxMessage.getToUser())
+          .toUser(wxMessage.getFromUser())
           .build();
       return m;
     } catch (WxErrorException e) {
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 de1c9546..5dc5437d 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
@@ -21,7 +21,7 @@ public class DemoOAuth2Handler implements WxMpMessageHandler {
         wxMpService.getWxMpConfigStorage().getOauth2redirectUri(),
         WxConsts.OAUTH2_SCOPE_USER_INFO, null) + "\">测试oauth2";
     return WxMpXmlOutMessage.TEXT().content(href)
-        .fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName())
+        .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
         .build();
   }
 }
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoTextHandler.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoTextHandler.java
index 43f017be..9ee15a28 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoTextHandler.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoTextHandler.java
@@ -17,8 +17,8 @@ public class DemoTextHandler implements WxMpMessageHandler {
   public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context,
       WxMpService wxMpService, WxSessionManager sessionManager) {
     WxMpXmlOutTextMessage m
-        = WxMpXmlOutMessage.TEXT().content("测试加密消息").fromUser(wxMessage.getToUserName())
-        .toUser(wxMessage.getFromUserName()).build();
+        = WxMpXmlOutMessage.TEXT().content("测试加密消息").fromUser(wxMessage.getToUser())
+        .toUser(wxMessage.getFromUser()).build();
     return m;
   }
 

From ae3577f48e652459c2fad9ce87cb7812ec227835 Mon Sep 17 00:00:00 2001
From: BinaryWang 
Date: Fri, 30 Sep 2016 16:49:08 +0800
Subject: [PATCH 19/76] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?=
 =?UTF-8?q?=E6=96=87=E5=AD=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../java/me/chanjar/weixin/mp/api/WxMpUserService.java | 10 +++++-----
 .../java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java |  9 ++++-----
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserService.java
index deaf85ab..f46ca634 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserService.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpUserService.java
@@ -1,14 +1,14 @@
 package me.chanjar.weixin.mp.api;
 
+import java.util.List;
+
 import me.chanjar.weixin.common.exception.WxErrorException;
 import me.chanjar.weixin.mp.bean.WxMpUserQuery;
 import me.chanjar.weixin.mp.bean.result.WxMpUser;
 import me.chanjar.weixin.mp.bean.result.WxMpUserList;
 
-import java.util.List;
-
 /**
- * 用户管理和统计相关操作接口
+ * 用户管理相关操作接口
  *
  * @author Binary Wang
  */
@@ -42,9 +42,9 @@ public interface WxMpUserService {
    * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=批量获取用户基本信息
    * 
* - * @param openidList 用户openid列表 + * @param openids 用户openid列表 */ - List userInfoList(List openidList) throws WxErrorException; + List userInfoList(List openids) throws WxErrorException; /** *
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
index b1997f92..9adcb54d 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
@@ -20,11 +20,10 @@ import me.chanjar.weixin.mp.util.xml.XStreamTransformer;
 
 /**
  * 
- * 微信推送过来的消息,也是同步回复给用户的消息,xml格式
- * 相关字段的解释看微信开发者文档:
- * http://mp.weixin.qq.com/wiki/index.php?title=接收普通消息
- * http://mp.weixin.qq.com/wiki/index.php?title=接收事件推送
- * http://mp.weixin.qq.com/wiki/index.php?title=接收语音识别结果
+ * 微信推送过来的消息,xml格式
+ * 部分未注释的字段的解释请查阅相关微信开发文档:
+ * 接收普通消息
+ * 接收事件推送
  * 
* * @author chanjarster From 5c53319464b439d42ec26cb35f5b6805634a1fc5 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Fri, 30 Sep 2016 16:56:40 +0800 Subject: [PATCH 20/76] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E4=B8=BA=E6=96=B0=E7=89=88=E6=9C=AC2.2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 ++++++------ build.gradle | 2 +- pom.xml | 2 +- weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 93da5c67..aba634dd 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ### 注意: 1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。*** 1. ***自2.0.0版本以来,主要是公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。*** -1. 最新更新:2016-08-31 发布2.1.0正式版! +1. 最新更新:2016-09-30 发布2.2.0正式版! =========== @@ -33,12 +33,12 @@ maven: com.github.binarywang weixin-java-mp - 2.1.0 + 2.2.0 ``` gradle: ```groovy -compile 'com.github.binarywang:weixin-java-mp:2.1.0' +compile 'com.github.binarywang:weixin-java-mp:2.2.0' ``` * 企业号: @@ -48,12 +48,12 @@ maven: com.github.binarywang weixin-java-cp - 2.1.0 + 2.2.0 ``` gradle: ```groovy -compile 'com.github.binarywang:weixin-java-cp:2.1.0' +compile 'com.github.binarywang:weixin-java-cp:2.2.0' ``` #### 本项目主要存放在github上,地址为 : @@ -74,4 +74,4 @@ compile 'com.github.binarywang:weixin-java-cp:2.1.0' * 本项目可以采用两种方式接受代码贡献: 1. 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支。 -1. 另外一种贡献代码的方式就是加入SDK Developers开发组,如果对自己的代码足够自信,可以随时提交代码,注意要随时进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询管理员。 +1. 另外一种贡献代码的方式就是加入SDK Developers开发组,前提是对自己的代码足够自信就可以申请加入,加入之后可以随时直接提交代码,但要注意对所做的修改或新增的代码进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询管理员。 diff --git a/build.gradle b/build.gradle index ba705da9..108e69c0 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ allprojects { apply plugin: 'maven' group = 'com.github.binarywang' - version = '2.1.0-SNAPSHOT' + version = '2.2.0' } subprojects { diff --git a/pom.xml b/pom.xml index d79f2f72..e94e5fc1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.1.2 + 2.2.0 pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 54922f7f..667aaf76 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -6,7 +6,7 @@ com.github.binarywang weixin-java-parent - 2.1.2 + 2.2.0 weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index 9de144fe..e87e2ea1 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -6,7 +6,7 @@ com.github.binarywang weixin-java-parent - 2.1.2 + 2.2.0 weixin-java-cp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 33a4f5ab..6fc42ee6 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -6,7 +6,7 @@ com.github.binarywang weixin-java-parent - 2.1.2 + 2.2.0 weixin-java-mp WeiXin Java Tools - MP From 25d9d5dba9334390ad7a4f848a451f9dc5712b3d Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 30 Sep 2016 17:35:04 +0800 Subject: [PATCH 21/76] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aba634dd..b4165f69 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ### 注意: 1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。*** -1. ***自2.0.0版本以来,主要是公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。*** +1. ***自2.0.0版本以来,公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。*** 1. 最新更新:2016-09-30 发布2.2.0正式版! =========== From 8281b636882b08a40a2e33c0a2e3f8f660bc407d Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 30 Sep 2016 17:35:24 +0800 Subject: [PATCH 22/76] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aba634dd..b4165f69 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ### 注意: 1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。*** -1. ***自2.0.0版本以来,主要是公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。*** +1. ***自2.0.0版本以来,公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。*** 1. 最新更新:2016-09-30 发布2.2.0正式版! =========== From 55940005e1cb2b9303eac5bbae68bb1969ebc34d Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 1 Oct 2016 14:51:17 +0800 Subject: [PATCH 23/76] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b4165f69..0d02922a 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ =========== ## 版本说明 -* 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.0.0,2.1.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request; -* BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版); -* 目前最新版本号为 ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) ,也可以通过访问链接[【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) 、[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22) +1. 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.0.0,2.1.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request; +1. BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版); +1. 目前最新版本号为 ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) ,也可以通过访问链接[【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) 、[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22) 分别查看所有最新的版本。 ## Maven & Gradle @@ -69,9 +69,9 @@ compile 'com.github.binarywang:weixin-java-cp:2.2.0' 1. https://github.com/wechat-group/weixin-java-tools-springmvc ## 关于代码贡献 -* 非常欢迎和感谢对本项目发起Pull Request的同学,本项目代码风格为使用2个空格代表一个Tab,因此在提交代码时请注意一下,否则很容易在IDE格式化代码后与原代码产生大量diff,这样会给其他人阅读代码带来极大的困扰。 -* 为了便于设置,本项目引入editorconfig插件,请使用eclipse的同学在贡献代码前安装相关插件,IntelliJ IDEA则自带支持,无需额外安装插件。 -* 本项目可以采用两种方式接受代码贡献: +1. 非常欢迎和感谢对本项目发起Pull Request的同学,本项目代码风格为使用2个空格代表一个Tab,因此在提交代码时请注意一下,否则很容易在IDE格式化代码后与原代码产生大量diff,这样会给其他人阅读代码带来极大的困扰。 +1. 为了便于设置,本项目引入editorconfig插件,请使用eclipse的同学在贡献代码前安装相关插件,IntelliJ IDEA则自带支持,无需额外安装插件。 +1. 本项目可以采用两种方式接受代码贡献: -1. 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支。 -1. 另外一种贡献代码的方式就是加入SDK Developers开发组,前提是对自己的代码足够自信就可以申请加入,加入之后可以随时直接提交代码,但要注意对所做的修改或新增的代码进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询管理员。 + 1. 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支。 + 1. 另外一种贡献代码的方式就是加入SDK Developers开发组,前提是对自己的代码足够自信就可以申请加入,加入之后可以随时直接提交代码,但要注意对所做的修改或新增的代码进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询管理员。 From 2ae95e48efe99f98690e3e0fcd3d7a10f05b2092 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 1 Oct 2016 14:55:47 +0800 Subject: [PATCH 24/76] clean code --- .../chanjar/weixin/mp/api/WxMpPayService.java | 1 - .../mp/api/impl/WxMpKefuServiceImpl.java | 35 +++++++++++-------- .../mp/api/impl/WxMpPayServiceImpl.java | 5 +-- .../weixin/mp/bean/store/WxMpStoreInfo.java | 1 - 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java index 72eabd08..c6480e6c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java @@ -6,7 +6,6 @@ import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.bean.pay.WxMpPayCallback; import me.chanjar.weixin.mp.bean.pay.WxMpPayRefundResult; import me.chanjar.weixin.mp.bean.pay.WxMpPayResult; -import me.chanjar.weixin.mp.bean.pay.WxMpPrepayIdResult; import me.chanjar.weixin.mp.bean.pay.WxRedpackResult; import me.chanjar.weixin.mp.bean.pay.WxSendRedpackRequest; import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest; 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 99428348..e83c17ac 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 @@ -1,6 +1,13 @@ package me.chanjar.weixin.mp.api.impl; +import java.io.File; +import java.util.Date; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.google.gson.JsonObject; + import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.exception.WxErrorException; @@ -10,12 +17,12 @@ import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.WxMpCustomMessage; import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfAccountRequest; import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfSessionRequest; -import me.chanjar.weixin.mp.bean.kefu.result.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.Date; +import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfList; +import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfMsgList; +import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfOnlineList; +import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionGetResult; +import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionList; +import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionWaitCaseList; /** * @@ -38,7 +45,7 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send"; String responseContent = this.wxMpService.post(url, message.toJson()); - return true; + return responseContent != null; } @Override @@ -60,7 +67,7 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { throws WxErrorException { String url = API_URL_PREFIX + "/kfaccount/add"; String responseContent = this.wxMpService.post(url, request.toJson()); - return true; + return responseContent != null; } @Override @@ -68,14 +75,14 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { throws WxErrorException { String url = API_URL_PREFIX + "/kfaccount/update"; String responseContent = this.wxMpService.post(url, request.toJson()); - return true; + return responseContent != null; } @Override public boolean kfAccountInviteWorker(WxMpKfAccountRequest request) throws WxErrorException { String url = API_URL_PREFIX + "/kfaccount/inviteworker"; String responseContent = this.wxMpService.post(url, request.toJson()); - return true; + return responseContent != null; } @Override @@ -84,14 +91,14 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { String url = API_URL_PREFIX + "/kfaccount/uploadheadimg?kf_account=" + kfAccount; WxMediaUploadResult responseContent = this.wxMpService .execute(new MediaUploadRequestExecutor(), url, imgFile); - return true; + return responseContent != null; } @Override public boolean kfAccountDel(String kfAccount) throws WxErrorException { String url = API_URL_PREFIX + "/kfaccount/del?kf_account=" + kfAccount; String responseContent = this.wxMpService.get(url, null); - return true; + return responseContent != null; } @Override @@ -100,7 +107,7 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { WxMpKfSessionRequest request = new WxMpKfSessionRequest(kfAccount, openid); String url = API_URL_PREFIX + "/kfsession/create"; String responseContent = this.wxMpService.post(url, request.toJson()); - return true; + return responseContent != null; } @Override @@ -109,7 +116,7 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { WxMpKfSessionRequest request = new WxMpKfSessionRequest(kfAccount, openid); String url = API_URL_PREFIX + "/kfsession/close"; String responseContent = this.wxMpService.post(url, request.toJson()); - return true; + return responseContent != null; } @Override diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java index dcb1e89f..bc48e0db 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java @@ -11,8 +11,6 @@ import java.util.TreeMap; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; import org.joor.Reflect; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -42,7 +40,6 @@ public class WxMpPayServiceImpl implements WxMpPayService { private static final List TRADE_TYPES = Lists.newArrayList("JSAPI", "NATIVE", "APP"); - private final Logger log = LoggerFactory.getLogger(WxMpPayServiceImpl.class); private WxMpService wxMpService; public WxMpPayServiceImpl(WxMpService wxMpService) { @@ -286,7 +283,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { if (!TRADE_TYPES.contains(request.getTradeType())) { throw new IllegalArgumentException( - "trade_type目前必须为" + TRADE_TYPES + "其中之一"); +"trade_type目前必须为" + TRADE_TYPES + "其中之一"); } 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 5b44b860..864d9d2c 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,6 +1,5 @@ package me.chanjar.weixin.mp.bean.store; -import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; From e26322dd2dbc4a83aad26c314a7406e46b8e01ee Mon Sep 17 00:00:00 2001 From: rtsbtx Date: Sat, 1 Oct 2016 15:01:16 +0800 Subject: [PATCH 25/76] Update WxMpUser.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增注释 --- .../main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java | 3 +++ 1 file changed, 3 insertions(+) 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 19d03abf..f56ccf5c 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 @@ -121,6 +121,9 @@ public class WxMpUser implements Serializable { this.subscribeTime = subscribeTime; } + /** + *只有在将公众号绑定到微信开放平台帐号后,才会出现该字段。 + */ public String getUnionId() { return this.unionId; } From 118e4c7a28be47c2488c77af43dab77edb7a27be Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 3 Oct 2016 23:13:59 +0800 Subject: [PATCH 26/76] =?UTF-8?q?=E6=8F=90=E5=8F=96=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=85=AC=E7=94=A8=E6=8E=A5=E5=8F=A3=E5=9C=B0=E5=9D=80=E5=B8=B8?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/impl/WxMpPayServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java index bc48e0db..965e5df1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java @@ -38,6 +38,7 @@ import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderResult; */ public class WxMpPayServiceImpl implements WxMpPayService { + private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com"; private static final List TRADE_TYPES = Lists.newArrayList("JSAPI", "NATIVE", "APP"); private WxMpService wxMpService; @@ -77,7 +78,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { } request.append(""); - String url = "https://api.mch.weixin.qq.com/pay/orderquery"; + String url = PAY_BASE_URL + "/pay/orderquery"; String responseContent = this.wxMpService.post(url, request.toString()); XStream xstream = XStreamInitializer.getInstance(); xstream.alias("xml", WxMpPayResult.class); @@ -119,7 +120,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { } request.append(""); - String url = "https://api.mch.weixin.qq.com/secapi/pay/refund"; + String url = PAY_BASE_URL + "/secapi/pay/refund"; String responseContent = this.wxMpService.post(url, request.toString()); XStream xstream = XStreamInitializer.getInstance(); xstream.processAnnotations(WxMpPayRefundResult.class); @@ -163,10 +164,10 @@ public class WxMpPayServiceImpl implements WxMpPayService { this.wxMpService.getWxMpConfigStorage().getPartnerKey()); request.setSign(sign); - String url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack"; + String url = PAY_BASE_URL + "/mmpaymkttransfers/sendredpack"; if (request.getAmtType() != null) { //裂变红包 - url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendgroupredpack"; + url = PAY_BASE_URL + "/mmpaymkttransfers/sendgroupredpack"; } String responseContent = this.wxMpService.post(url, xstream.toXML(request)); @@ -245,7 +246,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { this.wxMpService.getWxMpConfigStorage().getPartnerKey()); request.setSign(sign); - String url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; + String url = PAY_BASE_URL + "/pay/unifiedorder"; String responseContent = this.wxMpService.post(url, xstream.toXML(request)); WxUnifiedOrderResult result = (WxUnifiedOrderResult) xstream @@ -282,8 +283,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { } if (!TRADE_TYPES.contains(request.getTradeType())) { - throw new IllegalArgumentException( -"trade_type目前必须为" + TRADE_TYPES + "其中之一"); + throw new IllegalArgumentException("trade_type目前必须为" + TRADE_TYPES + "其中之一"); } From f2655e5eed9085d83a3ce77538f42d23fbc721b1 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 4 Oct 2016 23:38:17 +0800 Subject: [PATCH 27/76] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp/bean/pay/WxMpPrepayIdResult.java | 124 ------------------ 1 file changed, 124 deletions(-) delete mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPrepayIdResult.java diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPrepayIdResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPrepayIdResult.java deleted file mode 100644 index cff9d787..00000000 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPrepayIdResult.java +++ /dev/null @@ -1,124 +0,0 @@ -package me.chanjar.weixin.mp.bean.pay; - -import java.io.Serializable; - -/** - *
- * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"返回的结果
- * 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
- * 
- * - * @author chanjarster - */ -@Deprecated -public class WxMpPrepayIdResult implements Serializable { - private static final long serialVersionUID = -8970574397788396143L; - private String return_code; - private String return_msg; - private String appid; - private String mch_id; - private String nonce_str; - private String sign; - private String result_code; - private String prepay_id; - private String trade_type; - private String err_code; - private String err_code_des; - private String code_url; - - public String getReturn_code() { - return this.return_code; - } - - public void setReturn_code(String return_code) { - this.return_code = return_code; - } - - public String getReturn_msg() { - return this.return_msg; - } - - public void setReturn_msg(String return_msg) { - this.return_msg = return_msg; - } - - public String getAppid() { - return this.appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public String getMch_id() { - return this.mch_id; - } - - public void setMch_id(String mch_id) { - this.mch_id = mch_id; - } - - public String getNonce_str() { - return this.nonce_str; - } - - public void setNonce_str(String nonce_str) { - this.nonce_str = nonce_str; - } - - public String getSign() { - return this.sign; - } - - public void setSign(String sign) { - this.sign = sign; - } - - public String getResult_code() { - return this.result_code; - } - - public void setResult_code(String result_code) { - this.result_code = result_code; - } - - public String getPrepay_id() { - return this.prepay_id; - } - - public void setPrepay_id(String prepay_id) { - this.prepay_id = prepay_id; - } - - public String getTrade_type() { - return this.trade_type; - } - - public void setTrade_type(String trade_type) { - this.trade_type = trade_type; - } - - public String getErr_code() { - return this.err_code; - } - - public void setErr_code(String err_code) { - this.err_code = err_code; - } - - public String getErr_code_des() { - return this.err_code_des; - } - - public void setErr_code_des(String err_code_des) { - this.err_code_des = err_code_des; - } - - public String getCode_url() { - return this.code_url; - } - - public void setCode_url(String code_url) { - this.code_url = code_url; - } -} From 392429a476cfe1b96f5d06abe03a54a4e5a2fca7 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 4 Oct 2016 23:43:54 +0800 Subject: [PATCH 28/76] =?UTF-8?q?=E4=B8=BAWxErrorException=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=E6=9E=84=E9=80=A0=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E7=94=A8=E4=BA=8E=E5=BF=85=E8=A6=81=E6=97=B6=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E5=87=BA=E9=94=99=E8=AF=AF=E6=A0=B9=E6=BA=90=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/common/exception/WxErrorException.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/exception/WxErrorException.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/exception/WxErrorException.java index 51219a41..4038e601 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/exception/WxErrorException.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/exception/WxErrorException.java @@ -13,6 +13,11 @@ public class WxErrorException extends Exception { this.error = error; } + public WxErrorException(WxError error, Throwable cause) { + super(error.toString(), cause); + this.error = error; + } + public WxError getError() { return this.error; } From a4b0fdce937759fb309d610432eeb329fe75decc Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 5 Oct 2016 21:35:31 +0800 Subject: [PATCH 29/76] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E6=88=B7?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E7=9A=84=E6=B5=8B=E8=AF=95=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weixin-java-mp/src/test/resources/test-config.sample.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/weixin-java-mp/src/test/resources/test-config.sample.xml b/weixin-java-mp/src/test/resources/test-config.sample.xml index ad46a19e..2bbc8d8e 100644 --- a/weixin-java-mp/src/test/resources/test-config.sample.xml +++ b/weixin-java-mp/src/test/resources/test-config.sample.xml @@ -6,6 +6,8 @@ 可以不填写 可以不填写 某个加你公众号的用户的openId + 微信商户平台ID + 商户平台设置的API密钥 模版消息的模版ID 网页授权获取用户信息回调地址 网页应用授权登陆回调地址 From dabafc2a9e52db51f62662c024ded60a472fd300 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 6 Oct 2016 20:53:39 +0800 Subject: [PATCH 30/76] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E4=BB=98=E6=AC=BE=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E6=9C=AA=E8=B0=83=E9=80=9A=EF=BC=8C=E5=9B=A0=E7=BC=BA?= =?UTF-8?q?=E5=B0=91=E8=AF=81=E4=B9=A6=20for=20issue=20#50?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/mp/api/WxMpPayService.java | 16 ++ .../mp/api/impl/WxMpPayServiceImpl.java | 93 ++++++- .../weixin/mp/bean/pay/WxEntPayRequest.java | 253 ++++++++++++++++++ .../weixin/mp/bean/pay/WxEntPayResult.java | 190 +++++++++++++ .../mp/api/impl/WxMpPayServiceImplTest.java | 15 ++ 5 files changed, 553 insertions(+), 14 deletions(-) create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java index c6480e6c..cf5bb8c3 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java @@ -1,8 +1,11 @@ package me.chanjar.weixin.mp.api; +import java.io.File; import java.util.Map; import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.bean.pay.WxEntPayRequest; +import me.chanjar.weixin.mp.bean.pay.WxEntPayResult; import me.chanjar.weixin.mp.bean.pay.WxMpPayCallback; import me.chanjar.weixin.mp.bean.pay.WxMpPayRefundResult; import me.chanjar.weixin.mp.bean.pay.WxMpPayResult; @@ -85,4 +88,17 @@ public interface WxMpPayService { */ WxRedpackResult sendRedpack(WxSendRedpackRequest request) throws WxErrorException; + /** + *
 
+   * 企业付款业务是基于微信支付商户平台的资金管理能力,为了协助商户方便地实现企业向个人付款,针对部分有开发能力的商户,提供通过API完成企业付款的功能。
+   * 比如目前的保险行业向客户退保、给付、理赔。
+   * 企业付款将使用商户的可用余额,需确保可用余额充足。查看可用余额、充值、提现请登录商户平台“资金管理”https://pay.weixin.qq.com/进行操作。
+   * 注意:与商户微信支付收款资金并非同一账户,需要单独充值。
+   * 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
+   * 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers
+   * @param keyFile  证书文件对象
+   * 
+ */ + WxEntPayResult entPay(WxEntPayRequest request, File keyFile) throws WxErrorException; + } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java index 965e5df1..79e2c312 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java @@ -1,6 +1,9 @@ package me.chanjar.weixin.mp.api.impl; +import java.io.File; +import java.io.FileInputStream; import java.lang.reflect.Field; +import java.security.KeyStore; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -8,8 +11,19 @@ import java.util.Map.Entry; import java.util.SortedMap; import java.util.TreeMap; +import javax.net.ssl.SSLContext; + import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; +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.HttpClients; +import org.apache.http.ssl.SSLContexts; +import org.apache.http.util.EntityUtils; import org.joor.Reflect; import com.google.common.collect.Lists; @@ -23,6 +37,8 @@ import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.xml.XStreamInitializer; import me.chanjar.weixin.mp.api.WxMpPayService; import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.pay.WxEntPayRequest; +import me.chanjar.weixin.mp.bean.pay.WxEntPayResult; import me.chanjar.weixin.mp.bean.pay.WxMpPayCallback; import me.chanjar.weixin.mp.bean.pay.WxMpPayRefundResult; import me.chanjar.weixin.mp.bean.pay.WxMpPayResult; @@ -263,6 +279,23 @@ public class WxMpPayServiceImpl implements WxMpPayService { private void checkParameters(WxUnifiedOrderRequest request) { + checkNotNullParams(request); + + if (!TRADE_TYPES.contains(request.getTradeType())) { + throw new IllegalArgumentException("trade_type目前必须为" + TRADE_TYPES + "其中之一"); + + } + + if ("JSAPI".equals(request.getTradeType()) && request.getOpenid() == null) { + throw new IllegalArgumentException("当 trade_type是'JSAPI'时未指定openid"); + } + + if ("NATIVE".equals(request.getTradeType()) && request.getProductId() == null) { + throw new IllegalArgumentException("当 trade_type是'NATIVE'时未指定product_id"); + } + } + + private void checkNotNullParams(Object request) { List nullFields = Lists.newArrayList(); for (Entry entry : Reflect.on(request).fields() .entrySet()) { @@ -281,20 +314,6 @@ public class WxMpPayServiceImpl implements WxMpPayService { if (!nullFields.isEmpty()) { throw new IllegalArgumentException("必填字段[" + nullFields + "]必须提供值"); } - - if (!TRADE_TYPES.contains(request.getTradeType())) { - throw new IllegalArgumentException("trade_type目前必须为" + TRADE_TYPES + "其中之一"); - - } - - if ("JSAPI".equals(request.getTradeType()) && request.getOpenid() == null) { - throw new IllegalArgumentException("当 trade_type是'JSAPI'时未指定openid"); - } - - if ("NATIVE".equals(request.getTradeType()) - && request.getProductId() == null) { - throw new IllegalArgumentException("当 trade_type是'NATIVE'时未指定product_id"); - } } @Override @@ -332,4 +351,50 @@ public class WxMpPayServiceImpl implements WxMpPayService { return payInfo; } + @Override + public WxEntPayResult entPay(WxEntPayRequest request, File keyFile) throws WxErrorException { + checkNotNullParams(request); + + XStream xstream = XStreamInitializer.getInstance(); + xstream.processAnnotations(WxEntPayRequest.class); + xstream.processAnnotations(WxEntPayResult.class); + + request.setMchAppid(this.wxMpService.getWxMpConfigStorage().getAppId()); + request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId()); + request.setNonceStr(System.currentTimeMillis() + ""); + + String sign = this.createSign(xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey()); + request.setSign(sign); + + String url = PAY_BASE_URL + "/mmpaymkttransfers/promotion/transfers"; + + try (FileInputStream instream = new FileInputStream(keyFile)) { + String mchId = request.getMchId(); + KeyStore keyStore = KeyStore.getInstance("PKCS12"); + keyStore.load(instream, mchId.toCharArray()); + + SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, mchId.toCharArray()).build(); + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[] { "TLSv1" }, null, + new DefaultHostnameVerifier()); + + try (CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build()) { + HttpPost httpPost = new HttpPost(url); + httpPost.setEntity(new StringEntity(new String(xstream.toXML(request).getBytes("UTF-8"), "ISO-8859-1"))); + + try (CloseableHttpResponse response = httpclient.execute(httpPost)) { + String responseContent = EntityUtils.toString(response.getEntity()); + WxEntPayResult result = (WxEntPayResult) xstream.fromXML(responseContent); + if ("FAIL".equals(result.getResultCode())) { + throw new WxErrorException( + WxError.newBuilder().setErrorMsg(result.getErrCode() + ":" + result.getErrCodeDes()).build()); + } + + return result; + } + } + } catch (Exception e) { + throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e); + } + } + } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java new file mode 100644 index 00000000..9c7253d2 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java @@ -0,0 +1,253 @@ +package me.chanjar.weixin.mp.bean.pay; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import com.thoughtworks.xstream.annotations.XStreamAlias; + +/** + * 企业付款请求对象 + * 注释中各行含义如下: + * 字段名、 变量名、 是否必填、 示例值、 类型、 描述 + * Created by Binary Wang on 2016/10/02. + * @author binarywang (https://github.com/binarywang) + */ +@XStreamAlias("xml") +public class WxEntPayRequest { + /** + * 公众账号appid + * mch_appid + * 是 + * wx8888888888888888 + * String + * 微信分配的公众账号ID(企业号corpid即为此appId) + */ + @XStreamAlias("mch_appid") + private String mchAppid; + + /** + * 商户号 + * mchid + * 是 + * 1900000109 + * String(32) + * 微信支付分配的商户号 + */ + @XStreamAlias("mchid") + private String mchId; + + /** + * 设备号 + * device_info + * 否 + * 13467007045764 + * String(32) + *微信支付分配的终端设备号 + */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + * 随机字符串 + * nonce_str + *是 + *5K8264ILTKCH16CQ2502SI8ZNMTM67VS + *String(32) + *随机字符串,不长于32位 + */ + @XStreamAlias("nonce_str") + private String nonceStr; + + /** + * 签名 + * sign + * 是 + * C380BEC2BFD727A4B6845133519F3AD6 + * String(32) + *签名,详见签名算法 + */ + @XStreamAlias("sign") + private String sign; + + /** + * 商户订单号 + * partner_trade_no + * 是 + * 10000098201411111234567890 + * String + * 商户订单号, + */ + @XStreamAlias("partner_trade_no") + private String partnerTradeNo; + + /** + * 需保持唯一性 用户openid + * openid + * 是 + * oxTWIuGaIt6gTKsQRLau2M0yL16E + * String + * 商户appid下,某用户的openid + */ + @XStreamAlias("openid") + private String openid; + + /** + * 校验用户姓名选项 + * check_name + * 是 + * OPTION_CHECK + * String + * NO_CHECK:不校验真实姓名  + * FORCE_CHECK:强校验真实姓名(未实名认证的用户会校验失败,无法转账)  + * OPTION_CHECK:针对已实名认证的用户才校验真实姓名(未实名认证用户不校验,可以转账成功) + */ + @XStreamAlias("check_name") + private String checkName; + + /** + * 收款用户姓名 + * re_user_name + * 可选 + * 马花花 + * String + * 收款用户真实姓名。 + * 如果check_name设置为FORCE_CHECK或OPTION_CHECK, 则必填用户真实姓名 + */ + @XStreamAlias("re_user_name") + private String reUserName; + + /** + * 金额 + * amount + * 是 + * 10099 + * int + * 企业付款金额, 单位为分 + */ + @XStreamAlias("amount") + private Integer amount; + + /** + * 企业付款描述信息 + * desc + * 是 + * 理赔 + * String + * 企业付款操作说明信息。必填。 + */ + @XStreamAlias("desc") + private String description; + + /** + * Ip地址 + * spbill_create_ip + * 是 + * 192.168.0.1 + * String(32) + * 调用接口的机器Ip地址 + */ + @XStreamAlias("spbill_create_ip") + private String spbillCreateIp; + + public String getMchAppid() { + return mchAppid; + } + + public void setMchAppid(String mchAppid) { + this.mchAppid = mchAppid; + } + + public String getMchId() { + return mchId; + } + + public void setMchId(String mchId) { + this.mchId = mchId; + } + + public String getDeviceInfo() { + return deviceInfo; + } + + public void setDeviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + } + + public String getNonceStr() { + return nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public String getPartnerTradeNo() { + return partnerTradeNo; + } + + public void setPartnerTradeNo(String partnerTradeNo) { + this.partnerTradeNo = partnerTradeNo; + } + + public String getOpenid() { + return openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + + public String getCheckName() { + return checkName; + } + + public void setCheckName(String checkName) { + this.checkName = checkName; + } + + public String getReUserName() { + return reUserName; + } + + public void setReUserName(String reUserName) { + this.reUserName = reUserName; + } + + public Integer getAmount() { + return amount; + } + + public void setAmount(Integer amount) { + this.amount = amount; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSpbillCreateIp() { + return spbillCreateIp; + } + + public void setSpbillCreateIp(String spbillCreateIp) { + this.spbillCreateIp = spbillCreateIp; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java new file mode 100644 index 00000000..b2dbb8f1 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java @@ -0,0 +1,190 @@ +package me.chanjar.weixin.mp.bean.pay; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import com.thoughtworks.xstream.annotations.XStreamAlias; + +/** + * 企业付款返回结果 + * Created by Binary Wang on 2016/10/02. + * @author binarywang (https://github.com/binarywang) + */ +@XStreamAlias("xml") +public class WxEntPayResult { + + /** + * 返回状态码 + */ + @XStreamAlias("return_code") + private String returnCode; + + /** + * 返回信息 + */ + @XStreamAlias("return_msg") + private String returnMsg; + + //############以下字段在return_code为SUCCESS的时候有返回 + + /** + * 商户appid + */ + @XStreamAlias("mch_appid") + private String mchAppid; + + /** + * 商户号 + */ + @XStreamAlias("mchid") + private String mchId; + + /** + * 设备号 + */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + * 随机字符串 + */ + @XStreamAlias("nonce_str") + private String nonceStr; + + /** + * 业务结果 + */ + @XStreamAlias("result_code") + private String resultCode; + /** + * 错误代码 + */ + @XStreamAlias("err_code") + private String errCode; + + /** + * 错误代码描述 + */ + @XStreamAlias("err_code_des") + private String errCodeDes; + + //############以下字段在return_code 和result_code都为SUCCESS的时候有返回############## + /** + * 商户订单号 + */ + @XStreamAlias("partner_trade_no") + private String partnerTradeNo; + + /** + * 微信订单号 + */ + @XStreamAlias("payment_no") + private String paymentNo; + + /** + * 微信支付成功时间 + */ + @XStreamAlias("payment_time") + private String paymentTime; + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); + } + + 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 getMchAppid() { + return mchAppid; + } + + public void setMchAppid(String mchAppid) { + this.mchAppid = mchAppid; + } + + public String getMchId() { + return mchId; + } + + public void setMchId(String mchId) { + this.mchId = mchId; + } + + public String getDeviceInfo() { + return deviceInfo; + } + + public void setDeviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + } + + public String getNonceStr() { + return nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + 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 getPartnerTradeNo() { + return partnerTradeNo; + } + + public void setPartnerTradeNo(String partnerTradeNo) { + this.partnerTradeNo = partnerTradeNo; + } + + public String getPaymentNo() { + return paymentNo; + } + + public void setPaymentNo(String paymentNo) { + this.paymentNo = paymentNo; + } + + public String getPaymentTime() { + return paymentTime; + } + + public void setPaymentTime(String paymentTime) { + this.paymentTime = paymentTime; + } +} diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java index 092be38a..6199efeb 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java @@ -1,5 +1,7 @@ package me.chanjar.weixin.mp.api.impl; +import java.io.File; + import org.testng.annotations.Guice; import org.testng.annotations.Test; @@ -8,6 +10,7 @@ import com.google.inject.Inject; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.ApiTestModule; import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; +import me.chanjar.weixin.mp.bean.pay.WxEntPayRequest; import me.chanjar.weixin.mp.bean.pay.WxRedpackResult; import me.chanjar.weixin.mp.bean.pay.WxSendRedpackRequest; import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest; @@ -74,4 +77,16 @@ public class WxMpPayServiceImplTest { .tradeType("JSAPI").openid("122").outTradeNo("111111").build()); System.err.println(result); } + + /** + * Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#entPay(WxEntPayRequest, File)}. + * @throws WxErrorException + */ + @Test + public final void testEntPay() throws WxErrorException { + File keyFile = new File("E:\\dlt.p12"); + WxEntPayRequest request = new WxEntPayRequest(); + System.err.println(this.wxService.getPayService().entPay(request, keyFile)); + } + } From 782bc6a772bdd27e4160383ef9efd3ef3f808aff Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 7 Oct 2016 14:07:22 +0800 Subject: [PATCH 31/76] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0d02922a..d4440332 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ ### 注意: 1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。*** 1. ***自2.0.0版本以来,公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。*** +1. 本SDK要求的最低JDK版本是7,为解决少量还在使用JDK6的用户,特意抽出独立的代码分支项目,请参考 https://github.com/binarywang/weixin-java-tools-for-jdk ,其他更早的JDK版本则需要自己改造实现; 1. 最新更新:2016-09-30 发布2.2.0正式版! =========== @@ -19,9 +20,9 @@ =========== ## 版本说明 -1. 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.0.0,2.1.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request; +1. 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.1.0,2.2.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request; 1. BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版); -1. 目前最新版本号为 ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) ,也可以通过访问链接[【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) 、[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22) +1. 目前最新版本号为 ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) ,也可以通过访问链接 [【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) 、[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22) 分别查看所有最新的版本。 ## Maven & Gradle @@ -56,6 +57,8 @@ gradle: compile 'com.github.binarywang:weixin-java-cp:2.2.0' ``` +=========== + #### 本项目主要存放在github上,地址为 : * https://github.com/wechat-group/weixin-java-tools * ===========但同时会在其他几个网站同步更新,地址分别是: @@ -63,11 +66,12 @@ compile 'com.github.binarywang:weixin-java-cp:2.2.0' * http://git.oschina.net/binary/weixin-java-tools * https://git.coding.net/binarywang/weixin-java-tools.git - +=========== ## 目前可参考的Demo项目有两个: 1. https://github.com/wechat-group/weixin-mp-demo 1. https://github.com/wechat-group/weixin-java-tools-springmvc +=========== ## 关于代码贡献 1. 非常欢迎和感谢对本项目发起Pull Request的同学,本项目代码风格为使用2个空格代表一个Tab,因此在提交代码时请注意一下,否则很容易在IDE格式化代码后与原代码产生大量diff,这样会给其他人阅读代码带来极大的困扰。 1. 为了便于设置,本项目引入editorconfig插件,请使用eclipse的同学在贡献代码前安装相关插件,IntelliJ IDEA则自带支持,无需额外安装插件。 From 03f029c68c428a216c46e745c0e60b87b0f408b6 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 7 Oct 2016 14:12:27 +0800 Subject: [PATCH 32/76] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=8E=9F=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E4=BF=A1=E6=81=AF=20https://github.com/chanjarster/we?= =?UTF-8?q?ixin-java-tools/pull/277?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/common/util/http/ApacheHttpClientBuilder.java | 1 + .../common/util/http/DefaultApacheHttpClientBuilder.java | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/ApacheHttpClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/ApacheHttpClientBuilder.java index 8bd900ca..c932445d 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/ApacheHttpClientBuilder.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/ApacheHttpClientBuilder.java @@ -5,6 +5,7 @@ import org.apache.http.impl.client.CloseableHttpClient; /** * httpclient build interface + * @author kakotor */ public interface ApacheHttpClientBuilder { diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/DefaultApacheHttpClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/DefaultApacheHttpClientBuilder.java index f69dcc6c..0e6f9000 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/DefaultApacheHttpClientBuilder.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/DefaultApacheHttpClientBuilder.java @@ -1,6 +1,8 @@ package me.chanjar.weixin.common.util.http; -import me.chanjar.weixin.common.util.StringUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; + import org.apache.http.annotation.NotThreadSafe; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; @@ -21,11 +23,11 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.protocol.HttpContext; -import java.io.IOException; -import java.util.concurrent.TimeUnit; +import me.chanjar.weixin.common.util.StringUtils; /** * httpclient 连接管理器 + * @author kakotor */ @NotThreadSafe public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder { From d9a32d87b90d18052c1755f9e866a6b8d6ec463c Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 7 Oct 2016 14:17:20 +0800 Subject: [PATCH 33/76] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4440332..c473c9cd 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ### 注意: 1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。*** 1. ***自2.0.0版本以来,公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。*** -1. 本SDK要求的最低JDK版本是7,为解决少量还在使用JDK6的用户,特意抽出独立的代码分支项目,请参考 https://github.com/binarywang/weixin-java-tools-for-jdk ,其他更早的JDK版本则需要自己改造实现; +1. 本SDK要求的最低JDK版本是7,为解决少量还在使用JDK6的用户,特意抽出独立的代码分支项目,请参考 https://github.com/binarywang/weixin-java-tools-for-jdk6 ,其他更早的JDK版本则需要自己改造实现; 1. 最新更新:2016-09-30 发布2.2.0正式版! =========== From 5aba474ffe9331e2ddd79c02244968b4ed9f852f Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sat, 8 Oct 2016 12:07:47 +0800 Subject: [PATCH 34/76] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96javadoc?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0pre=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/bean/pay/WxEntPayRequest.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java index 9c7253d2..ea900b50 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java @@ -15,83 +15,98 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; @XStreamAlias("xml") public class WxEntPayRequest { /** + *
   * 公众账号appid
   * mch_appid
   * 是
   * wx8888888888888888
   * String
   * 微信分配的公众账号ID(企业号corpid即为此appId)
+   * 
*/ @XStreamAlias("mch_appid") private String mchAppid; /** + *
   *  商户号
   *  mchid
   *  是
   *  1900000109
   *  String(32)
   *  微信支付分配的商户号
+   * 
*/ @XStreamAlias("mchid") private String mchId; /** + *
   * 设备号
   * device_info
   * 否
   * 13467007045764
   * String(32)
   *微信支付分配的终端设备号
+   * 
*/ @XStreamAlias("device_info") private String deviceInfo; /** + *
   * 随机字符串
   * nonce_str
   *是
   *5K8264ILTKCH16CQ2502SI8ZNMTM67VS
   *String(32)
   *随机字符串,不长于32位
+   * 
*/ @XStreamAlias("nonce_str") private String nonceStr; /** + *
   * 签名
   * sign
   * 是
   * C380BEC2BFD727A4B6845133519F3AD6
   * String(32)
   *签名,详见签名算法
+   * 
*/ @XStreamAlias("sign") private String sign; /** + *
   * 商户订单号
   * partner_trade_no
   * 是
   * 10000098201411111234567890
   * String
-  * 商户订单号,
+  * 商户订单号
+   * 
*/ @XStreamAlias("partner_trade_no") private String partnerTradeNo; /** + *
   * 需保持唯一性 用户openid
   * openid
   * 是
   * oxTWIuGaIt6gTKsQRLau2M0yL16E
   * String
   * 商户appid下,某用户的openid
+   * 
*/ @XStreamAlias("openid") private String openid; /** + *
   * 校验用户姓名选项
   * check_name
   * 是
@@ -100,11 +115,13 @@ public class WxEntPayRequest {
   * NO_CHECK:不校验真实姓名 
   * FORCE_CHECK:强校验真实姓名(未实名认证的用户会校验失败,无法转账) 
   * OPTION_CHECK:针对已实名认证的用户才校验真实姓名(未实名认证用户不校验,可以转账成功)
+   * 
*/ @XStreamAlias("check_name") private String checkName; /** + *
   * 收款用户姓名
   * re_user_name
   * 可选
@@ -112,39 +129,46 @@ public class WxEntPayRequest {
   * String
   * 收款用户真实姓名。
   * 如果check_name设置为FORCE_CHECK或OPTION_CHECK,  则必填用户真实姓名
+   * 
*/ @XStreamAlias("re_user_name") private String reUserName; /** + *
   * 金额
   * amount
   * 是
   * 10099
   * int
   * 企业付款金额, 单位为分
+   * 
*/ @XStreamAlias("amount") private Integer amount; /** + *
   * 企业付款描述信息
   * desc
   * 是
   * 理赔
   * String
   * 企业付款操作说明信息。必填。
+   * 
*/ @XStreamAlias("desc") private String description; /** + *
   * Ip地址
   * spbill_create_ip
   * 是
   * 192.168.0.1
   * String(32)
   * 调用接口的机器Ip地址
+   * 
*/ @XStreamAlias("spbill_create_ip") private String spbillCreateIp; From ff20ecb56c52663e4b979241cc9ba36e3274ef1a Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sat, 8 Oct 2016 14:38:26 +0800 Subject: [PATCH 35/76] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E7=BD=91=E5=9D=80?= =?UTF-8?q?=E5=85=B1=E5=90=8C=E9=83=A8=E5=88=86=E4=B8=BA=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 --- .../chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 4d3639c8..94749c12 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 @@ -102,7 +102,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { @Override public boolean batchTagging(Long tagId, String[] openids) throws WxErrorException { - String url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging"; + String url = API_URL_PREFIX + "/members/batchtagging"; JsonObject json = new JsonObject(); json.addProperty("tagid", tagId); @@ -124,7 +124,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { @Override public boolean batchUntagging(Long tagId, String[] openids) throws WxErrorException { - String url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging"; + String url = API_URL_PREFIX + "/members/batchuntagging"; JsonObject json = new JsonObject(); json.addProperty("tagid", tagId); @@ -145,7 +145,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { @Override public List userTagList(String openid) throws WxErrorException { - String url = "https://api.weixin.qq.com/cgi-bin/tags/getidlist"; + String url = API_URL_PREFIX + "/getidlist"; JsonObject json = new JsonObject(); json.addProperty("openid", openid); From d9d0f5403ec7ce97179fdfffc7a45f426f24562c Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sat, 8 Oct 2016 14:38:44 +0800 Subject: [PATCH 36/76] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96javadoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/mp/bean/pay/WxEntPayRequest.java | 11 +++++++++-- .../weixin/mp/bean/pay/WxUnifiedOrderRequest.java | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java index ea900b50..38ed704a 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java @@ -6,9 +6,16 @@ import org.apache.commons.lang3.builder.ToStringStyle; import com.thoughtworks.xstream.annotations.XStreamAlias; /** + *
  * 企业付款请求对象
- * 注释中各行含义如下:
- * 字段名、 变量名、 是否必填、 示例值、 类型、 描述
+ * 注释中各行每个字段描述对应如下:
+ * 
  • 字段名 + *
  • 变量名 + *
  • 是否必填 + *
  • 类型 + *
  • 示例值 + *
  • 描述 + *
  • * Created by Binary Wang on 2016/10/02. * @author binarywang (https://github.com/binarywang) */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java index ccdfff90..4173c373 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java @@ -11,7 +11,7 @@ import me.chanjar.weixin.common.annotation.Required; *
      * 统一下单请求参数对象
      * 参考文档:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1
    - * 每个字段描述对应如下:
    + * 注释中各行每个字段描述对应如下:
      * 
  • 字段名 *
  • 变量名 *
  • 是否必填 From 10ce6a8920cf66680db771391a7534cf8250e07d Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sat, 8 Oct 2016 15:02:45 +0800 Subject: [PATCH 37/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/impl/WxMpUserTagServiceImplTest.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) 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 9fc579c9..569b696d 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 @@ -1,17 +1,15 @@ package me.chanjar.weixin.mp.api.impl; -import java.util.List; - -import org.testng.Assert; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - import com.google.inject.Inject; - import me.chanjar.weixin.mp.api.ApiTestModule; import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; import me.chanjar.weixin.mp.bean.tag.WxTagListUser; import me.chanjar.weixin.mp.bean.tag.WxUserTag; +import org.testng.Assert; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.List; /** * @@ -64,6 +62,14 @@ public class WxMpUserTagServiceImplTest { Assert.assertNotNull(res); } + @Test + public void testBatchTagging() throws Exception { + String[] openids = new String[]{((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()}; + boolean res = this.wxService.getUserTagService().batchTagging(this.tagId, openids); + System.out.println(res); + Assert.assertTrue(res); + } + @Test public void testBatchUntagging() throws Exception { String[] openids = new String[]{((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()}; From 5fe1c061f27f1abde29078a2a1454097a578eb45 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sat, 8 Oct 2016 17:07:36 +0800 Subject: [PATCH 38/76] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=94=B3=E8=AF=B7=E9=80=80=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20for=20issue=20#25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/mp/api/WxMpPayService.java | 35 +- .../mp/api/impl/WxMpPayServiceImpl.java | 147 ++++----- .../weixin/mp/api/impl/WxMpServiceImpl.java | 63 +--- .../mp/bean/pay/WxMpPayRefundRequest.java | 301 ++++++++++++++++++ .../mp/api/impl/WxMpPayServiceImplTest.java | 26 +- 5 files changed, 413 insertions(+), 159 deletions(-) create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java index cf5bb8c3..45973443 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java @@ -1,19 +1,11 @@ package me.chanjar.weixin.mp.api; +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.bean.pay.*; + import java.io.File; import java.util.Map; -import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.bean.pay.WxEntPayRequest; -import me.chanjar.weixin.mp.bean.pay.WxEntPayResult; -import me.chanjar.weixin.mp.bean.pay.WxMpPayCallback; -import me.chanjar.weixin.mp.bean.pay.WxMpPayRefundResult; -import me.chanjar.weixin.mp.bean.pay.WxMpPayResult; -import me.chanjar.weixin.mp.bean.pay.WxRedpackResult; -import me.chanjar.weixin.mp.bean.pay.WxSendRedpackRequest; -import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest; -import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderResult; - /** * 微信支付相关接口 * Created by Binary Wang on 2016/7/28. @@ -25,7 +17,7 @@ public interface WxMpPayService { * 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1) * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识" * 接口地址:https://api.mch.weixin.qq.com/pay/unifiedorder - * @throws WxErrorException + * @throws WxErrorException * */ WxUnifiedOrderResult unifiedOrder(WxUnifiedOrderRequest request) @@ -42,7 +34,7 @@ public interface WxMpPayService { /** * 该接口提供所有微信支付订单的查询,当支付通知处理异常戒丢失的情冴,商户可以通过该接口查询订单支付状态。 * 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2 - * @throws WxErrorException + * @throws WxErrorException * */ WxMpPayResult getJSSDKPayResult(String transactionId, String outTradeNo) @@ -56,18 +48,15 @@ public interface WxMpPayService { WxMpPayCallback getJSSDKCallbackData(String xmlData); /** + *
        * 微信支付-申请退款
        * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
    -   *
    -   * @param parameters 需要传入的退款参数的Map。以下几项为参数的必须项:
    - *
  • transaction_id - *
  • out_trade_no (仅在上述transaction_id为空时是必须项) - *
  • out_refund_no - *
  • total_fee - *
  • refund_fee + * 接口链接:https://api.mch.weixin.qq.com/secapi/pay/refund + *
  • + * @param keyFile 证书文件对象 * @return 退款操作结果 */ - WxMpPayRefundResult refundPay(Map parameters) throws WxErrorException; + WxMpPayRefundResult refund(WxMpPayRefundRequest request, File keyFile) throws WxErrorException; /** *
    @@ -80,7 +69,7 @@ public interface WxMpPayService {
     
       /**
        * 发送微信红包给个人用户
    -   * 
     
    +   * 
        * 文档详见:
        * 发送普通红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3
        * 发送裂变红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4
    @@ -89,7 +78,7 @@ public interface WxMpPayService {
       WxRedpackResult sendRedpack(WxSendRedpackRequest request) throws WxErrorException;
     
       /**
    -   * 
     
    +   * 
        * 企业付款业务是基于微信支付商户平台的资金管理能力,为了协助商户方便地实现企业向个人付款,针对部分有开发能力的商户,提供通过API完成企业付款的功能。
        * 比如目前的保险行业向客户退保、给付、理赔。
        * 企业付款将使用商户的可用余额,需确保可用余额充足。查看可用余额、充值、提现请登录商户平台“资金管理”https://pay.weixin.qq.com/进行操作。
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    index 79e2c312..a8d5dc3f 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    @@ -1,19 +1,18 @@
     package me.chanjar.weixin.mp.api.impl;
     
    -import java.io.File;
    -import java.io.FileInputStream;
    -import java.lang.reflect.Field;
    -import java.security.KeyStore;
    -import java.util.HashMap;
    -import java.util.List;
    -import java.util.Map;
    -import java.util.Map.Entry;
    -import java.util.SortedMap;
    -import java.util.TreeMap;
    -
    -import javax.net.ssl.SSLContext;
    -
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +import com.thoughtworks.xstream.XStream;
    +import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import me.chanjar.weixin.common.annotation.Required;
    +import me.chanjar.weixin.common.bean.result.WxError;
    +import me.chanjar.weixin.common.exception.WxErrorException;
    +import me.chanjar.weixin.common.util.xml.XStreamInitializer;
    +import me.chanjar.weixin.mp.api.WxMpPayService;
    +import me.chanjar.weixin.mp.api.WxMpService;
    +import me.chanjar.weixin.mp.bean.pay.*;
     import org.apache.commons.codec.digest.DigestUtils;
    +import org.apache.commons.lang3.ArrayUtils;
     import org.apache.commons.lang3.StringUtils;
     import org.apache.http.client.methods.CloseableHttpResponse;
     import org.apache.http.client.methods.HttpPost;
    @@ -26,26 +25,13 @@ import org.apache.http.ssl.SSLContexts;
     import org.apache.http.util.EntityUtils;
     import org.joor.Reflect;
     
    -import com.google.common.collect.Lists;
    -import com.google.common.collect.Maps;
    -import com.thoughtworks.xstream.XStream;
    -import com.thoughtworks.xstream.annotations.XStreamAlias;
    -
    -import me.chanjar.weixin.common.annotation.Required;
    -import me.chanjar.weixin.common.bean.result.WxError;
    -import me.chanjar.weixin.common.exception.WxErrorException;
    -import me.chanjar.weixin.common.util.xml.XStreamInitializer;
    -import me.chanjar.weixin.mp.api.WxMpPayService;
    -import me.chanjar.weixin.mp.api.WxMpService;
    -import me.chanjar.weixin.mp.bean.pay.WxEntPayRequest;
    -import me.chanjar.weixin.mp.bean.pay.WxEntPayResult;
    -import me.chanjar.weixin.mp.bean.pay.WxMpPayCallback;
    -import me.chanjar.weixin.mp.bean.pay.WxMpPayRefundResult;
    -import me.chanjar.weixin.mp.bean.pay.WxMpPayResult;
    -import me.chanjar.weixin.mp.bean.pay.WxRedpackResult;
    -import me.chanjar.weixin.mp.bean.pay.WxSendRedpackRequest;
    -import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest;
    -import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderResult;
    +import javax.net.ssl.SSLContext;
    +import java.io.File;
    +import java.io.FileInputStream;
    +import java.lang.reflect.Field;
    +import java.security.KeyStore;
    +import java.util.*;
    +import java.util.Map.Entry;
     
     /**
      * Created by Binary Wang on 2016/7/28.
    @@ -55,8 +41,10 @@ import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderResult;
     public class WxMpPayServiceImpl implements WxMpPayService {
     
       private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com";
    -  private static final List TRADE_TYPES = Lists.newArrayList("JSAPI",
    -      "NATIVE", "APP");
    +  private static final String[] TRADE_TYPES = new String[]{"JSAPI","NATIVE", "APP"};
    +  private static final String[] REFUND_ACCOUNT =  new String[]{"REFUND_SOURCE_RECHARGE_FUNDS",
    +    "REFUND_SOURCE_UNSETTLED_FUNDS"};
    +
       private WxMpService wxMpService;
     
       public WxMpPayServiceImpl(WxMpService wxMpService) {
    @@ -115,33 +103,25 @@ public class WxMpPayServiceImpl implements WxMpPayService {
       }
     
       @Override
    -  public WxMpPayRefundResult refundPay(Map parameters)
    +  public WxMpPayRefundResult refund(WxMpPayRefundRequest request, File keyFile)
           throws WxErrorException {
    -    SortedMap refundParams = new TreeMap<>(parameters);
    -    refundParams.put("appid",
    -        this.wxMpService.getWxMpConfigStorage().getAppId());
    -    refundParams.put("mch_id",
    -        this.wxMpService.getWxMpConfigStorage().getPartnerId());
    -    refundParams.put("nonce_str", System.currentTimeMillis() + "");
    -    refundParams.put("op_user_id",
    -        this.wxMpService.getWxMpConfigStorage().getPartnerId());
    -    String sign = this.createSign(refundParams,
    -        this.wxMpService.getWxMpConfigStorage().getPartnerKey());
    -    refundParams.put("sign", sign);
    -
    -    StringBuilder request = new StringBuilder("");
    -    for (Map.Entry para : refundParams.entrySet()) {
    -      request.append(String.format("<%s>%s", para.getKey(),
    -          para.getValue(), para.getKey()));
    -    }
    -    request.append("");
    +    checkParameters(request);
     
    -    String url = PAY_BASE_URL + "/secapi/pay/refund";
    -    String responseContent = this.wxMpService.post(url, request.toString());
         XStream xstream = XStreamInitializer.getInstance();
         xstream.processAnnotations(WxMpPayRefundResult.class);
    -    WxMpPayRefundResult wxMpPayRefundResult = (WxMpPayRefundResult) xstream
    -        .fromXML(responseContent);
    +    xstream.processAnnotations(WxMpPayRefundRequest.class);
    +
    +    request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId());
    +    String partnerId = this.wxMpService.getWxMpConfigStorage().getPartnerId();
    +    request.setMchId(partnerId);
    +    request.setNonceStr( System.currentTimeMillis() + "");
    +    request.setOpUserId(partnerId);
    +    String sign = this.createSign(this.xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey());
    +    request.setSign(sign);
    +
    +    String url = PAY_BASE_URL + "/secapi/pay/refund";
    +    String responseContent = this.executeRequestWithKeyFile(url, xstream.toXML(request), keyFile, partnerId);
    +    WxMpPayRefundResult wxMpPayRefundResult = (WxMpPayRefundResult) xstream.fromXML(responseContent);
     
         if (!"SUCCESS".equalsIgnoreCase(wxMpPayRefundResult.getResultCode())
             || !"SUCCESS".equalsIgnoreCase(wxMpPayRefundResult.getReturnCode())) {
    @@ -158,6 +138,20 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         return wxMpPayRefundResult;
       }
     
    +  private void checkParameters(WxMpPayRefundRequest request) {
    +    checkNotNullParams(request);
    +
    +    if (StringUtils.isNotBlank(request.getRefundAccount())) {
    +      if(!ArrayUtils.contains(REFUND_ACCOUNT, request.getRefundAccount())){
    +        throw new IllegalArgumentException("refund_account目前必须为" + Arrays.toString(REFUND_ACCOUNT) + "其中之一");
    +      }
    +    }
    +
    +    if (StringUtils.isBlank(request.getOutTradeNo()) && StringUtils.isBlank(request.getTransactionId())) {
    +      throw new IllegalArgumentException("transaction_id 和 out_trade_no 不能同时为空,必须提供一个");
    +    }
    +  }
    +
       @Override
       public boolean checkJSSDKCallbackDataSignature(Map kvm,
           String signature) {
    @@ -176,7 +170,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId());
         request.setNonceStr(System.currentTimeMillis() + "");
     
    -    String sign = this.createSign(xmlBean2Map(request),
    +    String sign = this.createSign(this.xmlBean2Map(request),
             this.wxMpService.getWxMpConfigStorage().getPartnerKey());
         request.setSign(sign);
     
    @@ -258,7 +252,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId());
         request.setNonceStr(System.currentTimeMillis() + "");
     
    -    String sign = this.createSign(xmlBean2Map(request),
    +    String sign = this.createSign(this.xmlBean2Map(request),
             this.wxMpService.getWxMpConfigStorage().getPartnerKey());
         request.setSign(sign);
     
    @@ -274,16 +268,13 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         }
     
         return result;
    -
       }
     
       private void checkParameters(WxUnifiedOrderRequest request) {
    -
         checkNotNullParams(request);
     
    -    if (!TRADE_TYPES.contains(request.getTradeType())) {
    -      throw new IllegalArgumentException("trade_type目前必须为" + TRADE_TYPES + "其中之一");
    -
    +    if (! ArrayUtils.contains(TRADE_TYPES, request.getTradeType())) {
    +      throw new IllegalArgumentException("trade_type目前必须为" + Arrays.toString(TRADE_TYPES) + "其中之一");
         }
     
         if ("JSAPI".equals(request.getTradeType()) && request.getOpenid() == null) {
    @@ -368,10 +359,19 @@ public class WxMpPayServiceImpl implements WxMpPayService {
     
         String url = PAY_BASE_URL + "/mmpaymkttransfers/promotion/transfers";
     
    -    try (FileInputStream instream = new FileInputStream(keyFile)) {
    -      String mchId = request.getMchId();
    +    String responseContent = this.executeRequestWithKeyFile(xstream.toXML(request), url, keyFile, request.getMchId());
    +    WxEntPayResult result = (WxEntPayResult) xstream.fromXML(responseContent);
    +    if ("FAIL".equals(result.getResultCode())) {
    +      throw new WxErrorException(
    +        WxError.newBuilder().setErrorMsg(result.getErrCode() + ":" + result.getErrCodeDes()).build());
    +    }
    +    return result;
    +  }
    +
    +  private String executeRequestWithKeyFile( String requestStr, String url, File keyFile, String mchId) throws WxErrorException {
    +    try (FileInputStream inputStream = new FileInputStream(keyFile)) {
           KeyStore keyStore = KeyStore.getInstance("PKCS12");
    -      keyStore.load(instream, mchId.toCharArray());
    +      keyStore.load(inputStream, mchId.toCharArray());
     
           SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, mchId.toCharArray()).build();
           SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[] { "TLSv1" }, null,
    @@ -379,17 +379,10 @@ public class WxMpPayServiceImpl implements WxMpPayService {
     
           try (CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build()) {
             HttpPost httpPost = new HttpPost(url);
    -        httpPost.setEntity(new StringEntity(new String(xstream.toXML(request).getBytes("UTF-8"), "ISO-8859-1")));
    +        httpPost.setEntity(new StringEntity(new String(requestStr.getBytes("UTF-8"), "ISO-8859-1")));
     
             try (CloseableHttpResponse response = httpclient.execute(httpPost)) {
    -          String responseContent = EntityUtils.toString(response.getEntity());
    -          WxEntPayResult result = (WxEntPayResult) xstream.fromXML(responseContent);
    -          if ("FAIL".equals(result.getResultCode())) {
    -            throw new WxErrorException(
    -                WxError.newBuilder().setErrorMsg(result.getErrCode() + ":" + result.getErrCodeDes()).build());
    -          }
    -
    -          return result;
    +          return EntityUtils.toString(response.getEntity());
             }
           }
         } catch (Exception e) {
    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 1a7ffe84..4cd26894 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
    @@ -1,23 +1,9 @@
     package me.chanjar.weixin.mp.api.impl;
     
    -import java.io.IOException;
    -
    -import org.apache.http.HttpHost;
    -import org.apache.http.client.config.RequestConfig;
    -import org.apache.http.client.methods.CloseableHttpResponse;
    -import org.apache.http.client.methods.HttpGet;
    -import org.apache.http.conn.ssl.DefaultHostnameVerifier;
    -import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
    -import org.apache.http.impl.client.BasicResponseHandler;
    -import org.apache.http.impl.client.CloseableHttpClient;
    -import org.slf4j.Logger;
    -import org.slf4j.LoggerFactory;
    -
     import com.google.gson.JsonArray;
     import com.google.gson.JsonElement;
     import com.google.gson.JsonObject;
     import com.google.gson.JsonParser;
    -
     import me.chanjar.weixin.common.bean.WxAccessToken;
     import me.chanjar.weixin.common.bean.WxJsapiSignature;
     import me.chanjar.weixin.common.bean.result.WxError;
    @@ -26,38 +12,22 @@ import me.chanjar.weixin.common.session.StandardSessionManager;
     import me.chanjar.weixin.common.session.WxSessionManager;
     import me.chanjar.weixin.common.util.RandomUtils;
     import me.chanjar.weixin.common.util.crypto.SHA1;
    -import me.chanjar.weixin.common.util.http.ApacheHttpClientBuilder;
    -import me.chanjar.weixin.common.util.http.DefaultApacheHttpClientBuilder;
    -import me.chanjar.weixin.common.util.http.RequestExecutor;
    -import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
    -import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
    -import me.chanjar.weixin.common.util.http.URIUtil;
    -import me.chanjar.weixin.mp.api.WxMpCardService;
    -import me.chanjar.weixin.mp.api.WxMpConfigStorage;
    -import me.chanjar.weixin.mp.api.WxMpDataCubeService;
    -import me.chanjar.weixin.mp.api.WxMpKefuService;
    -import me.chanjar.weixin.mp.api.WxMpMaterialService;
    -import me.chanjar.weixin.mp.api.WxMpMenuService;
    -import me.chanjar.weixin.mp.api.WxMpPayService;
    -import me.chanjar.weixin.mp.api.WxMpQrcodeService;
    -import me.chanjar.weixin.mp.api.WxMpService;
    -import me.chanjar.weixin.mp.api.WxMpStoreService;
    -import me.chanjar.weixin.mp.api.WxMpUserBlacklistService;
    -import me.chanjar.weixin.mp.api.WxMpUserService;
    -import me.chanjar.weixin.mp.api.WxMpUserTagService;
    -import me.chanjar.weixin.mp.bean.WxMpIndustry;
    -import me.chanjar.weixin.mp.bean.WxMpMassNews;
    -import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
    -import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage;
    -import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
    -import me.chanjar.weixin.mp.bean.WxMpMassVideo;
    -import me.chanjar.weixin.mp.bean.WxMpSemanticQuery;
    -import me.chanjar.weixin.mp.bean.WxMpTemplateMessage;
    -import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
    -import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
    -import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
    -import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
    -import me.chanjar.weixin.mp.bean.result.WxMpUser;
    +import me.chanjar.weixin.common.util.http.*;
    +import me.chanjar.weixin.mp.api.*;
    +import me.chanjar.weixin.mp.bean.*;
    +import me.chanjar.weixin.mp.bean.result.*;
    +import org.apache.http.HttpHost;
    +import org.apache.http.client.config.RequestConfig;
    +import org.apache.http.client.methods.CloseableHttpResponse;
    +import org.apache.http.client.methods.HttpGet;
    +import org.apache.http.conn.ssl.DefaultHostnameVerifier;
    +import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
    +import org.apache.http.impl.client.BasicResponseHandler;
    +import org.apache.http.impl.client.CloseableHttpClient;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.IOException;
     
     public class WxMpServiceImpl implements WxMpService {
     
    @@ -477,6 +447,7 @@ public class WxMpServiceImpl implements WxMpService {
           }
           return null;
         } catch (IOException e) {
    +      this.log.error("\n[URL]:  {}\n[PARAMS]: {}\n[EXECEPTION]: {}", uri, data, e.getMessage());
           throw new RuntimeException(e);
         }
       }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java
    new file mode 100644
    index 00000000..e375d64e
    --- /dev/null
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java
    @@ -0,0 +1,301 @@
    +package me.chanjar.weixin.mp.bean.pay;
    +
    +import com.thoughtworks.xstream.annotations.XStreamAlias;
    +import me.chanjar.weixin.common.annotation.Required;
    +
    +/**
    + * 
    + * 微信支付-申请退款请求参数
    + * 注释中各行每个字段描述对应如下:
    + * 
  • 字段名 + *
  • 变量名 + *
  • 是否必填 + *
  • 类型 + *
  • 示例值 + *
  • 描述 + *
  • + * + * @author binarywang(https://github.com/binarywang) + * Created by Binary Wang on 2016-10-08. + */ +@XStreamAlias("xml") +public class WxMpPayRefundRequest { + /** + *
    +   * 公众账号ID
    +   * appid
    +   * 是
    +   * String(32)
    +   * wx8888888888888888
    +   * 微信分配的公众账号ID(企业号corpid即为此appId)
    +   * 
    + */ + @XStreamAlias("appid") + private String appid; + + /** + *
    +   * 商户号
    +   * mch_id
    +   * 是
    +   * String(32)
    +   * 1900000109
    +   * 微信支付分配的商户号
    +   * 
    + */ + @XStreamAlias("mch_id") + private String mchId; + + /** + *
    +   * 设备号
    +   * device_info
    +   * 否
    +   * String(32)
    +   * 13467007045764
    +   * 终端设备号
    +   * 
    + */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + *
    +   * 随机字符串
    +   * nonce_str
    +   * 是
    +   * String(32)
    +   * 5K8264ILTKCH16CQ2502SI8ZNMTM67VS
    +   * 随机字符串,不长于32位。推荐随机数生成算法
    +   * 
    + */ + @XStreamAlias("nonce_str") + private String nonceStr; + + /** + *
    +   * 签名
    +   * sign
    +   * 是
    +   * String(32)
    +   * C380BEC2BFD727A4B6845133519F3AD6
    +   * 签名,详见签名生成算法
    +   * 
    + */ + @XStreamAlias("sign") + private String sign; + + /** + *
    +   * 微信订单号
    +   * transaction_id
    +   * 跟out_trade_no二选一
    +   * String(28)
    +   * 1217752501201400000000000000
    +   * 微信生成的订单号,在支付通知中有返回
    +   * 
    + */ + @XStreamAlias("transaction_id") + private String transactionId; + + /** + *
    +   * 商户订单号
    +   * out_trade_no
    +   * 跟transaction_id二选一
    +   * String(32)
    +   * 1217752501201400000000000000
    +   * 商户侧传给微信的订单号
    +   * 
    + */ + @XStreamAlias("out_trade_no") + private String outTradeNo; + + /** + *
    +   * 商户退款单号
    +   * out_refund_no
    +   * 是
    +   * String(32)
    +   * 1217752501201400000000000000
    +   * 商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔
    +   * 
    + */ + @Required + @XStreamAlias("out_refund_no") + private String outRefundNo; + + /** + *
    +   * 订单金额
    +   * total_fee
    +   * 是
    +   * Int
    +   * 100
    +   * 订单总金额,单位为分,只能为整数,详见支付金额
    +   * 
    + */ + @Required + @XStreamAlias("total_fee") + private Integer totalFee; + + /** + *
    +   * 退款金额
    +   * refund_fee
    +   * 是
    +   * Int
    +   * 100
    +   * 退款总金额,订单总金额,单位为分,只能为整数,详见支付金额
    +   * 
    + */ + @Required + @XStreamAlias("refund_fee") + private Integer refundFee; + + /** + *
    +   * 货币种类
    +   * refund_fee_type
    +   * 否
    +   * String(8)
    +   * CNY
    +   * 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
    +   * 
    + */ + @XStreamAlias("refund_fee_type") + private String refundFeeType; + + /** + *
    +   * 操作员
    +   * op_user_id
    +   * 是
    +   * String(32)
    +   * 1900000109
    +   * 操作员帐号, 默认为商户号
    +   * 
    + */ + //@Required + @XStreamAlias("op_user_id") + private String opUserId; + + /** + *
    +   * 退款资金来源
    +   * refund_account
    +   * 否
    +   * String(30)
    +   * REFUND_SOURCE_RECHARGE_FUNDS
    +   * 仅针对老资金流商户使用,
    +   * 
  • REFUND_SOURCE_UNSETTLED_FUNDS---未结算资金退款(默认使用未结算资金退款), + *
  • REFUND_SOURCE_RECHARGE_FUNDS---可用余额退款 + *
  • + */ + @XStreamAlias("refund_account") + private String refundAccount; + + 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 getDeviceInfo() { + return deviceInfo; + } + + public void setDeviceInfo(String deviceInfo) { + this.deviceInfo = deviceInfo; + } + + public String getNonceStr() { + return nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + 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 Integer getTotalFee() { + return totalFee; + } + + public void setTotalFee(Integer totalFee) { + this.totalFee = totalFee; + } + + public Integer getRefundFee() { + return refundFee; + } + + public void setRefundFee(Integer refundFee) { + this.refundFee = refundFee; + } + + public String getRefundFeeType() { + return refundFeeType; + } + + public void setRefundFeeType(String refundFeeType) { + this.refundFeeType = refundFeeType; + } + + public String getOpUserId() { + return opUserId; + } + + public void setOpUserId(String opUserId) { + this.opUserId = opUserId; + } + + public String getRefundAccount() { + return refundAccount; + } + + public void setRefundAccount(String refundAccount) { + this.refundAccount = refundAccount; + } +} diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java index 6199efeb..3f5dfe1a 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java @@ -1,20 +1,14 @@ package me.chanjar.weixin.mp.api.impl; -import java.io.File; - -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - import com.google.inject.Inject; - import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.ApiTestModule; import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; -import me.chanjar.weixin.mp.bean.pay.WxEntPayRequest; -import me.chanjar.weixin.mp.bean.pay.WxRedpackResult; -import me.chanjar.weixin.mp.bean.pay.WxSendRedpackRequest; -import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest; -import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderResult; +import me.chanjar.weixin.mp.bean.pay.*; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.io.File; /** * 测试支付相关接口 @@ -44,8 +38,14 @@ public class WxMpPayServiceImplTest { } @Test - public void testRefundPay() throws Exception { - + public void testRefund() throws Exception { + WxMpPayRefundRequest request = new WxMpPayRefundRequest(); + request.setOutRefundNo("aaa"); + request.setOutTradeNo("1111"); + request.setTotalFee(1222); + request.setRefundFee(111); + WxMpPayRefundResult result = this.wxService.getPayService().refund(request); + System.err.println(result); } @Test From a0dc8ca1ea7d9afd723067b910a33a22f7967867 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sat, 8 Oct 2016 17:11:40 +0800 Subject: [PATCH 39/76] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=94=B3=E8=AF=B7=E9=80=80=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20for=20issue=20#25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java index 3f5dfe1a..7f524fd1 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java @@ -44,7 +44,8 @@ public class WxMpPayServiceImplTest { request.setOutTradeNo("1111"); request.setTotalFee(1222); request.setRefundFee(111); - WxMpPayRefundResult result = this.wxService.getPayService().refund(request); + File keyFile = new File("E:\\dlt.p12"); + WxMpPayRefundResult result = this.wxService.getPayService().refund(request, keyFile); System.err.println(result); } From 049eb957d8988569dc8f7c828e86a73f7e0caddc Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sat, 8 Oct 2016 17:46:31 +0800 Subject: [PATCH 40/76] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96javadoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/chanjar/weixin/mp/api/WxMpStoreService.java | 2 +- .../java/me/chanjar/weixin/mp/api/WxMpUserTagService.java | 2 +- .../me/chanjar/weixin/mp/api/impl/WxMpUserTagServiceImpl.java | 2 +- .../weixin/mp/bean/datacube/WxDataCubeArticleResult.java | 2 +- .../weixin/mp/bean/datacube/WxDataCubeArticleTotal.java | 2 +- .../weixin/mp/bean/datacube/WxDataCubeArticleTotalDetail.java | 2 +- .../chanjar/weixin/mp/bean/datacube/WxDataCubeBaseResult.java | 4 ++-- .../weixin/mp/bean/datacube/WxDataCubeInterfaceResult.java | 4 ++-- .../chanjar/weixin/mp/bean/datacube/WxDataCubeMsgResult.java | 2 +- .../me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java | 2 +- .../me/chanjar/weixin/mp/bean/store/WxMpStoreBaseInfo.java | 2 +- .../me/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 +- .../chanjar/weixin/mp/api/impl/WxMpStoreServiceImplTest.java | 2 +- .../weixin/mp/api/impl/WxMpUserTagServiceImplTest.java | 2 +- 16 files changed, 18 insertions(+), 18 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 0ce7cc03..c214c46d 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,7 +9,7 @@ import java.util.List; /** * 门店管理的相关接口代码 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016-09-23. */ public interface WxMpStoreService { 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 0fcfb40f..90af7155 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 @@ -9,7 +9,7 @@ import me.chanjar.weixin.mp.bean.tag.WxUserTag; /** * 用户标签管理相关接口 * Created by Binary Wang on 2016/9/2. - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * */ public interface WxMpUserTagService { 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 94749c12..2cfb2884 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 @@ -17,7 +17,7 @@ import java.util.List; /** * - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016/9/2. */ public class WxMpUserTagServiceImpl implements WxMpUserTagService { 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 3dd28459..d763543e 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 @@ -10,7 +10,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * 图文分析数据接口返回结果对象 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016/8/24. */ public class WxDataCubeArticleResult extends WxDataCubeBaseResult { 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 37401cf8..d3236be3 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 @@ -10,7 +10,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * 图文分析数据接口返回结果对象 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016/8/24. */ public class WxDataCubeArticleTotal extends WxDataCubeBaseResult { 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 cbbf148f..e228a3cc 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 @@ -4,7 +4,7 @@ import com.google.gson.annotations.SerializedName; /** * 获取图文群发总数据接口(getarticletotal)中的详细字段 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016/8/24. */ public class WxDataCubeArticleTotalDetail { 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 f819ab42..58fc0179 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 @@ -6,7 +6,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** * 统计接口的共用属性类 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016/8/25. */ public class WxDataCubeBaseResult { @@ -29,5 +29,5 @@ public class WxDataCubeBaseResult { 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 82a45dcf..2088453c 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 @@ -10,7 +10,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * 接口分析数据接口返回结果对象 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016/8/30. */ public class WxDataCubeInterfaceResult extends WxDataCubeBaseResult { @@ -98,5 +98,5 @@ public class WxDataCubeInterfaceResult extends WxDataCubeBaseResult { new TypeToken>() { }.getType()); } - + } 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 908dfca8..01e40e80 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 @@ -10,7 +10,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * 消息分析数据接口返回结果对象 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016/8/29. */ public class WxDataCubeMsgResult extends WxDataCubeBaseResult { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java index e375d64e..26f837b4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java @@ -15,7 +15,7 @@ import me.chanjar.weixin.common.annotation.Required; *
  • 描述 *
  • * - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016-10-08. */ @XStreamAlias("xml") 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 dcfd3153..5dbd9e4e 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 @@ -13,7 +13,7 @@ import java.util.List; /** * 门店基础信息 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016-09-23. */ public class WxMpStoreBaseInfo { 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 2bc514ed..e02ae056 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 @@ -11,7 +11,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * 门店列表结果类 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016-09-27. * */ 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 b07314ba..3d7f57f3 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 @@ -11,7 +11,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * 获取标签下粉丝列表的结果对象 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016-09-19. */ public class WxTagListUser { 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 53e247a7..281b9b30 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 @@ -12,7 +12,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * 用户标签对象 - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016/9/2. */ public class WxUserTag { 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 76685470..6e31b769 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 @@ -15,7 +15,7 @@ import java.util.List; import static org.junit.Assert.assertNotNull; /** - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016-09-23. * */ 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 569b696d..4fca56be 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 @@ -13,7 +13,7 @@ import java.util.List; /** * - * @author binarywang(https://github.com/binarywang) + * @author binarywang(Binary Wang) * Created by Binary Wang on 2016/9/2. */ @Test From d933ab43e04c65f4a221b63f08fc6c89cbc30ce1 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sat, 8 Oct 2016 18:26:03 +0800 Subject: [PATCH 41/76] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=94=B3=E8=AF=B7=E9=80=80=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20for=20issue=20#25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp/bean/pay/WxMpPayRefundResult.java | 159 +++++++++--------- 1 file changed, 80 insertions(+), 79 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java index 3f917fe0..7e5d322d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java @@ -1,278 +1,279 @@ package me.chanjar.weixin.mp.bean.pay; -import java.io.Serializable; - import com.thoughtworks.xstream.annotations.XStreamAlias; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.io.Serializable; /** + *
      * 微信支付-申请退款返回结果
      * https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
    + * 
    * @author liukaitj * */ @XStreamAlias("xml") public class WxMpPayRefundResult implements Serializable { - private static final long serialVersionUID = 1L; @XStreamAlias("return_code") private String returnCode; - + @XStreamAlias("return_msg") private String returnMsg; - + @XStreamAlias("result_code") private String resultCode; - + @XStreamAlias("err_code") private String errCode; - + @XStreamAlias("err_code_des") private String errCodeDes; - + @XStreamAlias("appid") private String appid; - + @XStreamAlias("mch_id") private String mchId; - + @XStreamAlias("device_info") private String deviceInfo; - + @XStreamAlias("nonce_str") private String nonceStr; - + @XStreamAlias("sign") private String sign; - + @XStreamAlias("transaction_id") private String transactionId; - + @XStreamAlias("out_trade_no") private String outTradeNo; - + @XStreamAlias("out_refund_no") private String outRefundNo; - + @XStreamAlias("refund_id") private String refundId; - + @XStreamAlias("refund_channel") private String refundChannel; - + @XStreamAlias("refund_fee") private String refundFee; - + @XStreamAlias("total_fee") private String totalFee; - + @XStreamAlias("fee_type") private String feeType; - + @XStreamAlias("cash_fee") private String cashFee; - + @XStreamAlias("cash_refund_fee") - private String cashRefundfee; - + private String cashRefundFee; + @XStreamAlias("coupon_refund_fee") private String couponRefundFee; - + @XStreamAlias("coupon_refund_count") private String couponRefundCount; - + @XStreamAlias("coupon_refund_id") private String couponRefundId; 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 getDeviceInfo() { return this.deviceInfo; } - + public void setDeviceInfo(String deviceInfo) { this.deviceInfo = deviceInfo; } - + 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 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 String getCashRefundFee() { + return this.cashRefundFee; } - - public void setCashRefundfee(String cashRefundfee) { - this.cashRefundfee = 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; } - + @Override public String toString() { - return "[" + - "return_code:" + this.returnCode + ";" + - "return_msg" + this.returnMsg + ";"; + return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); } } From 076ae4fdfcea858d1653aa711450806ac9fd63c7 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sun, 9 Oct 2016 18:52:42 +0800 Subject: [PATCH 42/76] fix a typo --- .../java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4cd26894..db8cfffa 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 @@ -447,7 +447,7 @@ public class WxMpServiceImpl implements WxMpService { } return null; } catch (IOException e) { - this.log.error("\n[URL]: {}\n[PARAMS]: {}\n[EXECEPTION]: {}", uri, data, e.getMessage()); + this.log.error("\n[URL]: {}\n[PARAMS]: {}\n[EXCEPTION]: {}", uri, data, e.getMessage()); throw new RuntimeException(e); } } From a4642896a36bb712266a775daa2a7076ba636892 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sun, 9 Oct 2016 19:00:07 +0800 Subject: [PATCH 43/76] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=8C=E5=8E=BB=E6=8E=89=E4=B8=80=E4=BA=9B=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84jar=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 +------ weixin-java-common/pom.xml | 2 +- weixin-java-cp/pom.xml | 2 +- weixin-java-mp/pom.xml | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index e94e5fc1..804f3540 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.github.binarywang weixin-java-parent - 2.2.0 + 2.3.0-SNAPSHOT pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM @@ -72,11 +72,6 @@ ${logback.version} test - - org.apache.httpcomponents - fluent-hc - ${httpclient.version} - org.apache.httpcomponents httpmime diff --git a/weixin-java-common/pom.xml b/weixin-java-common/pom.xml index 667aaf76..fec020e7 100644 --- a/weixin-java-common/pom.xml +++ b/weixin-java-common/pom.xml @@ -6,7 +6,7 @@ com.github.binarywang weixin-java-parent - 2.2.0 + 2.3.0-SNAPSHOT weixin-java-common diff --git a/weixin-java-cp/pom.xml b/weixin-java-cp/pom.xml index e87e2ea1..f62f4d29 100644 --- a/weixin-java-cp/pom.xml +++ b/weixin-java-cp/pom.xml @@ -6,7 +6,7 @@ com.github.binarywang weixin-java-parent - 2.2.0 + 2.3.0-SNAPSHOT weixin-java-cp diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml index 6fc42ee6..a06184a8 100644 --- a/weixin-java-mp/pom.xml +++ b/weixin-java-mp/pom.xml @@ -6,7 +6,7 @@ com.github.binarywang weixin-java-parent - 2.2.0 + 2.3.0-SNAPSHOT weixin-java-mp WeiXin Java Tools - MP From f7f7d12347c0a753148d316a7001959905832883 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Sun, 9 Oct 2016 19:00:26 +0800 Subject: [PATCH 44/76] =?UTF-8?q?=E5=8F=91=E9=80=81=E7=BA=A2=E5=8C=85?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=E8=AF=81=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/chanjar/weixin/mp/api/WxMpPayService.java | 3 ++- .../me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java | 7 ++++--- .../chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java index 45973443..bdba22ad 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java @@ -74,8 +74,9 @@ public interface WxMpPayService { * 发送普通红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3 * 发送裂变红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4 *
    + * @param keyFile 证书文件对象 */ - WxRedpackResult sendRedpack(WxSendRedpackRequest request) throws WxErrorException; + WxRedpackResult sendRedpack(WxSendRedpackRequest request, File keyFile) throws WxErrorException; /** *
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    index a8d5dc3f..8e3e015e 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    @@ -160,14 +160,15 @@ public class WxMpPayServiceImpl implements WxMpPayService {
       }
     
       @Override
    -  public WxRedpackResult sendRedpack(WxSendRedpackRequest request)
    +  public WxRedpackResult sendRedpack(WxSendRedpackRequest request, File keyFile)
           throws WxErrorException {
         XStream xstream = XStreamInitializer.getInstance();
         xstream.processAnnotations(WxSendRedpackRequest.class);
         xstream.processAnnotations(WxRedpackResult.class);
     
         request.setWxAppid(this.wxMpService.getWxMpConfigStorage().getAppId());
    -    request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId());
    +    String mchId = this.wxMpService.getWxMpConfigStorage().getPartnerId();
    +    request.setMchId(mchId);
         request.setNonceStr(System.currentTimeMillis() + "");
     
         String sign = this.createSign(this.xmlBean2Map(request),
    @@ -180,7 +181,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
           url = PAY_BASE_URL + "/mmpaymkttransfers/sendgroupredpack";
         }
     
    -    String responseContent = this.wxMpService.post(url, xstream.toXML(request));
    +    String responseContent = this.executeRequestWithKeyFile(url, xstream.toXML(request), keyFile, mchId);
         WxRedpackResult redpackResult = (WxRedpackResult) xstream
             .fromXML(responseContent);
         if ("FAIL".equals(redpackResult.getResultCode())) {
    diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java
    index 7f524fd1..6d0b8a5c 100644
    --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java
    +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java
    @@ -62,7 +62,8 @@ public class WxMpPayServiceImplTest {
         request.setMchBillno("aaaa");
         request
             .setReOpenid(((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid());
    -    WxRedpackResult redpackResult = this.wxService.getPayService().sendRedpack(request);
    +    File keyFile = new File("E:\\dlt.p12");
    +    WxRedpackResult redpackResult = this.wxService.getPayService().sendRedpack(request, keyFile);
         System.err.println(redpackResult);
       }
     
    
    From 3d9bc6be0fe54233d1f5139214de147c9f4e1e2d Mon Sep 17 00:00:00 2001
    From: BinaryWang 
    Date: Sun, 9 Oct 2016 19:43:09 +0800
    Subject: [PATCH 45/76] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8F=82=E6=95=B0?=
     =?UTF-8?q?=E4=BD=8D=E7=BD=AE?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java | 8 ++++----
     1 file changed, 4 insertions(+), 4 deletions(-)
    
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    index 8e3e015e..fa1a44c5 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    @@ -120,7 +120,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         request.setSign(sign);
     
         String url = PAY_BASE_URL + "/secapi/pay/refund";
    -    String responseContent = this.executeRequestWithKeyFile(url, xstream.toXML(request), keyFile, partnerId);
    +    String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), partnerId);
         WxMpPayRefundResult wxMpPayRefundResult = (WxMpPayRefundResult) xstream.fromXML(responseContent);
     
         if (!"SUCCESS".equalsIgnoreCase(wxMpPayRefundResult.getResultCode())
    @@ -181,7 +181,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
           url = PAY_BASE_URL + "/mmpaymkttransfers/sendgroupredpack";
         }
     
    -    String responseContent = this.executeRequestWithKeyFile(url, xstream.toXML(request), keyFile, mchId);
    +    String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), mchId);
         WxRedpackResult redpackResult = (WxRedpackResult) xstream
             .fromXML(responseContent);
         if ("FAIL".equals(redpackResult.getResultCode())) {
    @@ -360,7 +360,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
     
         String url = PAY_BASE_URL + "/mmpaymkttransfers/promotion/transfers";
     
    -    String responseContent = this.executeRequestWithKeyFile(xstream.toXML(request), url, keyFile, request.getMchId());
    +    String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), request.getMchId());
         WxEntPayResult result = (WxEntPayResult) xstream.fromXML(responseContent);
         if ("FAIL".equals(result.getResultCode())) {
           throw new WxErrorException(
    @@ -369,7 +369,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         return result;
       }
     
    -  private String executeRequestWithKeyFile( String requestStr, String url, File keyFile, String mchId) throws WxErrorException {
    +  private String executeRequestWithKeyFile( String url, File keyFile, String requestStr, String mchId) throws WxErrorException {
         try (FileInputStream inputStream = new FileInputStream(keyFile)) {
           KeyStore keyStore = KeyStore.getInstance("PKCS12");
           keyStore.load(inputStream, mchId.toCharArray());
    
    From 25064c5ff8f4bb477ee749ff967b62d012fc9e20 Mon Sep 17 00:00:00 2001
    From: ben 
    Date: Mon, 10 Oct 2016 11:00:14 +0800
    Subject: [PATCH 46/76] =?UTF-8?q?=E4=BF=AE=E6=AD=A3me.chanjar.weixin.commo?=
     =?UTF-8?q?n.util.http.DefaultApacheHttpClientBuilder#prepare=E8=B0=83?=
     =?UTF-8?q?=E7=94=A8=E9=97=AE=E9=A2=98=EF=BC=8Ctry=20to=20fix#52?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../common/util/http/DefaultApacheHttpClientBuilder.java  | 8 +-------
     1 file changed, 1 insertion(+), 7 deletions(-)
    
    diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/DefaultApacheHttpClientBuilder.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/DefaultApacheHttpClientBuilder.java
    index f69dcc6c..fda72a76 100644
    --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/DefaultApacheHttpClientBuilder.java
    +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/DefaultApacheHttpClientBuilder.java
    @@ -58,9 +58,8 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
     
       private HttpClientBuilder httpClientBuilder;
     
    -  private boolean prepared = false;
    -
       private DefaultApacheHttpClientBuilder() {
    +    prepare();
       }
     
       public static DefaultApacheHttpClientBuilder get() {
    @@ -153,11 +152,6 @@ public class DefaultApacheHttpClientBuilder implements ApacheHttpClientBuilder {
     
       @Override
       public CloseableHttpClient build() {
    -    if (!this.prepared) {
    -      prepare();
    -      this.prepared = true;
    -    }
    -
         return this.httpClientBuilder.build();
       }
     
    
    From a345f8a639380fe95915b6751594356e5592c8bf Mon Sep 17 00:00:00 2001
    From: HaiJun Liu 
    Date: Mon, 10 Oct 2016 20:59:03 +0800
    Subject: [PATCH 47/76] issue #58 : remove fluent-hc for optimization
    
    ---
     build.gradle | 1 -
     1 file changed, 1 deletion(-)
    
    diff --git a/build.gradle b/build.gradle
    index 108e69c0..ba12afc4 100644
    --- a/build.gradle
    +++ b/build.gradle
    @@ -20,7 +20,6 @@ subprojects {
     
       dependencies {
         compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.10'
    -    compile group: 'org.apache.httpcomponents', name: 'fluent-hc', version:'4.5'
         compile group: 'org.apache.httpcomponents', name: 'httpmime', version:'4.5'
         compile group: 'org.jodd', name: 'jodd-http', version:'3.6.7'
         compile group: 'com.google.code.gson', name: 'gson', version:'2.7'
    
    From 636ae33daf5a23e661d73aae4794f620d592245d Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Tue, 11 Oct 2016 11:27:57 +0800
    Subject: [PATCH 48/76] Update README.md
    
    ---
     README.md | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/README.md b/README.md
    index c473c9cd..9be8db94 100644
    --- a/README.md
    +++ b/README.md
    @@ -67,7 +67,7 @@ compile 'com.github.binarywang:weixin-java-cp:2.2.0'
     * https://git.coding.net/binarywang/weixin-java-tools.git
     
     ===========
    -## 目前可参考的Demo项目有两个:
    +## 目前可参考的Demo项目有两个(目前都是公众号的,风格不同,欢迎提供更多的demo供新手参考):
     1. https://github.com/wechat-group/weixin-mp-demo
     1. https://github.com/wechat-group/weixin-java-tools-springmvc
     
    
    From e8d368f212e070d646bd2c4c11391029b4342ab9 Mon Sep 17 00:00:00 2001
    From: BinaryWang 
    Date: Wed, 12 Oct 2016 14:19:53 +0800
    Subject: [PATCH 49/76] =?UTF-8?q?toString()=E6=96=B9=E6=B3=95=E6=9B=BF?=
     =?UTF-8?q?=E6=8D=A2=E6=8E=89=E8=BE=83=E6=96=B0=E7=89=88=E6=9C=AC=E7=9A=84?=
     =?UTF-8?q?=20commons-lang3=E5=BC=95=E5=85=A5=E7=9A=84=20ToStringStyle.JSO?=
     =?UTF-8?q?N=5FSTYLE?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../chanjar/weixin/common/bean/WxCardApiSignature.java |  6 +++---
     .../chanjar/weixin/common/bean/menu/WxMenuButton.java  |  2 +-
     .../me/chanjar/weixin/common/bean/menu/WxMenuRule.java |  2 +-
     .../weixin/cp/api/WxCpInMemoryConfigStorage.java       |  2 +-
     .../weixin/mp/api/WxMpInMemoryConfigStorage.java       |  2 +-
     .../java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java | 10 +++++-----
     .../weixin/mp/bean/datacube/WxDataCubeBaseResult.java  |  2 +-
     .../mp/bean/datacube/WxDataCubeUserCumulate.java       |  2 +-
     .../weixin/mp/bean/datacube/WxDataCubeUserSummary.java |  2 +-
     .../mp/bean/kefu/request/WxMpKfSessionRequest.java     |  2 +-
     .../chanjar/weixin/mp/bean/kefu/result/WxMpKfInfo.java |  2 +-
     .../chanjar/weixin/mp/bean/kefu/result/WxMpKfList.java |  2 +-
     .../weixin/mp/bean/kefu/result/WxMpKfMsgList.java      |  2 +-
     .../weixin/mp/bean/kefu/result/WxMpKfMsgRecord.java    |  2 +-
     .../weixin/mp/bean/kefu/result/WxMpKfOnlineList.java   |  2 +-
     .../weixin/mp/bean/kefu/result/WxMpKfSession.java      |  2 +-
     .../mp/bean/kefu/result/WxMpKfSessionGetResult.java    |  2 +-
     .../weixin/mp/bean/kefu/result/WxMpKfSessionList.java  |  2 +-
     .../mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java |  2 +-
     .../me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java |  2 +-
     .../me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java  |  2 +-
     .../weixin/mp/bean/pay/WxMpPayRefundResult.java        |  2 +-
     .../me/chanjar/weixin/mp/bean/pay/WxMpPayResult.java   |  2 +-
     .../me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java |  2 +-
     .../weixin/mp/bean/pay/WxUnifiedOrderRequest.java      |  2 +-
     .../weixin/mp/bean/pay/WxUnifiedOrderResult.java       |  2 +-
     .../chanjar/weixin/mp/bean/result/WxMpCardResult.java  |  2 +-
     .../me/chanjar/weixin/mp/bean/result/WxMpUser.java     |  2 +-
     .../weixin/mp/bean/store/WxMpStoreBaseInfo.java        |  2 +-
     .../me/chanjar/weixin/mp/bean/store/WxMpStoreInfo.java |  2 +-
     .../weixin/mp/bean/store/WxMpStoreListResult.java      |  2 +-
     .../me/chanjar/weixin/mp/bean/tag/WxTagListUser.java   |  4 ++--
     .../java/me/chanjar/weixin/mp/bean/tag/WxUserTag.java  |  2 +-
     33 files changed, 40 insertions(+), 40 deletions(-)
    
    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 2ff252c3..f50b72f2 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,10 +1,10 @@
     package me.chanjar.weixin.common.bean;
     
    +import java.io.Serializable;
    +
     import org.apache.commons.lang3.builder.ToStringBuilder;
     import org.apache.commons.lang3.builder.ToStringStyle;
     
    -import java.io.Serializable;
    -
     /**
      * 卡券Api签名
      *
    @@ -35,7 +35,7 @@ public class WxCardApiSignature implements Serializable {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public String getAppId() {
    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 6a5e5426..1fe8bb90 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
    @@ -19,7 +19,7 @@ public class WxMenuButton {
       @Override
       public String toString() {
         return ToStringBuilder.reflectionToString(this, 
    -        ToStringStyle.JSON_STYLE);
    +        ToStringStyle.MULTI_LINE_STYLE);
       }
       
       public String getType() {
    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 b3e90886..ca6fdd24 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
    @@ -70,6 +70,6 @@ public class WxMenuRule {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     }
    \ No newline at end of file
    diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpInMemoryConfigStorage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpInMemoryConfigStorage.java
    index 17fda4ca..8914da53 100644
    --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpInMemoryConfigStorage.java
    +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpInMemoryConfigStorage.java
    @@ -203,7 +203,7 @@ public class WxCpInMemoryConfigStorage implements WxCpConfigStorage {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       @Override
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInMemoryConfigStorage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInMemoryConfigStorage.java
    index 765f6d53..784cfddc 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInMemoryConfigStorage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpInMemoryConfigStorage.java
    @@ -229,7 +229,7 @@ public class WxMpInMemoryConfigStorage implements WxMpConfigStorage {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this,ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
       }
     
       @Override
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
    index 9adcb54d..b938ceb0 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
    @@ -667,7 +667,7 @@ public class WxMpXmlMessage implements Serializable {
       public static class ScanCodeInfo {
         @Override
         public String toString() {
    -      return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +      return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
         }
     
         @XStreamAlias("ScanType")
    @@ -707,7 +707,7 @@ public class WxMpXmlMessage implements Serializable {
       public static class SendPicsInfo {
         @Override
         public String toString() {
    -      return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +      return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
         }
     
         @XStreamAlias("Count")
    @@ -733,7 +733,7 @@ public class WxMpXmlMessage implements Serializable {
           @Override
           public String toString() {
             return ToStringBuilder.reflectionToString(this,
    -            ToStringStyle.JSON_STYLE);
    +            ToStringStyle.MULTI_LINE_STYLE);
           }
     
           @XStreamAlias("PicMd5Sum")
    @@ -775,7 +775,7 @@ public class WxMpXmlMessage implements Serializable {
     
         @Override
         public String toString() {
    -      return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +      return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
         }
     
         public String getLocationX() {
    @@ -821,6 +821,6 @@ public class WxMpXmlMessage implements Serializable {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     }
    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 58fc0179..f3999fa2 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 @@ import org.apache.commons.lang3.builder.ToStringStyle;
     public class WxDataCubeBaseResult {
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       /**
    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 039bd189..e764f244 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
    @@ -46,7 +46,7 @@ public class WxDataCubeUserCumulate implements Serializable {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public static List fromJson(String json) {
    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 4802027e..54eb0d4a 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
    @@ -65,7 +65,7 @@ public class WxDataCubeUserSummary implements Serializable {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public static List fromJson(String json) {
    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 e821916e..420c0d62 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
    @@ -31,7 +31,7 @@ public class WxMpKfSessionRequest implements Serializable {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
       
       public String toJson() {
    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 37154aa4..bcb811bc 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
    @@ -127,7 +127,7 @@ public class WxMpKfInfo implements Serializable {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public String getWxAccount() {
    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 062ff9ac..3465073a 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
    @@ -19,7 +19,7 @@ public class WxMpKfList {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public List getKfList() {
    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 570f2def..cfcbba92 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
    @@ -46,7 +46,7 @@ public class WxMpKfMsgList {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public static WxMpKfMsgList fromJson(String responseContent) {
    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 7f326ac1..14b26567 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
    @@ -41,7 +41,7 @@ public class WxMpKfMsgRecord {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
       public String getWorker() {
         return this.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 b4a418f6..1cc674c9 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
    @@ -19,7 +19,7 @@ public class WxMpKfOnlineList {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
       
       public List getKfOnlineList() {
    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 e29f45b8..8a9ef842 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
    @@ -39,7 +39,7 @@ public class WxMpKfSession {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
       
       public String getKfAccount() {
    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 22a6cf24..eb78f3b6 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
    @@ -27,7 +27,7 @@ public class WxMpKfSessionGetResult {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
       
       public static WxMpKfSessionGetResult fromJson(String json) {
    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 dea7e243..8bcac0e4 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
    @@ -23,7 +23,7 @@ public class WxMpKfSessionList {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public static WxMpKfSessionList fromJson(String json) {
    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 dc2ab06b..7e876901 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
    @@ -29,7 +29,7 @@ public class WxMpKfSessionWaitCaseList {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public static WxMpKfSessionWaitCaseList fromJson(String json) {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java
    index 38ed704a..07549ab3 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java
    @@ -278,7 +278,7 @@ public class WxEntPayRequest {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
     }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java
    index b2dbb8f1..86c2c010 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java
    @@ -89,7 +89,7 @@ public class WxEntPayResult {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public String getReturnCode() {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java
    index 7e5d322d..5462d44a 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java
    @@ -273,7 +273,7 @@ public class WxMpPayRefundResult implements Serializable {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
     }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayResult.java
    index 2978ba17..6f453204 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayResult.java
    @@ -18,7 +18,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
     public class WxMpPayResult implements Serializable {
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       private static final long serialVersionUID = -570934170727777190L;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java
    index 297e07d7..a8287be6 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java
    @@ -100,6 +100,6 @@ public class WxRedpackResult implements Serializable {
       
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java
    index 4173c373..7cadd246 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java
    @@ -484,7 +484,7 @@ public class WxUnifiedOrderRequest {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public static WxUnifiedOrderRequestBuilder builder() {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderResult.java
    index 18817461..7dfc6598 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderResult.java
    @@ -150,6 +150,6 @@ public class WxUnifiedOrderResult {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     }
    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 8ce5ca47..7a711ba1 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
    @@ -65,7 +65,7 @@ public class WxMpCardResult implements Serializable {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public String getUserCardStatus() {
    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 f56ccf5c..b885ea4c 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
    @@ -179,7 +179,7 @@ public class WxMpUser implements Serializable {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
     }
    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 5dbd9e4e..409e41c3 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
    @@ -19,7 +19,7 @@ import java.util.List;
     public class WxMpStoreBaseInfo {
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public static WxMpStoreBaseInfo fromJson(String json) {
    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 864d9d2c..9d07eb03 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
    @@ -8,7 +8,7 @@ import com.google.gson.annotations.SerializedName;
     public class WxMpStoreInfo {
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       @SerializedName("base_info")
    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 e02ae056..f16c1534 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
    @@ -18,7 +18,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
     public class WxMpStoreListResult {
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       public static WxMpStoreListResult fromJson(String json) {
    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 3d7f57f3..47ed067a 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
    @@ -26,7 +26,7 @@ public class WxTagListUser {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     
       /**
    @@ -74,7 +74,7 @@ public class WxTagListUser {
       public static class WxTagListUserData {
         @Override
         public String toString() {
    -      return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +      return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
         }
     
         /**
    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 281b9b30..67b443a4 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
    @@ -73,6 +73,6 @@ public class WxUserTag {
     
       @Override
       public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     }
    
    From cd026278c220e2d4533d56eb541a6f149d763cb8 Mon Sep 17 00:00:00 2001
    From: BinaryWang 
    Date: Thu, 13 Oct 2016 09:11:15 +0800
    Subject: [PATCH 50/76] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B9=E6=B3=95?=
     =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B=EF=BC=8C=E4=BF=9D=E8=AF=81?=
     =?UTF-8?q?=E6=A0=87=E7=AD=BEId=E4=B8=8E=E5=85=B6=E4=BB=96=E5=9C=B0?=
     =?UTF-8?q?=E6=96=B9=E4=B8=80=E8=87=B4?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../chanjar/weixin/mp/api/WxMpUserTagService.java  |  4 ++--
     .../weixin/mp/api/impl/WxMpUserTagServiceImpl.java | 12 +++++++-----
     .../mp/api/impl/WxMpUserTagServiceImplTest.java    | 14 ++++++++------
     3 files changed, 17 insertions(+), 13 deletions(-)
    
    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 90af7155..4c0ab7c8 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
    @@ -94,8 +94,8 @@ public interface WxMpUserTagService {
        * 详情请见:用户标签管理
        * 接口url格式: https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN
        * 
    - * + * @return 标签Id的列表 */ - List userTagList(String openid) throws WxErrorException; + List userTagList(String openid) throws WxErrorException; } 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 2cfb2884..d1bdae1e 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 @@ -1,9 +1,14 @@ package me.chanjar.weixin.mp.api.impl; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; + import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; + import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; @@ -11,9 +16,6 @@ import me.chanjar.weixin.mp.api.WxMpUserTagService; import me.chanjar.weixin.mp.bean.tag.WxTagListUser; import me.chanjar.weixin.mp.bean.tag.WxUserTag; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; -import org.apache.commons.lang3.StringUtils; - -import java.util.List; /** * @@ -144,7 +146,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { } @Override - public List userTagList(String openid) throws WxErrorException { + public List userTagList(String openid) throws WxErrorException { String url = API_URL_PREFIX + "/getidlist"; JsonObject json = new JsonObject(); @@ -154,7 +156,7 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { return WxMpGsonBuilder.create().fromJson( new JsonParser().parse(responseContent).getAsJsonObject().get("tagid_list"), - new TypeToken>() { + new TypeToken>() { }.getType()); } } 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 4fca56be..2c67ea3f 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 @@ -1,15 +1,17 @@ package me.chanjar.weixin.mp.api.impl; +import java.util.List; + +import org.testng.Assert; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + import com.google.inject.Inject; + import me.chanjar.weixin.mp.api.ApiTestModule; import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; import me.chanjar.weixin.mp.bean.tag.WxTagListUser; import me.chanjar.weixin.mp.bean.tag.WxUserTag; -import org.testng.Assert; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import java.util.List; /** * @@ -80,7 +82,7 @@ public class WxMpUserTagServiceImplTest { @Test public void testUserTagList() throws Exception { - List res = this.wxService.getUserTagService().userTagList( + List res = this.wxService.getUserTagService().userTagList( ((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()); System.out.println(res); Assert.assertNotNull(res); From 2af7bee103d881469ef1a861bcd664f09dd9c371 Mon Sep 17 00:00:00 2001 From: BinaryWang Date: Thu, 13 Oct 2016 15:41:16 +0800 Subject: [PATCH 51/76] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessageTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessageTest.java index bd66743c..872c0ac3 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpXmlOutNewsMessageTest.java @@ -19,12 +19,12 @@ public class WxCpXmlOutNewsMessageTest { item.setUrl("url"); m.addArticle(item); m.addArticle(item); + String expected = "" + "" + "" + "1122" + "" - + " 2" + " " + " " + " <![CDATA[title]]>" @@ -39,6 +39,7 @@ public class WxCpXmlOutNewsMessageTest { + " " + " " + " " + + " 2" + ""; System.out.println(m.toXml()); Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", "")); @@ -62,7 +63,6 @@ public class WxCpXmlOutNewsMessageTest { + "" + "1122" + "" - + " 2" + " " + " " + " <![CDATA[title]]>" @@ -77,6 +77,7 @@ public class WxCpXmlOutNewsMessageTest { + " " + " " + " " + + " 2" + ""; System.out.println(m.toXml()); Assert.assertEquals( From 87f023e6807a91a75464f6061e107b69abd03617 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 14 Oct 2016 13:47:19 +0800 Subject: [PATCH 52/76] =?UTF-8?q?CP=E9=83=A8=E5=88=86bean=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=BA=8F=E5=88=97=E5=8F=B7=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E6=B7=BB=E5=8A=A0serialVersionUID=20to=20fix=20#66?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/chanjar/weixin/cp/bean/WxCpDepart.java | 7 ++---- .../chanjar/weixin/cp/bean/WxCpMessage.java | 14 +++++++----- .../me/chanjar/weixin/cp/bean/WxCpTag.java | 7 ++---- .../me/chanjar/weixin/cp/bean/WxCpUser.java | 7 ++---- .../weixin/cp/bean/WxCpXmlMessage.java | 22 +++++++++---------- .../cp/bean/WxCpXmlOutImageMessage.java | 2 ++ .../weixin/cp/bean/WxCpXmlOutMessage.java | 6 ++++- .../weixin/cp/bean/WxCpXmlOutNewsMessage.java | 8 ++++--- .../weixin/cp/bean/WxCpXmlOutTextMessage.java | 2 ++ .../cp/bean/WxCpXmlOutVideoMessage.java | 2 ++ .../cp/bean/WxCpXmlOutVoiceMessage.java | 2 ++ 11 files changed, 42 insertions(+), 37 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 c8735086..a679dffe 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,9 +1,9 @@ package me.chanjar.weixin.cp.bean; -import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; - import java.io.Serializable; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + /** * 微信部门 * @@ -11,9 +11,6 @@ import java.io.Serializable; */ public class WxCpDepart implements Serializable { - /** - * - */ private static final long serialVersionUID = -5028321625140879571L; private Integer id; private String name; 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 6dba9091..e2422e3b 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,12 +1,17 @@ package me.chanjar.weixin.cp.bean; -import me.chanjar.weixin.cp.bean.messagebuilder.*; -import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; - import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import me.chanjar.weixin.cp.bean.messagebuilder.FileBuilder; +import me.chanjar.weixin.cp.bean.messagebuilder.ImageBuilder; +import me.chanjar.weixin.cp.bean.messagebuilder.NewsBuilder; +import me.chanjar.weixin.cp.bean.messagebuilder.TextBuilder; +import me.chanjar.weixin.cp.bean.messagebuilder.VideoBuilder; +import me.chanjar.weixin.cp.bean.messagebuilder.VoiceBuilder; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + /** * 消息 * @@ -14,9 +19,6 @@ import java.util.List; */ public class WxCpMessage implements Serializable { - /** - * - */ private static final long serialVersionUID = -2082278303476631708L; private String toUser; private String toParty; 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 ca11cb1f..4e1c034f 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,17 +1,14 @@ package me.chanjar.weixin.cp.bean; -import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; - import java.io.Serializable; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + /** * Created by Daniel Qian */ public class WxCpTag implements Serializable { - /** - * - */ private static final long serialVersionUID = -7243320279646928402L; private String id; 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 d1737d5d..93c3e5fe 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,11 +1,11 @@ package me.chanjar.weixin.cp.bean; -import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; - import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + /** * 微信用户信息 * @@ -13,9 +13,6 @@ import java.util.List; */ public class WxCpUser implements Serializable { - /** - * - */ private static final long serialVersionUID = -5696099236344075582L; private final List extAttrs = new ArrayList<>(); private String userId; 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 352fa2e6..93ca45c3 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 @@ -1,18 +1,20 @@ package me.chanjar.weixin.cp.bean; +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.io.IOUtils; + import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; + import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import me.chanjar.weixin.cp.api.WxCpConfigStorage; import me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil; import me.chanjar.weixin.cp.util.xml.XStreamTransformer; -import org.apache.commons.io.IOUtils; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; /** *
    @@ -27,16 +29,12 @@ import java.util.List;
      */
     @XStreamAlias("xml")
     public class WxCpXmlMessage implements Serializable {
    +  private static final long serialVersionUID = -1042994982179476410L;
     
       ///////////////////////
       // 以下都是微信推送过来的消息的xml的element所对应的属性
       ///////////////////////
     
    -  /**
    -   * 
    -   */
    -  private static final long serialVersionUID = -1042994982179476410L;
    -
       @XStreamAlias("AgentID")
       private Integer agentId;
     
    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 44de8811..35cbe754 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,11 +2,13 @@ package me.chanjar.weixin.cp.bean;
     
     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.xml.XStreamMediaIdConverter;
     
     @XStreamAlias("xml")
     public class WxCpXmlOutImageMessage extends WxCpXmlOutMessage {
    +  private static final long serialVersionUID = -1099446240667237313L;
     
       @XStreamAlias("Image")
       @XStreamConverter(value = XStreamMediaIdConverter.class)
    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 332b5e24..0d90a012 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
    @@ -8,8 +8,12 @@ import me.chanjar.weixin.cp.bean.outxmlbuilder.*;
     import me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil;
     import me.chanjar.weixin.cp.util.xml.XStreamTransformer;
     
    +import java.io.Serializable;
    +
     @XStreamAlias("xml")
    -public abstract class WxCpXmlOutMessage {
    +public abstract class WxCpXmlOutMessage implements Serializable {
    +
    +  private static final long serialVersionUID = 1418629839964153110L;
     
       @XStreamAlias("ToUserName")
       @XStreamConverter(value = XStreamCDataConverter.class)
    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 5906a324..8910f03f 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
    @@ -1,15 +1,17 @@
     package me.chanjar.weixin.cp.bean;
     
    +import java.util.ArrayList;
    +import java.util.List;
    +
     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.xml.XStreamCDataConverter;
     
    -import java.util.ArrayList;
    -import java.util.List;
    -
     @XStreamAlias("xml")
     public class WxCpXmlOutNewsMessage extends WxCpXmlOutMessage {
    +  private static final long serialVersionUID = -5796178637883178826L;
     
       @XStreamAlias("Articles")
       protected final List articles = new ArrayList<>();
    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 3c59edf9..532e06c3 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,11 +2,13 @@ package me.chanjar.weixin.cp.bean;
     
     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.xml.XStreamCDataConverter;
     
     @XStreamAlias("xml")
     public class WxCpXmlOutTextMessage extends WxCpXmlOutMessage {
    +  private static final long serialVersionUID = 2569239617185930232L;
     
       @XStreamAlias("Content")
       @XStreamConverter(value = XStreamCDataConverter.class)
    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 6e2f268f..73c56d4c 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,11 +2,13 @@ package me.chanjar.weixin.cp.bean;
     
     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.xml.XStreamCDataConverter;
     
     @XStreamAlias("xml")
     public class WxCpXmlOutVideoMessage extends WxCpXmlOutMessage {
    +  private static final long serialVersionUID = -8672761162722733622L;
     
       @XStreamAlias("Video")
       protected final Video video = new Video();
    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 1fd6d4ce..bba95cfd 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,11 +2,13 @@ package me.chanjar.weixin.cp.bean;
     
     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.xml.XStreamMediaIdConverter;
     
     @XStreamAlias("xml")
     public class WxCpXmlOutVoiceMessage extends WxCpXmlOutMessage {
    +  private static final long serialVersionUID = -7947384031546099340L;
     
       @XStreamAlias("Voice")
       @XStreamConverter(value = XStreamMediaIdConverter.class)
    
    From 6682f5ff28117cda9a69ddfc79905e3459dbb261 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Fri, 14 Oct 2016 16:19:13 +0800
    Subject: [PATCH 53/76] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?=
     =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=E5=90=8D=E7=A7=B0:=20agendid=20->?=
     =?UTF-8?q?=20agentid?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../weixin/cp/api/WxCpServiceImpl.java        | 53 +++++++------------
     1 file changed, 20 insertions(+), 33 deletions(-)
    
    diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java
    index e3723a71..da95cab0 100644
    --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java
    +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java
    @@ -1,28 +1,7 @@
     package me.chanjar.weixin.cp.api;
     
    -import java.io.File;
    -import java.io.IOException;
    -import java.io.InputStream;
    -import java.util.List;
    -import java.util.UUID;
    -
    -import org.apache.http.HttpHost;
    -import org.apache.http.client.ClientProtocolException;
    -import org.apache.http.client.config.RequestConfig;
    -import org.apache.http.client.methods.CloseableHttpResponse;
    -import org.apache.http.client.methods.HttpGet;
    -import org.apache.http.impl.client.BasicResponseHandler;
    -import org.apache.http.impl.client.CloseableHttpClient;
    -import org.slf4j.Logger;
    -import org.slf4j.LoggerFactory;
    -
    -import com.google.gson.JsonArray;
    -import com.google.gson.JsonElement;
    -import com.google.gson.JsonObject;
    -import com.google.gson.JsonParser;
    -import com.google.gson.JsonPrimitive;
    +import com.google.gson.*;
     import com.google.gson.reflect.TypeToken;
    -
     import me.chanjar.weixin.common.bean.WxAccessToken;
     import me.chanjar.weixin.common.bean.WxJsapiSignature;
     import me.chanjar.weixin.common.bean.menu.WxMenu;
    @@ -36,20 +15,28 @@ import me.chanjar.weixin.common.util.RandomUtils;
     import me.chanjar.weixin.common.util.StringUtils;
     import me.chanjar.weixin.common.util.crypto.SHA1;
     import me.chanjar.weixin.common.util.fs.FileUtils;
    -import me.chanjar.weixin.common.util.http.ApacheHttpClientBuilder;
    -import me.chanjar.weixin.common.util.http.DefaultApacheHttpClientBuilder;
    -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 me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
    -import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
    -import me.chanjar.weixin.common.util.http.URIUtil;
    +import me.chanjar.weixin.common.util.http.*;
     import me.chanjar.weixin.common.util.json.GsonHelper;
     import me.chanjar.weixin.cp.bean.WxCpDepart;
     import me.chanjar.weixin.cp.bean.WxCpMessage;
     import me.chanjar.weixin.cp.bean.WxCpTag;
     import me.chanjar.weixin.cp.bean.WxCpUser;
     import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
    +import org.apache.http.HttpHost;
    +import org.apache.http.client.ClientProtocolException;
    +import org.apache.http.client.config.RequestConfig;
    +import org.apache.http.client.methods.CloseableHttpResponse;
    +import org.apache.http.client.methods.HttpGet;
    +import org.apache.http.impl.client.BasicResponseHandler;
    +import org.apache.http.impl.client.CloseableHttpClient;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.util.List;
    +import java.util.UUID;
     
     public class WxCpServiceImpl implements WxCpService {
     
    @@ -185,10 +172,10 @@ public class WxCpServiceImpl implements WxCpService {
         jsapiSignature.setNoncestr(noncestr);
         jsapiSignature.setUrl(url);
         jsapiSignature.setSignature(signature);
    -    
    +
         // Fixed bug
         jsapiSignature.setAppid(this.configStorage.getCorpId());
    -    
    +
         return jsapiSignature;
       }
     
    @@ -503,7 +490,7 @@ this.configStorage.getOauth2redirectUri(),
       public String[] oauth2getUserInfo(String agentId, String code) throws WxErrorException {
         String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?"
                 + "code=" + code
    -            + "&agendid=" + agentId;
    +            + "&agentid=" + agentId;
         String responseText = get(url, null);
         JsonElement je = new JsonParser().parse(responseText);
         JsonObject jo = je.getAsJsonObject();
    
    From 77db3c2dae5756930ce00772e26f112a26497fba Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Fri, 14 Oct 2016 19:33:34 +0800
    Subject: [PATCH 54/76] =?UTF-8?q?=E5=B0=86=E6=A8=A1=E6=9D=BF=E6=B6=88?=
     =?UTF-8?q?=E6=81=AF=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E4=BB=A3=E7=A0=81?=
     =?UTF-8?q?=E7=A7=BB=E5=88=B0=E5=8D=95=E7=8B=AC=E7=9A=84service=EF=BC=8C?=
     =?UTF-8?q?=E5=B9=B6=E4=BD=9C=E7=9B=B8=E5=BA=94=E9=87=8D=E6=9E=84=E8=B0=83?=
     =?UTF-8?q?=E6=95=B4=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=8D=95=E5=85=83=E6=B5=8B?=
     =?UTF-8?q?=E8=AF=95=20for=20issue=20#63?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../me/chanjar/weixin/mp/api/WxMpService.java | 53 ++--------
     .../weixin/mp/api/WxMpTemplateMsgService.java | 49 ++++++++++
     .../weixin/mp/api/impl/WxMpServiceImpl.java   | 36 ++-----
     .../api/impl/WxMpTemplateMsgServiceImpl.java  | 58 +++++++++++
     .../me/chanjar/weixin/mp/bean/Industry.java   | 38 -------
     .../chanjar/weixin/mp/bean/WxMpIndustry.java  | 98 ++++++++++++++++---
     .../mp/util/json/WxMpIndustryGsonAdapter.java | 18 +---
     .../mp/api/impl/WxMpServiceImplTest.java      | 28 +-----
     .../impl/WxMpTemplateMsgServiceImplTest.java  | 59 +++++++++++
     9 files changed, 273 insertions(+), 164 deletions(-)
     create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java
     create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java
     delete mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/Industry.java
     create mode 100644 weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java
    
    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 292c5645..e77b60d9 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
    @@ -3,19 +3,8 @@ package me.chanjar.weixin.mp.api;
     import me.chanjar.weixin.common.bean.WxJsapiSignature;
     import me.chanjar.weixin.common.exception.WxErrorException;
     import me.chanjar.weixin.common.util.http.RequestExecutor;
    -import me.chanjar.weixin.mp.bean.WxMpIndustry;
    -import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
    -import me.chanjar.weixin.mp.bean.WxMpMassNews;
    -import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
    -import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage;
    -import me.chanjar.weixin.mp.bean.WxMpMassVideo;
    -import me.chanjar.weixin.mp.bean.WxMpSemanticQuery;
    -import me.chanjar.weixin.mp.bean.WxMpTemplateMessage;
    -import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
    -import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
    -import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
    -import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
    -import me.chanjar.weixin.mp.bean.result.WxMpUser;
    +import me.chanjar.weixin.mp.bean.*;
    +import me.chanjar.weixin.mp.bean.result.*;
     
     /**
      * 微信API的Service
    @@ -133,16 +122,6 @@ public interface WxMpService {
        */
       String shortUrl(String long_url) throws WxErrorException;
     
    -  /**
    -   * 
    -   * 发送模板消息
    -   * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=模板消息接口
    -   * 
    - * - * @return msgid - */ - String templateSend(WxMpTemplateMessage templateMessage) throws WxErrorException; - /** *
        * 语义查询接口
    @@ -266,27 +245,6 @@ public interface WxMpService {
        */
       WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws Exception;
     
    -  /**
    -   * 
    -   * 设置所属行业
    -   * 官方文档中暂未告知响应内容
    -   * 详情请见:http://mp.weixin.qq.com/wiki/5/6dde9eaa909f83354e0094dc3ad99e05.html#.E8.AE.BE.E7.BD.AE.E6.89.80.E5.B1.9E.E8.A1.8C.E4.B8.9A
    -   * 
    - * - * @return JsonObject - */ - String setIndustry(WxMpIndustry wxMpIndustry) throws WxErrorException; - - /*** - *
    -   * 获取设置的行业信息
    -   * 详情请见:http://mp.weixin.qq.com/wiki/5/6dde9eaa909f83354e0094dc3ad99e05.html#.E8.AE.BE.E7.BD.AE.E6.89.80.E5.B1.9E.E8.A1.8C.E4.B8.9A
    -   * 
    - * - * @return wxMpIndustry - */ - WxMpIndustry getIndustry() throws WxErrorException; - /** * 获取WxMpConfigStorage 对象 * @@ -370,4 +328,11 @@ public interface WxMpService { * @return WxMpStoreService */ WxMpStoreService getStoreService(); + + /** + * 返回模板消息相关接口方法的实现类对象,以方便调用其各种接口 + * + * @return WxMpTemplateMsgService + */ + WxMpTemplateMsgService getTemplateMsgService(); } 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 new file mode 100644 index 00000000..d468a89e --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpTemplateMsgService.java @@ -0,0 +1,49 @@ +package me.chanjar.weixin.mp.api; + +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.bean.WxMpIndustry; +import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; + +/** + *
    + * 模板消息接口
    + * 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)
    + * 
    + */ +public interface WxMpTemplateMsgService { + + /** + *
    +   * 设置所属行业
    +   * 官方文档中暂未告知响应内容
    +   * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
    +   * 
    + * + * @return 是否成功 + */ + boolean setIndustry(WxMpIndustry wxMpIndustry) throws WxErrorException; + + /*** + *
    +   * 获取设置的行业信息
    +   * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
    +   * 
    + * + * @return wxMpIndustry + */ + WxMpIndustry getIndustry() throws WxErrorException; + + /** + *
    +   * 发送模板消息
    +   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
    +   * 
    + * + * @return 消息Id + */ + String sendTemplateMsg(WxMpTemplateMessage templateMessage) throws WxErrorException; + +} 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 db8cfffa..7b5171f5 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 @@ -69,6 +69,8 @@ public class WxMpServiceImpl implements WxMpService { private WxMpUserBlacklistService blackListService = new WxMpUserBlacklistServiceImpl(this); + private WxMpTemplateMsgService templateMsgService = new WxMpTemplateMsgServiceImpl(this); + private CloseableHttpClient httpClient; private HttpHost httpProxy; @@ -221,35 +223,6 @@ public class WxMpServiceImpl implements WxMpService { return tmpJsonElement.getAsJsonObject().get("short_url").getAsString(); } - @Override - public String templateSend(WxMpTemplateMessage templateMessage) throws WxErrorException { - String url = "https://api.weixin.qq.com/cgi-bin/message/template/send"; - String responseContent = this.post(url, templateMessage.toJson()); - final JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); - if (jsonObject.get("errcode").getAsInt() == 0){ - return jsonObject.get("msgid").getAsString(); - } - - throw new WxErrorException(WxError.fromJson(responseContent)); - } - - @Override - public String setIndustry(WxMpIndustry wxMpIndustry) throws WxErrorException { - if (null == wxMpIndustry.getPrimaryIndustry() || null == wxMpIndustry.getPrimaryIndustry().getId() - || null == wxMpIndustry.getSecondIndustry() || null == wxMpIndustry.getSecondIndustry().getId()) { - throw new IllegalArgumentException("industry id is empty"); - } - String url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry"; - return this.post(url, wxMpIndustry.toJson()); - } - - @Override - public WxMpIndustry getIndustry() throws WxErrorException { - String url = "https://api.weixin.qq.com/cgi-bin/template/get_industry"; - String responseContent = this.get(url, null); - return WxMpIndustry.fromJson(responseContent); - } - @Override public WxMpSemanticQueryResult semanticQuery(WxMpSemanticQuery semanticQuery) throws WxErrorException { String url = "https://api.weixin.qq.com/semantic/semproxy/search"; @@ -562,4 +535,9 @@ public class WxMpServiceImpl implements WxMpService { return this.storeService; } + @Override + public WxMpTemplateMsgService getTemplateMsgService() { + return this.templateMsgService; + } + } 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 new file mode 100644 index 00000000..d4f03ec9 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImpl.java @@ -0,0 +1,58 @@ +package me.chanjar.weixin.mp.api.impl; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +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.WxMpTemplateMsgService; +import me.chanjar.weixin.mp.bean.WxMpIndustry; +import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; + +/** + *
    + * Created by Binary Wang on 2016-10-14.
    + * @author binarywang(Binary Wang)
    + * 
    + */ +public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { + public static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/template"; + private static final JsonParser JSON_PARSER = new JsonParser(); + + private WxMpService wxMpService; + + public WxMpTemplateMsgServiceImpl(WxMpService wxMpService) { + this.wxMpService = wxMpService; + } + + @Override + public String sendTemplateMsg(WxMpTemplateMessage templateMessage) throws WxErrorException { + String url = "https://api.weixin.qq.com/cgi-bin/message/template/send"; + String responseContent = this.wxMpService.post(url, templateMessage.toJson()); + final JsonObject jsonObject = JSON_PARSER.parse(responseContent).getAsJsonObject(); + if (jsonObject.get("errcode").getAsInt() == 0) { + return jsonObject.get("msgid").getAsString(); + } + throw new WxErrorException(WxError.fromJson(responseContent)); + } + + @Override + public boolean setIndustry(WxMpIndustry wxMpIndustry) throws WxErrorException { + if (null == wxMpIndustry.getPrimaryIndustry() || null == wxMpIndustry.getPrimaryIndustry().getId() + || null == wxMpIndustry.getSecondIndustry() || null == wxMpIndustry.getSecondIndustry().getId()) { + throw new IllegalArgumentException("行业Id不能为空,请核实"); + } + + String url = API_URL_PREFIX + "/api_set_industry"; + this.wxMpService.post(url, wxMpIndustry.toJson()); + return true; + } + + @Override + public WxMpIndustry getIndustry() throws WxErrorException { + String url = API_URL_PREFIX + "/get_industry"; + String responseContent = this.wxMpService.get(url, null); + return WxMpIndustry.fromJson(responseContent); + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/Industry.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/Industry.java deleted file mode 100644 index da5b5134..00000000 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/Industry.java +++ /dev/null @@ -1,38 +0,0 @@ -package me.chanjar.weixin.mp.bean; - -import java.io.Serializable; - -/** - * @author miller - * 官方文档中,创建和获取的数据结构不一样。所以采用冗余字段的方式,实现相应的接口 - */ -public class Industry implements Serializable { - private static final long serialVersionUID = -1707184885588012142L; - private String id; - private String firstClass; - private String secondClass; - - 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/WxMpIndustry.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpIndustry.java index 281b9315..b94fe10b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpIndustry.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpIndustry.java @@ -2,6 +2,8 @@ package me.chanjar.weixin.mp.bean; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; import java.io.Serializable; @@ -9,31 +11,97 @@ import java.io.Serializable; * @author miller */ public class WxMpIndustry implements Serializable { - private static final long serialVersionUID = -7700398224795914722L; - private Industry primaryIndustry; - private Industry secondIndustry; + private static final long serialVersionUID = -7700398224795914722L; + private Industry primaryIndustry; + private Industry secondIndustry; - public static WxMpIndustry fromJson(String json) { - return WxMpGsonBuilder.create().fromJson(json, WxMpIndustry.class); + public WxMpIndustry() { + } + + public WxMpIndustry(Industry primaryIndustry, Industry secondIndustry) { + this.primaryIndustry = primaryIndustry; + this.secondIndustry = secondIndustry; + } + + /** + * @author miller + * 官方文档中,创建和获取的数据结构不一样。所以采用冗余字段的方式,实现相应的接口 + */ + public static class Industry implements Serializable { + private static final long serialVersionUID = -1707184885588012142L; + private String id; + private String firstClass; + private String secondClass; + + public Industry() { + } + + public Industry(String id) { + this.id = id; + } + + public Industry(String id, String firstClass, String secondClass) { + this.id = id; + this.firstClass = firstClass; + this.secondClass = secondClass; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); } - public String toJson() { - return WxMpGsonBuilder.create().toJson(this); + public String getId() { + return this.id; } - public Industry getPrimaryIndustry() { - return this.primaryIndustry; + public void setId(String id) { + this.id = id; } - public void setPrimaryIndustry(Industry primaryIndustry) { - this.primaryIndustry = primaryIndustry; + public String getFirstClass() { + return this.firstClass; } - public Industry getSecondIndustry() { - return this.secondIndustry; + public void setFirstClass(String firstClass) { + this.firstClass = firstClass; } - public void setSecondIndustry(Industry secondIndustry) { - this.secondIndustry = secondIndustry; + public String getSecondClass() { + return this.secondClass; } + + public void setSecondClass(String secondClass) { + this.secondClass = secondClass; + } + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } + + public static WxMpIndustry fromJson(String json) { + return WxMpGsonBuilder.create().fromJson(json, WxMpIndustry.class); + } + + 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; + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java index 60361249..ea715a70 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java @@ -1,19 +1,11 @@ package me.chanjar.weixin.mp.util.json; -import java.lang.reflect.Type; - -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 com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - +import com.google.gson.*; import me.chanjar.weixin.common.util.json.GsonHelper; -import me.chanjar.weixin.mp.bean.Industry; import me.chanjar.weixin.mp.bean.WxMpIndustry; +import java.lang.reflect.Type; + /** * @author miller */ @@ -42,8 +34,8 @@ public class WxMpIndustryGsonAdapter return wxMpIndustry; } - private static Industry convertFromJson(JsonObject json) { - Industry industry = new Industry(); + private static WxMpIndustry.Industry convertFromJson(JsonObject json) { + WxMpIndustry.Industry industry = new WxMpIndustry.Industry(); industry.setFirstClass(GsonHelper.getString(json, "first_class")); industry.setSecondClass(GsonHelper.getString(json, "second_class")); return industry; 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 c108d575..49316948 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 @@ -1,20 +1,12 @@ package me.chanjar.weixin.mp.api.impl; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.testng.Assert; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - 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.ApiTestModule; import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; -import me.chanjar.weixin.mp.bean.WxMpTemplateData; -import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; +import org.testng.Assert; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; @Test @Guice(modules = ApiTestModule.class) @@ -88,20 +80,6 @@ public class WxMpServiceImplTest { Assert.fail("Not yet implemented"); } - @Test(invocationCount = 100, threadPoolSize = 30) - public void testTemplateSend() throws WxErrorException { - SimpleDateFormat dateFormat = new SimpleDateFormat( - "yyyy-MM-dd HH:mm:ss.SSS"); - WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService - .getWxMpConfigStorage(); - WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder() - .toUser(configStorage.getOpenid()) - .templateId(configStorage.getTemplateId()).build(); - templateMessage.addWxMpTemplateData( - new WxMpTemplateData("first", dateFormat.format(new Date()))); - this.wxService.templateSend(templateMessage); - } - @Test public void testSetIndustry() { Assert.fail("Not yet implemented"); 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 new file mode 100644 index 00000000..5fb8061e --- /dev/null +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpTemplateMsgServiceImplTest.java @@ -0,0 +1,59 @@ +package me.chanjar.weixin.mp.api.impl; + +import com.google.inject.Inject; +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.api.ApiTestModule; +import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; +import me.chanjar.weixin.mp.bean.WxMpIndustry; +import me.chanjar.weixin.mp.bean.WxMpTemplateData; +import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; +import org.testng.Assert; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + *
    + * Created by Binary Wang on 2016-10-14.
    + * @author binarywang(Binary Wang)
    + * 
    + */ +@Guice(modules = ApiTestModule.class) +public class WxMpTemplateMsgServiceImplTest { + @Inject + protected WxMpServiceImpl wxService; + + @Test(invocationCount = 10, threadPoolSize = 10) + public void testSendTemplateMsg() throws WxErrorException { + SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-MM-dd HH:mm:ss.SSS"); + WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService + .getWxMpConfigStorage(); + WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder() + .toUser(configStorage.getOpenid()) + .templateId(configStorage.getTemplateId()).build(); + templateMessage.addWxMpTemplateData( + new WxMpTemplateData("first", dateFormat.format(new Date()))); + String msgId = this.wxService.getTemplateMsgService().sendTemplateMsg(templateMessage); + Assert.assertNotNull(msgId); + System.out.println(msgId); + } + + @Test + public void testGetIndustry() throws Exception { + final WxMpIndustry industry = this.wxService.getTemplateMsgService().getIndustry(); + Assert.assertNotNull(industry); + System.out.println(industry); + } + + @Test + public void testSetIndustry() throws Exception { + WxMpIndustry industry = new WxMpIndustry(new WxMpIndustry.Industry("1"), + new WxMpIndustry.Industry("04")); + boolean result = this.wxService.getTemplateMsgService().setIndustry(industry); + Assert.assertTrue(result); + } + +} From d7298ab790a3b36d4b8f39e93680a4cdd521a8a3 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 17 Oct 2016 23:43:31 +0800 Subject: [PATCH 55/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=BE=97?= =?UTF-8?q?=E6=A8=A1=E6=9D=BFID=E7=9A=84=E6=8E=A5=E5=8F=A3=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=AE=9E=E7=8E=B0=20for=20issue=20#63?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/WxMpTemplateMsgService.java | 11 ++++++++++ .../api/impl/WxMpTemplateMsgServiceImpl.java | 15 +++++++++++++ .../impl/WxMpTemplateMsgServiceImplTest.java | 21 +++++++++++++------ 3 files changed, 41 insertions(+), 6 deletions(-) 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 d468a89e..9f696597 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 @@ -46,4 +46,15 @@ public interface WxMpTemplateMsgService { */ String sendTemplateMsg(WxMpTemplateMessage templateMessage) throws WxErrorException; + /** + *
    +   * 获得模板ID
    +   * 从行业模板库选择模板到帐号后台,获得模板ID的过程可在MP中完成
    +   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
    +   * 接口地址格式:https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=ACCESS_TOKEN
    +   * 
    + *@param shortTemplateId 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式 + * @return templateId 模板Id + */ + String addTemplate(String shortTemplateId) throws WxErrorException; } 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 d4f03ec9..a404cb02 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 @@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api.impl; import com.google.gson.JsonObject; import com.google.gson.JsonParser; + import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; @@ -55,4 +56,18 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { return WxMpIndustry.fromJson(responseContent); } + @Override + public String addTemplate(String shortTemplateId) throws WxErrorException { + String url = API_URL_PREFIX + "/api_add_template"; + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("template_id_short", shortTemplateId); + String responseContent = this.wxMpService.post(url, jsonObject.toString()); + final JsonObject result = JSON_PARSER.parse(responseContent).getAsJsonObject(); + if (result.get("errcode").getAsInt() == 0) { + return result.get("template_id").getAsString(); + } + + throw new WxErrorException(WxError.fromJson(responseContent)); + } + } 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 5fb8061e..b967719f 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 @@ -1,18 +1,20 @@ package me.chanjar.weixin.mp.api.impl; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.testng.Assert; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + import com.google.inject.Inject; + import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.ApiTestModule; import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; import me.chanjar.weixin.mp.bean.WxMpIndustry; import me.chanjar.weixin.mp.bean.WxMpTemplateData; import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; -import org.testng.Assert; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; - -import java.text.SimpleDateFormat; -import java.util.Date; /** *
    @@ -56,4 +58,11 @@ public class WxMpTemplateMsgServiceImplTest {
         Assert.assertTrue(result);
       }
     
    +  @Test
    +  public void testAddTemplate() throws Exception {
    +    String result = this.wxService.getTemplateMsgService().addTemplate("TM00015");
    +    Assert.assertNotNull(result);
    +    System.err.println(result);
    +  }
    +
     }
    
    From 6dc0481d1d0bfbc711470bfd3dec1db3318336a9 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Tue, 18 Oct 2016 00:07:14 +0800
    Subject: [PATCH 56/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=BE=97?=
     =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=88=97=E8=A1=A8=E7=9A=84=E6=8E=A5=E5=8F=A3?=
     =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E5=B9=B6=E9=87=8D=E6=9E=84=E6=A8=A1?=
     =?UTF-8?q?=E6=9D=BF=E6=B6=88=E6=81=AF=E7=9B=B8=E5=85=B3=E7=B1=BB=E5=8C=85?=
     =?UTF-8?q?=E7=BB=93=E6=9E=84=20for=20issue=20#63?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../weixin/mp/api/WxMpTemplateMsgService.java |  25 +++-
     .../api/impl/WxMpTemplateMsgServiceImpl.java  |  19 ++-
     .../weixin/mp/bean/template/WxMpTemplate.java | 126 ++++++++++++++++++
     .../bean/{ => template}/WxMpTemplateData.java |   2 +-
     .../WxMpTemplateIndustry.java}                |  12 +-
     .../{ => template}/WxMpTemplateMessage.java   |   2 +-
     .../weixin/mp/util/json/WxMpGsonBuilder.java  |   6 +-
     .../mp/util/json/WxMpIndustryGsonAdapter.java |  14 +-
     .../json/WxMpTemplateMessageGsonAdapter.java  |   5 +-
     .../impl/WxMpTemplateMsgServiceImplTest.java  |  21 ++-
     10 files changed, 196 insertions(+), 36 deletions(-)
     create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java
     rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/{ => template}/WxMpTemplateData.java (95%)
     rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/{WxMpIndustry.java => template/WxMpTemplateIndustry.java} (86%)
     rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/{ => template}/WxMpTemplateMessage.java (98%)
    
    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 9f696597..4788bf3e 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
    @@ -1,8 +1,11 @@
     package me.chanjar.weixin.mp.api;
     
    +import java.util.List;
    +
     import me.chanjar.weixin.common.exception.WxErrorException;
    -import me.chanjar.weixin.mp.bean.WxMpIndustry;
    -import me.chanjar.weixin.mp.bean.WxMpTemplateMessage;
    +import me.chanjar.weixin.mp.bean.template.WxMpTemplate;
    +import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry;
    +import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
     
     /**
      * 
    @@ -24,7 +27,7 @@ public interface WxMpTemplateMsgService {
        *
        * @return 是否成功
        */
    -  boolean setIndustry(WxMpIndustry wxMpIndustry) throws WxErrorException;
    +  boolean setIndustry(WxMpTemplateIndustry wxMpIndustry) throws WxErrorException;
     
       /***
        * 
    @@ -34,7 +37,7 @@ public interface WxMpTemplateMsgService {
        *
        * @return wxMpIndustry
        */
    -  WxMpIndustry getIndustry() throws WxErrorException;
    +  WxMpTemplateIndustry getIndustry() throws WxErrorException;
     
       /**
        * 
    @@ -53,8 +56,20 @@ public interface WxMpTemplateMsgService {
        * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
        * 接口地址格式:https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=ACCESS_TOKEN
        * 
    - *@param shortTemplateId 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式 + * @param shortTemplateId 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式 * @return templateId 模板Id */ String addTemplate(String shortTemplateId) throws WxErrorException; + + /** + *
    +   * 获取模板列表
    +   * 获取已添加至帐号下所有模板列表,可在MP中查看模板列表信息,为方便第三方开发者,提供通过接口调用的方式来获取帐号下所有模板信息
    +   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
    +   * 接口地址格式:https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token=ACCESS_TOKEN
    +   * 
    + * + * @return templateId 模板Id + */ + List getAllPrivateTemplate() throws WxErrorException; } 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 a404cb02..e4ee2a1b 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 @@ -1,5 +1,7 @@ package me.chanjar.weixin.mp.api.impl; +import java.util.List; + import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -7,8 +9,9 @@ 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.WxMpTemplateMsgService; -import me.chanjar.weixin.mp.bean.WxMpIndustry; -import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; +import me.chanjar.weixin.mp.bean.template.WxMpTemplate; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; /** *
    @@ -38,7 +41,7 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
       }
     
       @Override
    -  public boolean setIndustry(WxMpIndustry wxMpIndustry) throws WxErrorException {
    +  public boolean setIndustry(WxMpTemplateIndustry wxMpIndustry) throws WxErrorException {
         if (null == wxMpIndustry.getPrimaryIndustry() || null == wxMpIndustry.getPrimaryIndustry().getId()
           || null == wxMpIndustry.getSecondIndustry() || null == wxMpIndustry.getSecondIndustry().getId()) {
           throw new IllegalArgumentException("行业Id不能为空,请核实");
    @@ -50,10 +53,10 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
       }
     
       @Override
    -  public WxMpIndustry getIndustry() throws WxErrorException {
    +  public WxMpTemplateIndustry getIndustry() throws WxErrorException {
         String url = API_URL_PREFIX + "/get_industry";
         String responseContent = this.wxMpService.get(url, null);
    -    return WxMpIndustry.fromJson(responseContent);
    +    return WxMpTemplateIndustry.fromJson(responseContent);
       }
     
       @Override
    @@ -70,4 +73,10 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
         throw new WxErrorException(WxError.fromJson(responseContent));
       }
     
    +  @Override
    +  public List getAllPrivateTemplate() throws WxErrorException {
    +    String url = API_URL_PREFIX + "/get_all_private_template";
    +    return WxMpTemplate.fromJson(this.wxMpService.get(url, null));
    +  }
    +
     }
    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
    new file mode 100644
    index 00000000..ffa2711f
    --- /dev/null
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplate.java
    @@ -0,0 +1,126 @@
    +package me.chanjar.weixin.mp.bean.template;
    +
    +import java.util.List;
    +
    +import org.apache.commons.lang3.builder.ToStringBuilder;
    +import org.apache.commons.lang3.builder.ToStringStyle;
    +
    +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;
    +
    +/**
    + * 
    + * 模板列表信息
    + * Created by Binary Wang on 2016-10-17.
    + * @author binarywang(Binary Wang)
    + * 
    + */ +public class WxMpTemplate { + + private static final JsonParser JSON_PARSER = new JsonParser(); + + public static List fromJson(String json) { + return WxMpGsonBuilder.create().fromJson(JSON_PARSER.parse(json).getAsJsonObject().get("template_list"), + new TypeToken>() { + }.getType()); + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } + + /** + * template_id + * 模板ID + */ + @SerializedName("template_id") + private String templateId; + + /** + * title + * 模板标题 + */ + @SerializedName("title") + private String title; + + /** + * primary_industry + * 模板所属行业的一级行业 + */ + @SerializedName("primary_industry") + private String primaryIndustry; + + /** + * deputy_industry + * 模板所属行业的二级行业 + */ + @SerializedName("deputy_industry") + private String deputyIndustry; + + /** + * content + * 模板内容 + */ + @SerializedName("content") + private String content; + + /** + * example + * 模板示例 + */ + @SerializedName("example") + private String example; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getPrimaryIndustry() { + return primaryIndustry; + } + + public void setPrimaryIndustry(String primaryIndustry) { + this.primaryIndustry = primaryIndustry; + } + + public String getDeputyIndustry() { + return deputyIndustry; + } + + public void setDeputyIndustry(String deputyIndustry) { + this.deputyIndustry = deputyIndustry; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getExample() { + return example; + } + + public void setExample(String example) { + this.example = example; + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpTemplateData.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java similarity index 95% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpTemplateData.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java index d46ae24b..0eb0eaa5 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpTemplateData.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateData.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.mp.bean; +package me.chanjar.weixin.mp.bean.template; import java.io.Serializable; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpIndustry.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java similarity index 86% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpIndustry.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java index b94fe10b..b0f689a4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpIndustry.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateIndustry.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.mp.bean; +package me.chanjar.weixin.mp.bean.template; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @@ -10,15 +10,15 @@ import java.io.Serializable; /** * @author miller */ -public class WxMpIndustry implements Serializable { +public class WxMpTemplateIndustry implements Serializable { private static final long serialVersionUID = -7700398224795914722L; private Industry primaryIndustry; private Industry secondIndustry; - public WxMpIndustry() { + public WxMpTemplateIndustry() { } - public WxMpIndustry(Industry primaryIndustry, Industry secondIndustry) { + public WxMpTemplateIndustry(Industry primaryIndustry, Industry secondIndustry) { this.primaryIndustry = primaryIndustry; this.secondIndustry = secondIndustry; } @@ -81,8 +81,8 @@ public class WxMpIndustry implements Serializable { return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); } - public static WxMpIndustry fromJson(String json) { - return WxMpGsonBuilder.create().fromJson(json, WxMpIndustry.class); + public static WxMpTemplateIndustry fromJson(String json) { + return WxMpGsonBuilder.create().fromJson(json, WxMpTemplateIndustry.class); } public String toJson() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpTemplateMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java similarity index 98% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpTemplateMessage.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java index 408abb50..106e5fb6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpTemplateMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/template/WxMpTemplateMessage.java @@ -1,4 +1,4 @@ -package me.chanjar.weixin.mp.bean; +package me.chanjar.weixin.mp.bean.template; import java.io.Serializable; import java.util.ArrayList; 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 df63ac64..e2f215e6 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 @@ -5,7 +5,6 @@ import com.google.gson.GsonBuilder; import me.chanjar.weixin.mp.bean.WxMpCard; import me.chanjar.weixin.mp.bean.WxMpCustomMessage; -import me.chanjar.weixin.mp.bean.WxMpIndustry; import me.chanjar.weixin.mp.bean.WxMpMassNews; import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage; import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage; @@ -13,7 +12,6 @@ import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; import me.chanjar.weixin.mp.bean.WxMpMassVideo; import me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate; import me.chanjar.weixin.mp.bean.WxMpMaterialNews; -import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; import me.chanjar.weixin.mp.bean.result.WxMediaImgUploadResult; @@ -31,6 +29,8 @@ import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult; import me.chanjar.weixin.mp.bean.result.WxMpUser; import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult; import me.chanjar.weixin.mp.bean.result.WxMpUserList; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; public class WxMpGsonBuilder { @@ -68,7 +68,7 @@ public class WxMpGsonBuilder { INSTANCE.registerTypeAdapter(WxMpCard.class, new WxMpCardGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpMassPreviewMessage.class, new WxMpMassPreviewMessageGsonAdapter()); INSTANCE.registerTypeAdapter(WxMediaImgUploadResult.class, new WxMediaImgUploadResultGsonAdapter()); - INSTANCE.registerTypeAdapter(WxMpIndustry.class, new WxMpIndustryGsonAdapter()); + INSTANCE.registerTypeAdapter(WxMpTemplateIndustry.class, new WxMpIndustryGsonAdapter()); INSTANCE.registerTypeAdapter(WxMpUserBlacklistGetResult.class, new WxUserBlacklistGetResultGsonAdapter()); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java index ea715a70..68106bb6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java @@ -2,7 +2,7 @@ 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.WxMpIndustry; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; import java.lang.reflect.Type; @@ -10,9 +10,9 @@ import java.lang.reflect.Type; * @author miller */ public class WxMpIndustryGsonAdapter - implements JsonSerializer, JsonDeserializer { + implements JsonSerializer, JsonDeserializer { @Override - public JsonElement serialize(WxMpIndustry wxMpIndustry, Type type, + public JsonElement serialize(WxMpTemplateIndustry wxMpIndustry, Type type, JsonSerializationContext jsonSerializationContext) { JsonObject json = new JsonObject(); json.addProperty("industry_id1", wxMpIndustry.getPrimaryIndustry().getId()); @@ -21,10 +21,10 @@ public class WxMpIndustryGsonAdapter } @Override - public WxMpIndustry deserialize(JsonElement jsonElement, Type type, + public WxMpTemplateIndustry deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { - WxMpIndustry wxMpIndustry = new WxMpIndustry(); + WxMpTemplateIndustry wxMpIndustry = new WxMpTemplateIndustry(); JsonObject primaryIndustry = jsonElement.getAsJsonObject() .get("primary_industry").getAsJsonObject(); wxMpIndustry.setPrimaryIndustry(convertFromJson(primaryIndustry)); @@ -34,8 +34,8 @@ public class WxMpIndustryGsonAdapter return wxMpIndustry; } - private static WxMpIndustry.Industry convertFromJson(JsonObject json) { - WxMpIndustry.Industry industry = new WxMpIndustry.Industry(); + private static WxMpTemplateIndustry.Industry convertFromJson(JsonObject json) { + WxMpTemplateIndustry.Industry industry = new WxMpTemplateIndustry.Industry(); industry.setFirstClass(GsonHelper.getString(json, "first_class")); industry.setSecondClass(GsonHelper.getString(json, "second_class")); return industry; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpTemplateMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpTemplateMessageGsonAdapter.java index 4c2d1227..4e263020 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpTemplateMessageGsonAdapter.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpTemplateMessageGsonAdapter.java @@ -12,8 +12,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import me.chanjar.weixin.mp.bean.WxMpTemplateData; -import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; + +import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; import java.lang.reflect.Type; 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 b967719f..3c6fd0b4 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 @@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api.impl; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import org.testng.Assert; import org.testng.annotations.Guice; @@ -12,9 +13,10 @@ import com.google.inject.Inject; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.ApiTestModule; import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage; -import me.chanjar.weixin.mp.bean.WxMpIndustry; -import me.chanjar.weixin.mp.bean.WxMpTemplateData; -import me.chanjar.weixin.mp.bean.WxMpTemplateMessage; +import me.chanjar.weixin.mp.bean.template.WxMpTemplate; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; /** *
    @@ -45,15 +47,15 @@ public class WxMpTemplateMsgServiceImplTest {
     
       @Test
       public void testGetIndustry() throws Exception {
    -    final WxMpIndustry industry = this.wxService.getTemplateMsgService().getIndustry();
    +    final WxMpTemplateIndustry industry = this.wxService.getTemplateMsgService().getIndustry();
         Assert.assertNotNull(industry);
         System.out.println(industry);
       }
     
       @Test
       public void testSetIndustry() throws Exception {
    -    WxMpIndustry industry = new WxMpIndustry(new WxMpIndustry.Industry("1"),
    -        new WxMpIndustry.Industry("04"));
    +    WxMpTemplateIndustry industry = new WxMpTemplateIndustry(new WxMpTemplateIndustry.Industry("1"),
    +        new WxMpTemplateIndustry.Industry("04"));
         boolean result = this.wxService.getTemplateMsgService().setIndustry(industry);
         Assert.assertTrue(result);
       }
    @@ -65,4 +67,11 @@ public class WxMpTemplateMsgServiceImplTest {
         System.err.println(result);
       }
     
    +  @Test
    +  public void testGetAllPrivateTemplate() throws Exception {
    +    List result = this.wxService.getTemplateMsgService().getAllPrivateTemplate();
    +    Assert.assertNotNull(result);
    +    System.err.println(result);
    +  }
    +
     }
    
    From 550bbe3d1b321b596742fb0c231b53a2d0197d5e Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Tue, 18 Oct 2016 00:13:53 +0800
    Subject: [PATCH 57/76] update readme
    
    ---
     README.md | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/README.md b/README.md
    index 9be8db94..7c1cee44 100644
    --- a/README.md
    +++ b/README.md
    @@ -5,7 +5,7 @@
     ### 注意:
     1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。***
     1. ***自2.0.0版本以来,公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。***
    -1. 本SDK要求的最低JDK版本是7,为解决少量还在使用JDK6的用户,特意抽出独立的代码分支项目,请参考 https://github.com/binarywang/weixin-java-tools-for-jdk6 ,其他更早的JDK版本则需要自己改造实现;
    +1. 本SDK要求的最低JDK版本是7,为满足少量还在使用JDK6的用户的需求,特意抽出独立的代码分支项目,请参考 https://github.com/binarywang/weixin-java-tools-for-jdk6 ,其他更早的JDK版本则需要自己改造实现;
     1. 最新更新:2016-09-30 发布2.2.0正式版!
     
     ===========
    
    From acc129111a2fe2452d375de5576bb5b96f0d41a0 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Tue, 18 Oct 2016 18:29:43 +0800
    Subject: [PATCH 58/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?=
     =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=9A=84=E6=8E=A5=E5=8F=A3=E6=96=B9=E6=B3=95?=
     =?UTF-8?q?=E5=AE=9E=E7=8E=B0=20for=20issue=20#63?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../weixin/mp/api/WxMpTemplateMsgService.java | 18 ++++++++++++---
     .../api/impl/WxMpTemplateMsgServiceImpl.java  | 19 ++++++++++++---
     .../impl/WxMpTemplateMsgServiceImplTest.java  | 23 +++++++++++--------
     3 files changed, 45 insertions(+), 15 deletions(-)
    
    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 4788bf3e..9b66f722 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
    @@ -1,12 +1,12 @@
     package me.chanjar.weixin.mp.api;
     
    -import java.util.List;
    -
     import me.chanjar.weixin.common.exception.WxErrorException;
     import me.chanjar.weixin.mp.bean.template.WxMpTemplate;
     import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry;
     import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
     
    +import java.util.List;
    +
     /**
      * 
      * 模板消息接口
    @@ -68,8 +68,20 @@ public interface WxMpTemplateMsgService {
        * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
        * 接口地址格式:https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token=ACCESS_TOKEN
        * 
    - * + * * @return templateId 模板Id */ List getAllPrivateTemplate() throws WxErrorException; + + /** + *
    +   * 删除模板
    +   * 删除模板可在MP中完成,为方便第三方开发者,提供通过接口调用的方式来删除某帐号下的模板
    +   * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277&token=&lang=zh_CN
    +   * 接口地址格式:https://api.weixin.qq.com/cgi-bin/template/del_private_template?access_token=ACCESS_TOKEN
    +   * 
    + * + * @param templateId 模板Id + */ + boolean delPrivateTemplate(String templateId) throws WxErrorException; } 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 e4ee2a1b..82ce829c 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 @@ -1,10 +1,7 @@ package me.chanjar.weixin.mp.api.impl; -import java.util.List; - import com.google.gson.JsonObject; import com.google.gson.JsonParser; - import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; @@ -13,6 +10,8 @@ import me.chanjar.weixin.mp.bean.template.WxMpTemplate; import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry; import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; +import java.util.List; + /** *
      * Created by Binary Wang on 2016-10-14.
    @@ -79,4 +78,18 @@ public class WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService {
         return WxMpTemplate.fromJson(this.wxMpService.get(url, null));
       }
     
    +  @Override
    +  public boolean delPrivateTemplate(String templateId) throws WxErrorException {
    +    String url = API_URL_PREFIX + "/del_private_template";
    +    JsonObject jsonObject = new JsonObject();
    +    jsonObject.addProperty("template_id", templateId);
    +    String responseContent = this.wxMpService.post(url, jsonObject.toString());
    +    WxError error = WxError.fromJson(responseContent);
    +    if (error.getErrorCode() == 0) {
    +      return true;
    +    }
    +
    +    throw new WxErrorException(error);
    +  }
    +
     }
    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 3c6fd0b4..d6f479b5 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
    @@ -1,15 +1,6 @@
     package me.chanjar.weixin.mp.api.impl;
     
    -import java.text.SimpleDateFormat;
    -import java.util.Date;
    -import java.util.List;
    -
    -import org.testng.Assert;
    -import org.testng.annotations.Guice;
    -import org.testng.annotations.Test;
    -
     import com.google.inject.Inject;
    -
     import me.chanjar.weixin.common.exception.WxErrorException;
     import me.chanjar.weixin.mp.api.ApiTestModule;
     import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage;
    @@ -17,6 +8,13 @@ import me.chanjar.weixin.mp.bean.template.WxMpTemplate;
     import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
     import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry;
     import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
    +import org.testng.Assert;
    +import org.testng.annotations.Guice;
    +import org.testng.annotations.Test;
    +
    +import java.text.SimpleDateFormat;
    +import java.util.Date;
    +import java.util.List;
     
     /**
      * 
    @@ -74,4 +72,11 @@ public class WxMpTemplateMsgServiceImplTest {
         System.err.println(result);
       }
     
    +  @Test
    +  public void testDelPrivateTemplate() throws Exception {
    +    String templateId = "RPcTe7-4BkU5A2J3imC6W0b4JbjEERcJg0whOMKJKIc";
    +    boolean result = this.wxService.getTemplateMsgService().delPrivateTemplate(templateId);
    +    Assert.assertTrue(result);
    +  }
    +
     }
    
    From f54097e19a45404bcb668e414cbad3e0aff1df02 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Tue, 18 Oct 2016 23:33:52 +0800
    Subject: [PATCH 59/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BE=AE=E4=BF=A1?=
     =?UTF-8?q?=E8=AE=A4=E8=AF=81=E4=BA=8B=E4=BB=B6=E6=8E=A8=E9=80=81=E6=B6=88?=
     =?UTF-8?q?=E6=81=AF=E7=9A=84=E6=94=AF=E6=8C=81=EF=BC=8C=E5=8C=85=E6=8B=AC?=
     =?UTF-8?q?=E5=B8=B8=E9=87=8F=E7=9A=84=E5=AE=9A=E4=B9=89=E4=BB=A5=E5=8F=8A?=
     =?UTF-8?q?=E6=8E=A5=E6=94=B6=E6=B6=88=E6=81=AF=E5=AD=97=E6=AE=B5=E7=9A=84?=
     =?UTF-8?q?=E5=AE=9A=E4=B9=89=E3=80=82=20finish=20#63?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../chanjar/weixin/common/api/WxConsts.java   | 26 ++++++++++
     .../weixin/mp/bean/WxMpXmlMessage.java        | 48 +++++++++++++++++++
     2 files changed, 74 insertions(+)
    
    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 6a1e4380..b3122863 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
    @@ -63,6 +63,7 @@ public class WxConsts {
        * 群发反馈消息代码所对应的文字描述
        */
       public static final Map MASS_ST_2_DESC = new HashMap<>();
    +
       ///////////////////////
       // 微信端推送过来的事件类型
       ///////////////////////
    @@ -94,6 +95,31 @@ public class WxConsts {
       public static final String EVT_KF_CLOSE_SESSION = "kf_close_session"; // 客服关闭会话
       public static final String EVT_KF_SWITCH_SESSION = "kf_switch_session"; // 客服转接会话
       public static final String EVT_POI_CHECK_NOTIFY = "poi_check_notify"; //门店审核事件推送
    +  //以下为微信认证事件
    +  /**
    +   * 资质认证成功
    +   */
    +  public static final String EVT_QUALIFICATION_VERIFY_SUCCESS = "qualification_verify_success";
    +  /**
    +   * 资质认证失败
    +   */
    +  public static final String EVT_QUALIFICATION_VERIFY_FAIL = "qualification_verify_fail";
    +  /**
    +   * 名称认证成功
    +   */
    +  public static final String EVT_NAMING_VERIFY_SUCCESS = "naming_verify_success";
    +  /**
    +   * 名称认证失败
    +   */
    +  public static final String EVT_NAMING_VERIFY_FAIL = "naming_verify_fail";
    +  /**
    +   * 年审通知
    +   */
    +  public static final String EVT_ANNUAL_RENEW = "annual_renew";
    +  /**
    +   * 认证过期失效通知
    +   */
    +  public static final String EVT_VERIFY_EXPIRED = "verify_expired";
     
       ///////////////////////
       // 上传多媒体文件的类型
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
    index b938ceb0..864b0d98 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlMessage.java
    @@ -239,6 +239,54 @@ public class WxMpXmlMessage implements Serializable {
       @XStreamAlias("msg")
       private String msg;
     
    +  ///////////////////////////////////////
    +  // 微信认证事件推送
    +  ///////////////////////////////////////
    +  /**
    +   * ExpiredTime
    +   * 资质认证成功/名称认证成功: 有效期 (整形),指的是时间戳,将于该时间戳认证过期
    +   * 年审通知: 有效期 (整形),指的是时间戳,将于该时间戳认证过期,需尽快年审
    +   * 认证过期失效通知: 有效期 (整形),指的是时间戳,表示已于该时间戳认证过期,需要重新发起微信认证
    +   */
    +  @XStreamAlias("ExpiredTime")
    +  private Long expiredTime;
    +  /**
    +   * FailTime
    +   * 失败发生时间 (整形),时间戳
    +   */
    +  @XStreamAlias("FailTime")
    +  private Long failTime;
    +  /**
    +   * FailReason
    +   * 认证失败的原因
    +   */
    +  @XStreamAlias("FailReason")
    +  private String failReason;
    +
    +  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 getStoreUniqId() {
         return this.storeUniqId;
       }
    
    From f0192cc0169e152e51e6f7699e955d0d0590e8ec Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Wed, 19 Oct 2016 20:28:47 +0800
    Subject: [PATCH 60/76] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=9F=A5=E8=AF=A2?=
     =?UTF-8?q?=E4=BC=81=E4=B8=9A=E4=BB=98=E6=AC=BE=E7=9A=84API=E3=80=82=20fin?=
     =?UTF-8?q?ish=20#51?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../chanjar/weixin/mp/api/WxMpPayService.java |  21 +-
     .../mp/api/impl/WxMpPayServiceImpl.java       |  25 ++
     .../mp/bean/pay/WxEntPayQueryRequest.java     | 135 ++++++++++
     .../mp/bean/pay/WxEntPayQueryResult.java      | 230 ++++++++++++++++++
     .../mp/api/impl/WxMpPayServiceImplTest.java   |   9 +
     5 files changed, 417 insertions(+), 3 deletions(-)
     create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java
     create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java
    
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java
    index bdba22ad..ffbbabd8 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java
    @@ -18,6 +18,7 @@ public interface WxMpPayService {
        * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
        * 接口地址:https://api.mch.weixin.qq.com/pay/unifiedorder
        * @throws WxErrorException
    +   * @param request 请求对象
        *
        */
       WxUnifiedOrderResult unifiedOrder(WxUnifiedOrderRequest request)
    @@ -26,11 +27,10 @@ public interface WxMpPayService {
       /**
        * 该接口调用“统一下单”接口,并拼装发起支付请求需要的参数
        * 详见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
    -   *
    +   * @param request 请求对象
        */
       Map getPayInfo(WxUnifiedOrderRequest request) throws WxErrorException;
     
    -
       /**
        * 该接口提供所有微信支付订单的查询,当支付通知处理异常戒丢失的情冴,商户可以通过该接口查询订单支付状态。
        * 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2
    @@ -53,6 +53,7 @@ public interface WxMpPayService {
        * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
        * 接口链接:https://api.mch.weixin.qq.com/secapi/pay/refund
        * 
    + * @param request 请求对象 * @param keyFile 证书文件对象 * @return 退款操作结果 */ @@ -74,6 +75,7 @@ public interface WxMpPayService { * 发送普通红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3 * 发送裂变红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4 *
    + * @param request 请求对象 * @param keyFile 证书文件对象 */ WxRedpackResult sendRedpack(WxSendRedpackRequest request, File keyFile) throws WxErrorException; @@ -86,9 +88,22 @@ public interface WxMpPayService { * 注意:与商户微信支付收款资金并非同一账户,需要单独充值。 * 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2 * 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers - * @param keyFile 证书文件对象 *
    + * @param request 请求对象 + * @param keyFile 证书文件对象 */ WxEntPayResult entPay(WxEntPayRequest request, File keyFile) throws WxErrorException; + /** + *
    +   * 查询企业付款API
    +   * 用于商户的企业付款操作进行结果查询,返回付款操作详细结果。
    +   * 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3
    +   * 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo
    +   * 
    + * @param partnerTradeNo 商户订单号 + * @param keyFile 证书文件对象 + */ + WxEntPayQueryResult queryEntPay(String partnerTradeNo, File keyFile) throws WxErrorException; + } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java index fa1a44c5..6da1001e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java @@ -369,6 +369,31 @@ public class WxMpPayServiceImpl implements WxMpPayService { return result; } + @Override + public WxEntPayQueryResult queryEntPay(String partnerTradeNo, File keyFile) throws WxErrorException { + XStream xstream = XStreamInitializer.getInstance(); + xstream.processAnnotations(WxEntPayQueryRequest.class); + xstream.processAnnotations(WxEntPayQueryResult.class); + + WxEntPayQueryRequest request = new WxEntPayQueryRequest(); + request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId()); + request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId()); + request.setNonceStr(System.currentTimeMillis() + ""); + + String sign = this.createSign(xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey()); + request.setSign(sign); + + String url = PAY_BASE_URL + "/mmpaymkttransfers/gettransferinfo"; + + String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), request.getMchId()); + WxEntPayQueryResult result = (WxEntPayQueryResult) xstream.fromXML(responseContent); + if ("FAIL".equals(result.getResultCode())) { + throw new WxErrorException( + WxError.newBuilder().setErrorMsg(result.getErrCode() + ":" + result.getErrCodeDes()).build()); + } + return result; + } + private String executeRequestWithKeyFile( String url, File keyFile, String requestStr, String mchId) throws WxErrorException { try (FileInputStream inputStream = new FileInputStream(keyFile)) { KeyStore keyStore = KeyStore.getInstance("PKCS12"); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java new file mode 100644 index 00000000..c1f540a4 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java @@ -0,0 +1,135 @@ +package me.chanjar.weixin.mp.bean.pay; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import me.chanjar.weixin.common.annotation.Required; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + *
    + * 企业付款请求对象
    + * 注释中各行每个字段描述对应如下:
    + * 
  • 字段名 + *
  • 变量名 + *
  • 是否必填 + *
  • 类型 + *
  • 示例值 + *
  • 描述 + *
  • + * Created by Binary Wang on 2016/10/19. + * @author binarywang (https://github.com/binarywang) + */ +@XStreamAlias("xml") +public class WxEntPayQueryRequest { + /** + *
    +   * Appid
    +   * appid
    +   * 是
    +   * wxe062425f740d30d8
    +   * String(32)
    +   * 商户号的appid
    +   * 
    + */ + @XStreamAlias("appid") + private String appid; + + /** + *
    +   * 商户号
    +   * mch_id
    +   * 是
    +   * 10000098
    +   * String(32)
    +   * 微信支付分配的商户号
    +   * 
    + */ + @XStreamAlias("mchid") + private String mchId; + + /** + *
    +   * 随机字符串
    +   * nonce_str
    +   * 是
    +   * 5K8264ILTKCH16CQ2502SI8ZNMTM67VS
    +   * String(32)
    +   * 随机字符串,不长于32位
    +   * 
    + */ + @XStreamAlias("nonce_str") + private String nonceStr; + + /** + *
    +  * 签名
    +  * sign
    +  * 是
    +  * C380BEC2BFD727A4B6845133519F3AD6
    +  * String(32)
    +  *签名,详见签名算法
    +   * 
    + */ + @XStreamAlias("sign") + private String sign; + + /** + *
    +  * 商户订单号
    +  * partner_trade_no
    +  * 是
    +  * 10000098201411111234567890
    +  * String
    +  * 商户订单号
    +   * 
    + */ + @Required + @XStreamAlias("partner_trade_no") + private String partnerTradeNo; + + 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 getNonceStr() { + return nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public String getPartnerTradeNo() { + return partnerTradeNo; + } + + public void setPartnerTradeNo(String partnerTradeNo) { + this.partnerTradeNo = partnerTradeNo; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java new file mode 100644 index 00000000..55659ca4 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java @@ -0,0 +1,230 @@ +package me.chanjar.weixin.mp.bean.pay; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 企业付款查询返回结果 + * Created by Binary Wang on 2016/10/19. + * @author binarywang (https://github.com/binarywang) + */ +@XStreamAlias("xml") +public class WxEntPayQueryResult { + + /** + * 返回状态码 + */ + @XStreamAlias("return_code") + private String returnCode; + + /** + * 返回信息 + */ + @XStreamAlias("return_msg") + private String returnMsg; + + //############以下字段在return_code为SUCCESS的时候有返回 + /** + * 业务结果 + */ + @XStreamAlias("result_code") + private String resultCode; + /** + * 错误代码 + */ + @XStreamAlias("err_code") + private String errCode; + + /** + * 错误代码描述 + */ + @XStreamAlias("err_code_des") + private String errCodeDes; + + //############以下字段在return_code 和result_code都为SUCCESS的时候有返回############## + /** + * 商户订单号 + */ + @XStreamAlias("partner_trade_no") + private String partnerTradeNo; + + /** + * 商户号 + */ + @XStreamAlias("mchid") + private String mchId; + + /** + * 付款单号 + */ + @XStreamAlias("detail_id") + private String detailId; + + /** + * 转账状态 + */ + @XStreamAlias("status") + private String status; + + /** + * 失败原因 + */ + @XStreamAlias("reason") + private String reason; + + /** + * 收款用户openid + */ + @XStreamAlias("openid") + private String openid; + + /** + * 收款用户姓名 + */ + @XStreamAlias("transfer_name") + private String transferName; + + /** + * 付款金额 + */ + @XStreamAlias("payment_amount") + private Integer paymentAmount; + + /** + * 转账时间 + */ + @XStreamAlias("transfer_time") + private String transferTime; + + /** + * 付款描述 + */ + @XStreamAlias("desc") + private String desc; + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } + + 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 getPartnerTradeNo() { + return partnerTradeNo; + } + + public void setPartnerTradeNo(String partnerTradeNo) { + this.partnerTradeNo = partnerTradeNo; + } + + public String getMchId() { + return mchId; + } + + public void setMchId(String mchId) { + this.mchId = mchId; + } + + 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 getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public String getOpenid() { + return openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + + public String getTransferName() { + return transferName; + } + + public void setTransferName(String transferName) { + this.transferName = transferName; + } + + public Integer getPaymentAmount() { + return paymentAmount; + } + + public void setPaymentAmount(Integer paymentAmount) { + this.paymentAmount = paymentAmount; + } + + public String getTransferTime() { + return transferTime; + } + + public void setTransferTime(String transferTime) { + this.transferTime = transferTime; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java index 6d0b8a5c..17cf5eec 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java @@ -91,4 +91,13 @@ public class WxMpPayServiceImplTest { System.err.println(this.wxService.getPayService().entPay(request, keyFile)); } + /** + * Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#queryEntPay(String, File)}. + * @throws WxErrorException + */ + @Test + public final void testQueryEntPay() throws WxErrorException { + File keyFile = new File("E:\\dlt.p12"); + System.err.println(this.wxService.getPayService().queryEntPay("11212121", keyFile)); + } } From 81b7a2cbcfb3136a47811180359a6091629b49b5 Mon Sep 17 00:00:00 2001 From: HaiJun Liu Date: Thu, 20 Oct 2016 15:18:23 +0800 Subject: [PATCH 61/76] Fix issue #62 : add osgi support --- pom.xml | 4 +- weixin-java-osgi/pom.xml | 141 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 weixin-java-osgi/pom.xml diff --git a/pom.xml b/pom.xml index 804f3540..390c8cc7 100644 --- a/pom.xml +++ b/pom.xml @@ -39,6 +39,7 @@ weixin-java-common weixin-java-cp weixin-java-mp + weixin-java-osgi @@ -106,7 +107,7 @@ redis.clients jedis ${jedis.version} - provided + true com.google.guava @@ -295,5 +296,4 @@ - diff --git a/weixin-java-osgi/pom.xml b/weixin-java-osgi/pom.xml new file mode 100644 index 00000000..381ec5f9 --- /dev/null +++ b/weixin-java-osgi/pom.xml @@ -0,0 +1,141 @@ + + + 4.0.0 + + com.github.binarywang + weixin-java-parent + 2.3.0-SNAPSHOT + + + weixin-java-osgi + bundle + WeiXin Java Tools - OSGI + 微信公众号Java SDK OSGI + + + + org.jodd + jodd-bean + ${jodd-http.version} + + + org.apache.servicemix.bundles + org.apache.servicemix.bundles.xmlpull + 1.1.3.1_2 + + + org.apache.servicemix.bundles + org.apache.servicemix.bundles.xpp3 + 1.1.4c_7 + + + com.thoughtworks.xstream + xstream + 1.4.7 + provided + + + xmlpull + xmlpull + + + xpp3 + xpp3_min + + + + + org.apache.httpcomponents + httpcore + 4.4.1 + provided + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + provided + + + org.apache.httpcomponents + httpmime + ${httpclient.version} + provided + + + com.github.binarywang + weixin-java-common + ${project.version} + provided + + + com.github.binarywang + weixin-java-cp + ${project.version} + provided + + + com.github.binarywang + weixin-java-mp + ${project.version} + provided + + + + + + + org.apache.felix + maven-bundle-plugin + 3.2.0 + true + + + + weixin-java-common;inline=true + ,weixin-java-cp;inline=true + ,weixin-java-mp;inline=true + ,httpcore;inline=true + ,httpclient;inline=true + ,httpmime;inline=true + ,xstream;inline=true + + me.chanjar.weixin.* + + !org.apache.commons.logging + ,com.bea.xml.stream;resolution:=optional + ,com.ctc.wstx.stax;resolution:=optional + ,javax.xml.namespace;resolution:=optional + ,javax.xml.stream;resolution:=optional, + ,net.sf.cglib.proxy;resolution:=optional + ,nu.xom;resolution:=optional + ,org.codehaus.jettison;version="[1.2,2)";resolution:=optional + ,org.codehaus.jettison.mapped;version="[1.2,2)";resolution:=optional + ,org.dom4j;resolution:=optional + ,org.dom4j.io;resolution:=optional + ,org.dom4j.tree;resolution:=op + tional,org.jdom;resolution:=optional + ,org.jdom.input;resolution:=optional + ,org.jdom2;resolution:=optional + ,org.jdom2.input;resolution:=optional + ,org.joda.time;version="[1.6,2)";resolution:=optional + ,org.joda.time.format;version="[1.6,2)";resolution:=optional + ,org.kxml2.io;resolution:=optional + ,org.w3c.dom;resolution:=optional + ,* + + + + + org.apache.felix + org.apache.felix.dependencymanager.annotation + 4.1.0 + + + + + + + From 9ee6d257d8805815b8d8f0829d2216c1a716a187 Mon Sep 17 00:00:00 2001 From: HaiJun Liu Date: Thu, 20 Oct 2016 15:22:03 +0800 Subject: [PATCH 62/76] ignore temp files on mac os --- .gitignore | 77 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index dd377af1..a2b51e4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,28 +1,49 @@ -*.class -test-output - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -target -bin -.project -.classpath -.settings - -sw-pom.xml -*.iml -test-config.xml -.idea -/.gradle/ -/gradle/ -*.bat -/gradlew +*.class +test-output + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +target +bin +.project +.classpath +.settings + +sw-pom.xml +*.iml +test-config.xml +.idea +/.gradle/ +/gradle/ +*.bat +/gradlew + +# OSX +# Icon must end with two \r +Icon + + +._* +.DS_Store +.AppleDouble +.LSOverride +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk From 4477e44de8bcb8eb88f9a2a70228e5ffaa1ca0f3 Mon Sep 17 00:00:00 2001 From: HaiJun Liu Date: Thu, 20 Oct 2016 15:38:03 +0800 Subject: [PATCH 63/76] =?UTF-8?q?=E6=A0=B9=E6=8D=AEjavabean=E8=A7=84?= =?UTF-8?q?=E8=8C=83=EF=BC=8C=E4=BF=9D=E7=95=99=E4=B8=80=E4=B8=AAget?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BB=A5=E4=BE=BF=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=8F=8D=E5=B0=84=E7=9A=84=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/chanjar/weixin/mp/bean/result/WxMpUser.java | 4 ---- 1 file changed, 4 deletions(-) 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 b885ea4c..e3e894cb 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 @@ -41,10 +41,6 @@ public class WxMpUser implements Serializable { return this.subscribe; } - public Boolean isSubscribe() { - return this.subscribe; - } - public void setSubscribe(Boolean subscribe) { this.subscribe = subscribe; } From 5885ce826eb28b47dc134e6cccbaf3d3d70e366f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Binary=EF=BC=88=E7=8F=AD=E7=BA=B3=E7=9D=BF=EF=BC=89?= Date: Fri, 21 Oct 2016 12:31:12 +0800 Subject: [PATCH 64/76] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c1cee44..07040c52 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,11 @@ =========== ## 开发交流方式: -1. ***入群须知:为保证入群成员质量,请申请入群前,先Star本项目,然后在申请入群时,输入您的Github帐号ID,以便管理员核对,ID即你的github主页地址https://github.com/XXXX 中最后的部分XXXX的内容,或者在github网页右上角点击头像后查看Signed in as后方内容。*** +1. ***QQ群入群须知:为保证入群成员质量,请申请入群前,先Star本项目,然后在申请入群时,输入您的Github帐号ID,以便管理员核对,ID即你的github主页地址https://github.com/XXXX 中最后的部分XXXX的内容,或者在github网页右上角点击头像后查看Signed in as后方内容。*** +1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB +1. 寻求帮助时需贴代码或大长串异常信息的,请利用http://paste.ubuntu.com 1. QQ群:343954419 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=078f7a153d243853e24cf2b542e7a6ccbf2a592bc138080f84d11297f736ec46) -1. 微信群: 因二维码有时间限制,如有想加入微信群的,请入QQ群后咨询获取最新入群二维码; +1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入; 1. 有功能需求或由于微信官方接口调整导致的代码问题,可以直接提出issue,便于讨论追踪问题; 1. 详细开发文档请看 [Wiki](https://github.com/wechat-group/weixin-java-tools/wiki)。 From 4b88c3d426361b3069d86924c4d20b3bc728cc84 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 21 Oct 2016 15:23:23 +0800 Subject: [PATCH 65/76] =?UTF-8?q?=E5=8E=BB=E6=8E=89joor=E7=9A=84=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=EF=BC=8C=E5=B9=B6=E9=87=8D=E6=9E=84=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=8F=8D=E5=B0=84=E4=BB=A3=E7=A0=81=20for=20#58?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 --- .../chanjar/weixin/common/util/BeanUtils.java | 82 +++++++++++++++++++ .../mp/api/impl/WxMpPayServiceImpl.java | 72 +++------------- .../mp/api/impl/WxMpStoreServiceImpl.java | 30 +------ .../mp/api/impl/WxMpStoreServiceImplTest.java | 1 + .../mp/bean/pay/WxSendRedpackRequestTest.java | 33 -------- 6 files changed, 96 insertions(+), 132 deletions(-) create mode 100644 weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java delete mode 100644 weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/pay/WxSendRedpackRequestTest.java diff --git a/pom.xml b/pom.xml index 390c8cc7..81e4412e 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,6 @@ 2.9.0 2.7 19.0 - 0.9.6 3.4 2.5 1.10 @@ -113,10 +112,6 @@ com.google.guava guava - - org.jooq - joor - @@ -162,11 +157,6 @@ guava ${guava.version} - - org.jooq - joor - ${joor.version} - 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 new file mode 100644 index 00000000..c73f1600 --- /dev/null +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java @@ -0,0 +1,82 @@ +package me.chanjar.weixin.common.util; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import me.chanjar.weixin.common.annotation.Required; +import me.chanjar.weixin.common.bean.result.WxError; +import me.chanjar.weixin.common.exception.WxErrorException; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +/** + *
    + * bean操作的一些工具类
    + * Created by Binary Wang on 2016-10-21.
    + * @author binarywang(Binary Wang)
    + * 
    + */ +public class BeanUtils { + + /** + * 检查bean里标记为@Required的field是否为空,为空则抛异常 + * @param bean 要检查的bean对象 + * @throws WxErrorException + */ + public static void checkRequiredFields(Object bean) throws WxErrorException { + List nullFields = Lists.newArrayList(); + + for (Field field : bean.getClass().getDeclaredFields()) { + try { + boolean isAccessible = field.isAccessible(); + field.setAccessible(true); + if (field.isAnnotationPresent(Required.class) + && field.get(bean) == null) { + nullFields.add(field.getName()); + } + field.setAccessible(isAccessible); + } catch (SecurityException | IllegalArgumentException + | IllegalAccessException e) { + e.printStackTrace(); + } + } + + if (!nullFields.isEmpty()) { + throw new WxErrorException(WxError.newBuilder().setErrorMsg("必填字段 " + nullFields + " 必须提供值").build()); + } + } + + /** + * 将bean按照@XStreamAlias标识的字符串内容生成以之为key的map对象 + * @param bean 包含@XStreamAlias的xml bean对象 + * @return map对象 + */ + public static Map xmlBean2Map(Object bean) { + Map result = Maps.newHashMap(); + for (Field field : bean.getClass().getDeclaredFields()) { + try { + boolean isAccessible = field.isAccessible(); + field.setAccessible(true); + if (field.get(bean) == null) { + field.setAccessible(isAccessible); + continue; + } + + if (field.isAnnotationPresent(XStreamAlias.class)) { + result.put(field.getAnnotation(XStreamAlias.class).value(), + field.get(bean).toString()); + } + + field.setAccessible(isAccessible); + } catch (SecurityException | IllegalArgumentException + | IllegalAccessException e) { + e.printStackTrace(); + } + + } + + return result; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java index 6da1001e..9745e22c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java @@ -1,12 +1,9 @@ package me.chanjar.weixin.mp.api.impl; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.annotations.XStreamAlias; -import me.chanjar.weixin.common.annotation.Required; import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.common.util.BeanUtils; import me.chanjar.weixin.common.util.xml.XStreamInitializer; import me.chanjar.weixin.mp.api.WxMpPayService; import me.chanjar.weixin.mp.api.WxMpService; @@ -23,15 +20,12 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; -import org.joor.Reflect; import javax.net.ssl.SSLContext; import java.io.File; import java.io.FileInputStream; -import java.lang.reflect.Field; import java.security.KeyStore; import java.util.*; -import java.util.Map.Entry; /** * Created by Binary Wang on 2016/7/28. @@ -116,7 +110,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { request.setMchId(partnerId); request.setNonceStr( System.currentTimeMillis() + ""); request.setOpUserId(partnerId); - String sign = this.createSign(this.xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey()); + String sign = this.createSign(BeanUtils.xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey()); request.setSign(sign); String url = PAY_BASE_URL + "/secapi/pay/refund"; @@ -138,8 +132,8 @@ public class WxMpPayServiceImpl implements WxMpPayService { return wxMpPayRefundResult; } - private void checkParameters(WxMpPayRefundRequest request) { - checkNotNullParams(request); + private void checkParameters(WxMpPayRefundRequest request) throws WxErrorException { + BeanUtils.checkRequiredFields(request); if (StringUtils.isNotBlank(request.getRefundAccount())) { if(!ArrayUtils.contains(REFUND_ACCOUNT, request.getRefundAccount())){ @@ -171,7 +165,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { request.setMchId(mchId); request.setNonceStr(System.currentTimeMillis() + ""); - String sign = this.createSign(this.xmlBean2Map(request), + String sign = this.createSign(BeanUtils.xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey()); request.setSign(sign); @@ -194,29 +188,6 @@ public class WxMpPayServiceImpl implements WxMpPayService { return redpackResult; } - private Map xmlBean2Map(Object bean) { - Map result = Maps.newHashMap(); - for (Entry entry : Reflect.on(bean).fields().entrySet()) { - Reflect reflect = entry.getValue(); - if (reflect.get() == null) { - continue; - } - - try { - Field field = bean.getClass().getDeclaredField(entry.getKey()); - if (field.isAnnotationPresent(XStreamAlias.class)) { - result.put(field.getAnnotation(XStreamAlias.class).value(), - reflect.get().toString()); - } - } catch (NoSuchFieldException | SecurityException e) { - e.printStackTrace(); - } - - } - - return result; - } - /** * 微信公众号支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3) * @param packageParams 原始参数 @@ -253,7 +224,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId()); request.setNonceStr(System.currentTimeMillis() + ""); - String sign = this.createSign(this.xmlBean2Map(request), + String sign = this.createSign(BeanUtils.xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey()); request.setSign(sign); @@ -271,8 +242,8 @@ public class WxMpPayServiceImpl implements WxMpPayService { return result; } - private void checkParameters(WxUnifiedOrderRequest request) { - checkNotNullParams(request); + private void checkParameters(WxUnifiedOrderRequest request) throws WxErrorException { + BeanUtils.checkRequiredFields(request); if (! ArrayUtils.contains(TRADE_TYPES, request.getTradeType())) { throw new IllegalArgumentException("trade_type目前必须为" + Arrays.toString(TRADE_TYPES) + "其中之一"); @@ -287,27 +258,6 @@ public class WxMpPayServiceImpl implements WxMpPayService { } } - private void checkNotNullParams(Object request) { - List nullFields = Lists.newArrayList(); - for (Entry entry : Reflect.on(request).fields() - .entrySet()) { - Reflect reflect = entry.getValue(); - try { - Field field = request.getClass().getDeclaredField(entry.getKey()); - if (field.isAnnotationPresent(Required.class) - && reflect.get() == null) { - nullFields.add(entry.getKey()); - } - } catch (NoSuchFieldException | SecurityException e) { - e.printStackTrace(); - } - } - - if (!nullFields.isEmpty()) { - throw new IllegalArgumentException("必填字段[" + nullFields + "]必须提供值"); - } - } - @Override public Map getPayInfo(WxUnifiedOrderRequest request) throws WxErrorException { WxUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request); @@ -345,7 +295,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { @Override public WxEntPayResult entPay(WxEntPayRequest request, File keyFile) throws WxErrorException { - checkNotNullParams(request); + BeanUtils.checkRequiredFields(request); XStream xstream = XStreamInitializer.getInstance(); xstream.processAnnotations(WxEntPayRequest.class); @@ -355,7 +305,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId()); request.setNonceStr(System.currentTimeMillis() + ""); - String sign = this.createSign(xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey()); + String sign = this.createSign(BeanUtils.xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey()); request.setSign(sign); String url = PAY_BASE_URL + "/mmpaymkttransfers/promotion/transfers"; @@ -380,7 +330,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId()); request.setNonceStr(System.currentTimeMillis() + ""); - String sign = this.createSign(xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey()); + String sign = this.createSign(BeanUtils.xmlBean2Map(request), this.wxMpService.getWxMpConfigStorage().getPartnerKey()); request.setSign(sign); String url = PAY_BASE_URL + "/mmpaymkttransfers/gettransferinfo"; 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 39c7f729..e1984204 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 @@ -1,23 +1,19 @@ package me.chanjar.weixin.mp.api.impl; -import com.google.common.collect.Lists; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; -import me.chanjar.weixin.common.annotation.Required; import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.common.util.BeanUtils; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpStoreService; import me.chanjar.weixin.mp.bean.store.WxMpStoreBaseInfo; import me.chanjar.weixin.mp.bean.store.WxMpStoreInfo; import me.chanjar.weixin.mp.bean.store.WxMpStoreListResult; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; -import org.joor.Reflect; -import java.lang.reflect.Field; import java.util.List; -import java.util.Map.Entry; /** * Created by Binary Wang on 2016/9/26. @@ -35,7 +31,7 @@ public class WxMpStoreServiceImpl implements WxMpStoreService { @Override public void add(WxMpStoreBaseInfo request) throws WxErrorException { - checkParameters(request); + BeanUtils.checkRequiredFields(request); String url = API_BASE_URL + "/addpoi"; String response = this.wxMpService.post(url, request.toJson()); @@ -71,28 +67,6 @@ public class WxMpStoreServiceImpl implements WxMpStoreService { } } - private void checkParameters(WxMpStoreBaseInfo request) { - List nullFields = Lists.newArrayList(); - for (Entry entry : Reflect.on(request).fields() - .entrySet()) { - Reflect reflect = entry.getValue(); - try { - Field field = request.getClass().getDeclaredField(entry.getKey()); - if (field.isAnnotationPresent(Required.class) - && reflect.get() == null) { - nullFields.add(entry.getKey()); - } - } catch (NoSuchFieldException | SecurityException e) { - e.printStackTrace(); - } - } - - if (!nullFields.isEmpty()) { - throw new IllegalArgumentException("必填字段[" + nullFields + "]必须提供值"); - } - - } - @Override public WxMpStoreListResult list(int begin, int limit) throws WxErrorException { 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 6e31b769..e610204b 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,6 +30,7 @@ public class WxMpStoreServiceImplTest { * @throws WxErrorException */ 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[] { "美食,江浙菜" }) diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/pay/WxSendRedpackRequestTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/pay/WxSendRedpackRequestTest.java deleted file mode 100644 index feb50c5a..00000000 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/pay/WxSendRedpackRequestTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.chanjar.weixin.mp.bean.pay; - -import java.lang.reflect.Field; -import java.util.Map.Entry; - -import org.joor.Reflect; -import org.testng.annotations.Test; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -@Test -public class WxSendRedpackRequestTest { - - public void test() throws NoSuchFieldException, SecurityException { - - WxSendRedpackRequest request = new WxSendRedpackRequest(); - request.setMchBillno("123"); - request.setActName("ab"); - for (Entry entry : Reflect.on(request).fields().entrySet()) { - Reflect reflect = entry.getValue(); - if (reflect.get() == null) { - continue; - } - - Field field = WxSendRedpackRequest.class.getDeclaredField(entry.getKey()); - if (field.isAnnotationPresent(XStreamAlias.class)) { - System.err.println(reflect.get() + " = " + field.getAnnotation(XStreamAlias.class).value()); - } - } - - } - -} From 3448eda65ec5fd0c0a89051cf709297e4b6a4a62 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 21 Oct 2016 15:24:27 +0800 Subject: [PATCH 66/76] =?UTF-8?q?gradle=E9=85=8D=E7=BD=AE=E9=87=8C=20?= =?UTF-8?q?=E5=8E=BB=E6=8E=89joor=E7=9A=84=E4=BE=9D=E8=B5=96=20for=20#58?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index ba12afc4..defc5a25 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,6 @@ subprojects { compile group: 'org.jodd', name: 'jodd-http', version:'3.6.7' compile group: 'com.google.code.gson', name: 'gson', version:'2.7' compile group: 'com.google.guava', name: 'guava', version:'19.0' - compile group: 'org.jooq', name: 'joor', version:'0.9.6' compile group: 'commons-codec', name: 'commons-codec', version:'1.10' compile group: 'commons-io', name: 'commons-io', version:'2.5' compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.4' From 6757af8429cd3bf045300667ee30bbc40bc83178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Binary=EF=BC=88=E7=8F=AD=E7=BA=B3=E7=9D=BF=EF=BC=89?= Date: Sun, 23 Oct 2016 16:07:14 +0800 Subject: [PATCH 67/76] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 07040c52..0c8848a2 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,11 @@ =========== -## 开发交流方式: -1. ***QQ群入群须知:为保证入群成员质量,请申请入群前,先Star本项目,然后在申请入群时,输入您的Github帐号ID,以便管理员核对,ID即你的github主页地址https://github.com/XXXX 中最后的部分XXXX的内容,或者在github网页右上角点击头像后查看Signed in as后方内容。*** -1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB -1. 寻求帮助时需贴代码或大长串异常信息的,请利用http://paste.ubuntu.com +## 开发交流方式及注意事项: 1. QQ群:343954419 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=078f7a153d243853e24cf2b542e7a6ccbf2a592bc138080f84d11297f736ec46) 1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入; +1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB +1. 寻求帮助时需贴代码或大长串异常信息的,请利用http://paste.ubuntu.com 1. 有功能需求或由于微信官方接口调整导致的代码问题,可以直接提出issue,便于讨论追踪问题; 1. 详细开发文档请看 [Wiki](https://github.com/wechat-group/weixin-java-tools/wiki)。 From 773c764872b426bb01e96e04685f20dd744c79ce Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Mon, 24 Oct 2016 11:52:16 +0800 Subject: [PATCH 68/76] =?UTF-8?q?=E5=8D=87=E7=BA=A7commons-lang3=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 81e4412e..2724dfcc 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,7 @@ 2.9.0 2.7 19.0 - 3.4 + 3.5 2.5 1.10 9.3.0.M0 From dff627b32743323be1a7cffa8ebae348754d166c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Binary=EF=BC=88=E7=8F=AD=E7=BA=B3=E7=9D=BF=EF=BC=89?= Date: Mon, 24 Oct 2016 15:28:37 +0800 Subject: [PATCH 69/76] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0c8848a2..96b2bcd8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Weixin Java Tools 微信公众号/企业号开发Java SDK -## [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badge/) ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) [![Build Status](https://travis-ci.org/wechat-group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/wechat-group/weixin-java-tools) +## ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) [![Build Status](https://travis-ci.org/wechat-group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/wechat-group/weixin-java-tools) [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK) ### 注意: @@ -11,12 +11,12 @@ =========== ## 开发交流方式及注意事项: -1. QQ群:343954419 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=078f7a153d243853e24cf2b542e7a6ccbf2a592bc138080f84d11297f736ec46) +1. QQ群:343954419(因群人数限制即将爆满,故开启付费加群方式并不定期清理不活跃人群,感谢理解) [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK) 1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入; 1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB 1. 寻求帮助时需贴代码或大长串异常信息的,请利用http://paste.ubuntu.com 1. 有功能需求或由于微信官方接口调整导致的代码问题,可以直接提出issue,便于讨论追踪问题; -1. 详细开发文档请看 [Wiki](https://github.com/wechat-group/weixin-java-tools/wiki)。 +1. 详细开发文档请看 [Wiki](https://github.com/wechat-group/weixin-java-tools/wiki),部分文档可能未能及时更新,如有发现,可以及时上报或者自行修改。 =========== From e30138f931dfdcdcb9dca78b4132036caf75ab0e Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 25 Oct 2016 10:27:29 +0800 Subject: [PATCH 70/76] =?UTF-8?q?#53=20=E5=AE=9E=E7=8E=B0=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=94=AF=E4=BB=98=E6=9F=A5=E8=AF=A2=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=B9=B6=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=8C=96=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E7=B1=BB=E7=9A=84=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/mp/api/WxMpPayService.java | 37 +- .../mp/api/impl/WxMpPayServiceImpl.java | 114 +++-- .../mp/bean/pay/WxEntPayQueryRequest.java | 41 +- .../mp/bean/pay/WxEntPayQueryResult.java | 77 +-- .../weixin/mp/bean/pay/WxEntPayResult.java | 109 +---- .../weixin/mp/bean/pay/WxMpPayResult.java | 259 ---------- .../weixin/mp/bean/pay/WxPayBaseRequest.java | 107 +++++ ...dOrderResult.java => WxPayBaseResult.java} | 162 +++---- ...yCallback.java => WxPayJsSDKCallback.java} | 8 +- .../mp/bean/pay/WxPayOrderQueryRequest.java | 63 +++ .../mp/bean/pay/WxPayOrderQueryResult.java | 444 ++++++++++++++++++ ...ndRequest.java => WxPayRefundRequest.java} | 2 +- ...fundResult.java => WxPayRefundResult.java} | 92 +--- ...uest.java => WxPaySendRedpackRequest.java} | 10 +- .../mp/bean/pay/WxPaySendRedpackResult.java | 82 ++++ ...est.java => WxPayUnifiedOrderRequest.java} | 69 +-- .../mp/bean/pay/WxPayUnifiedOrderResult.java | 48 ++ .../weixin/mp/bean/pay/WxRedpackResult.java | 105 ----- .../mp/api/impl/WxMpPayServiceImplTest.java | 30 +- .../weixin/mp/bean/WxRedpackResultTest.java | 60 +-- 20 files changed, 964 insertions(+), 955 deletions(-) delete mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayResult.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseRequest.java rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{WxUnifiedOrderResult.java => WxPayBaseResult.java} (61%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{WxMpPayCallback.java => WxPayJsSDKCallback.java} (97%) create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryRequest.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryResult.java rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{WxMpPayRefundRequest.java => WxPayRefundRequest.java} (99%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{WxMpPayRefundResult.java => WxPayRefundResult.java} (68%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{WxSendRedpackRequest.java => WxPaySendRedpackRequest.java} (96%) create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackResult.java rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{WxUnifiedOrderRequest.java => WxPayUnifiedOrderRequest.java} (91%) create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderResult.java delete mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java index ffbbabd8..a1dabfa0 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java @@ -13,6 +13,23 @@ import java.util.Map; */ public interface WxMpPayService { + /** + *
    +   * 查询订单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2)
    +   * 该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。
    +   * 需要调用查询接口的情况:
    +   ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
    +   ◆ 调用支付接口后,返回系统错误或未知交易状态情况;
    +   ◆ 调用被扫支付API,返回USERPAYING的状态;
    +   ◆ 调用关单或撤销接口API之前,需确认支付状态;
    +   * 接口地址:https://api.mch.weixin.qq.com/pay/orderquery
    +   * 
    + * @param transactionId 微信支付分配的商户号 + * @param outTradeNo 商户系统内部的订单号,当没提供transaction_id时需要传这个。 + * @throws WxErrorException + */ + WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) throws WxErrorException; + /** * 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1) * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识" @@ -21,31 +38,21 @@ public interface WxMpPayService { * @param request 请求对象 * */ - WxUnifiedOrderResult unifiedOrder(WxUnifiedOrderRequest request) - throws WxErrorException; + WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) throws WxErrorException; /** * 该接口调用“统一下单”接口,并拼装发起支付请求需要的参数 * 详见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN * @param request 请求对象 */ - Map getPayInfo(WxUnifiedOrderRequest request) throws WxErrorException; - - /** - * 该接口提供所有微信支付订单的查询,当支付通知处理异常戒丢失的情冴,商户可以通过该接口查询订单支付状态。 - * 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2 - * @throws WxErrorException - * - */ - WxMpPayResult getJSSDKPayResult(String transactionId, String outTradeNo) - throws WxErrorException; + Map getPayInfo(WxPayUnifiedOrderRequest request) throws WxErrorException; /** * 读取支付结果通知 * 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7 * */ - WxMpPayCallback getJSSDKCallbackData(String xmlData); + WxPayJsSDKCallback getJSSDKCallbackData(String xmlData); /** *
    @@ -57,7 +64,7 @@ public interface WxMpPayService {
        * @param keyFile  证书文件对象
        * @return 退款操作结果
        */
    -  WxMpPayRefundResult refund(WxMpPayRefundRequest request, File keyFile) throws WxErrorException;
    +  WxPayRefundResult refund(WxPayRefundRequest request, File keyFile) throws WxErrorException;
     
       /**
        * 
    @@ -78,7 +85,7 @@ public interface WxMpPayService {
        * @param request 请求对象
        * @param keyFile  证书文件对象
        */
    -  WxRedpackResult sendRedpack(WxSendRedpackRequest request, File keyFile) throws WxErrorException;
    +  WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request, File keyFile) throws WxErrorException;
     
       /**
        * 
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    index 9745e22c..8cb737c6 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    @@ -46,64 +46,26 @@ public class WxMpPayServiceImpl implements WxMpPayService {
       }
     
       @Override
    -  public WxMpPayResult getJSSDKPayResult(String transactionId,
    -      String outTradeNo) throws WxErrorException {
    -    String nonce_str = System.currentTimeMillis() + "";
    -
    -    SortedMap packageParams = new TreeMap<>();
    -    packageParams.put("appid",
    -        this.wxMpService.getWxMpConfigStorage().getAppId());
    -    packageParams.put("mch_id",
    -        this.wxMpService.getWxMpConfigStorage().getPartnerId());
    -
    -    if (transactionId != null && !"".equals(transactionId.trim())) {
    -      packageParams.put("transaction_id", transactionId);
    -    } else if (outTradeNo != null && !"".equals(outTradeNo.trim())) {
    -      packageParams.put("out_trade_no", outTradeNo);
    -    } else {
    -      throw new IllegalArgumentException(
    -          "Either 'transactionId' or 'outTradeNo' must be given.");
    -    }
    -
    -    packageParams.put("nonce_str", nonce_str);
    -    packageParams.put("sign", this.createSign(packageParams,
    -        this.wxMpService.getWxMpConfigStorage().getPartnerKey()));
    -
    -    StringBuilder request = new StringBuilder("");
    -    for (Map.Entry para : packageParams.entrySet()) {
    -      request.append(String.format("<%s>%s", para.getKey(),
    -          para.getValue(), para.getKey()));
    -    }
    -    request.append("");
    -
    -    String url = PAY_BASE_URL + "/pay/orderquery";
    -    String responseContent = this.wxMpService.post(url, request.toString());
    -    XStream xstream = XStreamInitializer.getInstance();
    -    xstream.alias("xml", WxMpPayResult.class);
    -    return (WxMpPayResult) xstream.fromXML(responseContent);
    -  }
    -
    -  @Override
    -  public WxMpPayCallback getJSSDKCallbackData(String xmlData) {
    +  public WxPayJsSDKCallback getJSSDKCallbackData(String xmlData) {
         try {
           XStream xstream = XStreamInitializer.getInstance();
    -      xstream.alias("xml", WxMpPayCallback.class);
    -      return (WxMpPayCallback) xstream.fromXML(xmlData);
    +      xstream.alias("xml", WxPayJsSDKCallback.class);
    +      return (WxPayJsSDKCallback) xstream.fromXML(xmlData);
         } catch (Exception e) {
           e.printStackTrace();
         }
     
    -    return new WxMpPayCallback();
    +    return new WxPayJsSDKCallback();
       }
     
       @Override
    -  public WxMpPayRefundResult refund(WxMpPayRefundRequest request, File keyFile)
    +  public WxPayRefundResult refund(WxPayRefundRequest request, File keyFile)
           throws WxErrorException {
         checkParameters(request);
     
         XStream xstream = XStreamInitializer.getInstance();
    -    xstream.processAnnotations(WxMpPayRefundResult.class);
    -    xstream.processAnnotations(WxMpPayRefundRequest.class);
    +    xstream.processAnnotations(WxPayRefundResult.class);
    +    xstream.processAnnotations(WxPayRefundRequest.class);
     
         request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId());
         String partnerId = this.wxMpService.getWxMpConfigStorage().getPartnerId();
    @@ -115,7 +77,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
     
         String url = PAY_BASE_URL + "/secapi/pay/refund";
         String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), partnerId);
    -    WxMpPayRefundResult wxMpPayRefundResult = (WxMpPayRefundResult) xstream.fromXML(responseContent);
    +    WxPayRefundResult wxMpPayRefundResult = (WxPayRefundResult) xstream.fromXML(responseContent);
     
         if (!"SUCCESS".equalsIgnoreCase(wxMpPayRefundResult.getResultCode())
             || !"SUCCESS".equalsIgnoreCase(wxMpPayRefundResult.getReturnCode())) {
    @@ -132,7 +94,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         return wxMpPayRefundResult;
       }
     
    -  private void checkParameters(WxMpPayRefundRequest request) throws WxErrorException {
    +  private void checkParameters(WxPayRefundRequest request) throws WxErrorException {
         BeanUtils.checkRequiredFields(request);
     
         if (StringUtils.isNotBlank(request.getRefundAccount())) {
    @@ -154,11 +116,11 @@ public class WxMpPayServiceImpl implements WxMpPayService {
       }
     
       @Override
    -  public WxRedpackResult sendRedpack(WxSendRedpackRequest request, File keyFile)
    +  public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request, File keyFile)
           throws WxErrorException {
         XStream xstream = XStreamInitializer.getInstance();
    -    xstream.processAnnotations(WxSendRedpackRequest.class);
    -    xstream.processAnnotations(WxRedpackResult.class);
    +    xstream.processAnnotations(WxPaySendRedpackRequest.class);
    +    xstream.processAnnotations(WxPaySendRedpackResult.class);
     
         request.setWxAppid(this.wxMpService.getWxMpConfigStorage().getAppId());
         String mchId = this.wxMpService.getWxMpConfigStorage().getPartnerId();
    @@ -176,7 +138,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         }
     
         String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), mchId);
    -    WxRedpackResult redpackResult = (WxRedpackResult) xstream
    +    WxPaySendRedpackResult redpackResult = (WxPaySendRedpackResult) xstream
             .fromXML(responseContent);
         if ("FAIL".equals(redpackResult.getResultCode())) {
           throw new WxErrorException(WxError.newBuilder()
    @@ -212,13 +174,49 @@ public class WxMpPayServiceImpl implements WxMpPayService {
       }
     
       @Override
    -  public WxUnifiedOrderResult unifiedOrder(WxUnifiedOrderRequest request)
    +  public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) throws WxErrorException {
    +    if ((StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)) ||
    +      (StringUtils.isNotBlank(transactionId) && StringUtils.isNotBlank(outTradeNo))) {
    +      throw new IllegalArgumentException("transaction_id 和 out_trade_no 不能同时存在或同时为空,必须二选一");
    +    }
    +
    +    XStream xstream = XStreamInitializer.getInstance();
    +    xstream.processAnnotations(WxPayOrderQueryRequest.class);
    +    xstream.processAnnotations(WxPayOrderQueryResult.class);
    +
    +    WxPayOrderQueryRequest request = new WxPayOrderQueryRequest();
    +    request.setOutTradeNo(StringUtils.trimToNull(outTradeNo));
    +    request.setTransactionId(StringUtils.trimToNull(transactionId));
    +    request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId());
    +    request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId());
    +    request.setNonceStr(System.currentTimeMillis() + "");
    +
    +    String sign = this.createSign(BeanUtils.xmlBean2Map(request),
    +      this.wxMpService.getWxMpConfigStorage().getPartnerKey());
    +    request.setSign(sign);
    +
    +    String url = PAY_BASE_URL + "/pay/orderquery";
    +
    +    String responseContent = this.wxMpService.post(url, xstream.toXML(request));
    +    WxPayOrderQueryResult result = (WxPayOrderQueryResult) xstream.fromXML(responseContent);
    +    result.composeCoupons(responseContent);
    +    if ("FAIL".equals(result.getResultCode())) {
    +      throw new WxErrorException(WxError.newBuilder()
    +        .setErrorMsg(result.getErrCode() + ":" + result.getErrCodeDes())
    +        .build());
    +    }
    +
    +    return result;
    +  }
    +
    +  @Override
    +  public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request)
           throws WxErrorException {
         checkParameters(request);
     
         XStream xstream = XStreamInitializer.getInstance();
    -    xstream.processAnnotations(WxUnifiedOrderRequest.class);
    -    xstream.processAnnotations(WxUnifiedOrderResult.class);
    +    xstream.processAnnotations(WxPayUnifiedOrderRequest.class);
    +    xstream.processAnnotations(WxPayUnifiedOrderResult.class);
     
         request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId());
         request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId());
    @@ -231,7 +229,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         String url = PAY_BASE_URL + "/pay/unifiedorder";
     
         String responseContent = this.wxMpService.post(url, xstream.toXML(request));
    -    WxUnifiedOrderResult result = (WxUnifiedOrderResult) xstream
    +    WxPayUnifiedOrderResult result = (WxPayUnifiedOrderResult) xstream
             .fromXML(responseContent);
         if ("FAIL".equals(result.getResultCode())) {
           throw new WxErrorException(WxError.newBuilder()
    @@ -242,7 +240,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         return result;
       }
     
    -  private void checkParameters(WxUnifiedOrderRequest request) throws WxErrorException {
    +  private void checkParameters(WxPayUnifiedOrderRequest request) throws WxErrorException {
         BeanUtils.checkRequiredFields(request);
     
         if (! ArrayUtils.contains(TRADE_TYPES, request.getTradeType())) {
    @@ -259,8 +257,8 @@ public class WxMpPayServiceImpl implements WxMpPayService {
       }
     
       @Override
    -  public Map getPayInfo(WxUnifiedOrderRequest request) throws WxErrorException {
    -    WxUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request);
    +  public Map getPayInfo(WxPayUnifiedOrderRequest request) throws WxErrorException {
    +    WxPayUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request);
     
         if (!"SUCCESS".equalsIgnoreCase(unifiedOrderResult.getReturnCode())
             || !"SUCCESS".equalsIgnoreCase(unifiedOrderResult.getResultCode())) {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java
    index c1f540a4..512ac159 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java
    @@ -20,20 +20,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
      * @author binarywang (https://github.com/binarywang)
      */
     @XStreamAlias("xml")
    -public class WxEntPayQueryRequest {
    -  /**
    -   * 
    -   * Appid
    -   * appid
    -   * 是
    -   * wxe062425f740d30d8
    -   * String(32)
    -   * 商户号的appid
    -   * 
    - */ - @XStreamAlias("appid") - private String appid; - +public class WxEntPayQueryRequest extends WxPayBaseRequest { /** *
        * 商户号
    @@ -47,32 +34,6 @@ public class WxEntPayQueryRequest {
       @XStreamAlias("mchid")
       private String mchId;
     
    -  /**
    -   * 
    -   * 随机字符串
    -   * nonce_str
    -   * 是
    -   * 5K8264ILTKCH16CQ2502SI8ZNMTM67VS
    -   * String(32)
    -   * 随机字符串,不长于32位
    -   * 
    - */ - @XStreamAlias("nonce_str") - private String nonceStr; - - /** - *
    -  * 签名
    -  * sign
    -  * 是
    -  * C380BEC2BFD727A4B6845133519F3AD6
    -  * String(32)
    -  *签名,详见签名算法
    -   * 
    - */ - @XStreamAlias("sign") - private String sign; - /** *
       * 商户订单号
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java
    index 55659ca4..382a8858 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java
    @@ -1,8 +1,6 @@
     package me.chanjar.weixin.mp.bean.pay;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    -import org.apache.commons.lang3.builder.ToStringBuilder;
    -import org.apache.commons.lang3.builder.ToStringStyle;
     
     /**
      * 企业付款查询返回结果
    @@ -10,37 +8,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
      * @author binarywang (https://github.com/binarywang)
      */
     @XStreamAlias("xml")
    -public class WxEntPayQueryResult {
    -
    -  /**
    -   * 返回状态码
    -   */
    -  @XStreamAlias("return_code")
    -  private String returnCode;
    -
    -  /**
    -   * 返回信息
    -   */
    -  @XStreamAlias("return_msg")
    -  private String returnMsg;
    -
    -  //############以下字段在return_code为SUCCESS的时候有返回
    -  /**
    -   * 业务结果
    -   */
    -  @XStreamAlias("result_code")
    -  private String resultCode;
    -  /**
    -   * 错误代码
    -   */
    -  @XStreamAlias("err_code")
    -  private String errCode;
    -
    -  /**
    -   * 错误代码描述
    -   */
    -  @XStreamAlias("err_code_des")
    -  private String errCodeDes;
    +public class WxEntPayQueryResult extends WxPayBaseResult {
     
       //############以下字段在return_code 和result_code都为SUCCESS的时候有返回##############
       /**
    @@ -49,12 +17,6 @@ public class WxEntPayQueryResult {
       @XStreamAlias("partner_trade_no")
       private String partnerTradeNo;
     
    -  /**
    -   * 商户号
    -   */
    -  @XStreamAlias("mchid")
    -  private String mchId;
    -
       /**
        * 付款单号
        */
    @@ -103,11 +65,6 @@ public class WxEntPayQueryResult {
       @XStreamAlias("desc")
       private String desc;
     
    -  @Override
    -  public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    -  }
    -
       public String getReturnCode() {
         return returnCode;
       }
    @@ -124,30 +81,6 @@ public class WxEntPayQueryResult {
         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 getPartnerTradeNo() {
         return partnerTradeNo;
       }
    @@ -156,14 +89,6 @@ public class WxEntPayQueryResult {
         this.partnerTradeNo = partnerTradeNo;
       }
     
    -  public String getMchId() {
    -    return mchId;
    -  }
    -
    -  public void setMchId(String mchId) {
    -    this.mchId = mchId;
    -  }
    -
       public String getDetailId() {
         return detailId;
       }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java
    index 86c2c010..07bac47b 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java
    @@ -1,8 +1,5 @@
     package me.chanjar.weixin.mp.bean.pay;
     
    -import org.apache.commons.lang3.builder.ToStringBuilder;
    -import org.apache.commons.lang3.builder.ToStringStyle;
    -
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     
     /**
    @@ -11,21 +8,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
      * @author binarywang (https://github.com/binarywang)
      */
     @XStreamAlias("xml")
    -public class WxEntPayResult {
    -
    -  /**
    -   * 返回状态码
    -   */
    -  @XStreamAlias("return_code")
    -  private String returnCode;
    -
    -  /**
    -   * 返回信息
    -   */
    -  @XStreamAlias("return_msg")
    -  private String returnMsg;
    -
    -  //############以下字段在return_code为SUCCESS的时候有返回
    +public class WxEntPayResult extends WxPayBaseResult {
     
       /**
        * 商户appid
    @@ -33,41 +16,12 @@ public class WxEntPayResult {
       @XStreamAlias("mch_appid")
       private String mchAppid;
     
    -  /**
    -   * 商户号
    -   */
    -  @XStreamAlias("mchid")
    -  private String mchId;
    -
       /**
        * 设备号
        */
       @XStreamAlias("device_info")
       private String deviceInfo;
     
    -  /**
    -   * 随机字符串
    -   */
    -  @XStreamAlias("nonce_str")
    -  private String nonceStr;
    -
    -  /**
    -   * 业务结果
    -   */
    -  @XStreamAlias("result_code")
    -  private String resultCode;
    -  /**
    -   * 错误代码
    -   */
    -  @XStreamAlias("err_code")
    -  private String errCode;
    -
    -  /**
    -   * 错误代码描述
    -   */
    -  @XStreamAlias("err_code_des")
    -  private String errCodeDes;
    -
       //############以下字段在return_code 和result_code都为SUCCESS的时候有返回##############
       /**
        * 商户订单号
    @@ -87,27 +41,6 @@ public class WxEntPayResult {
       @XStreamAlias("payment_time")
       private String paymentTime;
     
    -  @Override
    -  public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    -  }
    -
    -  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 getMchAppid() {
         return mchAppid;
       }
    @@ -116,14 +49,6 @@ public class WxEntPayResult {
         this.mchAppid = mchAppid;
       }
     
    -  public String getMchId() {
    -    return mchId;
    -  }
    -
    -  public void setMchId(String mchId) {
    -    this.mchId = mchId;
    -  }
    -
       public String getDeviceInfo() {
         return deviceInfo;
       }
    @@ -132,38 +57,6 @@ public class WxEntPayResult {
         this.deviceInfo = deviceInfo;
       }
     
    -  public String getNonceStr() {
    -    return nonceStr;
    -  }
    -
    -  public void setNonceStr(String nonceStr) {
    -    this.nonceStr = nonceStr;
    -  }
    -
    -  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 getPartnerTradeNo() {
         return partnerTradeNo;
       }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayResult.java
    deleted file mode 100644
    index 6f453204..00000000
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayResult.java
    +++ /dev/null
    @@ -1,259 +0,0 @@
    -package me.chanjar.weixin.mp.bean.pay;
    -
    -import java.io.Serializable;
    -
    -import org.apache.commons.lang3.builder.ToStringBuilder;
    -import org.apache.commons.lang3.builder.ToStringStyle;
    -
    -/**
    - * 
    - * 查询订单支付状态返回的结果
    - * 
    - * 查询订单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2)
    - *
    - * 
    - * - * @author ukid - */ -public class WxMpPayResult implements Serializable { - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); - } - - private static final long serialVersionUID = -570934170727777190L; - - private String return_code; - private String return_msg; - private String appid; - private String mch_id; - private String nonce_str; - private String sign; - private String result_code; - private String err_code; - private String err_code_des; - private String trade_state; - private String trade_state_desc; - private String device_info; - private String openid; - private String is_subscribe; - private String trade_type; - private String bank_type; - private String total_fee; - private String coupon_fee; - private String fee_type; - private String transaction_id; - private String out_trade_no; - private String attach; - private String time_end; - /** - * 现金支付金额 cash_fee 是 Int 100 现金支付金额订单现金支付金额,详见支付金额 - */ - private String cash_fee; - - /** - * 现金支付货币类型 cash_fee_type 否 - * - */ - private String cash_fee_type; - - public String getReturn_code() { - return this.return_code; - } - - public String getReturn_msg() { - return this.return_msg; - } - - public String getAppid() { - return this.appid; - } - - public String getMch_id() { - return this.mch_id; - } - - public String getNonce_str() { - return this.nonce_str; - } - - public String getSign() { - return this.sign; - } - - public String getResult_code() { - return this.result_code; - } - - public String getErr_code() { - return this.err_code; - } - - public String getErr_code_des() { - return this.err_code_des; - } - - public String getTrade_state() { - return this.trade_state; - } - - public String getDevice_info() { - return this.device_info; - } - - public String getOpenid() { - return this.openid; - } - - public String getIs_subscribe() { - return this.is_subscribe; - } - - public String getTrade_type() { - return this.trade_type; - } - - public String getBank_type() { - return this.bank_type; - } - - public String getTotal_fee() { - return this.total_fee; - } - - public String getCoupon_fee() { - return this.coupon_fee; - } - - public String getFee_type() { - return this.fee_type; - } - - public String getTransaction_id() { - return this.transaction_id; - } - - public String getOut_trade_no() { - return this.out_trade_no; - } - - public String getAttach() { - return this.attach; - } - - public String getTime_end() { - return this.time_end; - } - - public void setReturn_code(String return_code) { - this.return_code = return_code; - } - - public void setReturn_msg(String return_msg) { - this.return_msg = return_msg; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public void setMch_id(String mch_id) { - this.mch_id = mch_id; - } - - public void setNonce_str(String nonce_str) { - this.nonce_str = nonce_str; - } - - public void setSign(String sign) { - this.sign = sign; - } - - public void setResult_code(String result_code) { - this.result_code = result_code; - } - - public void setErr_code(String err_code) { - this.err_code = err_code; - } - - public void setErr_code_des(String err_code_des) { - this.err_code_des = err_code_des; - } - - public void setTrade_state(String trade_state) { - this.trade_state = trade_state; - } - - public void setDevice_info(String device_info) { - this.device_info = device_info; - } - - public void setOpenid(String openid) { - this.openid = openid; - } - - public void setIs_subscribe(String is_subscribe) { - this.is_subscribe = is_subscribe; - } - - public void setTrade_type(String trade_type) { - this.trade_type = trade_type; - } - - public void setBank_type(String bank_type) { - this.bank_type = bank_type; - } - - public void setTotal_fee(String total_fee) { - this.total_fee = total_fee; - } - - public void setCoupon_fee(String coupon_fee) { - this.coupon_fee = coupon_fee; - } - - public void setFee_type(String fee_type) { - this.fee_type = fee_type; - } - - public void setTransaction_id(String transaction_id) { - this.transaction_id = transaction_id; - } - - public void setOut_trade_no(String out_trade_no) { - this.out_trade_no = out_trade_no; - } - - public void setAttach(String attach) { - this.attach = attach; - } - - public void setTime_end(String time_end) { - this.time_end = time_end; - } - - public String getTrade_state_desc() { - return this.trade_state_desc; - } - - public void setTrade_state_desc(String trade_state_desc) { - this.trade_state_desc = trade_state_desc; - } - - public String getCash_fee() { - return this.cash_fee; - } - - public void setCash_fee(String cash_fee) { - this.cash_fee = cash_fee; - } - - public String getCash_fee_type() { - return this.cash_fee_type; - } - - public void setCash_fee_type(String cash_fee_type) { - this.cash_fee_type = cash_fee_type; - } -} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseRequest.java new file mode 100644 index 00000000..062152d8 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseRequest.java @@ -0,0 +1,107 @@ +package me.chanjar.weixin.mp.bean.pay; + +import com.thoughtworks.xstream.annotations.XStreamAlias; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + *
    + * Created by Binary Wang on 2016-10-24.
    + *  微信支付请求对象共用的参数存放类
    + * 注释中各行每个字段描述对应如下:
    + * 
  • 字段名 + *
  • 变量名 + *
  • 是否必填 + *
  • 类型 + *
  • 示例值 + *
  • 描述 + *
  • + * @author binarywang(Binary Wang) + */ +public abstract class WxPayBaseRequest { + /** + *
    +   * 公众账号ID
    +   * appid
    +   * 是
    +   * String(32)
    +   * wxd678efh567hg6787
    +   * 微信分配的公众账号ID(企业号corpid即为此appId)
    +   * 
    + */ + @XStreamAlias("appid") + protected String appid; + /** + *
    +   * 商户号
    +   * mch_id
    +   * 是
    +   * String(32)
    +   * 1230000109
    +   * 微信支付分配的商户号
    +   * 
    + */ + @XStreamAlias("mch_id") + protected String mchId; + /** + *
    +   * 随机字符串
    +   * nonce_str
    +   * 是
    +   * String(32)
    +   * 5K8264ILTKCH16CQ2502SI8ZNMTM67VS
    +   * 随机字符串,不长于32位。推荐随机数生成算法
    +   * 
    + */ + @XStreamAlias("nonce_str") + protected String nonceStr; + /** + *
    +   * 签名
    +   * sign
    +   * 是
    +   * String(32)
    +   * C380BEC2BFD727A4B6845133519F3AD6
    +   * 签名,详见签名生成算法
    +   * 
    + */ + @XStreamAlias("sign") + protected String sign; + + 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 getNonceStr() { + return nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } + + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseResult.java similarity index 61% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderResult.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseResult.java index 7dfc6598..cdec8273 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseResult.java @@ -1,59 +1,78 @@ package me.chanjar.weixin.mp.bean.pay; +import com.thoughtworks.xstream.annotations.XStreamAlias; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.thoughtworks.xstream.annotations.XStreamAlias; - /** *
    - * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"返回的结果
    - * 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
    + * 微信支付结果共用属性类
    + * Created by Binary Wang on 2016-10-24.
    + * @author binarywang(Binary Wang)
      * 
    - * - * @author chanjarster */ -@XStreamAlias("xml") -public class WxUnifiedOrderResult { +public abstract class WxPayBaseResult { + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } + /** + * 返回状态码 + */ @XStreamAlias("return_code") - private String returnCode; + protected String returnCode; + /** + * 返回信息 + */ @XStreamAlias("return_msg") - private String returnMsg; + protected String returnMsg; + + /** + * 业务结果 + */ + @XStreamAlias("result_code") + private String resultCode; + + /** + * 错误代码 + */ + @XStreamAlias("err_code") + private String errCode; + + /** + * 错误代码描述 + */ + @XStreamAlias("err_code_des") + private String errCodeDes; + /** + * 公众账号ID + */ @XStreamAlias("appid") private String appid; + /** + * 商户号 + */ @XStreamAlias("mch_id") private String mchId; + /** + * 随机字符串 + */ @XStreamAlias("nonce_str") private String nonceStr; + /** + * 签名 + */ @XStreamAlias("sign") private String sign; - @XStreamAlias("result_code") - private String resultCode; - - @XStreamAlias("prepay_id") - private String prepayId; - - @XStreamAlias("trade_type") - private String tradeType; - - @XStreamAlias("err_code") - private String errCode; - - @XStreamAlias("err_code_des") - private String errCodeDes; - - @XStreamAlias("code_url") - private String codeURL; - public String getReturnCode() { - return this.returnCode; + return returnCode; } public void setReturnCode(String returnCode) { @@ -61,95 +80,66 @@ public class WxUnifiedOrderResult { } public String getReturnMsg() { - return this.returnMsg; + return returnMsg; } public void setReturnMsg(String returnMsg) { this.returnMsg = returnMsg; } - 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 getResultCode() { - return this.resultCode; + return resultCode; } public void setResultCode(String resultCode) { this.resultCode = resultCode; } - public String getPrepayId() { - return this.prepayId; + public String getErrCode() { + return errCode; } - public void setPrepayId(String prepayId) { - this.prepayId = prepayId; + public void setErrCode(String errCode) { + this.errCode = errCode; } - public String getTradeType() { - return this.tradeType; + public String getErrCodeDes() { + return errCodeDes; } - public void setTradeType(String tradeType) { - this.tradeType = tradeType; + public void setErrCodeDes(String errCodeDes) { + this.errCodeDes = errCodeDes; } - public String getErrCode() { - return this.errCode; + public String getAppid() { + return appid; } - public void setErrCode(String errCode) { - this.errCode = errCode; + public void setAppid(String appid) { + this.appid = appid; } - public String getErrCodeDes() { - return this.errCodeDes; + public String getMchId() { + return mchId; } - public void setErrCodeDes(String errCodeDes) { - this.errCodeDes = errCodeDes; + public void setMchId(String mchId) { + this.mchId = mchId; } - public String getCodeURL() { - return this.codeURL; + public String getNonceStr() { + return nonceStr; } - public void setCodeURL(String codeURL) { - this.codeURL = codeURL; + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; } - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayCallback.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayJsSDKCallback.java similarity index 97% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayCallback.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayJsSDKCallback.java index e32e721e..11b8b0d5 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayCallback.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayJsSDKCallback.java @@ -4,16 +4,16 @@ import java.io.Serializable; /** * pre> 订单支付状态回调 - * + * * 支付结果通知(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7) * * /pre> * * @author ukid */ -public class WxMpPayCallback implements Serializable { +public class WxPayJsSDKCallback implements Serializable { /** - * + * */ private static final long serialVersionUID = -4143804055690843641L; private String return_code; @@ -263,7 +263,7 @@ public class WxMpPayCallback implements Serializable { @Override public String toString() { - return "WxMpPayCallback [return_code=" + this.return_code + ", return_msg=" + return "WxPayJsSDKCallback [return_code=" + this.return_code + ", return_msg=" + this.return_msg + ", appid=" + this.appid + ", mch_id=" + this.mch_id + ", device_info=" + this.device_info + ", nonce_str=" + this.nonce_str + ", sign=" + this.sign + ", result_code=" + this.result_code diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryRequest.java new file mode 100644 index 00000000..ede1b06a --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryRequest.java @@ -0,0 +1,63 @@ +package me.chanjar.weixin.mp.bean.pay; + +import com.thoughtworks.xstream.annotations.XStreamAlias; + +/** + *
    + * 订单查询请求对象
    + * Created by Binary Wang on 2016-10-24.
    + * 注释中各行每个字段描述对应如下:
    + * 
  • 字段名 + *
  • 变量名 + *
  • 是否必填 + *
  • 类型 + *
  • 示例值 + *
  • 描述 + *
  • + * @author binarywang(Binary Wang) + */ +@XStreamAlias("xml") +public class WxPayOrderQueryRequest extends WxPayBaseRequest { + + /** + *
    +   * 微信订单号
    +   * transaction_id
    +   * 二选一
    +   * String(32)
    +   * 1009660380201506130728806387
    +   * 微信的订单号,优先使用
    +   * 
    + */ + @XStreamAlias("transaction_id") + private String transactionId; + + /** + *
    +   * 商户订单号
    +   * out_trade_no
    +   * 二选一
    +   * String(32)
    +   * 20150806125346
    +   * 商户系统内部的订单号,当没提供transaction_id时需要传这个。
    +   * 
    + */ + @XStreamAlias("out_trade_no") + private String outTradeNo; + + 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; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryResult.java new file mode 100644 index 00000000..25dc6cc8 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryResult.java @@ -0,0 +1,444 @@ +package me.chanjar.weixin.mp.bean.pay; + +import com.google.common.collect.Lists; +import com.thoughtworks.xstream.annotations.XStreamAlias; + +import java.util.List; + +/** + *
    + *  查询订单 返回结果对象
    + * Created by Binary Wang on 2016-10-24.
    + * 注释中各行每个字段描述对应如下:
    + * 
  • 字段名 + *
  • 变量名 + *
  • 是否必填 + *
  • 类型 + *
  • 示例值 + *
  • 描述 + *
  • + * @author binarywang(Binary Wang) + */ +@XStreamAlias("xml") +public class WxPayOrderQueryResult extends WxPayBaseResult { + + /** + *
    设备号
    +   * device_info
    +   * 否
    +   * String(32)
    +   * 013467007045764
    +   * 微信支付分配的终端设备号,
    +   * 
    + */ + @XStreamAlias("device_info") + private String deviceInfo; + + /** + *
    用户标识
    +   * openid
    +   * 是
    +   * String(128)
    +   * oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
    +   * 用户在商户appid下的唯一标识
    +   * 
    + */ + @XStreamAlias("openid") + private String openid; + + /** + *
    是否关注公众账号
    +   * is_subscribe
    +   * 否
    +   * String(1)
    +   * Y
    +   * 用户是否关注公众账号,Y-关注,N-未关注,仅在公众账号类型支付有效
    +   * 
    + */ + @XStreamAlias("is_subscribe") + private String isSubscribe; + + /** + *
    交易类型
    +   * trade_type
    +   * 是
    +   * String(16)
    +   * JSAPI
    +   * 调用接口提交的交易类型,取值如下:JSAPI,NATIVE,APP,MICROPAY,详细说明见参数规定
    +   * 
    + */ + @XStreamAlias("trade_type") + private String tradeType; + + /** + *
    交易状态
    +   * trade_state
    +   * 是
    +   * String(32)
    +   * SUCCESS
    +   * SUCCESS—支付成功,REFUND—转入退款,NOTPAY—未支付,CLOSED—已关闭,REVOKED—已撤销(刷卡支付),USERPAYING--用户支付中,PAYERROR--支付失败(其他原因,如银行返回失败)
    +   * 
    + */ + @XStreamAlias("trade_state") + private String tradeState; + + /** + *
    付款银行
    +   * bank_type
    +   * 是
    +   * String(16)
    +   * CMC
    +   * 银行类型,采用字符串类型的银行标识
    +   * 
    + */ + @XStreamAlias("bank_type") + private String bankType; + + /** + *
    订单金额
    +   * total_fee
    +   * 是
    +   * Int
    +   * 100
    +   * 订单总金额,单位为分
    +   * 
    + */ + @XStreamAlias("total_fee") + private Integer totalFee; + + /** + *
    应结订单金额
    +   * settlement_total_fee
    +   * 否
    +   * Int
    +   * 100
    +   * 应结订单金额=订单金额-非充值代金券金额,应结订单金额<=订单金额。
    +   * 
    + */ + @XStreamAlias("settlement_total_fee") + private Integer settlementTotalFee; + + /** + *
    货币种类
    +   * fee_type
    +   * 否
    +   * String(8)
    +   * CNY
    +   * 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
    +   * 
    + */ + @XStreamAlias("fee_type") + private String feeType; + + /** + *
    现金支付金额
    +   * cash_fee
    +   * 是
    +   * Int
    +   * 100
    +   * 现金支付金额订单现金支付金额,详见支付金额
    +   * 
    + */ + @XStreamAlias("cash_fee") + private Integer cashFee; + + /** + *
    现金支付货币类型
    +   * cash_fee_type
    +   * 否
    +   * String(16)
    +   * CNY
    +   * 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
    +   * 
    + */ + @XStreamAlias("cash_fee_type") + private String cashFeeType; + + /** + *
    代金券金额
    +   * coupon_fee
    +   * 否
    +   * Int
    +   * 100
    +   * “代金券”金额<=订单金额,订单金额-“代金券”金额=现金支付金额,详见支付金额
    +   * 
    + */ + @XStreamAlias("coupon_fee") + private Integer couponFee; + + /** + *
    代金券使用数量
    +   * coupon_count
    +   * 否
    +   * Int
    +   * 1
    +   * 代金券使用数量
    +   * 
    + */ + @XStreamAlias("coupon_count") + private Integer couponCount; + + private List coupons; + + public static class Coupon { + /** + *
    代金券类型
    +     * coupon_type_$n
    +     * 否
    +     * String
    +     * CASH
    +     * 
  • CASH--充值代金券 + *
  • NO_CASH---非充值代金券 + * 订单使用代金券时有返回(取值:CASH、NO_CASH)。$n为下标,从0开始编号,举例:coupon_type_$0 + *
  • + */ + private String couponType; + + /** + *
    代金券ID
    +     * coupon_id_$n
    +     * 否
    +     * String(20)
    +     * 10000
    +     * 代金券ID, $n为下标,从0开始编号
    +     * 
    + */ + private String couponId; + + /** + *
    单个代金券支付金额
    +     * coupon_fee_$n
    +     * 否
    +     * Int
    +     * 100
    +     * 单个代金券支付金额, $n为下标,从0开始编号
    +     * 
    + */ + private Integer couponFee; + + public Coupon(String couponType, String couponId, Integer couponFee) { + this.couponType = couponType; + this.couponId = couponId; + this.couponFee = couponFee; + } + } + + /** + *
    微信支付订单号
    +   * transaction_id
    +   * 是
    +   * String(32)
    +   * 1009660380201506130728806387
    +   * 微信支付订单号
    +   * 
    + */ + @XStreamAlias("transaction_id") + private String transactionId; + + /** + *
    商户订单号
    +   * out_trade_no
    +   * 是
    +   * String(32)
    +   * 20150806125346
    +   * 商户系统的订单号,与请求一致。
    +   * 
    + */ + @XStreamAlias("out_trade_no") + private String outTradeNo; + + /** + *
    附加数据
    +   * attach
    +   * 否
    +   * String(128)
    +   * 深圳分店
    +   * 附加数据,原样返回
    +   * 
    + */ + @XStreamAlias("attach") + private String attach; + + /** + *
    支付完成时间
    +   * time_end
    +   * 是
    +   * String(14)
    +   * 20141030133525
    +   * 订单支付时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则
    +   * 
    + */ + @XStreamAlias("time_end") + private String timeEnd; + + /** + *
    交易状态描述
    +   * trade_state_desc
    +   * 是
    +   * String(256)
    +   * 支付失败,请重新下单支付
    +   * 对当前查询订单状态的描述和下一步操作的指引
    +   * 
    + */ + @XStreamAlias("trade_state_desc") + private String tradeStateDesc; + + 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 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 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 Integer getCouponCount() { + return couponCount; + } + + public void setCouponCount(Integer couponCount) { + this.couponCount = couponCount; + } + + public List getCoupons() { + return coupons; + } + + public void setCoupons(List coupons) { + this.coupons = coupons; + } + + 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 getTradeStateDesc() { + return tradeStateDesc; + } + + public void setTradeStateDesc(String tradeStateDesc) { + this.tradeStateDesc = tradeStateDesc; + } + + public void composeCoupons(String xmlString){ + if(this.couponCount > 0 ){ + this.coupons = Lists.newArrayList(); + //TODO 暂时待实现 + } + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundRequest.java similarity index 99% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundRequest.java index 26f837b4..bc2802b7 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundRequest.java @@ -19,7 +19,7 @@ import me.chanjar.weixin.common.annotation.Required; * Created by Binary Wang on 2016-10-08. */ @XStreamAlias("xml") -public class WxMpPayRefundRequest { +public class WxPayRefundRequest { /** *
        * 公众账号ID
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundResult.java
    similarity index 68%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundResult.java
    index 5462d44a..ad20b8f1 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxMpPayRefundResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundResult.java
    @@ -1,8 +1,6 @@
     package me.chanjar.weixin.mp.bean.pay;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    -import org.apache.commons.lang3.builder.ToStringBuilder;
    -import org.apache.commons.lang3.builder.ToStringStyle;
     
     import java.io.Serializable;
     
    @@ -15,39 +13,12 @@ import java.io.Serializable;
      *
      */
     @XStreamAlias("xml")
    -public class WxMpPayRefundResult implements Serializable {
    +public class WxPayRefundResult extends WxPayBaseResult implements Serializable{
       private static final long serialVersionUID = 1L;
     
    -  @XStreamAlias("return_code")
    -  private String returnCode;
    -
    -  @XStreamAlias("return_msg")
    -  private String returnMsg;
    -
    -  @XStreamAlias("result_code")
    -  private String resultCode;
    -
    -  @XStreamAlias("err_code")
    -  private String errCode;
    -
    -  @XStreamAlias("err_code_des")
    -  private String errCodeDes;
    -
    -  @XStreamAlias("appid")
    -  private String appid;
    -
    -  @XStreamAlias("mch_id")
    -  private String mchId;
    -
       @XStreamAlias("device_info")
       private String deviceInfo;
     
    -  @XStreamAlias("nonce_str")
    -  private String nonceStr;
    -
    -  @XStreamAlias("sign")
    -  private String sign;
    -
       @XStreamAlias("transaction_id")
       private String transactionId;
     
    @@ -103,46 +74,6 @@ public class WxMpPayRefundResult implements Serializable {
         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 getDeviceInfo() {
         return this.deviceInfo;
       }
    @@ -151,22 +82,6 @@ public class WxMpPayRefundResult implements Serializable {
         this.deviceInfo = deviceInfo;
       }
     
    -  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 getTransactionId() {
         return this.transactionId;
       }
    @@ -271,9 +186,4 @@ public class WxMpPayRefundResult implements Serializable {
         this.couponRefundId = couponRefundId;
       }
     
    -  @Override
    -  public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    -  }
    -
     }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxSendRedpackRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackRequest.java
    similarity index 96%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxSendRedpackRequest.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackRequest.java
    index abe0d68f..27a46a71 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxSendRedpackRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackRequest.java
    @@ -8,7 +8,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
      * @author binarywang (https://github.com/binarywang)
      */
     @XStreamAlias("xml")
    -public class WxSendRedpackRequest {
    +public class WxPaySendRedpackRequest {
       /**
       * mch_billno
       * 商户订单号(每个订单号必须唯一)  组成:mch_id+yyyymmdd+10位一天内不能重复的数字。  接口根据商户订单号支持重入,如出现超时可再调用。
    @@ -18,7 +18,7 @@ public class WxSendRedpackRequest {
     
       /**
        * send_name
    -   * 商户名称 
    +   * 商户名称
        * 红包发送者名称
        */
       @XStreamAlias("send_name")
    @@ -117,7 +117,7 @@ public class WxSendRedpackRequest {
        * 场景id
        * PRODUCT_1:商品促销
        * PRODUCT_2:抽奖
    -   * PRODUCT_3:虚拟物品兑奖 
    +   * PRODUCT_3:虚拟物品兑奖
        * PRODUCT_4:企业内部福利
        * PRODUCT_5:渠道分润
        * PRODUCT_6:保险回馈
    @@ -135,7 +135,7 @@ public class WxSendRedpackRequest {
        * 活动信息
        * posttime:用户操作的时间戳
        * mobile:业务系统账号的手机号,国家代码-手机号。不需要+号
    -   * deviceid :mac 地址或者设备唯一标识 
    +   * deviceid :mac 地址或者设备唯一标识
        * clientversion :用户操作的客户端版本
        * 把值为非空的信息用key=value进行拼接,再进行urlencode
        * urlencode(posttime=xx&mobile=xx&deviceid=xx)
    @@ -150,7 +150,7 @@ public class WxSendRedpackRequest {
        * consume_mch_id
        * 资金授权商户号
        * 资金授权商户号
    -   * 服务商替特约商户发放时使用  
    +   * 服务商替特约商户发放时使用
        * 非必填字段
        * 
    */ diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackResult.java new file mode 100644 index 00000000..4a5ab146 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackResult.java @@ -0,0 +1,82 @@ +package me.chanjar.weixin.mp.bean.pay; + +import com.thoughtworks.xstream.annotations.XStreamAlias; + +import java.io.Serializable; + +/** + * 向微信用户个人发现金红包返回结果 + * https://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_5 + * @author kane + * + */ +@XStreamAlias("xml") +public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializable { + private static final long serialVersionUID = -4837415036337132073L; + + @XStreamAlias("mch_billno") + private String mchBillno; + + @XStreamAlias("wxappid") + private String wxappid; + + @XStreamAlias("re_openid") + private String reOpenid; + + @XStreamAlias("total_amount") + private int totalAmount; + + @XStreamAlias("send_time") + private String sendTime; + + @XStreamAlias("send_listid") + private String sendListid; + + public String getMchBillno() { + return mchBillno; + } + + public void setMchBillno(String mchBillno) { + this.mchBillno = mchBillno; + } + + public String getWxappid() { + return wxappid; + } + + public void setWxappid(String wxappid) { + this.wxappid = wxappid; + } + + public String getReOpenid() { + return reOpenid; + } + + public void setReOpenid(String reOpenid) { + this.reOpenid = reOpenid; + } + + public int getTotalAmount() { + return totalAmount; + } + + public void setTotalAmount(int totalAmount) { + this.totalAmount = totalAmount; + } + + public String getSendTime() { + return sendTime; + } + + public void setSendTime(String sendTime) { + this.sendTime = sendTime; + } + + public String getSendListid() { + return sendListid; + } + + public void setSendListid(String sendListid) { + this.sendListid = sendListid; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderRequest.java similarity index 91% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderRequest.java index 7cadd246..de3518ae 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxUnifiedOrderRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderRequest.java @@ -1,10 +1,6 @@ package me.chanjar.weixin.mp.bean.pay; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - import com.thoughtworks.xstream.annotations.XStreamAlias; - import me.chanjar.weixin.common.annotation.Required; /** @@ -23,33 +19,7 @@ import me.chanjar.weixin.common.annotation.Required; * @author binarywang (https://github.com/binarywang) */ @XStreamAlias("xml") -public class WxUnifiedOrderRequest { - - /** - *
    -   * 公众账号ID
    -   * appid
    -   * 是
    -   * String(32)
    -   * wxd678efh567hg6787
    -   * 微信分配的公众账号ID(企业号corpid即为此appId)
    -   * 
    - */ - @XStreamAlias("appid") - private String appid; - - /** - *
    -   * 商户号
    -   * mch_id
    -   * 是
    -   * String(32)
    -   * 1230000109
    -   * 微信支付分配的商户号
    -   * 
    - */ - @XStreamAlias("mch_id") - private String mchId; +public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { /** *
    @@ -64,32 +34,6 @@ public class WxUnifiedOrderRequest {
       @XStreamAlias("device_info")
       private String deviceInfo;
     
    -  /**
    -   * 
    -   * 随机字符串
    -   * nonce_str
    -   * 是
    -   * String(32)
    -   * 5K8264ILTKCH16CQ2502SI8ZNMTM67VS
    -   * 随机字符串,不长于32位。推荐随机数生成算法
    -   * 
    - */ - @XStreamAlias("nonce_str") - private String nonceStr; - - /** - *
    -   * 签名
    -   * sign
    -   * 是
    -   * String(32)
    -   * C380BEC2BFD727A4B6845133519F3AD6
    -   * 签名,详见签名生成算法
    -   * 
    - */ - @XStreamAlias("sign") - private String sign; - /** *
        * 商品描述
    @@ -482,11 +426,6 @@ public class WxUnifiedOrderRequest {
         this.openid = openid;
       }
     
    -  @Override
    -  public String toString() {
    -    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    -  }
    -
       public static WxUnifiedOrderRequestBuilder builder() {
         return new WxUnifiedOrderRequestBuilder();
       }
    @@ -613,7 +552,7 @@ public class WxUnifiedOrderRequest {
           return this;
         }
     
    -    public WxUnifiedOrderRequestBuilder from(WxUnifiedOrderRequest origin) {
    +    public WxUnifiedOrderRequestBuilder from(WxPayUnifiedOrderRequest origin) {
           this.appid(origin.appid);
           this.mchId(origin.mchId);
           this.deviceInfo(origin.deviceInfo);
    @@ -637,8 +576,8 @@ public class WxUnifiedOrderRequest {
           return this;
         }
     
    -    public WxUnifiedOrderRequest build() {
    -      WxUnifiedOrderRequest m = new WxUnifiedOrderRequest();
    +    public WxPayUnifiedOrderRequest build() {
    +      WxPayUnifiedOrderRequest m = new WxPayUnifiedOrderRequest();
           m.appid = this.appid;
           m.mchId = this.mchId;
           m.deviceInfo = this.deviceInfo;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderResult.java
    new file mode 100644
    index 00000000..012da5a4
    --- /dev/null
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderResult.java
    @@ -0,0 +1,48 @@
    +package me.chanjar.weixin.mp.bean.pay;
    +
    +import com.thoughtworks.xstream.annotations.XStreamAlias;
    +
    +/**
    + * 
    + * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"返回的结果
    + * 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
    + * 
    + * + * @author chanjarster + */ +@XStreamAlias("xml") +public class WxPayUnifiedOrderResult extends WxPayBaseResult { + + @XStreamAlias("prepay_id") + private String prepayId; + + @XStreamAlias("trade_type") + private String tradeType; + + @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; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java deleted file mode 100644 index a8287be6..00000000 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxRedpackResult.java +++ /dev/null @@ -1,105 +0,0 @@ -package me.chanjar.weixin.mp.bean.pay; - -import java.io.Serializable; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 向微信用户个人发现金红包返回结果 - * https://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_5 - * @author kane - * - */ -@XStreamAlias("xml") -public class WxRedpackResult implements Serializable { - - private static final long serialVersionUID = -4837415036337132073L; - - @XStreamAlias("return_code") - private String returnCode; - @XStreamAlias("return_msg") - private String returnMsg; - @XStreamAlias("sign") - private String sign; - @XStreamAlias("result_code") - private String resultCode; - - @XStreamAlias("err_code") - private String errCode; - @XStreamAlias("err_code_des") - private String errCodeDes; - @XStreamAlias("mch_billno") - private String mchBillno; - @XStreamAlias("mch_id") - private String mchId; - @XStreamAlias("wxappid") - private String wxappid; - @XStreamAlias("re_openid") - private String reOpenid; - @XStreamAlias("total_amount") - private int totalAmount; - @XStreamAlias("send_time") - private String sendTime; - @XStreamAlias("send_listid") - private String sendListid; - - public String getErrCode() { - return this.errCode; - } - - public String getErrCodeDes() { - return this.errCodeDes; - } - - public String getReturnCode() { - return this.returnCode; - } - - public String getReturnMsg() { - return this.returnMsg; - } - - public String getSign() { - return this.sign; - } - - public String getResultCode() { - return this.resultCode; - } - - public String getMchBillno() { - return this.mchBillno; - } - - public String getMchId() { - return this.mchId; - } - - public String getWxappid() { - return this.wxappid; - } - - public String getReOpenid() { - return this.reOpenid; - } - - public int getTotalAmount() { - return this.totalAmount; - } - - public String getSendTime() { - return this.sendTime; - } - - public String getSendListid() { - return this.sendListid; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); - } -} diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java index 17cf5eec..51414e1b 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java @@ -27,11 +27,6 @@ public class WxMpPayServiceImplTest { } - @Test - public void testGetJSSDKPayResult() throws Exception { - - } - @Test public void testGetJSSDKCallbackData() throws Exception { @@ -39,13 +34,13 @@ public class WxMpPayServiceImplTest { @Test public void testRefund() throws Exception { - WxMpPayRefundRequest request = new WxMpPayRefundRequest(); + WxPayRefundRequest request = new WxPayRefundRequest(); request.setOutRefundNo("aaa"); request.setOutTradeNo("1111"); request.setTotalFee(1222); request.setRefundFee(111); File keyFile = new File("E:\\dlt.p12"); - WxMpPayRefundResult result = this.wxService.getPayService().refund(request, keyFile); + WxPayRefundResult result = this.wxService.getPayService().refund(request, keyFile); System.err.println(result); } @@ -56,30 +51,41 @@ public class WxMpPayServiceImplTest { @Test public void testSendRedpack() throws Exception { - WxSendRedpackRequest request = new WxSendRedpackRequest(); + WxPaySendRedpackRequest request = new WxPaySendRedpackRequest(); request.setActName("abc"); request.setClientIp("aaa"); request.setMchBillno("aaaa"); request .setReOpenid(((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()); File keyFile = new File("E:\\dlt.p12"); - WxRedpackResult redpackResult = this.wxService.getPayService().sendRedpack(request, keyFile); + WxPaySendRedpackResult redpackResult = this.wxService.getPayService().sendRedpack(request, keyFile); System.err.println(redpackResult); } /** - * Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#unifiedOrder(me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest)}. + * Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#unifiedOrder(WxPayUnifiedOrderRequest)}. * @throws WxErrorException */ @Test public void testUnifiedOrder() throws WxErrorException { - WxUnifiedOrderResult result = this.wxService.getPayService() - .unifiedOrder(WxUnifiedOrderRequest.builder().body("1111111") + WxPayUnifiedOrderResult result = this.wxService.getPayService() + .unifiedOrder(WxPayUnifiedOrderRequest.builder().body("1111111") .totalFee(1).spbillCreateIp("111111").notifyURL("111111") .tradeType("JSAPI").openid("122").outTradeNo("111111").build()); System.err.println(result); } + /** + * Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#queryOrder(String, String)} . + * @throws WxErrorException + */ + @Test + public final void testQueryOrder() throws WxErrorException { + //System.err.println(this.wxService.getPayService().queryOrder(null, null)); + System.err.println(this.wxService.getPayService().queryOrder("11212121", null)); + System.err.println(this.wxService.getPayService().queryOrder(null, "11111")); + } + /** * Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#entPay(WxEntPayRequest, File)}. * @throws WxErrorException diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxRedpackResultTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxRedpackResultTest.java index 5a5275d4..557065ca 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxRedpackResultTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxRedpackResultTest.java @@ -8,7 +8,7 @@ import org.junit.Test; import com.thoughtworks.xstream.XStream; import me.chanjar.weixin.common.util.xml.XStreamInitializer; -import me.chanjar.weixin.mp.bean.pay.WxRedpackResult; +import me.chanjar.weixin.mp.bean.pay.WxPaySendRedpackResult; public class WxRedpackResultTest { @@ -17,44 +17,44 @@ public class WxRedpackResultTest { @Before public void setup() { this.xstream = XStreamInitializer.getInstance(); - this.xstream.processAnnotations(WxRedpackResult.class); + this.xstream.processAnnotations(WxPaySendRedpackResult.class); } - + @Test public void loadSuccessResult() { - final String successSample = "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "10010404\n" + - "\n" + - "\n" + - "1\n" + - "100000000020150520314766074200\n" + - "20150520102602\n" + + final String successSample = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "10010404\n" + + "\n" + + "\n" + + "1\n" + + "100000000020150520314766074200\n" + + "20150520102602\n" + ""; - WxRedpackResult wxMpRedpackResult = (WxRedpackResult) this.xstream.fromXML(successSample); + WxPaySendRedpackResult wxMpRedpackResult = (WxPaySendRedpackResult) this.xstream.fromXML(successSample); assertEquals("SUCCESS", wxMpRedpackResult.getReturnCode()); assertEquals("SUCCESS", wxMpRedpackResult.getResultCode()); assertEquals("20150520102602", wxMpRedpackResult.getSendTime()); } - + @Test public void loadFailureResult() { - final String failureSample = "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "10010404\n" + - "\n" + - "\n" + - "1\n" + + final String failureSample = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "10010404\n" + + "\n" + + "\n" + + "1\n" + ""; - WxRedpackResult wxMpRedpackResult = (WxRedpackResult) this.xstream.fromXML(failureSample); + WxPaySendRedpackResult wxMpRedpackResult = (WxPaySendRedpackResult) this.xstream.fromXML(failureSample); assertEquals("FAIL", wxMpRedpackResult.getReturnCode()); assertEquals("FAIL", wxMpRedpackResult.getResultCode()); assertEquals("onqOjjmM1tad-3ROpncN-yUfa6uI", wxMpRedpackResult.getReOpenid()); From 585cee0fd5f679680906b29b7a9fb6b0c1345e5c Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 25 Oct 2016 10:46:43 +0800 Subject: [PATCH 71/76] =?UTF-8?q?=E4=BF=AE=E6=94=B9pom=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=B4=A1=E7=8C=AE=E8=80=85=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 2724dfcc..7418974e 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ pom WeiXin Java Tools - Parent 微信公众号、企业号上级POM - https://github.com/binarywang/weixin-java-tools + https://github.com/wechat-group/weixin-java-tools @@ -22,17 +22,24 @@ 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 - scm:git:https://github.com/binarywang/weixin-java-tools.git - scm:git:git@github.com:binarywang/weixin-java-tools.git - https://github.com/binarywang/weixin-java-tools + 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 From 912ef628412b1a8e965eaccd88ba46f04094ec88 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 25 Oct 2016 12:05:50 +0800 Subject: [PATCH 72/76] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=AE=A2=E6=9C=8D?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9B=B8=E5=85=B3=E5=91=BD=E5=90=8D=EF=BC=8C?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=B8=8D=E5=90=88=E7=90=86=E7=9A=84=E5=91=BD?= =?UTF-8?q?=E5=90=8D=EF=BC=9ACustomMessage=20->=20KefuMessage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/api/WxMpKefuService.java | 17 ++--- .../mp/api/impl/WxMpKefuServiceImpl.java | 4 +- ...ava => WxMpXmlOutTransferKefuMessage.java} | 6 +- .../mp/bean/custombuilder/BaseBuilder.java | 6 +- .../mp/bean/custombuilder/ImageBuilder.java | 8 +-- .../mp/bean/custombuilder/MusicBuilder.java | 8 +-- .../mp/bean/custombuilder/NewsBuilder.java | 14 ++--- .../mp/bean/custombuilder/TextBuilder.java | 8 +-- .../mp/bean/custombuilder/VideoBuilder.java | 8 +-- .../mp/bean/custombuilder/VoiceBuilder.java | 8 +-- .../mp/bean/custombuilder/WxCardBuilder.java | 8 +-- .../WxMpKefuMessage.java} | 16 ++--- .../TransferCustomerServiceBuilder.java | 12 ++-- .../weixin/mp/util/json/WxMpGsonBuilder.java | 4 +- ...r.java => WxMpKefuMessageGsonAdapter.java} | 21 +++---- .../mp/util/xml/XStreamTransformer.java | 8 +-- .../mp/api/impl/WxMpKefuServiceImplTest.java | 10 +-- ...=> WxMpXmlOutTransferKefuMessageTest.java} | 10 +-- .../WxMpKefuMessageTest.java} | 62 +++++++++---------- .../mp/demo/DemoGuessNumberHandler.java | 22 +++---- weixin-java-mp/src/test/resources/testng.xml | 2 +- 21 files changed, 125 insertions(+), 137 deletions(-) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/{WxMpXmlOutTransferCustomerServiceMessage.java => WxMpXmlOutTransferKefuMessage.java} (87%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/{WxMpCustomMessage.java => kefu/WxMpKefuMessage.java} (89%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/{WxMpCustomMessageGsonAdapter.java => WxMpKefuMessageGsonAdapter.java} (89%) rename weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/{WxMpXmlOutTransferCustomerServiceMessageTest.java => WxMpXmlOutTransferKefuMessageTest.java} (84%) rename weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/{WxMpCustomMessageTest.java => kefu/WxMpKefuMessageTest.java} (80%) 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 fc678b42..5bad7da2 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 @@ -1,17 +1,12 @@ package me.chanjar.weixin.mp.api; -import java.io.File; -import java.util.Date; - import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.bean.WxMpCustomMessage; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfAccountRequest; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfList; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfMsgList; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfOnlineList; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionGetResult; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionList; -import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionWaitCaseList; +import me.chanjar.weixin.mp.bean.kefu.result.*; + +import java.io.File; +import java.util.Date; /** * 客服接口 , @@ -29,7 +24,7 @@ public interface WxMpKefuService { * 详情请见: 发送客服消息 *
    */ - boolean customMessageSend(WxMpCustomMessage message) throws WxErrorException; + boolean sendKefuMessage(WxMpKefuMessage message) throws WxErrorException; //*******************客服管理接口***********************// 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 e83c17ac..09a68adf 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 @@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api.impl; import java.io.File; import java.util.Date; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,7 +15,6 @@ import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.mp.api.WxMpKefuService; import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.WxMpCustomMessage; import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfAccountRequest; import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfSessionRequest; import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfList; @@ -41,7 +41,7 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { } @Override - public boolean customMessageSend(WxMpCustomMessage message) + public boolean sendKefuMessage(WxMpKefuMessage message) throws WxErrorException { String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send"; String responseContent = this.wxMpService.post(url, message.toJson()); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferCustomerServiceMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferKefuMessage.java similarity index 87% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferCustomerServiceMessage.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferKefuMessage.java index a1a48bbe..3022e70d 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferCustomerServiceMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferKefuMessage.java @@ -6,13 +6,13 @@ import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; @XStreamAlias("xml") -public class WxMpXmlOutTransferCustomerServiceMessage extends WxMpXmlOutMessage { +public class WxMpXmlOutTransferKefuMessage extends WxMpXmlOutMessage { private static final long serialVersionUID = 1850903037285841322L; - + @XStreamAlias("TransInfo") protected TransInfo transInfo; - public WxMpXmlOutTransferCustomerServiceMessage() { + public WxMpXmlOutTransferKefuMessage() { this.msgType = WxConsts.CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/BaseBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/BaseBuilder.java index 18bf81f9..911e3f62 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/BaseBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/BaseBuilder.java @@ -1,6 +1,6 @@ package me.chanjar.weixin.mp.bean.custombuilder; -import me.chanjar.weixin.mp.bean.WxMpCustomMessage; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; public class BaseBuilder { protected String msgType; @@ -11,8 +11,8 @@ public class BaseBuilder { return (T) this; } - public WxMpCustomMessage build() { - WxMpCustomMessage m = new WxMpCustomMessage(); + public WxMpKefuMessage build() { + WxMpKefuMessage m = new WxMpKefuMessage(); m.setMsgType(this.msgType); m.setToUser(this.toUser); return m; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/ImageBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/ImageBuilder.java index 1fb5363c..85855d25 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/ImageBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/ImageBuilder.java @@ -1,12 +1,12 @@ package me.chanjar.weixin.mp.bean.custombuilder; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.WxMpCustomMessage; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; /** * 获得消息builder *
    - * 用法: WxMpCustomMessage m = WxMpCustomMessage.IMAGE().mediaId(...).toUser(...).build();
    + * 用法: WxMpKefuMessage m = WxMpKefuMessage.IMAGE().mediaId(...).toUser(...).build();
      * 
    * @author chanjarster * @@ -24,8 +24,8 @@ public final class ImageBuilder extends BaseBuilder { } @Override - public WxMpCustomMessage build() { - WxMpCustomMessage m = super.build(); + public WxMpKefuMessage build() { + WxMpKefuMessage m = super.build(); m.setMediaId(this.mediaId); return m; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/MusicBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/MusicBuilder.java index 7a9994ad..3555f7a9 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/MusicBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/MusicBuilder.java @@ -1,12 +1,12 @@ package me.chanjar.weixin.mp.bean.custombuilder; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.WxMpCustomMessage; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; /** * 音乐消息builder *
    - * 用法: WxMpCustomMessage m = WxMpCustomMessage.MUSIC()
    + * 用法: WxMpKefuMessage m = WxMpKefuMessage.MUSIC()
      *                      .musicUrl(...)
      *                      .hqMusicUrl(...)
      *                      .title(...)
    @@ -53,8 +53,8 @@ public final class MusicBuilder extends BaseBuilder {
       }
     
       @Override
    -  public WxMpCustomMessage build() {
    -    WxMpCustomMessage m = super.build();
    +  public WxMpKefuMessage build() {
    +    WxMpKefuMessage m = super.build();
         m.setMusicUrl(this.musicUrl);
         m.setHqMusicUrl(this.hqMusicUrl);
         m.setTitle(this.title);
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/NewsBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/NewsBuilder.java
    index ad0efb23..d909eb7d 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/NewsBuilder.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/NewsBuilder.java
    @@ -1,7 +1,7 @@
     package me.chanjar.weixin.mp.bean.custombuilder;
     
     import me.chanjar.weixin.common.api.WxConsts;
    -import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
    +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
     
     import java.util.ArrayList;
     import java.util.List;
    @@ -10,27 +10,27 @@ import java.util.List;
      * 图文消息builder
      * 
      * 用法:
    - * WxMpCustomMessage m = WxMpCustomMessage.NEWS().addArticle(article).toUser(...).build();
    + * WxMpKefuMessage m = WxMpKefuMessage.NEWS().addArticle(article).toUser(...).build();
      * 
    * @author chanjarster * */ public final class NewsBuilder extends BaseBuilder { - private List articles = new ArrayList<>(); - + private List articles = new ArrayList<>(); + public NewsBuilder() { this.msgType = WxConsts.CUSTOM_MSG_NEWS; } - public NewsBuilder addArticle(WxMpCustomMessage.WxArticle article) { + public NewsBuilder addArticle(WxMpKefuMessage.WxArticle article) { this.articles.add(article); return this; } @Override - public WxMpCustomMessage build() { - WxMpCustomMessage m = super.build(); + public WxMpKefuMessage build() { + WxMpKefuMessage m = super.build(); m.setArticles(this.articles); return m; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/TextBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/TextBuilder.java index 7f458457..770675f5 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/TextBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/TextBuilder.java @@ -1,12 +1,12 @@ package me.chanjar.weixin.mp.bean.custombuilder; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.WxMpCustomMessage; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; /** * 文本消息builder *
    - * 用法: WxMpCustomMessage m = WxMpCustomMessage.TEXT().content(...).toUser(...).build();
    + * 用法: WxMpKefuMessage m = WxMpKefuMessage.TEXT().content(...).toUser(...).build();
      * 
    * @author chanjarster * @@ -24,8 +24,8 @@ public final class TextBuilder extends BaseBuilder { } @Override - public WxMpCustomMessage build() { - WxMpCustomMessage m = super.build(); + public WxMpKefuMessage build() { + WxMpKefuMessage m = super.build(); m.setContent(this.content); return m; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/VideoBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/VideoBuilder.java index bda6ef7c..f9740e2f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/VideoBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/VideoBuilder.java @@ -1,12 +1,12 @@ package me.chanjar.weixin.mp.bean.custombuilder; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.WxMpCustomMessage; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; /** * 视频消息builder *
    - * 用法: WxMpCustomMessage m = WxMpCustomMessage.VOICE()
    + * 用法: WxMpKefuMessage m = WxMpKefuMessage.VOICE()
      *                              .mediaId(...)
      *                              .title(...)
      *                              .thumbMediaId(..)
    @@ -48,8 +48,8 @@ public final class VideoBuilder extends BaseBuilder {
       }
     
       @Override
    -  public WxMpCustomMessage build() {
    -    WxMpCustomMessage m = super.build();
    +  public WxMpKefuMessage build() {
    +    WxMpKefuMessage m = super.build();
         m.setMediaId(this.mediaId);
         m.setTitle(this.title);
         m.setDescription(this.description);
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/VoiceBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/VoiceBuilder.java
    index 867c8aff..7686a56d 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/VoiceBuilder.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/VoiceBuilder.java
    @@ -1,12 +1,12 @@
     package me.chanjar.weixin.mp.bean.custombuilder;
     
     import me.chanjar.weixin.common.api.WxConsts;
    -import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
    +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
     
     /**
      * 语音消息builder
      * 
    - * 用法: WxMpCustomMessage m = WxMpCustomMessage.VOICE().mediaId(...).toUser(...).build();
    + * 用法: WxMpKefuMessage m = WxMpKefuMessage.VOICE().mediaId(...).toUser(...).build();
      * 
    * @author chanjarster * @@ -24,8 +24,8 @@ public final class VoiceBuilder extends BaseBuilder { } @Override - public WxMpCustomMessage build() { - WxMpCustomMessage m = super.build(); + public WxMpKefuMessage build() { + WxMpKefuMessage m = super.build(); m.setMediaId(this.mediaId); return m; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/WxCardBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/WxCardBuilder.java index 8620cd84..fb5e81c2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/WxCardBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/WxCardBuilder.java @@ -1,12 +1,12 @@ package me.chanjar.weixin.mp.bean.custombuilder; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.WxMpCustomMessage; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; /** * 卡券消息builder *
    - * 用法: WxMpCustomMessage m = WxMpCustomMessage.WXCARD().cardId(...).toUser(...).build();
    + * 用法: WxMpKefuMessage m = WxMpKefuMessage.WXCARD().cardId(...).toUser(...).build();
      * 
    * @author mgcnrx11 * @@ -24,8 +24,8 @@ public final class WxCardBuilder extends BaseBuilder { } @Override - public WxMpCustomMessage build() { - WxMpCustomMessage m = super.build(); + public WxMpKefuMessage build() { + WxMpKefuMessage m = super.build(); m.setCardId(this.cardId); return m; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCustomMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java similarity index 89% rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCustomMessage.java rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java index a7f1670f..7963f53e 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpCustomMessage.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessage.java @@ -1,24 +1,18 @@ -package me.chanjar.weixin.mp.bean; +package me.chanjar.weixin.mp.bean.kefu; + +import me.chanjar.weixin.mp.bean.custombuilder.*; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import me.chanjar.weixin.mp.bean.custombuilder.ImageBuilder; -import me.chanjar.weixin.mp.bean.custombuilder.MusicBuilder; -import me.chanjar.weixin.mp.bean.custombuilder.NewsBuilder; -import me.chanjar.weixin.mp.bean.custombuilder.TextBuilder; -import me.chanjar.weixin.mp.bean.custombuilder.VideoBuilder; -import me.chanjar.weixin.mp.bean.custombuilder.VoiceBuilder; -import me.chanjar.weixin.mp.bean.custombuilder.WxCardBuilder; -import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; - /** * 客服消息 * @author chanjarster * */ -public class WxMpCustomMessage implements Serializable { +public class WxMpKefuMessage implements Serializable { private static final long serialVersionUID = -9196732086954365246L; private String toUser; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/outxmlbuilder/TransferCustomerServiceBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/outxmlbuilder/TransferCustomerServiceBuilder.java index 87ec3a04..b89e31b4 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/outxmlbuilder/TransferCustomerServiceBuilder.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/outxmlbuilder/TransferCustomerServiceBuilder.java @@ -1,17 +1,17 @@ package me.chanjar.weixin.mp.bean.outxmlbuilder; import me.chanjar.weixin.common.util.StringUtils; -import me.chanjar.weixin.mp.bean.WxMpXmlOutTransferCustomerServiceMessage; +import me.chanjar.weixin.mp.bean.WxMpXmlOutTransferKefuMessage; /** * 客服消息builder *
    - * 用法: WxMpCustomMessage m = WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE().content(...).toUser(...).build();
    + * 用法: WxMpKefuMessage m = WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE().content(...).toUser(...).build();
      * 
    * * @author chanjarster */ -public final class TransferCustomerServiceBuilder extends BaseBuilder { +public final class TransferCustomerServiceBuilder extends BaseBuilder { private String kfAccount; public TransferCustomerServiceBuilder kfAccount(String kf) { @@ -20,11 +20,11 @@ public final class TransferCustomerServiceBuilder extends BaseBuilder { +public class WxMpKefuMessageGsonAdapter implements JsonSerializer { @Override - public JsonElement serialize(WxMpCustomMessage message, Type typeOfSrc, JsonSerializationContext context) { + public JsonElement serialize(WxMpKefuMessage message, Type typeOfSrc, JsonSerializationContext context) { JsonObject messageJson = new JsonObject(); messageJson.addProperty("touser", message.getToUser()); messageJson.addProperty("msgtype", message.getMsgType()); - + if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) { JsonObject text = new JsonObject(); text.addProperty("content", message.getContent()); @@ -60,11 +59,11 @@ public class WxMpCustomMessageGsonAdapter implements JsonSerializerHello World"); - this.wxService.getKefuService().customMessageSend(message); + this.wxService.getKefuService().sendKefuMessage(message); } public void testSendCustomMessageWithKfAccount() throws WxErrorException { WxXmlMpInMemoryConfigStorage configStorage = (WxXmlMpInMemoryConfigStorage) this.wxService .getWxMpConfigStorage(); - WxMpCustomMessage message = new WxMpCustomMessage(); + WxMpKefuMessage message = new WxMpKefuMessage(); message.setMsgType(WxConsts.CUSTOM_MSG_TEXT); message.setToUser(configStorage.getOpenid()); message.setKfAccount(configStorage.getKfAccount()); message.setContent( "欢迎欢迎,热烈欢迎\n换行测试\n超链接:Hello World"); - this.wxService.getKefuService().customMessageSend(message); + this.wxService.getKefuService().sendKefuMessage(message); } public void testKfList() throws WxErrorException { diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferCustomerServiceMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferKefuMessageTest.java similarity index 84% rename from weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferCustomerServiceMessageTest.java rename to weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferKefuMessageTest.java index 012a0986..ad167738 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferCustomerServiceMessageTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpXmlOutTransferKefuMessageTest.java @@ -6,10 +6,10 @@ import org.testng.annotations.Test; /** * Created by ben on 2015/12/29. */ -public class WxMpXmlOutTransferCustomerServiceMessageTest { +public class WxMpXmlOutTransferKefuMessageTest { @Test public void test() { - WxMpXmlOutTransferCustomerServiceMessage m = new WxMpXmlOutTransferCustomerServiceMessage(); + WxMpXmlOutTransferKefuMessage m = new WxMpXmlOutTransferKefuMessage(); m.setCreateTime(1399197672L); m.setFromUserName("fromuser"); m.setToUserName("touser"); @@ -32,7 +32,7 @@ public class WxMpXmlOutTransferCustomerServiceMessageTest { "" + "" + ""; - WxMpXmlOutTransferCustomerServiceMessage.TransInfo transInfo = new WxMpXmlOutTransferCustomerServiceMessage.TransInfo(); + WxMpXmlOutTransferKefuMessage.TransInfo transInfo = new WxMpXmlOutTransferKefuMessage.TransInfo(); transInfo.setKfAccount("test1@test"); m.setTransInfo(transInfo); System.out.println(m.toXml()); @@ -41,7 +41,7 @@ public class WxMpXmlOutTransferCustomerServiceMessageTest { @Test public void testBuild() { - WxMpXmlOutTransferCustomerServiceMessage m = WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE().fromUser("fromuser").toUser("touser").build(); + WxMpXmlOutTransferKefuMessage m = WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE().fromUser("fromuser").toUser("touser").build(); m.setCreateTime(1399197672L); String expected = "" + "" + @@ -67,4 +67,4 @@ public class WxMpXmlOutTransferCustomerServiceMessageTest { System.out.println(m.toXml()); Assert.assertEquals(m.toXml().replaceAll("\\s", ""), expected.replaceAll("\\s", "")); } -} \ No newline at end of file +} diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpCustomMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java similarity index 80% rename from weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpCustomMessageTest.java rename to weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java index aa8de0df..9f19029e 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxMpCustomMessageTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/kefu/WxMpKefuMessageTest.java @@ -1,54 +1,54 @@ -package me.chanjar.weixin.mp.bean; +package me.chanjar.weixin.mp.bean.kefu; import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.WxMpCustomMessage.WxArticle; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage.WxArticle; import org.testng.Assert; import org.testng.annotations.Test; @Test -public class WxMpCustomMessageTest { +public class WxMpKefuMessageTest { public void testTextReply() { - WxMpCustomMessage reply = new WxMpCustomMessage(); + WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT); reply.setContent("sfsfdsdf"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); } - + public void testTextBuild() { - WxMpCustomMessage reply = WxMpCustomMessage.TEXT().toUser("OPENID").content("sfsfdsdf").build(); + WxMpKefuMessage reply = WxMpKefuMessage.TEXT().toUser("OPENID").content("sfsfdsdf").build(); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}"); } - + public void testImageReply() { - WxMpCustomMessage reply = new WxMpCustomMessage(); + WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE); reply.setMediaId("MEDIA_ID"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); } - + public void testImageBuild() { - WxMpCustomMessage reply = WxMpCustomMessage.IMAGE().toUser("OPENID").mediaId("MEDIA_ID").build(); + WxMpKefuMessage reply = WxMpKefuMessage.IMAGE().toUser("OPENID").mediaId("MEDIA_ID").build(); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}"); } - + public void testVoiceReply() { - WxMpCustomMessage reply = new WxMpCustomMessage(); + WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_VOICE); reply.setMediaId("MEDIA_ID"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}"); } - + public void testVoiceBuild() { - WxMpCustomMessage reply = WxMpCustomMessage.VOICE().toUser("OPENID").mediaId("MEDIA_ID").build(); + WxMpKefuMessage reply = WxMpKefuMessage.VOICE().toUser("OPENID").mediaId("MEDIA_ID").build(); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}"); } - + public void testVideoReply() { - WxMpCustomMessage reply = new WxMpCustomMessage(); + WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_VIDEO); reply.setMediaId("MEDIA_ID"); @@ -57,14 +57,14 @@ public class WxMpCustomMessageTest { reply.setDescription("DESCRIPTION"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"video\",\"video\":{\"media_id\":\"MEDIA_ID\",\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"}}"); } - + public void testVideoBuild() { - WxMpCustomMessage reply = WxMpCustomMessage.VIDEO().toUser("OPENID").title("TITLE").mediaId("MEDIA_ID").thumbMediaId("MEDIA_ID").description("DESCRIPTION").build(); + WxMpKefuMessage reply = WxMpKefuMessage.VIDEO().toUser("OPENID").title("TITLE").mediaId("MEDIA_ID").thumbMediaId("MEDIA_ID").description("DESCRIPTION").build(); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"video\",\"video\":{\"media_id\":\"MEDIA_ID\",\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"}}"); } - + public void testMusicReply() { - WxMpCustomMessage reply = new WxMpCustomMessage(); + WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_MUSIC); reply.setThumbMediaId("MEDIA_ID"); @@ -74,9 +74,9 @@ public class WxMpCustomMessageTest { reply.setHqMusicUrl("HQ_MUSIC_URL"); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"music\",\"music\":{\"title\":\"TITLE\",\"description\":\"DESCRIPTION\",\"thumb_media_id\":\"MEDIA_ID\",\"musicurl\":\"MUSIC_URL\",\"hqmusicurl\":\"HQ_MUSIC_URL\"}}"); } - + public void testMusicBuild() { - WxMpCustomMessage reply = WxMpCustomMessage.MUSIC() + WxMpKefuMessage reply = WxMpKefuMessage.MUSIC() .toUser("OPENID") .title("TITLE") .thumbMediaId("MEDIA_ID") @@ -86,19 +86,19 @@ public class WxMpCustomMessageTest { .build(); Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"music\",\"music\":{\"title\":\"TITLE\",\"description\":\"DESCRIPTION\",\"thumb_media_id\":\"MEDIA_ID\",\"musicurl\":\"MUSIC_URL\",\"hqmusicurl\":\"HQ_MUSIC_URL\"}}"); } - + public void testNewsReply() { - WxMpCustomMessage reply = new WxMpCustomMessage(); + WxMpKefuMessage reply = new WxMpKefuMessage(); reply.setToUser("OPENID"); reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS); - + WxArticle article1 = new WxArticle(); article1.setUrl("URL"); article1.setPicUrl("PIC_URL"); article1.setDescription("Is Really A Happy Day"); article1.setTitle("Happy Day"); reply.getArticles().add(article1); - + WxArticle article2 = new WxArticle(); article2.setUrl("URL"); article2.setPicUrl("PIC_URL"); @@ -106,26 +106,26 @@ public class WxMpCustomMessageTest { article2.setTitle("Happy Day"); reply.getArticles().add(article2); - + Assert.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\"}]}}"); } - + public void testNewsBuild() { WxArticle article1 = new WxArticle(); article1.setUrl("URL"); article1.setPicUrl("PIC_URL"); article1.setDescription("Is Really A Happy Day"); article1.setTitle("Happy Day"); - + WxArticle article2 = new WxArticle(); article2.setUrl("URL"); article2.setPicUrl("PIC_URL"); article2.setDescription("Is Really A Happy Day"); article2.setTitle("Happy Day"); - WxMpCustomMessage reply = WxMpCustomMessage.NEWS().toUser("OPENID").addArticle(article1).addArticle(article2).build(); + WxMpKefuMessage reply = WxMpKefuMessage.NEWS().toUser("OPENID").addArticle(article1).addArticle(article2).build(); Assert.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\"}]}}"); } - + } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoGuessNumberHandler.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoGuessNumberHandler.java index f35b3b87..604531b1 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoGuessNumberHandler.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoGuessNumberHandler.java @@ -10,7 +10,7 @@ import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.mp.api.WxMpMessageHandler; import me.chanjar.weixin.mp.api.WxMpMessageMatcher; import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.WxMpCustomMessage; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; import me.chanjar.weixin.mp.bean.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage; @@ -52,19 +52,19 @@ public class DemoGuessNumberHandler implements WxMpMessageHandler, WxMpMessageMa protected void letsGo(WxMpXmlMessage wxMessage, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException { WxSession session = sessionManager.getSession(wxMessage.getFromUser()); if (session.getAttribute("guessing") == null) { - WxMpCustomMessage m = WxMpCustomMessage + WxMpKefuMessage m = WxMpKefuMessage .TEXT() .toUser(wxMessage.getFromUser()) .content("请猜一个100以内的数字") .build(); - wxMpService.getKefuService().customMessageSend(m); + wxMpService.getKefuService().sendKefuMessage(m); } else { - WxMpCustomMessage m = WxMpCustomMessage + WxMpKefuMessage m = WxMpKefuMessage .TEXT() .toUser(wxMessage.getFromUser()) .content("放弃了吗?那请重新猜一个100以内的数字") .build(); - wxMpService.getKefuService().customMessageSend(m); + wxMpService.getKefuService().sendKefuMessage(m); } session.setAttribute("guessing", Boolean.TRUE); @@ -87,28 +87,28 @@ public class DemoGuessNumberHandler implements WxMpMessageHandler, WxMpMessageMa int answer = (Integer) session.getAttribute("number"); int guessNumber = Integer.valueOf(wxMessage.getContent()); if (guessNumber < answer) { - WxMpCustomMessage m = WxMpCustomMessage + WxMpKefuMessage m = WxMpKefuMessage .TEXT() .toUser(wxMessage.getFromUser()) .content("小了") .build(); - wxMpService.getKefuService().customMessageSend(m); + wxMpService.getKefuService().sendKefuMessage(m); } else if (guessNumber > answer) { - WxMpCustomMessage m = WxMpCustomMessage + WxMpKefuMessage m = WxMpKefuMessage .TEXT() .toUser(wxMessage.getFromUser()) .content("大了") .build(); - wxMpService.getKefuService().customMessageSend(m); + wxMpService.getKefuService().sendKefuMessage(m); } else { - WxMpCustomMessage m = WxMpCustomMessage + WxMpKefuMessage m = WxMpKefuMessage .TEXT() .toUser(wxMessage.getFromUser()) .content("Bingo!") .build(); session.removeAttribute("guessing"); - wxMpService.getKefuService().customMessageSend(m); + wxMpService.getKefuService().sendKefuMessage(m); } } diff --git a/weixin-java-mp/src/test/resources/testng.xml b/weixin-java-mp/src/test/resources/testng.xml index 6d5310ce..addf7be4 100644 --- a/weixin-java-mp/src/test/resources/testng.xml +++ b/weixin-java-mp/src/test/resources/testng.xml @@ -17,7 +17,7 @@ - + From a3ada2c0aead836f8c2f64bd0a742ca59783afc1 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 25 Oct 2016 12:06:26 +0800 Subject: [PATCH 73/76] =?UTF-8?q?=E9=87=8D=E6=9E=84=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E5=8C=96=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=B1=BB=E7=9A=84=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/mp/api/WxMpPayService.java | 13 +- .../mp/api/impl/WxMpPayServiceImpl.java | 16 +- .../mp/bean/pay/WxPayJsSDKCallback.java | 520 +++++++++--------- .../{ => request}/WxEntPayQueryRequest.java | 2 +- .../pay/{ => request}/WxEntPayRequest.java | 2 +- .../pay/{ => request}/WxPayBaseRequest.java | 2 +- .../{ => request}/WxPayOrderQueryRequest.java | 2 +- .../pay/{ => request}/WxPayRefundRequest.java | 2 +- .../WxPaySendRedpackRequest.java | 2 +- .../WxPayUnifiedOrderRequest.java | 2 +- .../pay/{ => result}/WxEntPayQueryResult.java | 2 +- .../bean/pay/{ => result}/WxEntPayResult.java | 2 +- .../pay/{ => result}/WxPayBaseResult.java | 2 +- .../{ => result}/WxPayOrderQueryResult.java | 4 +- .../pay/{ => result}/WxPayRefundResult.java | 2 +- .../{ => result}/WxPaySendRedpackResult.java | 2 +- .../{ => result}/WxPayUnifiedOrderResult.java | 2 +- .../mp/api/impl/WxMpPayServiceImplTest.java | 13 +- .../result/WxPaySendRedpackResultTest.java} | 36 +- 19 files changed, 304 insertions(+), 324 deletions(-) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => request}/WxEntPayQueryRequest.java (97%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => request}/WxEntPayRequest.java (99%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => request}/WxPayBaseRequest.java (97%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => request}/WxPayOrderQueryRequest.java (96%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => request}/WxPayRefundRequest.java (99%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => request}/WxPaySendRedpackRequest.java (99%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => request}/WxPayUnifiedOrderRequest.java (99%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => result}/WxEntPayQueryResult.java (98%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => result}/WxEntPayResult.java (97%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => result}/WxPayBaseResult.java (98%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => result}/WxPayOrderQueryResult.java (98%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => result}/WxPayRefundResult.java (98%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => result}/WxPaySendRedpackResult.java (97%) rename weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/{ => result}/WxPayUnifiedOrderResult.java (95%) rename weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/{WxRedpackResultTest.java => pay/result/WxPaySendRedpackResultTest.java} (71%) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java index a1dabfa0..411c2abf 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java @@ -1,7 +1,11 @@ package me.chanjar.weixin.mp.api; import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.mp.bean.pay.*; +import me.chanjar.weixin.mp.bean.pay.request.WxEntPayRequest; +import me.chanjar.weixin.mp.bean.pay.request.WxPayRefundRequest; +import me.chanjar.weixin.mp.bean.pay.request.WxPaySendRedpackRequest; +import me.chanjar.weixin.mp.bean.pay.request.WxPayUnifiedOrderRequest; +import me.chanjar.weixin.mp.bean.pay.result.*; import java.io.File; import java.util.Map; @@ -47,13 +51,6 @@ public interface WxMpPayService { */ Map getPayInfo(WxPayUnifiedOrderRequest request) throws WxErrorException; - /** - * 读取支付结果通知 - * 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7 - * - */ - WxPayJsSDKCallback getJSSDKCallbackData(String xmlData); - /** *
        * 微信支付-申请退款
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    index 8cb737c6..3b3b7510 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java
    @@ -7,7 +7,8 @@ import me.chanjar.weixin.common.util.BeanUtils;
     import me.chanjar.weixin.common.util.xml.XStreamInitializer;
     import me.chanjar.weixin.mp.api.WxMpPayService;
     import me.chanjar.weixin.mp.api.WxMpService;
    -import me.chanjar.weixin.mp.bean.pay.*;
    +import me.chanjar.weixin.mp.bean.pay.request.*;
    +import me.chanjar.weixin.mp.bean.pay.result.*;
     import org.apache.commons.codec.digest.DigestUtils;
     import org.apache.commons.lang3.ArrayUtils;
     import org.apache.commons.lang3.StringUtils;
    @@ -45,19 +46,6 @@ public class WxMpPayServiceImpl implements WxMpPayService {
         this.wxMpService = wxMpService;
       }
     
    -  @Override
    -  public WxPayJsSDKCallback getJSSDKCallbackData(String xmlData) {
    -    try {
    -      XStream xstream = XStreamInitializer.getInstance();
    -      xstream.alias("xml", WxPayJsSDKCallback.class);
    -      return (WxPayJsSDKCallback) xstream.fromXML(xmlData);
    -    } catch (Exception e) {
    -      e.printStackTrace();
    -    }
    -
    -    return new WxPayJsSDKCallback();
    -  }
    -
       @Override
       public WxPayRefundResult refund(WxPayRefundRequest request, File keyFile)
           throws WxErrorException {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayJsSDKCallback.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayJsSDKCallback.java
    index 11b8b0d5..742f5e18 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayJsSDKCallback.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayJsSDKCallback.java
    @@ -3,281 +3,277 @@ package me.chanjar.weixin.mp.bean.pay;
     import java.io.Serializable;
     
     /**
    - * pre> 订单支付状态回调
    - *
    + * 
    + * 订单支付状态回调
      * 支付结果通知(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7)
    - *
      * /pre>
      *
      * @author ukid
      */
     public class WxPayJsSDKCallback implements Serializable {
    -    /**
    -   *
    -   */
       private static final long serialVersionUID = -4143804055690843641L;
    -    private String return_code;
    -    private String return_msg;
    -
    -    private String appid;
    -    private String mch_id;
    -    private String device_info;
    -    private String nonce_str;
    -    private String sign;
    -    private String result_code;
    -    private String err_code;
    -    private String err_code_des;
    -    private String openid;
    -    private String is_subscribe;
    -    private String trade_type;
    -    private String bank_type;
    -    private String total_fee;
    -    private String fee_type;
    -    private String cash_fee;
    -    private String cash_fee_type;
    -    private String coupon_fee;
    -    private String coupon_count;
    -    private String coupon_batch_id_$n;
    -    private String coupon_id_$n;
    -    private String coupon_fee_$n;
    -    private String transaction_id;
    -    private String out_trade_no;
    -    private String attach;
    -    private String time_end;
    -
    -    public String getReturn_code() {
    -        return this.return_code;
    -    }
    -
    -    public String getReturn_msg() {
    -        return this.return_msg;
    -    }
    -
    -    public String getAppid() {
    -        return this.appid;
    -    }
    -
    -    public String getMch_id() {
    -        return this.mch_id;
    -    }
    -
    -    public String getDevice_info() {
    -        return this.device_info;
    -    }
    -
    -    public String getNonce_str() {
    -        return this.nonce_str;
    -    }
    -
    -    public String getSign() {
    -        return this.sign;
    -    }
    -
    -    public String getResult_code() {
    -        return this.result_code;
    -    }
    -
    -    public String getErr_code() {
    -        return this.err_code;
    -    }
    -
    -    public String getErr_code_des() {
    -        return this.err_code_des;
    -    }
    -
    -    public String getOpenid() {
    -        return this.openid;
    -    }
    -
    -    public String getIs_subscribe() {
    -        return this.is_subscribe;
    -    }
    -
    -    public String getTrade_type() {
    -        return this.trade_type;
    -    }
    -
    -    public String getBank_type() {
    -        return this.bank_type;
    -    }
    -
    -    public String getTotal_fee() {
    -        return this.total_fee;
    -    }
    -
    -    public String getFee_type() {
    -        return this.fee_type;
    -    }
    -
    -    public String getCash_fee() {
    -        return this.cash_fee;
    -    }
    -
    -    public String getCash_fee_type() {
    -        return this.cash_fee_type;
    -    }
    -
    -    public String getCoupon_fee() {
    -        return this.coupon_fee;
    -    }
    -
    -    public String getCoupon_count() {
    -        return this.coupon_count;
    -    }
    -
    -    public String getCoupon_batch_id_$n() {
    -        return this.coupon_batch_id_$n;
    -    }
    -
    -    public String getCoupon_id_$n() {
    -        return this.coupon_id_$n;
    -    }
    -
    -    public String getCoupon_fee_$n() {
    -        return this.coupon_fee_$n;
    -    }
    -
    -    public String getTransaction_id() {
    -        return this.transaction_id;
    -    }
    +  private String return_code;
    +  private String return_msg;
    +
    +  private String appid;
    +  private String mch_id;
    +  private String device_info;
    +  private String nonce_str;
    +  private String sign;
    +  private String result_code;
    +  private String err_code;
    +  private String err_code_des;
    +  private String openid;
    +  private String is_subscribe;
    +  private String trade_type;
    +  private String bank_type;
    +  private String total_fee;
    +  private String fee_type;
    +  private String cash_fee;
    +  private String cash_fee_type;
    +  private String coupon_fee;
    +  private String coupon_count;
    +  private String coupon_batch_id_$n;
    +  private String coupon_id_$n;
    +  private String coupon_fee_$n;
    +  private String transaction_id;
    +  private String out_trade_no;
    +  private String attach;
    +  private String time_end;
    +
    +  public String getReturn_code() {
    +    return this.return_code;
    +  }
    +
    +  public void setReturn_code(String return_code) {
    +    this.return_code = return_code;
    +  }
    +
    +  public String getReturn_msg() {
    +    return this.return_msg;
    +  }
    +
    +  public void setReturn_msg(String return_msg) {
    +    this.return_msg = return_msg;
    +  }
    +
    +  public String getAppid() {
    +    return this.appid;
    +  }
    +
    +  public void setAppid(String appid) {
    +    this.appid = appid;
    +  }
    +
    +  public String getMch_id() {
    +    return this.mch_id;
    +  }
    +
    +  public void setMch_id(String mch_id) {
    +    this.mch_id = mch_id;
    +  }
    +
    +  public String getDevice_info() {
    +    return this.device_info;
    +  }
    +
    +  public void setDevice_info(String device_info) {
    +    this.device_info = device_info;
    +  }
    +
    +  public String getNonce_str() {
    +    return this.nonce_str;
    +  }
    +
    +  public void setNonce_str(String nonce_str) {
    +    this.nonce_str = nonce_str;
    +  }
    +
    +  public String getSign() {
    +    return this.sign;
    +  }
    +
    +  public void setSign(String sign) {
    +    this.sign = sign;
    +  }
    +
    +  public String getResult_code() {
    +    return this.result_code;
    +  }
    +
    +  public void setResult_code(String result_code) {
    +    this.result_code = result_code;
    +  }
    +
    +  public String getErr_code() {
    +    return this.err_code;
    +  }
    +
    +  public void setErr_code(String err_code) {
    +    this.err_code = err_code;
    +  }
    +
    +  public String getErr_code_des() {
    +    return this.err_code_des;
    +  }
    +
    +  public void setErr_code_des(String err_code_des) {
    +    this.err_code_des = err_code_des;
    +  }
    +
    +  public String getOpenid() {
    +    return this.openid;
    +  }
    +
    +  public void setOpenid(String openid) {
    +    this.openid = openid;
    +  }
    +
    +  public String getIs_subscribe() {
    +    return this.is_subscribe;
    +  }
    +
    +  public void setIs_subscribe(String is_subscribe) {
    +    this.is_subscribe = is_subscribe;
    +  }
     
    -    public String getOut_trade_no() {
    -        return this.out_trade_no;
    -    }
    +  public String getTrade_type() {
    +    return this.trade_type;
    +  }
     
    -    public String getAttach() {
    -        return this.attach;
    -    }
    +  public void setTrade_type(String trade_type) {
    +    this.trade_type = trade_type;
    +  }
     
    -    public String getTime_end() {
    -        return this.time_end;
    -    }
    +  public String getBank_type() {
    +    return this.bank_type;
    +  }
     
    -    public void setReturn_code(String return_code) {
    -        this.return_code = return_code;
    -    }
    +  public void setBank_type(String bank_type) {
    +    this.bank_type = bank_type;
    +  }
     
    -    public void setReturn_msg(String return_msg) {
    -        this.return_msg = return_msg;
    -    }
    +  public String getTotal_fee() {
    +    return this.total_fee;
    +  }
     
    -    public void setAppid(String appid) {
    -        this.appid = appid;
    -    }
    +  public void setTotal_fee(String total_fee) {
    +    this.total_fee = total_fee;
    +  }
     
    -    public void setMch_id(String mch_id) {
    -        this.mch_id = mch_id;
    -    }
    -
    -    public void setDevice_info(String device_info) {
    -        this.device_info = device_info;
    -    }
    -
    -    public void setNonce_str(String nonce_str) {
    -        this.nonce_str = nonce_str;
    -    }
    -
    -    public void setSign(String sign) {
    -        this.sign = sign;
    -    }
    -
    -    public void setResult_code(String result_code) {
    -        this.result_code = result_code;
    -    }
    -
    -    public void setErr_code(String err_code) {
    -        this.err_code = err_code;
    -    }
    -
    -    public void setErr_code_des(String err_code_des) {
    -        this.err_code_des = err_code_des;
    -    }
    -
    -    public void setOpenid(String openid) {
    -        this.openid = openid;
    -    }
    -
    -    public void setIs_subscribe(String is_subscribe) {
    -        this.is_subscribe = is_subscribe;
    -    }
    -
    -    public void setTrade_type(String trade_type) {
    -        this.trade_type = trade_type;
    -    }
    -
    -    public void setBank_type(String bank_type) {
    -        this.bank_type = bank_type;
    -    }
    -
    -    public void setTotal_fee(String total_fee) {
    -        this.total_fee = total_fee;
    -    }
    -
    -    public void setFee_type(String fee_type) {
    -        this.fee_type = fee_type;
    -    }
    -
    -    public void setCash_fee(String cash_fee) {
    -        this.cash_fee = cash_fee;
    -    }
    -
    -    public void setCash_fee_type(String cash_fee_type) {
    -        this.cash_fee_type = cash_fee_type;
    -    }
    -
    -    public void setCoupon_fee(String coupon_fee) {
    -        this.coupon_fee = coupon_fee;
    -    }
    -
    -    public void setCoupon_count(String coupon_count) {
    -        this.coupon_count = coupon_count;
    -    }
    -
    -    public void setCoupon_batch_id_$n(String coupon_batch_id_$n) {
    -        this.coupon_batch_id_$n = coupon_batch_id_$n;
    -    }
    -
    -    public void setCoupon_id_$n(String coupon_id_$n) {
    -        this.coupon_id_$n = coupon_id_$n;
    -    }
    -
    -    public void setCoupon_fee_$n(String coupon_fee_$n) {
    -        this.coupon_fee_$n = coupon_fee_$n;
    -    }
    -
    -    public void setTransaction_id(String transaction_id) {
    -        this.transaction_id = transaction_id;
    -    }
    -
    -    public void setOut_trade_no(String out_trade_no) {
    -        this.out_trade_no = out_trade_no;
    -    }
    -
    -    public void setAttach(String attach) {
    -        this.attach = attach;
    -    }
    -
    -    public void setTime_end(String time_end) {
    -        this.time_end = time_end;
    -    }
    -
    -    @Override
    -    public String toString() {
    -        return "WxPayJsSDKCallback [return_code=" + this.return_code + ", return_msg="
    -                + this.return_msg + ", appid=" + this.appid + ", mch_id=" + this.mch_id
    -                + ", device_info=" + this.device_info + ", nonce_str=" + this.nonce_str
    -                + ", sign=" + this.sign + ", result_code=" + this.result_code
    -                + ", err_code=" + this.err_code + ", err_code_des=" + this.err_code_des
    -                + ", openid=" + this.openid + ", is_subscribe=" + this.is_subscribe
    -                + ", trade_type=" + this.trade_type + ", bank_type=" + this.bank_type
    -                + ", total_fee=" + this.total_fee + ", fee_type=" + this.fee_type
    -                + ", cash_fee=" + this.cash_fee + ", cash_fee_type=" + this.cash_fee_type
    -                + ", coupon_fee=" + this.coupon_fee + ", coupon_count="
    -                + this.coupon_count + ", coupon_batch_id_$n=" + this.coupon_batch_id_$n
    -                + ", coupon_id_$n=" + this.coupon_id_$n + ", coupon_fee_$n="
    -                + this.coupon_fee_$n + ", transaction_id=" + this.transaction_id
    -                + ", out_trade_no=" + this.out_trade_no + ", attach=" + this.attach
    -                + ", time_end=" + this.time_end + "]";
    -    }
    +  public String getFee_type() {
    +    return this.fee_type;
    +  }
    +
    +  public void setFee_type(String fee_type) {
    +    this.fee_type = fee_type;
    +  }
    +
    +  public String getCash_fee() {
    +    return this.cash_fee;
    +  }
    +
    +  public void setCash_fee(String cash_fee) {
    +    this.cash_fee = cash_fee;
    +  }
    +
    +  public String getCash_fee_type() {
    +    return this.cash_fee_type;
    +  }
    +
    +  public void setCash_fee_type(String cash_fee_type) {
    +    this.cash_fee_type = cash_fee_type;
    +  }
    +
    +  public String getCoupon_fee() {
    +    return this.coupon_fee;
    +  }
    +
    +  public void setCoupon_fee(String coupon_fee) {
    +    this.coupon_fee = coupon_fee;
    +  }
    +
    +  public String getCoupon_count() {
    +    return this.coupon_count;
    +  }
    +
    +  public void setCoupon_count(String coupon_count) {
    +    this.coupon_count = coupon_count;
    +  }
    +
    +  public String getCoupon_batch_id_$n() {
    +    return this.coupon_batch_id_$n;
    +  }
    +
    +  public void setCoupon_batch_id_$n(String coupon_batch_id_$n) {
    +    this.coupon_batch_id_$n = coupon_batch_id_$n;
    +  }
    +
    +  public String getCoupon_id_$n() {
    +    return this.coupon_id_$n;
    +  }
    +
    +  public void setCoupon_id_$n(String coupon_id_$n) {
    +    this.coupon_id_$n = coupon_id_$n;
    +  }
    +
    +  public String getCoupon_fee_$n() {
    +    return this.coupon_fee_$n;
    +  }
    +
    +  public void setCoupon_fee_$n(String coupon_fee_$n) {
    +    this.coupon_fee_$n = coupon_fee_$n;
    +  }
    +
    +  public String getTransaction_id() {
    +    return this.transaction_id;
    +  }
    +
    +  public void setTransaction_id(String transaction_id) {
    +    this.transaction_id = transaction_id;
    +  }
    +
    +  public String getOut_trade_no() {
    +    return this.out_trade_no;
    +  }
    +
    +  public void setOut_trade_no(String out_trade_no) {
    +    this.out_trade_no = out_trade_no;
    +  }
    +
    +  public String getAttach() {
    +    return this.attach;
    +  }
    +
    +  public void setAttach(String attach) {
    +    this.attach = attach;
    +  }
    +
    +  public String getTime_end() {
    +    return this.time_end;
    +  }
    +
    +  public void setTime_end(String time_end) {
    +    this.time_end = time_end;
    +  }
    +
    +  @Override
    +  public String toString() {
    +    return "WxPayJsSDKCallback [return_code=" + this.return_code + ", return_msg="
    +      + this.return_msg + ", appid=" + this.appid + ", mch_id=" + this.mch_id
    +      + ", device_info=" + this.device_info + ", nonce_str=" + this.nonce_str
    +      + ", sign=" + this.sign + ", result_code=" + this.result_code
    +      + ", err_code=" + this.err_code + ", err_code_des=" + this.err_code_des
    +      + ", openid=" + this.openid + ", is_subscribe=" + this.is_subscribe
    +      + ", trade_type=" + this.trade_type + ", bank_type=" + this.bank_type
    +      + ", total_fee=" + this.total_fee + ", fee_type=" + this.fee_type
    +      + ", cash_fee=" + this.cash_fee + ", cash_fee_type=" + this.cash_fee_type
    +      + ", coupon_fee=" + this.coupon_fee + ", coupon_count="
    +      + this.coupon_count + ", coupon_batch_id_$n=" + this.coupon_batch_id_$n
    +      + ", coupon_id_$n=" + this.coupon_id_$n + ", coupon_fee_$n="
    +      + this.coupon_fee_$n + ", transaction_id=" + this.transaction_id
    +      + ", out_trade_no=" + this.out_trade_no + ", attach=" + this.attach
    +      + ", time_end=" + this.time_end + "]";
    +  }
     
     }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayQueryRequest.java
    similarity index 97%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayQueryRequest.java
    index 512ac159..47612ad3 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayQueryRequest.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     import me.chanjar.weixin.common.annotation.Required;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayRequest.java
    similarity index 99%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayRequest.java
    index 07549ab3..6f019c1e 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayRequest.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.request;
     
     import org.apache.commons.lang3.builder.ToStringBuilder;
     import org.apache.commons.lang3.builder.ToStringStyle;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayBaseRequest.java
    similarity index 97%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseRequest.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayBaseRequest.java
    index 062152d8..a66f9379 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayBaseRequest.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     import org.apache.commons.lang3.builder.ToStringBuilder;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayOrderQueryRequest.java
    similarity index 96%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryRequest.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayOrderQueryRequest.java
    index ede1b06a..153831d3 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayOrderQueryRequest.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayRefundRequest.java
    similarity index 99%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundRequest.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayRefundRequest.java
    index bc2802b7..f816fd0c 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayRefundRequest.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     import me.chanjar.weixin.common.annotation.Required;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPaySendRedpackRequest.java
    similarity index 99%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackRequest.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPaySendRedpackRequest.java
    index 27a46a71..cad2cc52 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPaySendRedpackRequest.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayUnifiedOrderRequest.java
    similarity index 99%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderRequest.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayUnifiedOrderRequest.java
    index de3518ae..1a6f3f80 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayUnifiedOrderRequest.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     import me.chanjar.weixin.common.annotation.Required;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java
    similarity index 98%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java
    index 382a8858..5682a393 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayQueryResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayResult.java
    similarity index 97%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayResult.java
    index 07bac47b..61679b6a 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxEntPayResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayResult.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayBaseResult.java
    similarity index 98%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseResult.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayBaseResult.java
    index cdec8273..18b33748 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayBaseResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayBaseResult.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     import org.apache.commons.lang3.builder.ToStringBuilder;
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayOrderQueryResult.java
    similarity index 98%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryResult.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayOrderQueryResult.java
    index 25dc6cc8..679c70c9 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayOrderQueryResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayOrderQueryResult.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.result;
     
     import com.google.common.collect.Lists;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    @@ -436,7 +436,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public void composeCoupons(String xmlString){
    -    if(this.couponCount > 0 ){
    +    if(this.couponCount != null && this.couponCount > 0 ){
           this.coupons = Lists.newArrayList();
           //TODO 暂时待实现
         }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayRefundResult.java
    similarity index 98%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundResult.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayRefundResult.java
    index ad20b8f1..5be68d94 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayRefundResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayRefundResult.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPaySendRedpackResult.java
    similarity index 97%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackResult.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPaySendRedpackResult.java
    index 4a5ab146..d53fb693 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPaySendRedpackResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPaySendRedpackResult.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayUnifiedOrderResult.java
    similarity index 95%
    rename from weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderResult.java
    rename to weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayUnifiedOrderResult.java
    index 012da5a4..70c13519 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/WxPayUnifiedOrderResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayUnifiedOrderResult.java
    @@ -1,4 +1,4 @@
    -package me.chanjar.weixin.mp.bean.pay;
    +package me.chanjar.weixin.mp.bean.pay.result;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     
    diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java
    index 51414e1b..0f946dc3 100644
    --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java
    +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImplTest.java
    @@ -4,7 +4,13 @@ import com.google.inject.Inject;
     import me.chanjar.weixin.common.exception.WxErrorException;
     import me.chanjar.weixin.mp.api.ApiTestModule;
     import me.chanjar.weixin.mp.api.WxXmlMpInMemoryConfigStorage;
    -import me.chanjar.weixin.mp.bean.pay.*;
    +import me.chanjar.weixin.mp.bean.pay.request.WxEntPayRequest;
    +import me.chanjar.weixin.mp.bean.pay.request.WxPayRefundRequest;
    +import me.chanjar.weixin.mp.bean.pay.request.WxPaySendRedpackRequest;
    +import me.chanjar.weixin.mp.bean.pay.request.WxPayUnifiedOrderRequest;
    +import me.chanjar.weixin.mp.bean.pay.result.WxPayRefundResult;
    +import me.chanjar.weixin.mp.bean.pay.result.WxPaySendRedpackResult;
    +import me.chanjar.weixin.mp.bean.pay.result.WxPayUnifiedOrderResult;
     import org.testng.annotations.Guice;
     import org.testng.annotations.Test;
     
    @@ -27,11 +33,6 @@ public class WxMpPayServiceImplTest {
     
       }
     
    -  @Test
    -  public void testGetJSSDKCallbackData() throws Exception {
    -
    -  }
    -
       @Test
       public void testRefund() throws Exception {
         WxPayRefundRequest request = new WxPayRefundRequest();
    diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxRedpackResultTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/pay/result/WxPaySendRedpackResultTest.java
    similarity index 71%
    rename from weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxRedpackResultTest.java
    rename to weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/pay/result/WxPaySendRedpackResultTest.java
    index 557065ca..a07ec972 100644
    --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/WxRedpackResultTest.java
    +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/pay/result/WxPaySendRedpackResultTest.java
    @@ -1,26 +1,23 @@
    -package me.chanjar.weixin.mp.bean;
    -
    -import static org.junit.Assert.assertEquals;
    -
    -import org.junit.Before;
    -import org.junit.Test;
    +package me.chanjar.weixin.mp.bean.pay.result;
     
     import com.thoughtworks.xstream.XStream;
    -
     import me.chanjar.weixin.common.util.xml.XStreamInitializer;
    -import me.chanjar.weixin.mp.bean.pay.WxPaySendRedpackResult;
    +import org.testng.Assert;
    +import org.testng.annotations.BeforeTest;
    +import org.testng.annotations.Test;
     
    -public class WxRedpackResultTest {
    +public class WxPaySendRedpackResultTest {
     
       private XStream xstream;
     
    -  @Before
    +  @BeforeTest
       public void setup() {
          this.xstream = XStreamInitializer.getInstance();
          this.xstream.processAnnotations(WxPaySendRedpackResult.class);
       }
     
    -  @Test public void loadSuccessResult() {
    +  @Test
    +  public void loadSuccessResult() {
         final String successSample = "\n" +
             "\n" +
             "\n" +
    @@ -36,12 +33,13 @@ public class WxRedpackResultTest {
             "20150520102602\n" +
             "";
         WxPaySendRedpackResult wxMpRedpackResult = (WxPaySendRedpackResult) this.xstream.fromXML(successSample);
    -    assertEquals("SUCCESS", wxMpRedpackResult.getReturnCode());
    -    assertEquals("SUCCESS", wxMpRedpackResult.getResultCode());
    -    assertEquals("20150520102602", wxMpRedpackResult.getSendTime());
    +    Assert.assertEquals("SUCCESS", wxMpRedpackResult.getReturnCode());
    +    Assert.assertEquals("SUCCESS", wxMpRedpackResult.getResultCode());
    +    Assert.assertEquals("20150520102602", wxMpRedpackResult.getSendTime());
       }
     
    -  @Test public void loadFailureResult() {
    +  @Test
    +  public void loadFailureResult() {
         final String failureSample = "\n" +
             "\n" +
             "\n" +
    @@ -55,9 +53,9 @@ public class WxRedpackResultTest {
             "1\n" +
             "";
         WxPaySendRedpackResult wxMpRedpackResult = (WxPaySendRedpackResult) this.xstream.fromXML(failureSample);
    -    assertEquals("FAIL", wxMpRedpackResult.getReturnCode());
    -    assertEquals("FAIL", wxMpRedpackResult.getResultCode());
    -    assertEquals("onqOjjmM1tad-3ROpncN-yUfa6uI", wxMpRedpackResult.getReOpenid());
    -    assertEquals(1, wxMpRedpackResult.getTotalAmount());
    +    Assert.assertEquals("FAIL", wxMpRedpackResult.getReturnCode());
    +    Assert.assertEquals("FAIL", wxMpRedpackResult.getResultCode());
    +    Assert.assertEquals("onqOjjmM1tad-3ROpncN-yUfa6uI", wxMpRedpackResult.getReOpenid());
    +    Assert.assertEquals(1, wxMpRedpackResult.getTotalAmount());
       }
     }
    
    From 8a376f5dc9725e49e0d976221e87a004231c8f18 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Tue, 25 Oct 2016 14:26:37 +0800
    Subject: [PATCH 74/76] =?UTF-8?q?=E9=87=8D=E6=9E=84=E8=A7=84=E8=8C=83?=
     =?UTF-8?q?=E5=8C=96=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E7=9B=B8=E5=85=B3?=
     =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=B1=BB?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../pay/request/WxEntPayQueryRequest.java     | 37 +++-------
     .../mp/bean/pay/request/WxEntPayRequest.java  | 24 +++----
     .../mp/bean/pay/request/WxPayBaseRequest.java | 11 +--
     .../pay/request/WxPayOrderQueryRequest.java   |  4 +-
     .../bean/pay/request/WxPayRefundRequest.java  | 27 ++++----
     .../pay/request/WxPayUnifiedOrderRequest.java | 32 +--------
     .../bean/pay/result/WxEntPayQueryResult.java  | 22 +++---
     .../mp/bean/pay/result/WxEntPayResult.java    | 10 +--
     .../mp/bean/pay/result/WxPayBaseResult.java   | 21 +++---
     .../pay/result/WxPayOrderQueryResult.java     | 67 +++++++++++++------
     .../mp/bean/pay/result/WxPayRefundResult.java | 20 +-----
     .../pay/result/WxPaySendRedpackResult.java    | 16 ++---
     12 files changed, 127 insertions(+), 164 deletions(-)
    
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayQueryRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayQueryRequest.java
    index 47612ad3..499e111d 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayQueryRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayQueryRequest.java
    @@ -1,10 +1,12 @@
     package me.chanjar.weixin.mp.bean.pay.request;
     
    -import com.thoughtworks.xstream.annotations.XStreamAlias;
    -import me.chanjar.weixin.common.annotation.Required;
     import org.apache.commons.lang3.builder.ToStringBuilder;
     import org.apache.commons.lang3.builder.ToStringStyle;
     
    +import com.thoughtworks.xstream.annotations.XStreamAlias;
    +
    +import me.chanjar.weixin.common.annotation.Required;
    +
     /**
      * 
      * 企业付款请求对象
    @@ -31,6 +33,7 @@ public class WxEntPayQueryRequest extends WxPayBaseRequest {
        * 微信支付分配的商户号
        * 
    */ + @SuppressWarnings("hiding") @XStreamAlias("mchid") private String mchId; @@ -48,40 +51,18 @@ public class WxEntPayQueryRequest extends WxPayBaseRequest { @XStreamAlias("partner_trade_no") private String partnerTradeNo; - public String getAppid() { - return appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - + @Override public String getMchId() { - return mchId; + return this.mchId; } + @Override public void setMchId(String mchId) { this.mchId = mchId; } - public String getNonceStr() { - return nonceStr; - } - - public void setNonceStr(String nonceStr) { - this.nonceStr = nonceStr; - } - - public String getSign() { - return sign; - } - - public void setSign(String sign) { - this.sign = sign; - } - public String getPartnerTradeNo() { - return partnerTradeNo; + return this.partnerTradeNo; } public void setPartnerTradeNo(String partnerTradeNo) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayRequest.java index 6f019c1e..196ef95f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxEntPayRequest.java @@ -181,7 +181,7 @@ public class WxEntPayRequest { private String spbillCreateIp; public String getMchAppid() { - return mchAppid; + return this.mchAppid; } public void setMchAppid(String mchAppid) { @@ -189,7 +189,7 @@ public class WxEntPayRequest { } public String getMchId() { - return mchId; + return this.mchId; } public void setMchId(String mchId) { @@ -197,7 +197,7 @@ public class WxEntPayRequest { } public String getDeviceInfo() { - return deviceInfo; + return this.deviceInfo; } public void setDeviceInfo(String deviceInfo) { @@ -205,7 +205,7 @@ public class WxEntPayRequest { } public String getNonceStr() { - return nonceStr; + return this.nonceStr; } public void setNonceStr(String nonceStr) { @@ -213,7 +213,7 @@ public class WxEntPayRequest { } public String getSign() { - return sign; + return this.sign; } public void setSign(String sign) { @@ -221,7 +221,7 @@ public class WxEntPayRequest { } public String getPartnerTradeNo() { - return partnerTradeNo; + return this.partnerTradeNo; } public void setPartnerTradeNo(String partnerTradeNo) { @@ -229,7 +229,7 @@ public class WxEntPayRequest { } public String getOpenid() { - return openid; + return this.openid; } public void setOpenid(String openid) { @@ -237,7 +237,7 @@ public class WxEntPayRequest { } public String getCheckName() { - return checkName; + return this.checkName; } public void setCheckName(String checkName) { @@ -245,7 +245,7 @@ public class WxEntPayRequest { } public String getReUserName() { - return reUserName; + return this.reUserName; } public void setReUserName(String reUserName) { @@ -253,7 +253,7 @@ public class WxEntPayRequest { } public Integer getAmount() { - return amount; + return this.amount; } public void setAmount(Integer amount) { @@ -261,7 +261,7 @@ public class WxEntPayRequest { } public String getDescription() { - return description; + return this.description; } public void setDescription(String description) { @@ -269,7 +269,7 @@ public class WxEntPayRequest { } public String getSpbillCreateIp() { - return spbillCreateIp; + return this.spbillCreateIp; } public void setSpbillCreateIp(String spbillCreateIp) { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayBaseRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayBaseRequest.java index a66f9379..aabbdfd1 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayBaseRequest.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayBaseRequest.java @@ -1,9 +1,10 @@ package me.chanjar.weixin.mp.bean.pay.request; -import com.thoughtworks.xstream.annotations.XStreamAlias; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import com.thoughtworks.xstream.annotations.XStreamAlias; + /** *
      * Created by Binary Wang on 2016-10-24.
    @@ -69,7 +70,7 @@ public abstract class WxPayBaseRequest {
       protected String sign;
     
       public String getAppid() {
    -    return appid;
    +    return this.appid;
       }
     
       public void setAppid(String appid) {
    @@ -77,7 +78,7 @@ public abstract class WxPayBaseRequest {
       }
     
       public String getMchId() {
    -    return mchId;
    +    return this.mchId;
       }
     
       public void setMchId(String mchId) {
    @@ -85,7 +86,7 @@ public abstract class WxPayBaseRequest {
       }
     
       public String getNonceStr() {
    -    return nonceStr;
    +    return this.nonceStr;
       }
     
       public void setNonceStr(String nonceStr) {
    @@ -93,7 +94,7 @@ public abstract class WxPayBaseRequest {
       }
     
       public String getSign() {
    -    return sign;
    +    return this.sign;
       }
     
       public void setSign(String sign) {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayOrderQueryRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayOrderQueryRequest.java
    index 153831d3..3cc7dd2b 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayOrderQueryRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayOrderQueryRequest.java
    @@ -46,7 +46,7 @@ public class WxPayOrderQueryRequest extends WxPayBaseRequest {
       private String outTradeNo;
     
       public String getTransactionId() {
    -    return transactionId;
    +    return this.transactionId;
       }
     
       public void setTransactionId(String transactionId) {
    @@ -54,7 +54,7 @@ public class WxPayOrderQueryRequest extends WxPayBaseRequest {
       }
     
       public String getOutTradeNo() {
    -    return outTradeNo;
    +    return this.outTradeNo;
       }
     
       public void setOutTradeNo(String outTradeNo) {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayRefundRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayRefundRequest.java
    index f816fd0c..9a0c0178 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayRefundRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayRefundRequest.java
    @@ -1,6 +1,7 @@
     package me.chanjar.weixin.mp.bean.pay.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +
     import me.chanjar.weixin.common.annotation.Required;
     
     /**
    @@ -196,7 +197,7 @@ public class WxPayRefundRequest {
       private String refundAccount;
     
       public String getAppid() {
    -    return appid;
    +    return this.appid;
       }
     
       public void setAppid(String appid) {
    @@ -204,7 +205,7 @@ public class WxPayRefundRequest {
       }
     
       public String getMchId() {
    -    return mchId;
    +    return this.mchId;
       }
     
       public void setMchId(String mchId) {
    @@ -212,7 +213,7 @@ public class WxPayRefundRequest {
       }
     
       public String getDeviceInfo() {
    -    return deviceInfo;
    +    return this.deviceInfo;
       }
     
       public void setDeviceInfo(String deviceInfo) {
    @@ -220,7 +221,7 @@ public class WxPayRefundRequest {
       }
     
       public String getNonceStr() {
    -    return nonceStr;
    +    return this.nonceStr;
       }
     
       public void setNonceStr(String nonceStr) {
    @@ -228,7 +229,7 @@ public class WxPayRefundRequest {
       }
     
       public String getSign() {
    -    return sign;
    +    return this.sign;
       }
     
       public void setSign(String sign) {
    @@ -236,7 +237,7 @@ public class WxPayRefundRequest {
       }
     
       public String getTransactionId() {
    -    return transactionId;
    +    return this.transactionId;
       }
     
       public void setTransactionId(String transactionId) {
    @@ -244,7 +245,7 @@ public class WxPayRefundRequest {
       }
     
       public String getOutTradeNo() {
    -    return outTradeNo;
    +    return this.outTradeNo;
       }
     
       public void setOutTradeNo(String outTradeNo) {
    @@ -252,7 +253,7 @@ public class WxPayRefundRequest {
       }
     
       public String getOutRefundNo() {
    -    return outRefundNo;
    +    return this.outRefundNo;
       }
     
       public void setOutRefundNo(String outRefundNo) {
    @@ -260,7 +261,7 @@ public class WxPayRefundRequest {
       }
     
       public Integer getTotalFee() {
    -    return totalFee;
    +    return this.totalFee;
       }
     
       public void setTotalFee(Integer totalFee) {
    @@ -268,7 +269,7 @@ public class WxPayRefundRequest {
       }
     
       public Integer getRefundFee() {
    -    return refundFee;
    +    return this.refundFee;
       }
     
       public void setRefundFee(Integer refundFee) {
    @@ -276,7 +277,7 @@ public class WxPayRefundRequest {
       }
     
       public String getRefundFeeType() {
    -    return refundFeeType;
    +    return this.refundFeeType;
       }
     
       public void setRefundFeeType(String refundFeeType) {
    @@ -284,7 +285,7 @@ public class WxPayRefundRequest {
       }
     
       public String getOpUserId() {
    -    return opUserId;
    +    return this.opUserId;
       }
     
       public void setOpUserId(String opUserId) {
    @@ -292,7 +293,7 @@ public class WxPayRefundRequest {
       }
     
       public String getRefundAccount() {
    -    return refundAccount;
    +    return this.refundAccount;
       }
     
       public void setRefundAccount(String refundAccount) {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayUnifiedOrderRequest.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayUnifiedOrderRequest.java
    index 1a6f3f80..195e13b0 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayUnifiedOrderRequest.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/request/WxPayUnifiedOrderRequest.java
    @@ -1,6 +1,7 @@
     package me.chanjar.weixin.mp.bean.pay.request;
     
     import com.thoughtworks.xstream.annotations.XStreamAlias;
    +
     import me.chanjar.weixin.common.annotation.Required;
     
     /**
    @@ -266,21 +267,6 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest {
       @XStreamAlias("openid")
       private String openid;
     
    -  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 getDeviceInfo() {
         return this.deviceInfo;
    @@ -290,22 +276,6 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest {
         this.deviceInfo = deviceInfo;
       }
     
    -  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 getBody() {
         return this.body;
       }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java
    index 5682a393..d74c0b41 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java
    @@ -66,7 +66,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       private String desc;
     
       public String getReturnCode() {
    -    return returnCode;
    +    return this.returnCode;
       }
     
       public void setReturnCode(String returnCode) {
    @@ -74,7 +74,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       }
     
       public String getReturnMsg() {
    -    return returnMsg;
    +    return this.returnMsg;
       }
     
       public void setReturnMsg(String returnMsg) {
    @@ -82,7 +82,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       }
     
       public String getPartnerTradeNo() {
    -    return partnerTradeNo;
    +    return this.partnerTradeNo;
       }
     
       public void setPartnerTradeNo(String partnerTradeNo) {
    @@ -90,7 +90,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       }
     
       public String getDetailId() {
    -    return detailId;
    +    return this.detailId;
       }
     
       public void setDetailId(String detailId) {
    @@ -98,7 +98,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       }
     
       public String getStatus() {
    -    return status;
    +    return this.status;
       }
     
       public void setStatus(String status) {
    @@ -106,7 +106,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       }
     
       public String getReason() {
    -    return reason;
    +    return this.reason;
       }
     
       public void setReason(String reason) {
    @@ -114,7 +114,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       }
     
       public String getOpenid() {
    -    return openid;
    +    return this.openid;
       }
     
       public void setOpenid(String openid) {
    @@ -122,7 +122,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       }
     
       public String getTransferName() {
    -    return transferName;
    +    return this.transferName;
       }
     
       public void setTransferName(String transferName) {
    @@ -130,7 +130,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       }
     
       public Integer getPaymentAmount() {
    -    return paymentAmount;
    +    return this.paymentAmount;
       }
     
       public void setPaymentAmount(Integer paymentAmount) {
    @@ -138,7 +138,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       }
     
       public String getTransferTime() {
    -    return transferTime;
    +    return this.transferTime;
       }
     
       public void setTransferTime(String transferTime) {
    @@ -146,7 +146,7 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       }
     
       public String getDesc() {
    -    return desc;
    +    return this.desc;
       }
     
       public void setDesc(String desc) {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayResult.java
    index 61679b6a..5a8c4b75 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayResult.java
    @@ -42,7 +42,7 @@ public class WxEntPayResult extends WxPayBaseResult {
       private String paymentTime;
     
       public String getMchAppid() {
    -    return mchAppid;
    +    return this.mchAppid;
       }
     
       public void setMchAppid(String mchAppid) {
    @@ -50,7 +50,7 @@ public class WxEntPayResult extends WxPayBaseResult {
       }
     
       public String getDeviceInfo() {
    -    return deviceInfo;
    +    return this.deviceInfo;
       }
     
       public void setDeviceInfo(String deviceInfo) {
    @@ -58,7 +58,7 @@ public class WxEntPayResult extends WxPayBaseResult {
       }
     
       public String getPartnerTradeNo() {
    -    return partnerTradeNo;
    +    return this.partnerTradeNo;
       }
     
       public void setPartnerTradeNo(String partnerTradeNo) {
    @@ -66,7 +66,7 @@ public class WxEntPayResult extends WxPayBaseResult {
       }
     
       public String getPaymentNo() {
    -    return paymentNo;
    +    return this.paymentNo;
       }
     
       public void setPaymentNo(String paymentNo) {
    @@ -74,7 +74,7 @@ public class WxEntPayResult extends WxPayBaseResult {
       }
     
       public String getPaymentTime() {
    -    return paymentTime;
    +    return this.paymentTime;
       }
     
       public void setPaymentTime(String paymentTime) {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayBaseResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayBaseResult.java
    index 18b33748..79f8dbb5 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayBaseResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayBaseResult.java
    @@ -1,9 +1,10 @@
     package me.chanjar.weixin.mp.bean.pay.result;
     
    -import com.thoughtworks.xstream.annotations.XStreamAlias;
     import org.apache.commons.lang3.builder.ToStringBuilder;
     import org.apache.commons.lang3.builder.ToStringStyle;
     
    +import com.thoughtworks.xstream.annotations.XStreamAlias;
    +
     /**
      * 
      * 微信支付结果共用属性类
    @@ -72,7 +73,7 @@ public abstract class WxPayBaseResult {
       private String sign;
     
       public String getReturnCode() {
    -    return returnCode;
    +    return this.returnCode;
       }
     
       public void setReturnCode(String returnCode) {
    @@ -80,7 +81,7 @@ public abstract class WxPayBaseResult {
       }
     
       public String getReturnMsg() {
    -    return returnMsg;
    +    return this.returnMsg;
       }
     
       public void setReturnMsg(String returnMsg) {
    @@ -88,7 +89,7 @@ public abstract class WxPayBaseResult {
       }
     
       public String getResultCode() {
    -    return resultCode;
    +    return this.resultCode;
       }
     
       public void setResultCode(String resultCode) {
    @@ -96,7 +97,7 @@ public abstract class WxPayBaseResult {
       }
     
       public String getErrCode() {
    -    return errCode;
    +    return this.errCode;
       }
     
       public void setErrCode(String errCode) {
    @@ -104,7 +105,7 @@ public abstract class WxPayBaseResult {
       }
     
       public String getErrCodeDes() {
    -    return errCodeDes;
    +    return this.errCodeDes;
       }
     
       public void setErrCodeDes(String errCodeDes) {
    @@ -112,7 +113,7 @@ public abstract class WxPayBaseResult {
       }
     
       public String getAppid() {
    -    return appid;
    +    return this.appid;
       }
     
       public void setAppid(String appid) {
    @@ -120,7 +121,7 @@ public abstract class WxPayBaseResult {
       }
     
       public String getMchId() {
    -    return mchId;
    +    return this.mchId;
       }
     
       public void setMchId(String mchId) {
    @@ -128,7 +129,7 @@ public abstract class WxPayBaseResult {
       }
     
       public String getNonceStr() {
    -    return nonceStr;
    +    return this.nonceStr;
       }
     
       public void setNonceStr(String nonceStr) {
    @@ -136,7 +137,7 @@ public abstract class WxPayBaseResult {
       }
     
       public String getSign() {
    -    return sign;
    +    return this.sign;
       }
     
       public void setSign(String sign) {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayOrderQueryResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayOrderQueryResult.java
    index 679c70c9..17b3a412 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayOrderQueryResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayOrderQueryResult.java
    @@ -1,10 +1,10 @@
     package me.chanjar.weixin.mp.bean.pay.result;
     
    +import java.util.List;
    +
     import com.google.common.collect.Lists;
     import com.thoughtworks.xstream.annotations.XStreamAlias;
     
    -import java.util.List;
    -
     /**
      * 
      *  查询订单 返回结果对象
    @@ -221,6 +221,31 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
           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;
    +    }
    +
       }
     
       /**
    @@ -284,7 +309,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       private String tradeStateDesc;
     
       public String getDeviceInfo() {
    -    return deviceInfo;
    +    return this.deviceInfo;
       }
     
       public void setDeviceInfo(String deviceInfo) {
    @@ -292,7 +317,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getOpenid() {
    -    return openid;
    +    return this.openid;
       }
     
       public void setOpenid(String openid) {
    @@ -300,7 +325,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getIsSubscribe() {
    -    return isSubscribe;
    +    return this.isSubscribe;
       }
     
       public void setIsSubscribe(String isSubscribe) {
    @@ -308,7 +333,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getTradeType() {
    -    return tradeType;
    +    return this.tradeType;
       }
     
       public void setTradeType(String tradeType) {
    @@ -316,7 +341,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getTradeState() {
    -    return tradeState;
    +    return this.tradeState;
       }
     
       public void setTradeState(String tradeState) {
    @@ -324,7 +349,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getBankType() {
    -    return bankType;
    +    return this.bankType;
       }
     
       public void setBankType(String bankType) {
    @@ -332,7 +357,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public Integer getTotalFee() {
    -    return totalFee;
    +    return this.totalFee;
       }
     
       public void setTotalFee(Integer totalFee) {
    @@ -340,7 +365,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public Integer getSettlementTotalFee() {
    -    return settlementTotalFee;
    +    return this.settlementTotalFee;
       }
     
       public void setSettlementTotalFee(Integer settlementTotalFee) {
    @@ -348,7 +373,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getFeeType() {
    -    return feeType;
    +    return this.feeType;
       }
     
       public void setFeeType(String feeType) {
    @@ -356,7 +381,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public Integer getCashFee() {
    -    return cashFee;
    +    return this.cashFee;
       }
     
       public void setCashFee(Integer cashFee) {
    @@ -364,7 +389,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getCashFeeType() {
    -    return cashFeeType;
    +    return this.cashFeeType;
       }
     
       public void setCashFeeType(String cashFeeType) {
    @@ -372,7 +397,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public Integer getCouponFee() {
    -    return couponFee;
    +    return this.couponFee;
       }
     
       public void setCouponFee(Integer couponFee) {
    @@ -380,7 +405,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public Integer getCouponCount() {
    -    return couponCount;
    +    return this.couponCount;
       }
     
       public void setCouponCount(Integer couponCount) {
    @@ -388,7 +413,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public List getCoupons() {
    -    return coupons;
    +    return this.coupons;
       }
     
       public void setCoupons(List coupons) {
    @@ -396,7 +421,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getTransactionId() {
    -    return transactionId;
    +    return this.transactionId;
       }
     
       public void setTransactionId(String transactionId) {
    @@ -404,7 +429,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getOutTradeNo() {
    -    return outTradeNo;
    +    return this.outTradeNo;
       }
     
       public void setOutTradeNo(String outTradeNo) {
    @@ -412,7 +437,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getAttach() {
    -    return attach;
    +    return this.attach;
       }
     
       public void setAttach(String attach) {
    @@ -420,7 +445,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getTimeEnd() {
    -    return timeEnd;
    +    return this.timeEnd;
       }
     
       public void setTimeEnd(String timeEnd) {
    @@ -428,7 +453,7 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
       }
     
       public String getTradeStateDesc() {
    -    return tradeStateDesc;
    +    return this.tradeStateDesc;
       }
     
       public void setTradeStateDesc(String tradeStateDesc) {
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayRefundResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayRefundResult.java
    index 5be68d94..d00e2db5 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayRefundResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPayRefundResult.java
    @@ -1,9 +1,9 @@
     package me.chanjar.weixin.mp.bean.pay.result;
     
    -import com.thoughtworks.xstream.annotations.XStreamAlias;
    -
     import java.io.Serializable;
     
    +import com.thoughtworks.xstream.annotations.XStreamAlias;
    +
     /**
      * 
      * 微信支付-申请退款返回结果
    @@ -58,22 +58,6 @@ public class WxPayRefundResult extends WxPayBaseResult implements Serializable{
       @XStreamAlias("coupon_refund_id")
       private String couponRefundId;
     
    -  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 getDeviceInfo() {
         return this.deviceInfo;
       }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPaySendRedpackResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPaySendRedpackResult.java
    index d53fb693..8fe009bc 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPaySendRedpackResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxPaySendRedpackResult.java
    @@ -1,9 +1,9 @@
     package me.chanjar.weixin.mp.bean.pay.result;
     
    -import com.thoughtworks.xstream.annotations.XStreamAlias;
    -
     import java.io.Serializable;
     
    +import com.thoughtworks.xstream.annotations.XStreamAlias;
    +
     /**
      * 向微信用户个人发现金红包返回结果
      * https://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_5
    @@ -33,7 +33,7 @@ public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializa
       private String sendListid;
     
       public String getMchBillno() {
    -    return mchBillno;
    +    return this.mchBillno;
       }
     
       public void setMchBillno(String mchBillno) {
    @@ -41,7 +41,7 @@ public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializa
       }
     
       public String getWxappid() {
    -    return wxappid;
    +    return this.wxappid;
       }
     
       public void setWxappid(String wxappid) {
    @@ -49,7 +49,7 @@ public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializa
       }
     
       public String getReOpenid() {
    -    return reOpenid;
    +    return this.reOpenid;
       }
     
       public void setReOpenid(String reOpenid) {
    @@ -57,7 +57,7 @@ public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializa
       }
     
       public int getTotalAmount() {
    -    return totalAmount;
    +    return this.totalAmount;
       }
     
       public void setTotalAmount(int totalAmount) {
    @@ -65,7 +65,7 @@ public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializa
       }
     
       public String getSendTime() {
    -    return sendTime;
    +    return this.sendTime;
       }
     
       public void setSendTime(String sendTime) {
    @@ -73,7 +73,7 @@ public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializa
       }
     
       public String getSendListid() {
    -    return sendListid;
    +    return this.sendListid;
       }
     
       public void setSendListid(String sendListid) {
    
    From 11452e6de09dfd41a8861df8946dfb3ec608e8e5 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Tue, 25 Oct 2016 14:32:29 +0800
    Subject: [PATCH 75/76] =?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
    
    ---
     .../mp/bean/pay/result/WxEntPayQueryResult.java | 17 -----------------
     .../weixin/mp/bean/template/WxMpTemplate.java   | 12 ++++++------
     .../weixin/mp/demo/WxMpEndpointServlet.java     |  3 +--
     .../weixin/mp/demo/WxMpOAuth2Servlet.java       |  3 +--
     4 files changed, 8 insertions(+), 27 deletions(-)
    
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java
    index d74c0b41..8ffbeff2 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/pay/result/WxEntPayQueryResult.java
    @@ -10,7 +10,6 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
     @XStreamAlias("xml")
     public class WxEntPayQueryResult extends WxPayBaseResult {
     
    -  //############以下字段在return_code 和result_code都为SUCCESS的时候有返回##############
       /**
        * 商户订单号
        */
    @@ -65,22 +64,6 @@ public class WxEntPayQueryResult extends WxPayBaseResult {
       @XStreamAlias("desc")
       private String desc;
     
    -  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 getPartnerTradeNo() {
         return this.partnerTradeNo;
       }
    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 ffa2711f..0b3a1e61 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
    @@ -76,7 +76,7 @@ public class WxMpTemplate {
       private String example;
     
       public String getTemplateId() {
    -    return templateId;
    +    return this.templateId;
       }
     
       public void setTemplateId(String templateId) {
    @@ -84,7 +84,7 @@ public class WxMpTemplate {
       }
     
       public String getTitle() {
    -    return title;
    +    return this.title;
       }
     
       public void setTitle(String title) {
    @@ -92,7 +92,7 @@ public class WxMpTemplate {
       }
     
       public String getPrimaryIndustry() {
    -    return primaryIndustry;
    +    return this.primaryIndustry;
       }
     
       public void setPrimaryIndustry(String primaryIndustry) {
    @@ -100,7 +100,7 @@ public class WxMpTemplate {
       }
     
       public String getDeputyIndustry() {
    -    return deputyIndustry;
    +    return this.deputyIndustry;
       }
     
       public void setDeputyIndustry(String deputyIndustry) {
    @@ -108,7 +108,7 @@ public class WxMpTemplate {
       }
     
       public String getContent() {
    -    return content;
    +    return this.content;
       }
     
       public void setContent(String content) {
    @@ -116,7 +116,7 @@ public class WxMpTemplate {
       }
     
       public String getExample() {
    -    return example;
    +    return this.example;
       }
     
       public void setExample(String example) {
    diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpEndpointServlet.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpEndpointServlet.java
    index d052af6c..63052f8b 100644
    --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpEndpointServlet.java
    +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpEndpointServlet.java
    @@ -2,7 +2,6 @@ package me.chanjar.weixin.mp.demo;
     
     import java.io.IOException;
     
    -import javax.servlet.ServletException;
     import javax.servlet.http.HttpServlet;
     import javax.servlet.http.HttpServletRequest;
     import javax.servlet.http.HttpServletResponse;
    @@ -33,7 +32,7 @@ public class WxMpEndpointServlet extends HttpServlet {
     
       @Override
       protected void service(HttpServletRequest request, HttpServletResponse response)
    -      throws ServletException, IOException {
    +      throws IOException {
     
         response.setContentType("text/html;charset=utf-8");
         response.setStatus(HttpServletResponse.SC_OK);
    diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpOAuth2Servlet.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpOAuth2Servlet.java
    index 4008e1fb..8eeb9052 100644
    --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpOAuth2Servlet.java
    +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpOAuth2Servlet.java
    @@ -2,7 +2,6 @@ package me.chanjar.weixin.mp.demo;
     
     import java.io.IOException;
     
    -import javax.servlet.ServletException;
     import javax.servlet.http.HttpServlet;
     import javax.servlet.http.HttpServletRequest;
     import javax.servlet.http.HttpServletResponse;
    @@ -23,7 +22,7 @@ public class WxMpOAuth2Servlet extends HttpServlet {
     
       @Override
       protected void service(HttpServletRequest request, HttpServletResponse response)
    -      throws ServletException, IOException {
    +      throws IOException {
     
         response.setContentType("text/html;charset=utf-8");
         response.setStatus(HttpServletResponse.SC_OK);
    
    From b23b76457cf8741592ae9f1e03940d5f5a4b36c5 Mon Sep 17 00:00:00 2001
    From: Binary Wang 
    Date: Tue, 25 Oct 2016 15:04:58 +0800
    Subject: [PATCH 76/76] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=AE=A2?=
     =?UTF-8?q?=E6=9C=8D=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81=EF=BC=88=E7=82=B9?=
     =?UTF-8?q?=E5=87=BB=E8=B7=B3=E8=BD=AC=E5=88=B0=E5=9B=BE=E6=96=87=E6=B6=88?=
     =?UTF-8?q?=E6=81=AF=E9=A1=B5=E9=9D=A2=EF=BC=89=20=E5=9B=BE=E6=96=87?=
     =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9A=84=E6=94=AF=E6=8C=81=20#67?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     .../chanjar/weixin/common/api/WxConsts.java   |  19 +-
     .../weixin/mp/bean/WxMpMaterialNews.java      |  14 +-
     .../mp/bean/custombuilder/MpNewsBuilder.java  |  33 ++++
     .../weixin/mp/bean/kefu/WxMpKefuMessage.java  | 173 +++++++++++-------
     .../util/json/WxMpKefuMessageGsonAdapter.java |   6 +
     .../mp/api/impl/WxMpKefuServiceImplTest.java  |  41 +++--
     .../api/impl/WxMpMaterialServiceImplTest.java |  60 +++---
     7 files changed, 216 insertions(+), 130 deletions(-)
     create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/MpNewsBuilder.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 b3122863..3bfd1175 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
    @@ -23,14 +23,15 @@ public class WxConsts {
       ///////////////////////
       // 主动发送消息(即客服消息)的消息类型
       ///////////////////////
    -  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_FILE = "file";
    -  public static final String CUSTOM_MSG_WXCARD = "wxcard";
    +  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_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";
    @@ -193,7 +194,7 @@ public class WxConsts {
        * 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息
        */
       public static final String OAUTH2_SCOPE_USER_INFO = "snsapi_userinfo";
    -  
    +
       /**
        * 网页应用登录授权作用域 snsapi_login
        */
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMaterialNews.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMaterialNews.java
    index df40f6c3..fc7c983c 100644
    --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMaterialNews.java
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMpMaterialNews.java
    @@ -1,17 +1,16 @@
     package me.chanjar.weixin.mp.bean;
     
     import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
    +import org.apache.commons.lang3.builder.ToStringBuilder;
    +import org.apache.commons.lang3.builder.ToStringStyle;
     
     import java.io.Serializable;
     import java.util.ArrayList;
     import java.util.List;
     
     public class WxMpMaterialNews implements Serializable {
    -
    -  /**
    -   * 
    -   */
       private static final long serialVersionUID = -3283203652013494976L;
    +
       private List articles = new ArrayList<>();
     
       public List getArticles() {
    @@ -81,7 +80,6 @@ public class WxMpMaterialNews implements Serializable {
     
         /**
          * 点击图文消息跳转链接
    -     * @return
         */
         private String url;
     
    @@ -159,14 +157,12 @@ public class WxMpMaterialNews implements Serializable {
     
         @Override
         public String toString() {
    -      return "WxMpMassNewsArticle [" + "thumbMediaId=" + this.thumbMediaId + "thumbUrl=" + this.thumbUrl + ", author=" + this.author + ", title=" + this.title +
    -          ", contentSourceUrl=" + this.contentSourceUrl + ", content=" + this.content + ", digest=" + this.digest +
    -          ", showCoverPic=" + this.showCoverPic +", url=" + this.url + "]";
    +      return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
         }
       }
     
       @Override
       public String toString() {
    -    return "WxMpMaterialNews [" + "articles=" + this.articles + "]";
    +    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
       }
     }
    diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/MpNewsBuilder.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/MpNewsBuilder.java
    new file mode 100644
    index 00000000..4ab90dce
    --- /dev/null
    +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/custombuilder/MpNewsBuilder.java
    @@ -0,0 +1,33 @@
    +package me.chanjar.weixin.mp.bean.custombuilder;
    +
    +import me.chanjar.weixin.common.api.WxConsts;
    +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
    +
    +/**
    + * 图文消息builder
    + * 
    + * 用法:
    + * WxMpKefuMessage m = WxMpKefuMessage.NEWS().mediaId("xxxxx").toUser(...).build();
    + * 
    + * @author Binary Wang + * + */ +public final class MpNewsBuilder extends BaseBuilder { + private String mediaId; + + public MpNewsBuilder() { + this.msgType = WxConsts.CUSTOM_MSG_MPNEWS; + } + + public MpNewsBuilder mediaId(String mediaId) { + this.mediaId = mediaId; + return this; + } + + @Override + public WxMpKefuMessage build() { + WxMpKefuMessage m = super.build(); + m.setMpNewsMediaId(this.mediaId); + return m; + } +} 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 7963f53e..36c2525c 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,16 +1,23 @@ package me.chanjar.weixin.mp.bean.kefu; -import me.chanjar.weixin.mp.bean.custombuilder.*; -import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; - import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import me.chanjar.weixin.mp.bean.custombuilder.ImageBuilder; +import me.chanjar.weixin.mp.bean.custombuilder.MpNewsBuilder; +import me.chanjar.weixin.mp.bean.custombuilder.MusicBuilder; +import me.chanjar.weixin.mp.bean.custombuilder.NewsBuilder; +import me.chanjar.weixin.mp.bean.custombuilder.TextBuilder; +import me.chanjar.weixin.mp.bean.custombuilder.VideoBuilder; +import me.chanjar.weixin.mp.bean.custombuilder.VoiceBuilder; +import me.chanjar.weixin.mp.bean.custombuilder.WxCardBuilder; +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + /** * 客服消息 - * @author chanjarster * + * @author chanjarster */ public class WxMpKefuMessage implements Serializable { private static final long serialVersionUID = -9196732086954365246L; @@ -26,18 +33,85 @@ public class WxMpKefuMessage implements Serializable { private String hqMusicUrl; private String kfAccount; private String cardId; + private String mpNewsMediaId; private List articles = new ArrayList<>(); + /** + * 获得文本消息builder + */ + public static TextBuilder TEXT() { + return new TextBuilder(); + } + + /** + * 获得图片消息builder + */ + public static ImageBuilder IMAGE() { + return new ImageBuilder(); + } + + /** + * 获得语音消息builder + */ + public static VoiceBuilder VOICE() { + return new VoiceBuilder(); + } + + /** + * 获得视频消息builder + */ + public static VideoBuilder VIDEO() { + return new VideoBuilder(); + } + + /** + * 获得音乐消息builder + */ + public static MusicBuilder MUSIC() { + return new MusicBuilder(); + } + + /** + * 获得图文消息(点击跳转到外链)builder + */ + public static NewsBuilder NEWS() { + return new NewsBuilder(); + } + + /** + * 获得图文消息(点击跳转到图文消息页面)builder + */ + public static MpNewsBuilder MPNEWS() { + return new MpNewsBuilder(); + } + + /** + * 获得卡券消息builder + */ + 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; } + public String getMpNewsMediaId() { + return this.mpNewsMediaId; + } + + public void setMpNewsMediaId(String mpNewsMediaId) { + this.mpNewsMediaId = mpNewsMediaId; + } + /** *
        * 请使用
    @@ -47,52 +121,68 @@ public class WxMpKefuMessage implements Serializable {
        * {@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}
        * 
    + * * @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 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; } @@ -108,6 +198,7 @@ public class WxMpKefuMessage implements Serializable { public List getArticles() { return this.articles; } + public void setArticles(List articles) { this.articles = articles; } @@ -116,8 +207,15 @@ public class WxMpKefuMessage implements Serializable { return WxMpGsonBuilder.INSTANCE.create().toJson(this); } - public static class WxArticle { + public String getKfAccount() { + return this.kfAccount; + } + public void setKfAccount(String kfAccount) { + this.kfAccount = kfAccount; + } + + public static class WxArticle { private String title; private String description; private String url; @@ -126,85 +224,34 @@ public class WxMpKefuMessage implements Serializable { 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; } } - - /** - * 获得文本消息builder - */ - public static TextBuilder TEXT() { - return new TextBuilder(); - } - - /** - * 获得图片消息builder - */ - public static ImageBuilder IMAGE() { - return new ImageBuilder(); - } - - /** - * 获得语音消息builder - */ - public static VoiceBuilder VOICE() { - return new VoiceBuilder(); - } - - /** - * 获得视频消息builder - */ - public static VideoBuilder VIDEO() { - return new VideoBuilder(); - } - - /** - * 获得音乐消息builder - */ - public static MusicBuilder MUSIC() { - return new MusicBuilder(); - } - - /** - * 获得图文消息builder - */ - public static NewsBuilder NEWS() { - return new NewsBuilder(); - } - - - /** - * 获得卡券消息builder - */ - public static WxCardBuilder WXCARD() { - return new WxCardBuilder(); - } - - 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/util/json/WxMpKefuMessageGsonAdapter.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpKefuMessageGsonAdapter.java index 5b310cb0..abab87a1 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 @@ -75,6 +75,12 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer mediaIdsToDownload = new ArrayList<>(); + @Test(dataProvider="mediaFiles") public void testUploadMedia(String mediaType, String fileType, String fileName) throws WxErrorException, IOException { try(InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName)){