This commit is contained in:
007
2017-12-04 16:26:19 +08:00
22 changed files with 317 additions and 408 deletions

View File

@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<version>2.8.8.BETA</version> <version>2.9.0</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WeiXin Java Tools - Parent</name> <name>WeiXin Java Tools - Parent</name>
<description>微信公众号、企业号上级POM</description> <description>微信公众号、企业号上级POM</description>

View File

@@ -1,4 +1,4 @@
微信支付/公众号/企业/小程序的Java开发工具包SDK 微信支付/开放平台/公众号/企业微信/小程序的Java开发工具包SDK
--------------------------------- ---------------------------------
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent)
[![Build Status](https://travis-ci.org/Wechat-Group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/Wechat-Group/weixin-java-tools) [![Build Status](https://travis-ci.org/Wechat-Group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/Wechat-Group/weixin-java-tools)
@@ -16,14 +16,15 @@
* https://github.com/binarywang/weixin-java-mp-demo 公众号Demo使用Spring MVC实现 * https://github.com/binarywang/weixin-java-mp-demo 公众号Demo使用Spring MVC实现
* https://github.com/binarywang/weixin-java-mp-demo-springboot 公众号Demo使用Spring Boot实现 * https://github.com/binarywang/weixin-java-mp-demo-springboot 公众号Demo使用Spring Boot实现
* https://github.com/binarywang/weixin-java-mp-multi-demo (支持多公众号) * https://github.com/binarywang/weixin-java-mp-multi-demo (支持多公众号)
* https://github.com/wechat-group/weixin-java-tools-springmvc 公众号Demo内含部分微信支付代码 * https://github.com/Wechat-Group/weixin-java-open-demo 开放平台Demo
* https://github.com/Wechat-Group/weixin-java-tools-springmvc 公众号Demo内含部分微信支付代码
--------------------------------- ---------------------------------
### 重要提示信息(部分为新手必读): ### 重要提示信息(部分为新手必读):
1. 最新更新:**2017-9-3 发布[【2.8.0正式版】](https://github.com/Wechat-Group/weixin-java-tools/releases)** 1. 最新更新:**2017-9-3 发布[【2.8.0正式版】](https://github.com/Wechat-Group/weixin-java-tools/releases)**
1. 开源中国本项目的首页地址https://www.oschina.net/p/weixin-java-tools-new (欢迎大家积极留言评分 🙂) 1. 开源中国本项目的首页地址https://www.oschina.net/p/weixin-java-tools-new (欢迎大家积极留言评分 🙂)
1. SDK详细开发文档请查阅 [【Wiki】](https://github.com/wechat-group/weixin-java-tools/wiki),部分文档可能未能及时更新,如有发现,可以及时上报或者自行修改。 1. SDK详细开发文档请查阅 [【Wiki】](https://github.com/wechat-group/weixin-java-tools/wiki),部分文档可能未能及时更新,如有发现,可以及时上报或者自行修改。
1. 各个模块的Javadoc可以在线查看有可能是最新的测试版本的请注意观察版本号[weixin-java-miniapp](https://binarywang.github.io/weixin-java-miniapp-javadoc/)、[weixin-java-pay](https://binarywang.github.io/weixin-java-pay-javadoc/)、[weixin-java-mp](https://binarywang.github.io/weixin-java-mp-javadoc/)、[weixin-java-common](https://binarywang.github.io/weixin-java-common-javadoc/)、[weixin-java-cp](https://binarywang.github.io/weixin-java-cp-javadoc/) 1. 各个模块的Javadoc可以在线查看有可能是最新的测试版本的请注意观察版本号[weixin-java-miniapp](https://binarywang.github.io/weixin-java-miniapp-javadoc/)、[weixin-java-pay](https://binarywang.github.io/weixin-java-pay-javadoc/)、[weixin-java-mp](https://binarywang.github.io/weixin-java-mp-javadoc/)、[weixin-java-common](https://binarywang.github.io/weixin-java-common-javadoc/)、[weixin-java-cp](https://binarywang.github.io/weixin-java-cp-javadoc/)、[weixin-java-open](https://binarywang.github.io/weixin-java-open-javadoc/)
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. 如有新功能需求发现BUG或者由于微信官方接口调整导致的代码问题可以直接在[【Issues】](https://github.com/Wechat-Group/weixin-java-tools/issues)页提出issue便于讨论追踪问题 1. 如有新功能需求发现BUG或者由于微信官方接口调整导致的代码问题可以直接在[【Issues】](https://github.com/Wechat-Group/weixin-java-tools/issues)页提出issue便于讨论追踪问题
1. 如果想贡献代码,请阅读[【代码贡献指南】](contribution.md) 1. 如果想贡献代码,请阅读[【代码贡献指南】](contribution.md)
@@ -41,7 +42,7 @@
## 版本说明 ## 版本说明
1. 本项目定为大约每两个月发布一次正式版版本号格式为X.X.0如2.1.02.2.0等遇到重大问题需修复会及时提交新版本欢迎大家随时提交Pull Request 1. 本项目定为大约每两个月发布一次正式版版本号格式为X.X.0如2.1.02.2.0等遇到重大问题需修复会及时提交新版本欢迎大家随时提交Pull Request
1. BUG修复和新特性一般会先发布成小版本作为临时测试版本如2.4.5.BETA2.4.6.BETA等即尾号不为0并添加BETA字样以区别于正式版 1. BUG修复和新特性一般会先发布成小版本作为临时测试版本如2.4.5.BETA2.4.6.BETA等即尾号不为0并添加BETA字样以区别于正式版
1. 目前最新版本号为 [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent) ,也可以通过访问链接 [【微信支付】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-pay%22) 、[【微信小程序】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-miniapp%22) 、[【公众号】](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://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent) ,也可以通过访问链接 [【微信支付】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-pay%22) 、[【微信小程序】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-miniapp%22) 、[【公众号】](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)、[【开放平台】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-open%22)
分别查看所有最新的版本。 分别查看所有最新的版本。
--------------------------------- ---------------------------------
@@ -52,44 +53,16 @@
* Coding: https://git.coding.net/binarywang/weixin-java-tools.git * Coding: https://git.coding.net/binarywang/weixin-java-tools.git
--------------------------------- ---------------------------------
## Maven 最新正式版本 ## Maven 引用
* 微信小程序:
```xml ```xml
<dependency> <dependency>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
 <artifactId>weixin-java-miniapp</artifactId>  <artifactId>(按模块不同)</artifactId>
 <version>2.8.0</version>  <version>2.8.0</version>
</dependency> </dependency>
``` ```
* 各模块的artifactId
* 微信支付: - 微信小程序:`weixin-java-miniapp`
- 微信支付:`weixin-java-pay`
```xml - 公众号(订阅号及服务号):`weixin-java-mp`
<dependency> - 企业号:`weixin-java-cp`
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-pay</artifactId>
<version>2.8.0</version>
</dependency>
```
* 公众号(订阅号及服务号):
```xml
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-mp</artifactId>
<version>2.8.0</version>
</dependency>
```
* 企业号:
```xml
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-cp</artifactId>
<version>2.8.0</version>
</dependency>
```

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<version>2.8.8.BETA</version> <version>2.9.0</version>
</parent> </parent>
<artifactId>weixin-java-common</artifactId> <artifactId>weixin-java-common</artifactId>

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<version>2.8.8.BETA</version> <version>2.9.0</version>
</parent> </parent>
<artifactId>weixin-java-cp</artifactId> <artifactId>weixin-java-cp</artifactId>

View File

@@ -381,7 +381,7 @@ public abstract class WxCpServiceAbstractImpl<H, P> implements WxCpService, Requ
throw new RuntimeException("微信服务端异常,超出重试次数"); throw new RuntimeException("微信服务端异常,超出重试次数");
} }
protected synchronized <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
if (uri.contains("access_token=")) { if (uri.contains("access_token=")) {
throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri); throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri);
} }

View File

@@ -9,7 +9,11 @@ import redis.clients.jedis.JedisPoolConfig;
import java.io.File; import java.io.File;
/** /**
* Jedis client implementor for wechat config storage * Jedis client implementor for wechat config storage.
* <pre>
* 使用说明:本实现仅供参考,并不完整,
* 比如为减少项目依赖未加入redis分布式锁的实现如有需要请自行实现。
* </pre>
* *
* @author gaigeshen * @author gaigeshen
*/ */

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<version>2.8.8.BETA</version> <version>2.9.0</version>
</parent> </parent>
<artifactId>weixin-java-miniapp</artifactId> <artifactId>weixin-java-miniapp</artifactId>
<name>WeiXin Java Tools - MiniApp</name> <name>WeiXin Java Tools - MiniApp</name>

View File

@@ -181,7 +181,7 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl
throw new RuntimeException("微信服务端异常,超出重试次数"); throw new RuntimeException("微信服务端异常,超出重试次数");
} }
public synchronized <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { public <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
if (uri.contains("access_token=")) { if (uri.contains("access_token=")) {
throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri); throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri);
} }

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<version>2.8.8.BETA</version> <version>2.9.0</version>
</parent> </parent>
<artifactId>weixin-java-mp</artifactId> <artifactId>weixin-java-mp</artifactId>
<name>WeiXin Java Tools - MP</name> <name>WeiXin Java Tools - MP</name>

View File

@@ -5,7 +5,10 @@ import redis.clients.jedis.JedisPool;
/** /**
* 基于Redis的微信配置provider * 基于Redis的微信配置provider
* * <pre>
* 使用说明:本实现仅供参考,并不完整,
* 比如为减少项目依赖未加入redis分布式锁的实现如有需要请自行实现。
* </pre>
* @author nickwong * @author nickwong
*/ */
@SuppressWarnings("hiding") @SuppressWarnings("hiding")

View File

@@ -5,8 +5,11 @@ import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.mp.bean.*; import me.chanjar.weixin.mp.bean.WxMpSemanticQuery;
import me.chanjar.weixin.mp.bean.result.*; import me.chanjar.weixin.mp.bean.result.WxMpCurrentAutoReplyInfo;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
/** /**
* 微信API的Service * 微信API的Service
@@ -62,6 +65,11 @@ public interface WxMpService {
*/ */
String GET_CURRENT_AUTOREPLY_INFO_URL = "https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info"; String GET_CURRENT_AUTOREPLY_INFO_URL = "https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info";
/**
* 公众号调用或第三方平台帮公众号调用对公众号的所有api调用包括第三方帮其调用次数进行清零
*/
String CLEAR_QUOTA_URL = "https://api.weixin.qq.com/cgi-bin/clear_quota";
/** /**
* <pre> * <pre>
* 验证消息的确来自微信服务器 * 验证消息的确来自微信服务器
@@ -219,6 +227,18 @@ public interface WxMpService {
*/ */
WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException; WxMpCurrentAutoReplyInfo getCurrentAutoReplyInfo() throws WxErrorException;
/**
* <pre>
* 公众号调用或第三方平台帮公众号调用对公众号的所有api调用包括第三方帮其调用次数进行清零
* HTTP调用https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN
* 接口文档地址https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433744592
*
* </pre>
*
* @param appid 公众号的APPID
*/
void clearQuota(String appid) throws WxErrorException;
/** /**
* 当本Service没有实现某个API的时候可以用这个针对所有微信API中的GET请求 * 当本Service没有实现某个API的时候可以用这个针对所有微信API中的GET请求
*/ */
@@ -376,6 +396,7 @@ public interface WxMpService {
/** /**
* 返回群发消息相关接口方法的实现类对象,以方便调用其各个接口 * 返回群发消息相关接口方法的实现类对象,以方便调用其各个接口
*
* @return WxMpMassMessageService * @return WxMpMassMessageService
*/ */
WxMpMassMessageService getMassMessageService(); WxMpMassMessageService getMassMessageService();

View File

@@ -207,6 +207,13 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
return WxMpCurrentAutoReplyInfo.fromJson(this.get(GET_CURRENT_AUTOREPLY_INFO_URL, null)); return WxMpCurrentAutoReplyInfo.fromJson(this.get(GET_CURRENT_AUTOREPLY_INFO_URL, null));
} }
@Override
public void clearQuota(String appid) throws WxErrorException {
JsonObject o = new JsonObject();
o.addProperty("appid", appid);
this.post(CLEAR_QUOTA_URL, o.toString());
}
@Override @Override
public String get(String url, String queryParam) throws WxErrorException { public String get(String url, String queryParam) throws WxErrorException {
return execute(SimpleGetRequestExecutor.create(this), url, queryParam); return execute(SimpleGetRequestExecutor.create(this), url, queryParam);
@@ -252,7 +259,7 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
throw new RuntimeException("微信服务端异常,超出重试次数"); throw new RuntimeException("微信服务端异常,超出重试次数");
} }
public synchronized <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { public <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
if (uri.contains("access_token=")) { if (uri.contains("access_token=")) {
throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri); throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri);
} }

View File

@@ -1,5 +1,6 @@
package me.chanjar.weixin.mp.util.http.apache; package me.chanjar.weixin.mp.util.http.apache;
import com.google.common.collect.ImmutableMap;
import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.common.util.http.RequestHttp;
@@ -43,9 +44,7 @@ public class ApacheMaterialNewsInfoRequestExecutor
httpPost.setConfig(config); httpPost.setConfig(config);
} }
Map<String, String> params = new HashMap<>(); httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId))));
params.put("media_id", materialId);
httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(params)));
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) { try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) {
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
this.logger.debug("响应原始数据:{}", responseContent); this.logger.debug("响应原始数据:{}", responseContent);

View File

@@ -1,5 +1,6 @@
package me.chanjar.weixin.mp.util.http.jodd; package me.chanjar.weixin.mp.util.http.jodd;
import com.google.common.collect.ImmutableMap;
import jodd.http.HttpConnectionProvider; import jodd.http.HttpConnectionProvider;
import jodd.http.HttpRequest; import jodd.http.HttpRequest;
import jodd.http.HttpResponse; import jodd.http.HttpResponse;
@@ -9,6 +10,7 @@ import jodd.util.StringPool;
import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews;
import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor; import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
@@ -28,13 +30,13 @@ public class JoddMaterialNewsInfoRequestExecutor extends MaterialNewsInfoRequest
@Override @Override
public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorException, IOException { public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorException, IOException {
HttpRequest request = HttpRequest.post(uri);
if (requestHttp.getRequestHttpProxy() != null) { if (requestHttp.getRequestHttpProxy() != null) {
requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy()); requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
} }
request.withConnectionProvider(requestHttp.getRequestHttpClient());
request.query("media_id", materialId); HttpRequest request = HttpRequest.post(uri)
.withConnectionProvider(requestHttp.getRequestHttpClient())
.body(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId)));
HttpResponse response = request.send(); HttpResponse response = request.send();
response.charset(StringPool.UTF_8); response.charset(StringPool.UTF_8);

View File

@@ -1,9 +1,11 @@
package me.chanjar.weixin.mp.util.http.okhttp; package me.chanjar.weixin.mp.util.http.okhttp;
import com.google.common.collect.ImmutableMap;
import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews;
import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor; import me.chanjar.weixin.mp.util.http.MaterialNewsInfoRequestExecutor;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
@@ -28,7 +30,8 @@ public class OkhttpMaterialNewsInfoRequestExecutor extends MaterialNewsInfoReque
//得到httpClient //得到httpClient
OkHttpClient client = requestHttp.getRequestHttpClient(); OkHttpClient client = requestHttp.getRequestHttpClient();
RequestBody requestBody = new FormBody.Builder().add("media_id", materialId).build(); RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"),
WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId)));
Request request = new Request.Builder().url(uri).post(requestBody).build(); Request request = new Request.Builder().url(uri).post(requestBody).build();
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();

View File

@@ -15,7 +15,6 @@ import static org.testng.Assert.*;
@Test @Test
@Guice(modules = ApiTestModule.class) @Guice(modules = ApiTestModule.class)
public class WxMpServiceImplTest { public class WxMpServiceImplTest {
@Inject @Inject
private WxMpService wxService; private WxMpService wxService;
@@ -28,88 +27,8 @@ public class WxMpServiceImplTest {
} }
@Test @Test
public void testCheckSignature() { public void testClearQuota() throws WxErrorException {
Assert.fail("Not yet implemented"); this.wxService.clearQuota(wxService.getWxMpConfigStorage().getAppId());
}
@Test
public void testGetAccessToken() {
Assert.fail("Not yet implemented");
}
@Test
public void testGetAccessTokenBoolean() {
Assert.fail("Not yet implemented");
}
@Test
public void testGetJsapiTicket() {
Assert.fail("Not yet implemented");
}
@Test
public void testGetJsapiTicketBoolean() {
Assert.fail("Not yet implemented");
}
@Test
public void testCreateJsapiSignature() {
Assert.fail("Not yet implemented");
}
@Test
public void testCustomMessageSend() {
Assert.fail("Not yet implemented");
}
@Test
public void testMassNewsUpload() {
Assert.fail("Not yet implemented");
}
@Test
public void testMassVideoUpload() {
Assert.fail("Not yet implemented");
}
@Test
public void testMassGroupMessageSend() {
Assert.fail("Not yet implemented");
}
@Test
public void testMassOpenIdsMessageSend() {
Assert.fail("Not yet implemented");
}
@Test
public void testMassMessagePreview() {
Assert.fail("Not yet implemented");
}
@Test
public void testShortUrl() {
Assert.fail("Not yet implemented");
}
@Test
public void testSetIndustry() {
Assert.fail("Not yet implemented");
}
@Test
public void testGetIndustry() {
Assert.fail("Not yet implemented");
}
@Test
public void testSemanticQuery() {
Assert.fail("Not yet implemented");
}
@Test
public void testOauth2buildAuthorizationUrl() {
Assert.fail("Not yet implemented");
} }
@Test @Test
@@ -121,44 +40,4 @@ public class WxMpServiceImplTest {
System.out.println(qrConnectUrl); System.out.println(qrConnectUrl);
} }
@Test
public void testOauth2getAccessToken() {
Assert.fail("Not yet implemented");
}
@Test
public void testOauth2refreshAccessToken() {
Assert.fail("Not yet implemented");
}
@Test
public void testOauth2getUserInfo() {
Assert.fail("Not yet implemented");
}
@Test
public void testOauth2validateAccessToken() {
Assert.fail("Not yet implemented");
}
@Test
public void testGetCallbackIP() {
Assert.fail("Not yet implemented");
}
@Test
public void testGet() {
Assert.fail("Not yet implemented");
}
@Test
public void testPost() {
Assert.fail("Not yet implemented");
}
@Test
public void testExecute() {
Assert.fail("Not yet implemented");
}
} }

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<version>2.8.8.BETA</version> <version>2.9.0</version>
</parent> </parent>
<artifactId>weixin-java-open</artifactId> <artifactId>weixin-java-open</artifactId>
<name>WeiXin Java Tools - Open</name> <name>WeiXin Java Tools - Open</name>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<version>2.8.8.BETA</version> <version>2.9.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -21,7 +21,7 @@ import lombok.NoArgsConstructor;
public class WxPayCouponInfoQueryResult extends WxPayBaseResult { public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:设备号 * 字段名:设备号.
* 变量名device_info * 变量名device_info
* 是否必填:否 * 是否必填:否
* 示例值123456sb * 示例值123456sb
@@ -34,7 +34,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名批次ID * 字段名批次ID.
* 变量名coupon_stock_id * 变量名coupon_stock_id
* 是否必填:是 * 是否必填:是
* 示例值1567 * 示例值1567
@@ -47,7 +47,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名代金券id * 字段名代金券id.
* 变量名coupon_id * 变量名coupon_id
* 是否必填:是 * 是否必填:是
* 示例值4242 * 示例值4242
@@ -60,7 +60,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:代金券面额 * 字段名:代金券面额.
* 变量名coupon_value * 变量名coupon_value
* 是否必填:是 * 是否必填:是
* 示例值4 * 示例值4
@@ -73,7 +73,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:代金券使用门槛 * 字段名:代金券使用门槛.
* 变量名coupon_mininum * 变量名coupon_mininum
* 是否必填:是 * 是否必填:是
* 示例值10 * 示例值10
@@ -86,7 +86,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:代金券名称 * 字段名:代金券名称.
* 变量名coupon_name * 变量名coupon_name
* 是否必填:是 * 是否必填:是
* 示例值:测试代金券 * 示例值:测试代金券
@@ -99,20 +99,20 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:代金券状态 * 字段名:代金券状态.
* 变量名coupon_state * 变量名coupon_state
* 是否必填:是 * 是否必填:是
* 示例值SENDED * 示例值SENDED
* 类型int * 类型:String
* 说明代金券状态SENDED-可用USED-已实扣EXPIRED-已过期 * 说明代金券状态SENDED-可用USED-已实扣EXPIRED-已过期
* </pre> * </pre>
*/ */
@XStreamAlias("coupon_state") @XStreamAlias("coupon_state")
private Integer couponState; private String couponState;
/** /**
* <pre> * <pre>
* 字段名:代金券描述 * 字段名:代金券描述.
* 变量名coupon_desc * 变量名coupon_desc
* 是否必填:是 * 是否必填:是
* 示例值:微信支付-代金券 * 示例值:微信支付-代金券
@@ -125,7 +125,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:实际优惠金额 * 字段名:实际优惠金额.
* 变量名coupon_use_value * 变量名coupon_use_value
* 是否必填:是 * 是否必填:是
* 示例值0 * 示例值0
@@ -138,7 +138,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:优惠剩余可用额 * 字段名:优惠剩余可用额.
* 变量名coupon_remain_value * 变量名coupon_remain_value
* 是否必填:是 * 是否必填:是
* 示例值4 * 示例值4
@@ -151,7 +151,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:生效开始时间 * 字段名:生效开始时间.
* 变量名begin_time * 变量名begin_time
* 是否必填:是 * 是否必填:是
* 示例值1943787483 * 示例值1943787483
@@ -164,7 +164,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:生效结束时间 * 字段名:生效结束时间.
* 变量名end_time * 变量名end_time
* 是否必填:是 * 是否必填:是
* 示例值1943787484 * 示例值1943787484
@@ -177,7 +177,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:发放时间 * 字段名:发放时间.
* 变量名send_time * 变量名send_time
* 是否必填:是 * 是否必填:是
* 示例值1943787420 * 示例值1943787420
@@ -190,7 +190,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名消耗方商户id * 字段名消耗方商户id.
* 变量名consumer_mch_id * 变量名consumer_mch_id
* 是否必填:否 * 是否必填:否
* 示例值10000098 * 示例值10000098
@@ -203,7 +203,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:发放来源 * 字段名:发放来源.
* 变量名send_source * 变量名send_source
* 是否必填:是 * 是否必填:是
* 示例值FULL_SEND * 示例值FULL_SEND
@@ -216,7 +216,7 @@ public class WxPayCouponInfoQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 字段名:是否允许部分使用 * 字段名:是否允许部分使用.
* 变量名is_partial_use * 变量名is_partial_use
* 是否必填:否 * 是否必填:否
* 示例值1 * 示例值1

View File

@@ -14,13 +14,6 @@ import java.util.Arrays;
/** /**
* <pre> * <pre>
* 微信支付-申请退款请求参数 * 微信支付-申请退款请求参数
* 注释中各行每个字段描述对应如下:
* <li>字段名
* <li>变量名
* <li>是否必填
* <li>类型
* <li>示例值
* <li>描述
* Created by Binary Wang on 2016-10-08. * Created by Binary Wang on 2016-10-08.
* </pre> * </pre>
* *
@@ -34,53 +27,52 @@ import java.util.Arrays;
@XStreamAlias("xml") @XStreamAlias("xml")
public class WxPayRefundRequest extends WxPayBaseRequest { public class WxPayRefundRequest extends WxPayBaseRequest {
private static final String[] REFUND_ACCOUNT = new String[]{ private static final String[] REFUND_ACCOUNT = new String[]{
RefundAccountSource.RECHARGE_FUNDS, RefundAccountSource.RECHARGE_FUNDS, RefundAccountSource.UNSETTLED_FUNDS};
RefundAccountSource.UNSETTLED_FUNDS
};
/** /**
* <pre> * <pre>
* 设备号 * 字段名:设备号.
* device_info * 变量名:device_info
* 否 * 是否必填:
* String(32) * 类型:String(32)
* 13467007045764 * 示例值:13467007045764
* 终端设备号 * 描述:终端设备号
* </pre> * </pre>
*/ */
@XStreamAlias("device_info") @XStreamAlias("device_info")
private String deviceInfo; private String deviceInfo;
/** /**
* <pre> * <pre>
* 微信订单号 * 字段名:微信订单号.
* transaction_id * 变量名:transaction_id
* 跟out_trade_no二选一 * 是否必填:跟out_trade_no二选一
* String(28) * 类型:String(28)
* 1217752501201400000000000000 * 示例值:1217752501201400000000000000
* 微信生成的订单号,在支付通知中有返回 * 描述:微信生成的订单号,在支付通知中有返回
* </pre> * </pre>
*/ */
@XStreamAlias("transaction_id") @XStreamAlias("transaction_id")
private String transactionId; private String transactionId;
/** /**
* <pre> * <pre>
* 商户订单号 * 字段名:商户订单号.
* out_trade_no * 变量名:out_trade_no
* 跟transaction_id二选一 * 是否必填:跟transaction_id二选一
* String(32) * 类型:String(32)
* 1217752501201400000000000000 * 示例值:1217752501201400000000000000
* 商户侧传给微信的订单号 * 描述:商户侧传给微信的订单号
* </pre> * </pre>
*/ */
@XStreamAlias("out_trade_no") @XStreamAlias("out_trade_no")
private String outTradeNo; private String outTradeNo;
/** /**
* <pre> * <pre>
* 商户退款单号 * 字段名:商户退款单号.
* out_refund_no * 变量名:out_refund_no
* 是 * 是否必填:是
* String(32) * 类型:String(32)
* 1217752501201400000000000000 * 示例值:1217752501201400000000000000
* 商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔 * 描述:商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔
* </pre> * </pre>
*/ */
@Required @Required
@@ -88,12 +80,12 @@ public class WxPayRefundRequest extends WxPayBaseRequest {
private String outRefundNo; private String outRefundNo;
/** /**
* <pre> * <pre>
* 订单金额 * 字段名:订单金额.
* total_fee * 变量名:total_fee
* 是 * 是否必填:是
* Int * 类型:Int
* 100 * 示例值:100
* 订单总金额,单位为分,只能为整数,详见支付金额 * 描述:订单总金额,单位为分,只能为整数,详见支付金额
* </pre> * </pre>
*/ */
@Required @Required
@@ -101,12 +93,12 @@ public class WxPayRefundRequest extends WxPayBaseRequest {
private Integer totalFee; private Integer totalFee;
/** /**
* <pre> * <pre>
* 退款金额 * 字段名:退款金额.
* refund_fee * 变量名:refund_fee
* 是 * 是否必填:是
* Int * 类型:Int
* 100 * 示例值:100
* 退款总金额,订单总金额,单位为分,只能为整数,详见支付金额 * 描述:退款总金额,订单总金额,单位为分,只能为整数,详见支付金额
* </pre> * </pre>
*/ */
@Required @Required
@@ -114,24 +106,24 @@ public class WxPayRefundRequest extends WxPayBaseRequest {
private Integer refundFee; private Integer refundFee;
/** /**
* <pre> * <pre>
* 货币种类 * 字段名:货币种类.
* refund_fee_type * 变量名:refund_fee_type
* 否 * 是否必填:
* String(8) * 类型:String(8)
* CNY * 示例值:CNY
* 货币类型符合ISO 4217标准的三位字母代码默认人民币CNY其他值列表详见货币类型 * 描述:货币类型符合ISO 4217标准的三位字母代码默认人民币CNY其他值列表详见货币类型
* </pre> * </pre>
*/ */
@XStreamAlias("refund_fee_type") @XStreamAlias("refund_fee_type")
private String refundFeeType; private String refundFeeType;
/** /**
* <pre> * <pre>
* 操作员 * 字段名:操作员.
* op_user_id * 变量名:op_user_id
* 是 * 是否必填:是
* String(32) * 类型:String(32)
* 1900000109 * 示例值:1900000109
* 操作员帐号, 默认为商户号 * 描述:操作员帐号, 默认为商户号
* </pre> * </pre>
*/ */
//@Required //@Required
@@ -139,12 +131,12 @@ public class WxPayRefundRequest extends WxPayBaseRequest {
private String opUserId; private String opUserId;
/** /**
* <pre> * <pre>
* 退款资金来源 * 字段名:退款资金来源.
* refund_account * 变量名:refund_account
* 否 * 是否必填:
* String(30) * 类型:String(30)
* REFUND_SOURCE_RECHARGE_FUNDS * 示例值:REFUND_SOURCE_RECHARGE_FUNDS
* 仅针对老资金流商户使用, * 描述:仅针对老资金流商户使用,
* <li>REFUND_SOURCE_UNSETTLED_FUNDS---未结算资金退款(默认使用未结算资金退款), * <li>REFUND_SOURCE_UNSETTLED_FUNDS---未结算资金退款(默认使用未结算资金退款),
* <li>REFUND_SOURCE_RECHARGE_FUNDS---可用余额退款 * <li>REFUND_SOURCE_RECHARGE_FUNDS---可用余额退款
* </pre> * </pre>
@@ -153,12 +145,12 @@ public class WxPayRefundRequest extends WxPayBaseRequest {
private String refundAccount; private String refundAccount;
/** /**
* <pre> * <pre>
* 退款原因 * 字段名:退款原因.
* refund_account * 变量名:refund_account
* 否 * 是否必填:
* String(80) * 类型:String(80)
* 商品已售完 * 示例值:商品已售完
* 若商户传入,会在下发给用户的退款消息中体现退款原因 * 描述:若商户传入,会在下发给用户的退款消息中体现退款原因
* </pre> * </pre>
*/ */
@XStreamAlias("refund_desc") @XStreamAlias("refund_desc")
@@ -177,8 +169,8 @@ public class WxPayRefundRequest extends WxPayBaseRequest {
protected void checkConstraints() throws WxPayException { protected void checkConstraints() throws WxPayException {
if (StringUtils.isNotBlank(this.getRefundAccount())) { if (StringUtils.isNotBlank(this.getRefundAccount())) {
if (!ArrayUtils.contains(REFUND_ACCOUNT, this.getRefundAccount())) { if (!ArrayUtils.contains(REFUND_ACCOUNT, this.getRefundAccount())) {
throw new WxPayException(String.format("refund_account目前必须为%s其中之一,实际值:%s", throw new WxPayException(
Arrays.toString(REFUND_ACCOUNT), this.getRefundAccount())); String.format("refund_account目前必须为%s其中之一,实际值:%s", Arrays.toString(REFUND_ACCOUNT), this.getRefundAccount()));
} }
} }

View File

@@ -8,6 +8,7 @@ import java.util.List;
/** /**
* <pre> * <pre>
* 微信支付-退款查询返回结果
* Created by Binary Wang on 2016-11-24. * Created by Binary Wang on 2016-11-24.
* </pre> * </pre>
* *
@@ -20,96 +21,104 @@ import java.util.List;
public class WxPayRefundQueryResult extends WxPayBaseResult { public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 设备号 * 字段名:设备号.
* device_info * 变量名:device_info
* 否 * 是否必填:
* String(32) * 类型:String(32)
* 013467007045764 * 示例值:013467007045764
* 终端设备号 * 描述:终端设备号
* </pre>
*/ */
@XStreamAlias("device_info") @XStreamAlias("device_info")
private String deviceInfo; private String deviceInfo;
/** /**
* <pre> * <pre>
* 微信订单号 * 字段名:微信订单号.
* transaction_id * 变量名:transaction_id
* 是 * 是否必填:是
* String(32) * 类型:String(32)
* 1217752501201407033233368018 * 示例值:1217752501201407033233368018
* 微信订单号 * 描述:微信订单号
* </pre>
*/ */
@XStreamAlias("transaction_id") @XStreamAlias("transaction_id")
private String transactionId; private String transactionId;
/** /**
* <pre> * <pre>
* 商户订单号 * 字段名:商户订单号.
* out_trade_no * 变量名:out_trade_no
* 是 * 是否必填:是
* String(32) * 类型:String(32)
* 1217752501201407033233368018 * 示例值:1217752501201407033233368018
* 商户系统内部的订单号 * 描述:商户系统内部的订单号
* </pre>
*/ */
@XStreamAlias("out_trade_no") @XStreamAlias("out_trade_no")
private String outTradeNo; private String outTradeNo;
/** /**
* <pre> * <pre>
* 订单金额 * 字段名:订单金额.
* total_fee * 变量名:total_fee
* 是 * 是否必填:是
* Int * 类型:Int
* 100 * 示例值:100
* 订单总金额,单位为分,只能为整数,详见支付金额 * 描述:订单总金额,单位为分,只能为整数,详见支付金额
* </pre>
*/ */
@XStreamAlias("total_fee") @XStreamAlias("total_fee")
private Integer totalFee; private Integer totalFee;
/** /**
* <pre> * <pre>
* 应结订单金额 * 字段名:应结订单金额.
* settlement_total_fee * 变量名:settlement_total_fee
* 否 * 是否必填:
* Int * 类型:Int
* 100 * 示例值:100
* 应结订单金额=订单金额-非充值代金券金额,应结订单金额<=订单金额。 * 描述:应结订单金额=订单金额-非充值代金券金额,应结订单金额<=订单金额。
* </pre>
*/ */
@XStreamAlias("settlement_total_fee") @XStreamAlias("settlement_total_fee")
private Integer settlementTotalFee; private Integer settlementTotalFee;
/** /**
* <pre> * <pre>
* 货币种类 * 字段名:货币种类.
* fee_type * 变量名:fee_type
* 否 * 是否必填:
* String(8) * 类型:String(8)
* CNY * 示例值:CNY
* 订单金额货币类型符合ISO 4217标准的三位字母代码默认人民币CNY其他值列表详见货币类型 * 描述:订单金额货币类型符合ISO 4217标准的三位字母代码默认人民币CNY其他值列表详见货币类型
* </pre>
*/ */
@XStreamAlias("fee_type") @XStreamAlias("fee_type")
private String feeType; private String feeType;
/** /**
* <pre> * <pre>
* 现金支付金额 * 字段名:现金支付金额.
* cash_fee * 变量名:cash_fee
* 是 * 是否必填:是
* Int * 类型:Int
* 100 * 示例值:100
* 现金支付金额,单位为分,只能为整数,详见支付金额 * 描述:现金支付金额,单位为分,只能为整数,详见支付金额
* </pre>
*/ */
@XStreamAlias("cash_fee") @XStreamAlias("cash_fee")
private Integer cashFee; private Integer cashFee;
/** /**
* <pre> * <pre>
* 退款笔数 * 字段名:退款笔数.
* refund_count * 变量名:refund_count
* 是 * 是否必填:是
* Int * 类型:Int
* 1 * 示例值:1
* 退款记录数 * 描述:退款记录数
* </pre>
*/ */
@XStreamAlias("refund_count") @XStreamAlias("refund_count")
private Integer refundCount; private Integer refundCount;
@@ -117,7 +126,7 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
private List<RefundRecord> refundRecords; private List<RefundRecord> refundRecords;
/** /**
* 组装生成退款记录属性的内容 * 组装生成退款记录属性的内容.
*/ */
public void composeRefundRecords() { public void composeRefundRecords() {
if (this.refundCount != null && this.refundCount > 0) { if (this.refundCount != null && this.refundCount > 0) {
@@ -137,6 +146,7 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
refundRecord.setCouponRefundCount(this.getXmlValueAsInt("xml/coupon_refund_count_" + i)); refundRecord.setCouponRefundCount(this.getXmlValueAsInt("xml/coupon_refund_count_" + i));
refundRecord.setRefundStatus(this.getXmlValue("xml/refund_status_" + i)); refundRecord.setRefundStatus(this.getXmlValue("xml/refund_status_" + i));
refundRecord.setRefundRecvAccount(this.getXmlValue("xml/refund_recv_accout_" + i)); refundRecord.setRefundRecvAccount(this.getXmlValue("xml/refund_recv_accout_" + i));
refundRecord.setRefundSuccessTime(this.getXmlValue("xml/refund_success_time_" + i));
if (refundRecord.getCouponRefundCount() == null || refundRecord.getCouponRefundCount() == 0) { if (refundRecord.getCouponRefundCount() == null || refundRecord.getCouponRefundCount() == 0) {
continue; continue;
@@ -151,6 +161,8 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
) )
); );
} }
refundRecord.setRefundCoupons(coupons);
} }
} }
@@ -163,12 +175,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
public static class RefundRecord { public static class RefundRecord {
/** /**
* <pre> * <pre>
* 商户退款单号 * 字段名:商户退款单号.
* out_refund_no_$n * 变量名:out_refund_no_$n
* 是 * 是否必填:是
* String(32) * 类型:String(32)
* 1217752501201407033233368018 * 示例值:1217752501201407033233368018
* 商户退款单号 * 描述:商户退款单号
* </pre> * </pre>
*/ */
@XStreamAlias("out_refund_no") @XStreamAlias("out_refund_no")
@@ -176,12 +188,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 微信退款单号 * 字段名:微信退款单号.
* refund_id_$n * 变量名:refund_id_$n
* 是 * 是否必填:是
* String(28) * 类型:String(28)
* 1217752501201407033233368018 * 示例值:1217752501201407033233368018
* 微信退款单号 * 描述:微信退款单号
* </pre> * </pre>
*/ */
@XStreamAlias("refund_id") @XStreamAlias("refund_id")
@@ -189,12 +201,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 退款渠道 * 字段名:退款渠道.
* refund_channel_$n * 变量名:refund_channel_$n
* 否 * 是否必填:
* String(16) * 类型:String(16)
* ORIGINAL * 示例值:ORIGINAL
* ORIGINAL—原路退款 BALANCE—退回到余额 * 描述:ORIGINAL—原路退款 BALANCE—退回到余额
* </pre> * </pre>
*/ */
@XStreamAlias("refund_channel") @XStreamAlias("refund_channel")
@@ -202,12 +214,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 申请退款金额 * 字段名:申请退款金额.
* refund_fee_$n * 变量名:refund_fee_$n
* 是 * 是否必填:是
* Int * 类型:Int
* 100 * 示例值:100
* 退款总金额,单位为分,可以做部分退款 * 描述:退款总金额,单位为分,可以做部分退款
* </pre> * </pre>
*/ */
@XStreamAlias("refund_fee") @XStreamAlias("refund_fee")
@@ -215,12 +227,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 退款金额 * 字段名:退款金额.
* settlement_refund_fee_$n * 变量名:settlement_refund_fee_$n
* 否 * 是否必填:
* Int * 类型:Int
* 100 * 示例值:100
* 退款金额=申请退款金额-非充值代金券退款金额,退款金额<=申请退款金额 * 描述:退款金额=申请退款金额-非充值代金券退款金额,退款金额<=申请退款金额
* </pre> * </pre>
*/ */
@XStreamAlias("settlement_refund_fee") @XStreamAlias("settlement_refund_fee")
@@ -228,12 +240,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 退款资金来源 * 字段名:退款资金来源.
* refund_account * 变量名:refund_account
* 否 * 是否必填:
* String(30) * 类型:String(30)
* REFUND_SOURCE_RECHARGE_FUNDS * 示例值:REFUND_SOURCE_RECHARGE_FUNDS
* REFUND_SOURCE_RECHARGE_FUNDS---可用余额退款/基本账户, REFUND_SOURCE_UNSETTLED_FUNDS---未结算资金退款 * 描述:REFUND_SOURCE_RECHARGE_FUNDS---可用余额退款/基本账户, REFUND_SOURCE_UNSETTLED_FUNDS---未结算资金退款
* </pre> * </pre>
*/ */
@XStreamAlias("refund_account") @XStreamAlias("refund_account")
@@ -241,12 +253,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 代金券类型 * 字段名:代金券类型.
* coupon_type_$n * 变量名:coupon_type_$n
* 否 * 是否必填:
* Int * 类型:Int
* CASH * 示例值:CASH
* CASH--充值代金券 , NO_CASH---非充值代金券。订单使用代金券时有返回取值CASH、NO_CASH。$n为下标,从0开始编号举例coupon_type_$0 * 描述:CASH--充值代金券 , NO_CASH---非充值代金券。订单使用代金券时有返回取值CASH、NO_CASH。$n为下标,从0开始编号举例coupon_type_$0
* </pre> * </pre>
*/ */
@XStreamAlias("coupon_type") @XStreamAlias("coupon_type")
@@ -254,12 +266,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 代金券退款金额 * 字段名:代金券退款金额.
* coupon_refund_fee_$n * 变量名:coupon_refund_fee_$n
* 否 * 是否必填:
* Int * 类型:Int
* 100 * 示例值:100
* 代金券退款金额<=退款金额,退款金额-代金券或立减优惠退款金额为现金,说明详见代金券或立减优惠 * 描述:代金券退款金额<=退款金额,退款金额-代金券或立减优惠退款金额为现金,说明详见代金券或立减优惠
* </pre> * </pre>
*/ */
@XStreamAlias("coupon_refund_fee") @XStreamAlias("coupon_refund_fee")
@@ -267,12 +279,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 退款代金券使用数量 * 字段名:退款代金券使用数量.
* coupon_refund_count_$n * 变量名:coupon_refund_count_$n
* 否 * 是否必填:
* Int * 类型:Int
* 1 * 示例值:1
* 退款代金券使用数量 ,$n为下标,从0开始编号 * 描述:退款代金券使用数量 ,$n为下标,从0开始编号
* </pre> * </pre>
*/ */
@XStreamAlias("coupon_refund_count") @XStreamAlias("coupon_refund_count")
@@ -282,12 +294,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 退款状态 * 字段名:退款状态.
* refund_status_$n * 变量名:refund_status_$n
* 是 * 是否必填:是
* String(16) * 类型:String(16)
* SUCCESS * 示例值:SUCCESS
* 退款状态: * 描述:退款状态:
* SUCCESS—退款成功 * SUCCESS—退款成功
* FAIL—退款失败 * FAIL—退款失败
* PROCESSING—退款处理中 * PROCESSING—退款处理中
@@ -297,30 +309,44 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
*/ */
@XStreamAlias("refund_status") @XStreamAlias("refund_status")
private String refundStatus; private String refundStatus;
/** /**
* <pre> * <pre>
* 退款入账账户 * 字段名:退款入账账户.
* refund_recv_accout_$n * 变量名:refund_recv_accout_$n
* 是 * 是否必填:是
* String(64) * 类型:String(64)
* 招商银行信用卡0403 * 示例值:招商银行信用卡0403
* 取当前退款单的退款入账方1退回银行卡{银行名称}{卡类型}{卡尾号}2退回支付用户零钱:支付用户零钱 * 描述:取当前退款单的退款入账方1退回银行卡{银行名称}{卡类型}{卡尾号}2退回支付用户零钱:支付用户零钱
* </pre> * </pre>
*/ */
@XStreamAlias("refund_recv_accout") @XStreamAlias("refund_recv_accout")
private String refundRecvAccount; private String refundRecvAccount;
/**
* <pre>
* 字段名:退款成功时间.
* 变量名refund_success_time_$n
* 是否必填:否
* 类型String(20)
* 示例值2016-07-25 15:26:26
* 描述:退款成功时间,当退款状态为退款成功时有返回。$n为下标从0开始编号。
* </pre>
*/
@XStreamAlias("refund_success_time")
private String refundSuccessTime;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public static class RefundCoupon { public static class RefundCoupon {
/** /**
* <pre> * <pre>
* 退款代金券批次ID * 字段名:退款代金券批次ID.
* coupon_refund_batch_id_$n_$m * 变量名:coupon_refund_batch_id_$n_$m
* 否 * 是否必填:
* String(20) * 类型:String(20)
* 100 * 示例值:100
* 退款代金券批次ID ,$n为下标$m为下标从0开始编号 * 描述:退款代金券批次ID ,$n为下标$m为下标从0开始编号
* </pre> * </pre>
* *
* @deprecated 貌似是被去掉了,但不知是何时! * @deprecated 貌似是被去掉了,但不知是何时!
@@ -330,12 +356,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 退款代金券ID * 字段名:退款代金券ID.
* coupon_refund_id_$n_$m * 变量名:coupon_refund_id_$n_$m
* 否 * 是否必填:
* String(20) * 类型:String(20)
* 10000 * 示例值:10000
* 退款代金券ID, $n为下标$m为下标从0开始编号 * 描述:退款代金券ID, $n为下标$m为下标从0开始编号
* </pre> * </pre>
*/ */
@XStreamAlias("coupon_refund_id") @XStreamAlias("coupon_refund_id")
@@ -343,12 +369,12 @@ public class WxPayRefundQueryResult extends WxPayBaseResult {
/** /**
* <pre> * <pre>
* 单个退款代金券支付金额 * 字段名:单个退款代金券支付金额.
* coupon_refund_fee_$n_$m * 变量名:coupon_refund_fee_$n_$m
* 否 * 是否必填:
* Int * 类型:Int
* 100 * 示例值:100
* 单个退款代金券支付金额, $n为下标$m为下标从0开始编号 * 描述:单个退款代金券支付金额, $n为下标$m为下标从0开始编号
* </pre> * </pre>
*/ */
@XStreamAlias("coupon_refund_fee") @XStreamAlias("coupon_refund_fee")

View File

@@ -422,9 +422,9 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService {
String responseContent = this.post(url, request.toXML(), false); String responseContent = this.post(url, request.toXML(), false);
if (responseContent.startsWith("<")) { if (responseContent.startsWith("<")) {
throw WxPayException.from(WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class)); throw WxPayException.from(WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class));
} else {
return this.handleBillInformation(responseContent);
} }
return this.handleBillInformation(responseContent);
} }
private WxPayBillResult handleBillInformation(String responseContent) { private WxPayBillResult handleBillInformation(String responseContent) {