executor, String uri, E
return null;
} catch (IOException e) {
log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage());
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
@@ -273,4 +279,9 @@ public void setTmpDirFile(File tmpDirFile) {
return this;
}
+ @Override
+ public WxSessionManager getSessionManager() {
+ return this.sessionManager;
+ }
+
}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTpServiceApacheHttpClientImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java
similarity index 96%
rename from weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTpServiceApacheHttpClientImpl.java
rename to weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java
index cdc6b2cfc0..22962d933b 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTpServiceApacheHttpClientImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java
@@ -1,10 +1,11 @@
-package me.chanjar.weixin.cp.api.impl;
+package me.chanjar.weixin.cp.tp.service.impl;
import com.google.gson.JsonObject;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.http.HttpType;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
@@ -81,7 +82,7 @@ public String getSuiteAccessToken(boolean forceRefresh) throws WxErrorException
Integer expiresIn = jsonObject.get("expires_in").getAsInt();
this.configStorage.updateSuiteAccessToken(suiteAccussToken, expiresIn);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
return this.configStorage.getSuiteAccessToken();
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceImpl.java
similarity index 82%
rename from weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTpServiceImpl.java
rename to weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceImpl.java
index f5582021e7..58fb09cf97 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTpServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceImpl.java
@@ -1,4 +1,4 @@
-package me.chanjar.weixin.cp.api.impl;
+package me.chanjar.weixin.cp.tp.service.impl;
/**
*
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapter.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapter.java
index 5ec9d14824..835f89cc50 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapter.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpUserGsonAdapter.java
@@ -16,6 +16,8 @@
import java.lang.reflect.Type;
+import static me.chanjar.weixin.cp.bean.WxCpUser.*;
+
/**
* cp user gson adapter.
*
@@ -104,7 +106,7 @@ private void buildExtraAttrs(JsonObject o, WxCpUser user) {
JsonArray attrJsonElements = o.get(EXTRA_ATTR).getAsJsonObject().get("attrs").getAsJsonArray();
for (JsonElement attrJsonElement : attrJsonElements) {
final Integer type = GsonHelper.getInteger(attrJsonElement.getAsJsonObject(), "type");
- final WxCpUser.Attr attr = new WxCpUser.Attr().setType(type)
+ final Attr attr = new Attr().setType(type)
.setName(GsonHelper.getString(attrJsonElement.getAsJsonObject(), "name"));
user.getExtAttrs().add(attr);
@@ -142,7 +144,7 @@ private void buildExternalAttrs(JsonObject o, WxCpUser user) {
switch (type) {
case 0: {
user.getExternalAttrs()
- .add(WxCpUser.ExternalAttribute.builder()
+ .add(ExternalAttribute.builder()
.type(type)
.name(name)
.value(GsonHelper.getString(element.getAsJsonObject().get("text").getAsJsonObject(), "value"))
@@ -153,7 +155,7 @@ private void buildExternalAttrs(JsonObject o, WxCpUser user) {
case 1: {
final JsonObject web = element.getAsJsonObject().get("web").getAsJsonObject();
user.getExternalAttrs()
- .add(WxCpUser.ExternalAttribute.builder()
+ .add(ExternalAttribute.builder()
.type(type)
.name(name)
.url(GsonHelper.getString(web, "url"))
@@ -165,7 +167,7 @@ private void buildExternalAttrs(JsonObject o, WxCpUser user) {
case 2: {
final JsonObject miniprogram = element.getAsJsonObject().get("miniprogram").getAsJsonObject();
user.getExternalAttrs()
- .add(WxCpUser.ExternalAttribute.builder()
+ .add(ExternalAttribute.builder()
.type(type)
.name(name)
.appid(GsonHelper.getString(miniprogram, "appid"))
@@ -278,7 +280,7 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon
if (!user.getExtAttrs().isEmpty()) {
JsonArray attrsJsonArray = new JsonArray();
- for (WxCpUser.Attr attr : user.getExtAttrs()) {
+ for (Attr attr : user.getExtAttrs()) {
JsonObject attrJson = GsonHelper.buildJsonObject("type", attr.getType(),
"name", attr.getName());
attrsJsonArray.add(attrJson);
@@ -317,7 +319,7 @@ public JsonElement serialize(WxCpUser user, Type typeOfSrc, JsonSerializationCon
if (!user.getExternalAttrs().isEmpty()) {
JsonArray attrsJsonArray = new JsonArray();
- for (WxCpUser.ExternalAttribute attr : user.getExternalAttrs()) {
+ for (ExternalAttribute attr : user.getExternalAttrs()) {
JsonObject attrJson = GsonHelper.buildJsonObject("type", attr.getType(),
"name", attr.getName());
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModule.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModule.java
index e5aa151933..9d89892f4f 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModule.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/ApiTestModule.java
@@ -7,6 +7,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
@@ -30,7 +31,7 @@ private static T fromXml(Class clazz, InputStream is) {
public void configure(Binder binder) {
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
if (inputStream == null) {
- throw new RuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
+ throw new WxRuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
}
config = fromXml(WxXmlCpInMemoryConfigStorage.class, inputStream);
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java
index 0bd8a24de3..b8a72add12 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java
@@ -1,8 +1,8 @@
package me.chanjar.weixin.cp.api;
import lombok.extern.slf4j.Slf4j;
-import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import org.testng.annotations.DataProvider;
@@ -25,7 +25,7 @@ public synchronized T executeInternal(
RequestExecutor executor, String uri, E data)
throws WxErrorException {
log.info("Executed");
- throw new WxErrorException(WxError.builder().errorCode(-1).build());
+ throw new WxErrorException("something");
}
};
@@ -45,18 +45,15 @@ public void testRetry(WxCpService service) throws WxErrorException {
public void testRetryInThreadPool(final WxCpService service) throws InterruptedException, ExecutionException {
// 当线程池中的线程复用的时候,还是能保证相同的重试次数
ExecutorService executorService = Executors.newFixedThreadPool(1);
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- try {
- System.out.println("=====================");
- System.out.println(Thread.currentThread().getName() + ": testRetry");
- service.execute(null, null, null);
- } catch (WxErrorException e) {
- throw new RuntimeException(e);
- } catch (RuntimeException e) {
- // OK
- }
+ Runnable runnable = () -> {
+ try {
+ System.out.println("=====================");
+ System.out.println(Thread.currentThread().getName() + ": testRetry");
+ service.execute(null, null, null);
+ } catch (WxErrorException e) {
+ throw new WxRuntimeException(e);
+ } catch (RuntimeException e) {
+ // OK
}
};
Future> submit1 = executorService.submit(runnable);
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java
index 112e9f8c38..5e3f665c35 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpMessageRouterTest.java
@@ -84,14 +84,11 @@ public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map co
}).end();
final WxCpXmlMessage m = new WxCpXmlMessage();
- Runnable r = new Runnable() {
- @Override
- public void run() {
- router.route(m);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
+ Runnable r = () -> {
+ router.route(m);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
}
};
for (int i = 0; i < 10; i++) {
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java
index 9a0fbdbd3d..8cace0fe3e 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImplTest.java
@@ -217,4 +217,17 @@ public void testSendWelcomeMsg() throws WxErrorException {
.welcomeCode("abc")
.build());
}
+
+ @Test
+ public void testUpdateRemark() throws WxErrorException {
+ this.wxCpService.getExternalContactService().updateRemark(WxCpUpdateRemarkRequest.builder()
+ .description("abc")
+ .userId("aaa")
+ .externalUserId("aaa")
+ .remark("aa")
+ .remarkCompany("aaa")
+ .remarkMobiles(new String[]{"111","222"})
+ .remarkPicMediaId("aaa")
+ .build());
+ }
}
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImplTest.java
index 40597fa24c..57bd9b750d 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImplTest.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImplTest.java
@@ -46,7 +46,7 @@ public void testSendMarkDown() throws WxErrorException {
">类型:用户反馈 \n" +
">普通用户反馈:117例 \n" +
">VIP用户反馈:15例";
- robotService.sendMarkDown(content);
+ robotService.sendMarkdown(content);
}
@Test
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImplTest.java
new file mode 100644
index 0000000000..905dc4995b
--- /dev/null
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaCalendarServiceImplTest.java
@@ -0,0 +1,39 @@
+package me.chanjar.weixin.cp.api.impl;
+
+import com.google.inject.Inject;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.api.ApiTestModule;
+import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.bean.oa.calendar.WxCpOaCalendar;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+
+/**
+ * 单元测试.
+ *
+ * @author Binary Wang
+ * @date 2020-09-20
+ */
+
+@Test
+@Guice(modules = ApiTestModule.class)
+public class WxCpOaCalendarServiceImplTest {
+ @Inject
+ protected WxCpService wxService;
+
+ @Test
+ public void testAdd() throws WxErrorException {
+ this.wxService.getOaCalendarService().add(WxCpOaCalendar.builder()
+ .organizer("userid1")
+ .readonly(1)
+ .setAsDefault(1)
+ .summary("test_summary")
+ .color("#FF3030")
+ .description("test_describe")
+ .shares(Arrays.asList(new WxCpOaCalendar.ShareInfo("userid2", null),
+ new WxCpOaCalendar.ShareInfo("userid3", 1)))
+ .build());
+ }
+}
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java
index 6f3a76b0ab..758f77970e 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpOaServiceImplTest.java
@@ -37,7 +37,7 @@ public void testGetCheckinData() throws ParseException, WxErrorException {
Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-04-11");
Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-05-10");
- List results = wxService.getOAService()
+ List results = wxService.getOaService()
.getCheckinData(1, startTime, endTime, Lists.newArrayList("binary"));
assertThat(results).isNotNull();
@@ -51,7 +51,7 @@ public void testGetCheckinData() throws ParseException, WxErrorException {
public void testGetCheckinOption() throws WxErrorException {
Date now = new Date();
- List results = wxService.getOAService().getCheckinOption(now, Lists.newArrayList("binary"));
+ List results = wxService.getOaService().getCheckinOption(now, Lists.newArrayList("binary"));
assertThat(results).isNotNull();
System.out.println("results ");
System.out.println(gson.toJson(results));
@@ -61,7 +61,7 @@ public void testGetCheckinOption() throws WxErrorException {
public void testGetApprovalInfo() throws WxErrorException, ParseException {
Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-12-01");
Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-12-31");
- WxCpApprovalInfo result = wxService.getOAService().getApprovalInfo(startTime, endTime);
+ WxCpApprovalInfo result = wxService.getOaService().getApprovalInfo(startTime, endTime);
assertThat(result).isNotNull();
@@ -72,7 +72,7 @@ public void testGetApprovalInfo() throws WxErrorException, ParseException {
@Test
public void testGetApprovalDetail() throws WxErrorException {
String spNo = "201912020001";
- WxCpApprovalDetailResult result = wxService.getOAService().getApprovalDetail(spNo);
+ WxCpApprovalDetailResult result = wxService.getOaService().getApprovalDetail(spNo);
assertThat(result).isNotNull();
@@ -83,7 +83,7 @@ public void testGetApprovalDetail() throws WxErrorException {
@Test
public void testGetTemplateDetail() throws WxErrorException {
String templateId = "3TkZjxugodbqpEMk9j7X6h6zKqYkc7MxQrrFmT7H";
- WxCpTemplateResult result = wxService.getOAService().getTemplateDetail(templateId);
+ WxCpTemplateResult result = wxService.getOaService().getTemplateDetail(templateId);
assertThat(result).isNotNull();
System.out.println("result ");
System.out.println(gson.toJson(result));
@@ -91,7 +91,7 @@ public void testGetTemplateDetail() throws WxErrorException {
@Test
public void testApply() throws WxErrorException {
- this.wxService.getOAService().apply(new WxCpOaApplyEventRequest().setCreatorUserId("123"));
+ this.wxService.getOaService().apply(new WxCpOaApplyEventRequest().setCreatorUserId("123"));
}
@Test
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequestTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequestTest.java
new file mode 100644
index 0000000000..9564cdf9bc
--- /dev/null
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/external/WxCpUpdateRemarkRequestTest.java
@@ -0,0 +1,42 @@
+package me.chanjar.weixin.cp.bean.external;
+
+import me.chanjar.weixin.common.util.json.GsonParser;
+import org.testng.annotations.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * 单元测试.
+ *
+ * @author Binary Wang
+ * @date 2020-09-20
+ */
+public class WxCpUpdateRemarkRequestTest {
+
+ @Test
+ public void testToJson() {
+ String json = "{\n" +
+ " \"userid\":\"zhangsan\",\n" +
+ " \"external_userid\":\"woAJ2GCAAAd1asdasdjO4wKmE8Aabj9AAA\",\n" +
+ " \"remark\":\"备注信息\",\n" +
+ " \"description\":\"描述信息\",\n" +
+ " \"remark_company\":\"腾讯科技\",\n" +
+ " \"remark_mobiles\":[\n" +
+ " \"13800000001\",\n" +
+ " \"13800000002\"\n" +
+ " ],\n" +
+ " \"remark_pic_mediaid\":\"MEDIAID\"\n" +
+ "}\n";
+
+ WxCpUpdateRemarkRequest request = WxCpUpdateRemarkRequest.builder()
+ .description("描述信息")
+ .userId("zhangsan")
+ .externalUserId("woAJ2GCAAAd1asdasdjO4wKmE8Aabj9AAA")
+ .remark("备注信息")
+ .remarkCompany("腾讯科技")
+ .remarkMobiles(new String[]{"13800000001","13800000002"})
+ .remarkPicMediaId("MEDIAID")
+ .build();
+ assertThat(request.toJson()).isEqualTo(GsonParser.parse(json).toString());
+ }
+}
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/calendar/WxCpOaCalendarTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/calendar/WxCpOaCalendarTest.java
new file mode 100644
index 0000000000..761b0f8f9a
--- /dev/null
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/oa/calendar/WxCpOaCalendarTest.java
@@ -0,0 +1,52 @@
+package me.chanjar.weixin.cp.bean.oa.calendar;
+
+import me.chanjar.weixin.common.util.json.GsonParser;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * 单元测试.
+ *
+ * @author Binary Wang
+ * @date 2020-09-20
+ */
+public class WxCpOaCalendarTest {
+
+ @Test
+ public void testToJson() {
+ String json = "{\n" +
+ " \"calendar\" : {\n" +
+ " \"organizer\" : \"userid1\",\n" +
+ " \"readonly\" : 1,\n" +
+ " \"set_as_default\" : 1,\n" +
+ " \"summary\" : \"test_summary\",\n" +
+ " \"color\" : \"#FF3030\",\n" +
+ " \"description\" : \"test_describe\",\n" +
+ " \"shares\" : [\n" +
+ " {\n" +
+ " \"userid\" : \"userid2\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"userid\" : \"userid3\",\n" +
+ " \"readonly\" : 1\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ "}\n";
+
+ assertThat(WxCpOaCalendar.builder()
+ .organizer("userid1")
+ .readonly(1)
+ .setAsDefault(1)
+ .summary("test_summary")
+ .color("#FF3030")
+ .description("test_describe")
+ .shares(Arrays.asList(new WxCpOaCalendar.ShareInfo("userid2", null),
+ new WxCpOaCalendar.ShareInfo("userid3", 1)))
+ .build().toJson())
+ .isEqualTo(GsonParser.parse(json).toString());
+ }
+}
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoServer.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoServer.java
index 2067e03eb9..52bc8e2ab7 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoServer.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpDemoServer.java
@@ -1,24 +1,19 @@
package me.chanjar.weixin.cp.demo;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.servlet.ServletHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
-
-import me.chanjar.weixin.common.error.WxErrorException;
-import me.chanjar.weixin.common.session.WxSessionManager;
-import me.chanjar.weixin.cp.constant.WxCpConsts;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
-import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage;
import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage;
import me.chanjar.weixin.cp.bean.message.WxCpXmlOutTextMessage;
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
+import me.chanjar.weixin.cp.constant.WxCpConsts;
import me.chanjar.weixin.cp.message.WxCpMessageHandler;
import me.chanjar.weixin.cp.message.WxCpMessageRouter;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+import java.io.IOException;
+import java.io.InputStream;
public class WxCpDemoServer {
@@ -54,30 +49,20 @@ private static void initWeixin() throws IOException {
wxCpService = new WxCpServiceImpl();
wxCpService.setWxCpConfigStorage(config);
- WxCpMessageHandler handler = new WxCpMessageHandler() {
- @Override
- public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage,
- Map context, WxCpService wxService,
- WxSessionManager sessionManager) {
- WxCpXmlOutTextMessage m = WxCpXmlOutMessage.TEXT().content("测试加密消息")
- .fromUser(wxMessage.getToUserName())
- .toUser(wxMessage.getFromUserName()).build();
- return m;
- }
+ WxCpMessageHandler handler = (wxMessage, context, wxService, sessionManager) -> {
+ WxCpXmlOutTextMessage m = WxCpXmlOutMessage.TEXT().content("测试加密消息")
+ .fromUser(wxMessage.getToUserName())
+ .toUser(wxMessage.getFromUserName()).build();
+ return m;
};
- WxCpMessageHandler oauth2handler = new WxCpMessageHandler() {
- @Override
- public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage,
- Map context, WxCpService wxService,
- WxSessionManager sessionManager) {
- String href = "测试oauth2";
- return WxCpXmlOutMessage.TEXT().content(href)
- .fromUser(wxMessage.getToUserName())
- .toUser(wxMessage.getFromUserName()).build();
- }
+ WxCpMessageHandler oauth2handler = (wxMessage, context, wxService, sessionManager) -> {
+ String href = "测试oauth2";
+ return WxCpXmlOutMessage.TEXT().content(href)
+ .fromUser(wxMessage.getToUserName())
+ .toUser(wxMessage.getFromUserName()).build();
};
wxCpMessageRouter = new WxCpMessageRouter(wxCpService);
@@ -93,12 +78,9 @@ public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage,
.end()
.rule()
.event(WxCpConsts.EventType.CHANGE_CONTACT)
- .handler(new WxCpMessageHandler() {
- @Override
- public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map context, WxCpService wxCpService, WxSessionManager sessionManager) throws WxErrorException {
- System.out.println("通讯录发生变更");
- return null;
- }
+ .handler((wxMessage, context, wxCpService, sessionManager) -> {
+ System.out.println("通讯录发生变更");
+ return null;
})
.end();
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpEndpointServlet.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpEndpointServlet.java
index 3f48c32130..a5e785ffdf 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpEndpointServlet.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/demo/WxCpEndpointServlet.java
@@ -61,7 +61,6 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
response.getWriter().write(outMessage.toEncryptedXml(this.wxCpConfigStorage));
}
- return;
}
}
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpTpServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java
similarity index 91%
rename from weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpTpServiceImplTest.java
rename to weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java
index 9f79735612..83ace79f3c 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpTpServiceImplTest.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java
@@ -1,20 +1,20 @@
-package me.chanjar.weixin.cp.api.impl;
+package me.chanjar.weixin.cp.tp.service.impl;
import com.google.gson.JsonObject;
import me.chanjar.weixin.common.error.WxErrorException;
-import me.chanjar.weixin.cp.api.WxCpTpService;
import me.chanjar.weixin.cp.bean.WxCpTpAuthInfo;
import me.chanjar.weixin.cp.bean.WxCpTpCorp;
import me.chanjar.weixin.cp.bean.WxCpTpPermanentCodeInfo;
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage;
import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl;
+import me.chanjar.weixin.cp.tp.service.WxCpTpService;
+import org.mockito.Mockito;
+import org.testng.Assert;
import org.testng.annotations.Test;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_AUTH_INFO;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_PERMANENT_CODE;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
-import static org.testng.Assert.*;
/**
* 测试代码.
@@ -23,7 +23,7 @@
* @date 2019-08-18
*/
public class BaseWxCpTpServiceImplTest {
- private WxCpTpService tpService = spy(new WxCpTpServiceImpl());
+ private final WxCpTpService tpService = Mockito.spy(new WxCpTpServiceImpl());
@Test
public void testCheckSignature() {
@@ -123,7 +123,7 @@ public void testGetPermanentCode() throws WxErrorException {
JsonObject jsonObject = new JsonObject();
String authCode = "";
jsonObject.addProperty("auth_code", authCode);
- doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString());
+ Mockito.doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString());
final WxCpTpCorp tpCorp = tpService.getPermanentCode(authCode);
assertThat(tpCorp.getPermanentCode()).isEqualTo("xxxx");
@@ -134,7 +134,7 @@ public void testGetPermanentCode() throws WxErrorException {
}
@Test
- public void testGetPermanentCodeInfo() throws WxErrorException{
+ public void testGetPermanentCodeInfo() throws WxErrorException {
String returnJson = "{\n" +
" \"access_token\": \"u6SoEWyrEmworJ1uNzddbiXh42mCLNU_mdd6b01Afo2LKmyi-WdaaYqhEGFZjB1RGZ-rhjLcAJ86ger7b7Q0gowSw9iIDR8dm49aVH_MztzmQttP3XFG7np1Dxs_VQkVwhhRmfRpEonAmK1_JWIFqayJXXiPUS3LsFd3tWpE7rxmsRa7Ev2ml2htbRp_qGUjtFTErKoDsnNGSka6_RqFPA\", \n" +
" \"expires_in\": 7200, \n" +
@@ -187,15 +187,15 @@ public void testGetPermanentCodeInfo() throws WxErrorException{
JsonObject jsonObject = new JsonObject();
String authCode = "";
jsonObject.addProperty("auth_code", authCode);
- doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString());
+ Mockito.doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString());
final WxCpTpPermanentCodeInfo tpPermanentCodeInfo = tpService.getPermanentCodeInfo(authCode);
assertThat(tpPermanentCodeInfo.getAuthInfo().getAgents().get(0).getAgentId()).isEqualTo(1000012);
- assertNotNull(tpPermanentCodeInfo.getAuthInfo().getAgents().get(0).getSquareLogoUrl());
- assertNotNull(tpPermanentCodeInfo.getAuthCorpInfo().getCorpSquareLogoUrl());
+ Assert.assertNotNull(tpPermanentCodeInfo.getAuthInfo().getAgents().get(0).getSquareLogoUrl());
+ Assert.assertNotNull(tpPermanentCodeInfo.getAuthCorpInfo().getCorpSquareLogoUrl());
}
@Test
- public void testGetAuthInfo() throws WxErrorException{
+ public void testGetAuthInfo() throws WxErrorException {
String returnJson = "{\n" +
" \"errcode\":0 ,\n" +
" \"errmsg\":\"ok\" ,\n" +
@@ -260,9 +260,9 @@ public void testGetAuthInfo() throws WxErrorException{
String permanentCode = "xxxxx";
jsonObject.addProperty("auth_corpid", authCorpId);
jsonObject.addProperty("permanent_code", permanentCode);
- doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_AUTH_INFO), jsonObject.toString());
- WxCpTpAuthInfo authInfo = tpService.getAuthInfo(authCorpId,permanentCode);
- assertNotNull(authInfo.getAuthCorpInfo().getCorpId());
+ Mockito.doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_AUTH_INFO), jsonObject.toString());
+ WxCpTpAuthInfo authInfo = tpService.getAuthInfo(authCorpId, permanentCode);
+ Assert.assertNotNull(authInfo.getAuthCorpInfo().getCorpId());
}
@Test
diff --git a/weixin-java-miniapp/pom.xml b/weixin-java-miniapp/pom.xml
index 41ddb0a636..43f460ceed 100644
--- a/weixin-java-miniapp/pom.xml
+++ b/weixin-java-miniapp/pom.xml
@@ -7,7 +7,7 @@
com.github.binarywang
wx-java
- 3.9.2.B
+ 3.9.4.B
weixin-java-miniapp
@@ -126,7 +126,7 @@
3.5.1
- cn.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
+ com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java
index 7bd1eec748..e155fea0dc 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java
@@ -17,6 +17,7 @@
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.DataUtils;
import me.chanjar.weixin.common.util.crypto.SHA1;
import me.chanjar.weixin.common.util.http.RequestExecutor;
@@ -155,7 +156,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
String response = doGetAccessTokenRequest();
return extractAccessToken(response);
} catch (IOException | InterruptedException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
} finally {
if (locked) {
lock.unlock();
@@ -222,7 +223,7 @@ public T execute(RequestExecutor executor, String uri, E data) thro
} while (retryTimes++ < this.maxRetryTimes);
log.warn("重试达到最大次数【{}】", this.maxRetryTimes);
- throw new RuntimeException("微信服务端异常,超出重试次数");
+ throw new WxRuntimeException("微信服务端异常,超出重试次数");
}
private T executeInternal(RequestExecutor executor, String uri, E data) throws WxErrorException {
@@ -267,7 +268,7 @@ private T executeInternal(RequestExecutor executor, String uri, E d
return null;
} catch (IOException e) {
log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage());
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
@@ -354,7 +355,7 @@ public WxMaService switchoverTo(String miniappId) {
return this;
}
- throw new RuntimeException(String.format("无法找到对应【%s】的小程序配置信息,请核实!", miniappId));
+ throw new WxRuntimeException(String.format("无法找到对应【%s】的小程序配置信息,请核实!", miniappId));
}
@Override
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java
index 4e06e42394..08a2e5794c 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java
@@ -8,6 +8,7 @@
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import lombok.Data;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
import org.apache.commons.io.IOUtils;
@@ -174,7 +175,7 @@ public static WxMaMessage fromEncryptedXml(InputStream is, WxMaConfig wxMaConfig
return fromEncryptedXml(IOUtils.toString(is, StandardCharsets.UTF_8), wxMaConfig,
timestamp, nonce, msgSignature);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
@@ -188,7 +189,7 @@ public static WxMaMessage fromEncryptedJson(String encryptedJson, WxMaConfig con
String plainText = new WxMaCryptUtils(config).decrypt(encryptedMessage.getEncrypt());
return fromJson(plainText);
} catch (Exception e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
@@ -196,7 +197,7 @@ public static WxMaMessage fromEncryptedJson(InputStream inputStream, WxMaConfig
try {
return fromEncryptedJson(IOUtils.toString(inputStream, StandardCharsets.UTF_8), config);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java
index ac75b3697d..9b94a04bbb 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java
@@ -1,6 +1,7 @@
package cn.binarywang.wx.miniapp.config.impl;
import com.github.jedis.lock.JedisLock;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import redis.clients.jedis.Jedis;
import java.io.File;
@@ -232,10 +233,10 @@ private DistributedLock(String key) {
public void lock() {
try (Jedis jedis = getConfiguredJedis()) {
if (!lock.acquire(jedis)) {
- throw new RuntimeException("acquire timeouted");
+ throw new WxRuntimeException("acquire timeouted");
}
} catch (InterruptedException e) {
- throw new RuntimeException("lock failed", e);
+ throw new WxRuntimeException("lock failed", e);
}
}
@@ -243,7 +244,7 @@ public void lock() {
public void lockInterruptibly() throws InterruptedException {
try (Jedis jedis = getConfiguredJedis()) {
if (!lock.acquire(jedis)) {
- throw new RuntimeException("acquire timeouted");
+ throw new WxRuntimeException("acquire timeouted");
}
}
}
@@ -253,7 +254,7 @@ public boolean tryLock() {
try (Jedis jedis = getConfiguredJedis()) {
return lock.acquire(jedis);
} catch (InterruptedException e) {
- throw new RuntimeException("lock failed", e);
+ throw new WxRuntimeException("lock failed", e);
}
}
@@ -273,7 +274,7 @@ public void unlock() {
@Override
public Condition newCondition() {
- throw new RuntimeException("unsupported method");
+ throw new WxRuntimeException("unsupported method");
}
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java
index e932da641d..031c688c52 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java
@@ -45,7 +45,7 @@ public WxMaMessageRouter(WxMaService wxMaService) {
this.wxMaService = wxMaService;
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxMaMessageRouter-pool-%d").build();
this.executorService = new ThreadPoolExecutor(DEFAULT_THREAD_POOL_SIZE, DEFAULT_THREAD_POOL_SIZE,
- 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), namedThreadFactory);
+ 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory);
this.sessionManager = new StandardSessionManager();
this.exceptionHandler = new LogExceptionHandler();
this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker();
@@ -88,11 +88,8 @@ private WxMaXmlOutMessage route(final WxMaMessage wxMessage, final Map {
+ rule.service(wxMessage, context, WxMaMessageRouter.this.wxMaService, WxMaMessageRouter.this.sessionManager, WxMaMessageRouter.this.exceptionHandler);
})
);
} else {
@@ -104,18 +101,15 @@ public void run() {
}
if (futures.size() > 0) {
- this.executorService.submit(new Runnable() {
- @Override
- public void run() {
- for (Future> future : futures) {
- try {
- future.get();
- WxMaMessageRouter.this.log.debug("End session access: async=true, sessionId={}", wxMessage.getFromUser());
- // 异步操作结束,session访问结束
- sessionEndAccess(wxMessage);
- } catch (InterruptedException | ExecutionException e) {
- WxMaMessageRouter.this.log.error("Error happened when wait task finish", e);
- }
+ this.executorService.submit(() -> {
+ for (Future> future : futures) {
+ try {
+ future.get();
+ WxMaMessageRouter.this.log.debug("End session access: async=true, sessionId={}", wxMessage.getFromUser());
+ // 异步操作结束,session访问结束
+ sessionEndAccess(wxMessage);
+ } catch (InterruptedException | ExecutionException e) {
+ WxMaMessageRouter.this.log.error("Error happened when wait task finish", e);
}
}
});
@@ -124,7 +118,7 @@ public void run() {
}
public WxMaXmlOutMessage route(final WxMaMessage wxMessage) {
- return this.route(wxMessage, new HashMap(2));
+ return this.route(wxMessage, new HashMap<>(2));
}
private boolean isMsgDuplicated(WxMaMessage wxMessage) {
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java
index 41f3e99574..99181e0434 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java
@@ -6,10 +6,7 @@
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.regex.Pattern;
/**
@@ -135,9 +132,7 @@ public WxMaMessageRouterRule interceptor(WxMaMessageInterceptor interceptor) {
public WxMaMessageRouterRule interceptor(WxMaMessageInterceptor interceptor, WxMaMessageInterceptor... otherInterceptors) {
this.interceptors.add(interceptor);
if (otherInterceptors != null && otherInterceptors.length > 0) {
- for (WxMaMessageInterceptor i : otherInterceptors) {
- this.interceptors.add(i);
- }
+ Collections.addAll(this.interceptors, otherInterceptors);
}
return this;
}
@@ -155,9 +150,7 @@ public WxMaMessageRouterRule handler(WxMaMessageHandler handler) {
public WxMaMessageRouterRule handler(WxMaMessageHandler handler, WxMaMessageHandler... otherHandlers) {
this.handlers.add(handler);
if (otherHandlers != null && otherHandlers.length > 0) {
- for (WxMaMessageHandler i : otherHandlers) {
- this.handlers.add(i);
- }
+ Collections.addAll(this.handlers, otherHandlers);
}
return this;
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java
index 6913541de7..f1a05d001a 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/crypt/WxMaCryptUtils.java
@@ -12,6 +12,7 @@
import com.google.common.base.CharMatcher;
import com.google.common.io.BaseEncoding;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import org.apache.commons.codec.binary.Base64;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
@@ -47,7 +48,7 @@ public static String decrypt(String sessionKey, String encryptedData, String ivS
return new String(PKCS7Encoder.decode(cipher.doFinal(Base64.decodeBase64(encryptedData))), UTF_8);
} catch (Exception e) {
- throw new RuntimeException("AES解密失败!", e);
+ throw new WxRuntimeException("AES解密失败!", e);
}
}
@@ -78,7 +79,7 @@ public static String decryptAnotherWay(String sessionKey, String encryptedData,
cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(Base64.decodeBase64(ivStr.getBytes(UTF_8))));
return new String(cipher.doFinal(Base64.decodeBase64(encryptedData.getBytes(UTF_8))), UTF_8);
} catch (Exception e) {
- throw new RuntimeException("AES解密失败!", e);
+ throw new WxRuntimeException("AES解密失败!", e);
}
}
diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/ApiTestModule.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/ApiTestModule.java
index 267eb70ca3..a9f5def789 100644
--- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/ApiTestModule.java
+++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/test/ApiTestModule.java
@@ -4,6 +4,7 @@
import java.io.InputStream;
import java.util.concurrent.locks.ReentrantLock;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,7 +24,7 @@ public class ApiTestModule implements Module {
public void configure(Binder binder) {
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
if (inputStream == null) {
- throw new RuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
+ throw new WxRuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
}
TestConfig config = TestConfig.fromXml(inputStream);
config.setAccessTokenLock(new ReentrantLock());
diff --git a/weixin-java-mp/pom.xml b/weixin-java-mp/pom.xml
index d1f1ac0fd0..89efb9869d 100644
--- a/weixin-java-mp/pom.xml
+++ b/weixin-java-mp/pom.xml
@@ -7,7 +7,7 @@
com.github.binarywang
wx-java
- 3.9.2.B
+ 3.9.4.B
weixin-java-mp
@@ -115,7 +115,7 @@
3.5.1
- cn.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
+ com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
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 9b2ca03fe9..263305c0d0 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
@@ -1,5 +1,8 @@
package me.chanjar.weixin.mp.api;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxErrorExceptionHandler;
import me.chanjar.weixin.common.api.WxMessageDuplicateChecker;
import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker;
@@ -18,10 +21,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
+import java.util.concurrent.*;
/**
*
@@ -51,9 +51,10 @@
*
* @author Daniel Qian
*/
+@Slf4j
+@AllArgsConstructor
public class WxMpMessageRouter {
private static final int DEFAULT_THREAD_POOL_SIZE = 100;
- protected final Logger log = LoggerFactory.getLogger(WxMpMessageRouter.class);
private final List rules = new ArrayList<>();
private final WxMpService wxMpService;
@@ -68,7 +69,9 @@ public class WxMpMessageRouter {
public WxMpMessageRouter(WxMpService wxMpService) {
this.wxMpService = wxMpService;
- this.executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE);
+ ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxMpMessageRouter-pool-%d").build();
+ this.executorService = new ThreadPoolExecutor(DEFAULT_THREAD_POOL_SIZE, DEFAULT_THREAD_POOL_SIZE,
+ 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory);
this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker();
this.sessionManager = new StandardSessionManager();
this.exceptionHandler = new LogExceptionHandler();
@@ -199,7 +202,7 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map future : futures) {
try {
future.get();
- WxMpMessageRouter.this.log.debug("End session access: async=true, sessionId={}", wxMessage.getFromUser());
+ log.debug("End session access: async=true, sessionId={}", wxMessage.getFromUser());
// 异步操作结束,session访问结束
sessionEndAccess(wxMessage);
} catch (InterruptedException e) {
- WxMpMessageRouter.this.log.error("Error happened when wait task finish", e);
+ log.error("Error happened when wait task finish", e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
- WxMpMessageRouter.this.log.error("Error happened when wait task finish", e);
+ log.error("Error happened when wait task finish", e);
}
}
});
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 ad11e81b41..a742c196c9 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
@@ -7,10 +7,7 @@
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.apache.commons.lang3.StringUtils;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.regex.Pattern;
public class WxMpMessageRouterRule {
@@ -130,9 +127,7 @@ public WxMpMessageRouterRule interceptor(WxMpMessageInterceptor interceptor) {
public WxMpMessageRouterRule interceptor(WxMpMessageInterceptor interceptor, WxMpMessageInterceptor... otherInterceptors) {
this.interceptors.add(interceptor);
if (otherInterceptors != null && otherInterceptors.length > 0) {
- for (WxMpMessageInterceptor i : otherInterceptors) {
- this.interceptors.add(i);
- }
+ Collections.addAll(this.interceptors, otherInterceptors);
}
return this;
}
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 aa7a872f39..958e7f7309 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
@@ -12,9 +12,7 @@
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.mp.bean.WxMpSemanticQuery;
import me.chanjar.weixin.mp.bean.result.WxMpCurrentAutoReplyInfo;
-import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
-import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.enums.WxMpApiUrl;
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java
index f836cebaa6..966ddc4c05 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java
@@ -17,6 +17,7 @@
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.session.StandardSessionManager;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.common.util.DataUtils;
@@ -28,9 +29,7 @@
import me.chanjar.weixin.mp.api.*;
import me.chanjar.weixin.mp.bean.WxMpSemanticQuery;
import me.chanjar.weixin.mp.bean.result.WxMpCurrentAutoReplyInfo;
-import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
-import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.enums.WxMpApiUrl;
import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder;
@@ -203,9 +202,8 @@ public String getAccessToken() throws WxErrorException {
@Override
public String shortUrl(String longUrl) throws WxErrorException {
if (longUrl.contains("&access_token=")) {
- throw new WxErrorException(WxError.builder().errorCode(-1)
- .errorMsg("要转换的网址中存在非法字符{&access_token=},会导致微信接口报错,属于微信bug,请调整地址,否则不建议使用此方法!")
- .build());
+ throw new WxErrorException("要转换的网址中存在非法字符{&access_token=}," +
+ "会导致微信接口报错,属于微信bug,请调整地址,否则不建议使用此方法!");
}
JsonObject o = new JsonObject();
@@ -303,7 +301,7 @@ public T execute(RequestExecutor executor, String uri, E data) thro
if (retryTimes + 1 > this.maxRetryTimes) {
log.warn("重试达到最大次数【{}】", maxRetryTimes);
//最后一次重试失败后,直接抛出异常,不再等待
- throw new RuntimeException("微信服务端异常,超出重试次数");
+ throw new WxRuntimeException("微信服务端异常,超出重试次数");
}
WxError error = e.getError();
@@ -314,7 +312,7 @@ public T execute(RequestExecutor executor, String uri, E data) thro
log.warn("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1);
Thread.sleep(sleepMillis);
} catch (InterruptedException e1) {
- throw new RuntimeException(e1);
+ throw new WxRuntimeException(e1);
}
} else {
throw e;
@@ -323,7 +321,7 @@ public T execute(RequestExecutor executor, String uri, E data) thro
} while (retryTimes++ < this.maxRetryTimes);
log.warn("重试达到最大次数【{}】", this.maxRetryTimes);
- throw new RuntimeException("微信服务端异常,超出重试次数");
+ throw new WxRuntimeException("微信服务端异常,超出重试次数");
}
protected T executeInternal(RequestExecutor executor, String uri, E data) throws WxErrorException {
@@ -448,7 +446,7 @@ public WxMpService switchoverTo(String mpId) {
return this;
}
- throw new RuntimeException(String.format("无法找到对应【%s】的公众号配置信息,请核实!", mpId));
+ throw new WxRuntimeException(String.format("无法找到对应【%s】的公众号配置信息,请核实!", mpId));
}
@Override
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 a131e3a9f3..1ed957aae5 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
@@ -115,11 +115,11 @@ public WxMpKfSessionWaitCaseList kfSessionGetWaitCase() throws WxErrorException
@Override
public WxMpKfMsgList kfMsgList(Date startTime, Date endTime, Long msgId, Integer number) throws WxErrorException {
if (number > 10000) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法参数请求,每次最多查询10000条记录!").build());
+ throw new WxErrorException("非法参数请求,每次最多查询10000条记录!");
}
if (startTime.after(endTime)) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("起始时间不能晚于结束时间!").build());
+ throw new WxErrorException("起始时间不能晚于结束时间!");
}
JsonObject param = new JsonObject();
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java
index a654afb769..7bad648cb5 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpQrcodeServiceImpl.java
@@ -29,7 +29,7 @@ public class WxMpQrcodeServiceImpl implements WxMpQrcodeService {
@Override
public WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds) throws WxErrorException {
if (sceneId == 0) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("临时二维码场景值不能为0!").build());
+ throw new WxErrorException("临时二维码场景值不能为0!");
}
return this.createQrCode("QR_SCENE", null, sceneId, expireSeconds);
@@ -38,7 +38,7 @@ public WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds
@Override
public WxMpQrCodeTicket qrCodeCreateTmpTicket(String sceneStr, Integer expireSeconds) throws WxErrorException {
if (StringUtils.isBlank(sceneStr)) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("临时二维码场景值不能为空!").build());
+ throw new WxErrorException("临时二维码场景值不能为空!");
}
return this.createQrCode("QR_STR_SCENE", sceneStr, null, expireSeconds);
@@ -48,8 +48,7 @@ private WxMpQrCodeTicket createQrCode(String actionName, String sceneStr, Intege
throws WxErrorException {
//expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。
if (expireSeconds != null && expireSeconds > 2592000) {
- throw new WxErrorException(WxError.builder().errorCode(-1)
- .errorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build());
+ throw new WxErrorException("临时二维码有效时间最大不能超过2592000(即30天)!");
}
if (expireSeconds == null) {
@@ -84,9 +83,7 @@ private WxMpQrCodeTicket getQrCodeTicket(String actionName, String sceneStr, Int
@Override
public WxMpQrCodeTicket qrCodeCreateLastTicket(int sceneId) throws WxErrorException {
if (sceneId < 1 || sceneId > 100000) {
- throw new WxErrorException(WxError.builder().errorCode(-1)
- .errorMsg("永久二维码的场景值目前只支持1--100000!")
- .build());
+ throw new WxErrorException("永久二维码的场景值目前只支持1--100000!");
}
return this.getQrCodeTicket("QR_LIMIT_SCENE", null, sceneId, null);
@@ -113,7 +110,7 @@ public String qrCodePictureUrl(String ticket, boolean needShortUrl) throws WxErr
return resultUrl;
} catch (UnsupportedEncodingException e) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg(e.getMessage()).build());
+ throw new WxErrorException(e.getMessage());
}
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpClientImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpClientImpl.java
index 6e7ee376c7..8b5e029104 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpClientImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceHttpClientImpl.java
@@ -1,6 +1,7 @@
package me.chanjar.weixin.mp.api.impl;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.http.HttpType;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
@@ -92,10 +93,10 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
httpGet.releaseConnection();
}
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
} catch (InterruptedException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
} finally {
if (locked) {
lock.unlock();
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java
index 56b8eb12eb..eb75f1ff62 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceJoddHttpImpl.java
@@ -5,6 +5,7 @@
import jodd.http.ProxyInfo;
import jodd.http.net.SocketHttpConnectionProvider;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.http.HttpType;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
@@ -77,7 +78,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
return this.extractAccessToken(request.send().bodyText());
} catch (InterruptedException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
} finally {
if (locked) {
lock.unlock();
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
index 6d6708349f..3639d1bc06 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceOkHttpImpl.java
@@ -1,6 +1,7 @@
package me.chanjar.weixin.mp.api.impl;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.http.HttpType;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
@@ -59,9 +60,9 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
Response response = getRequestHttpClient().newCall(request).execute();
return this.extractAccessToken(Objects.requireNonNull(response.body()).string());
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
} catch (InterruptedException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
} finally {
if (locked) {
lock.unlock();
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxOAuth2ServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxOAuth2ServiceImpl.java
index 3c6287b7dd..7ad8ed2c4a 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxOAuth2ServiceImpl.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxOAuth2ServiceImpl.java
@@ -5,6 +5,7 @@
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
import me.chanjar.weixin.common.util.http.URIUtil;
@@ -75,7 +76,7 @@ public WxMpUser getUserInfo(WxMpOAuth2AccessToken token, String lang) throws WxE
String responseText = executor.execute(url, null, WxType.MP);
return WxMpUser.fromJson(responseText);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
@@ -86,7 +87,7 @@ public boolean validateAccessToken(WxMpOAuth2AccessToken token) {
try {
SimpleGetRequestExecutor.create(this.wxMpService.getRequestHttp()).execute(url, null, WxType.MP);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
} catch (WxErrorException e) {
return false;
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java
index f6b54a20b2..adee564f96 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessage.java
@@ -5,6 +5,7 @@
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.XmlUtils;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
@@ -716,7 +717,7 @@ public static WxMpXmlMessage fromEncryptedXml(InputStream is, WxMpConfigStorage
try {
return fromEncryptedXml(IOUtils.toString(is, StandardCharsets.UTF_8), wxMpConfigStorage, timestamp, nonce, msgSignature);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
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 e9e5112d31..679f8db1ac 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
@@ -2,6 +2,7 @@
import com.google.gson.*;
import me.chanjar.weixin.common.api.WxConsts.KefuMsgType;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
import org.apache.commons.lang3.StringUtils;
@@ -96,7 +97,7 @@ public JsonElement serialize(WxMpKefuMessage message, Type typeOfSrc, JsonSerial
break;
}
default: {
- throw new RuntimeException("非法消息类型,暂不支持");
+ throw new WxRuntimeException("非法消息类型,暂不支持");
}
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialDeleteJoddHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialDeleteJoddHttpRequestExecutor.java
index afc99d62c0..318299bb34 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialDeleteJoddHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialDeleteJoddHttpRequestExecutor.java
@@ -12,6 +12,7 @@
import me.chanjar.weixin.common.util.http.RequestHttp;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
/**
* Created by ecoolper on 2017/5/5.
@@ -31,7 +32,7 @@ public Boolean execute(String uri, String materialId, WxType wxType) throws WxEr
request.query("media_id", materialId);
HttpResponse response = request.send();
- response.charset(StringPool.UTF_8);
+ response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
WxError error = WxError.fromJson(responseContent, WxType.MP);
if (error.getErrorCode() != 0) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoJoddHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoJoddHttpRequestExecutor.java
index 59f0710692..780c0734e1 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoJoddHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialNewsInfoJoddHttpRequestExecutor.java
@@ -7,6 +7,7 @@
import jodd.http.ProxyInfo;
import jodd.util.StringPool;
+import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
@@ -18,12 +19,13 @@
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
/**
* Created by ecoolper on 2017/5/5.
*/
+@Slf4j
public class MaterialNewsInfoJoddHttpRequestExecutor extends MaterialNewsInfoRequestExecutor {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
public MaterialNewsInfoJoddHttpRequestExecutor(RequestHttp requestHttp) {
super(requestHttp);
}
@@ -38,10 +40,10 @@ public WxMpMaterialNews execute(String uri, String materialId, WxType wxType) th
.withConnectionProvider(requestHttp.getRequestHttpClient())
.body(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId)));
HttpResponse response = request.send();
- response.charset(StringPool.UTF_8);
+ response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
- this.logger.debug("响应原始数据:{}", responseContent);
+ log.debug("响应原始数据:{}", responseContent);
WxError error = WxError.fromJson(responseContent, WxType.MP);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadApacheHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadApacheHttpRequestExecutor.java
index a89687cd22..053ff16cba 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadApacheHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadApacheHttpRequestExecutor.java
@@ -41,7 +41,7 @@ public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material, WxTyp
}
if (material == null) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法请求,material参数为空").build());
+ throw new WxErrorException("非法请求,material参数为空");
}
File file = material.getFile();
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadJoddHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadJoddHttpRequestExecutor.java
index 7699f2f202..d4c4dfbf89 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadJoddHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadJoddHttpRequestExecutor.java
@@ -17,6 +17,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
@@ -36,7 +37,7 @@ public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material, WxTyp
request.withConnectionProvider(requestHttp.getRequestHttpClient());
if (material == null) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法请求,material参数为空").build());
+ throw new WxErrorException("非法请求,material参数为空");
}
File file = material.getFile();
@@ -50,7 +51,7 @@ public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material, WxTyp
}
HttpResponse response = request.send();
- response.charset(StringPool.UTF_8);
+ response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
WxError error = WxError.fromJson(responseContent, WxType.MP);
if (error.getErrorCode() != 0) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadOkhttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadOkhttpRequestExecutor.java
index f4654f9fb1..7416f94f0e 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadOkhttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialUploadOkhttpRequestExecutor.java
@@ -31,7 +31,7 @@ public MaterialUploadOkhttpRequestExecutor(RequestHttp requestHttp) {
public WxMpMaterialUploadResult execute(String uri, WxMpMaterial material, WxType wxType) throws WxErrorException, IOException {
logger.debug("MaterialUploadOkhttpRequestExecutor is running");
if (material == null) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法请求,material参数为空").build());
+ throw new WxErrorException("非法请求,material参数为空");
}
File file = material.getFile();
if (file == null || !file.exists()) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialVideoInfoJoddHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialVideoInfoJoddHttpRequestExecutor.java
index f142c21788..9149d46794 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialVideoInfoJoddHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialVideoInfoJoddHttpRequestExecutor.java
@@ -13,6 +13,7 @@
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
/**
* Created by ecoolper on 2017/5/5.
@@ -32,7 +33,7 @@ public WxMpMaterialVideoInfoResult execute(String uri, String materialId, WxType
request.query("media_id", materialId);
HttpResponse response = request.send();
- response.charset(StringPool.UTF_8);
+ response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
WxError error = WxError.fromJson(responseContent, WxType.MP);
if (error.getErrorCode() != 0) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialVoiceAndImageDownloadJoddHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialVoiceAndImageDownloadJoddHttpRequestExecutor.java
index 1a4c25590c..e4da2004ec 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialVoiceAndImageDownloadJoddHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/material/MaterialVoiceAndImageDownloadJoddHttpRequestExecutor.java
@@ -37,7 +37,7 @@ public InputStream execute(String uri, String materialId, WxType wxType) throws
request.query("media_id", materialId);
HttpResponse response = request.send();
- response.charset(StringPool.UTF_8);
+ response.charset(StandardCharsets.UTF_8.name());
try (InputStream inputStream = new ByteArrayInputStream(response.bodyBytes())) {
// 下载媒体文件出错
byte[] responseContent = IOUtils.toByteArray(inputStream);
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/media/MediaImgUploadApacheHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/media/MediaImgUploadApacheHttpRequestExecutor.java
index 989e388632..b570a1c43b 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/media/MediaImgUploadApacheHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/media/MediaImgUploadApacheHttpRequestExecutor.java
@@ -32,7 +32,7 @@ public MediaImgUploadApacheHttpRequestExecutor(RequestHttp requestHttp) {
@Override
public WxMediaImgUploadResult execute(String uri, File data, WxType wxType) throws WxErrorException, IOException {
if (data == null) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build());
+ throw new WxErrorException("文件对象为空");
}
HttpPost httpPost = new HttpPost(uri);
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/media/MediaImgUploadHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/media/MediaImgUploadHttpRequestExecutor.java
index 76c625141e..1ca4c7c8bf 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/media/MediaImgUploadHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/media/MediaImgUploadHttpRequestExecutor.java
@@ -14,6 +14,7 @@
import java.io.File;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
/**
* Created by ecoolper on 2017/5/5.
@@ -28,7 +29,7 @@ public MediaImgUploadHttpRequestExecutor(RequestHttp requestHttp) {
@Override
public WxMediaImgUploadResult execute(String uri, File data, WxType wxType) throws WxErrorException, IOException {
if (data == null) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build());
+ throw new WxErrorException("文件对象为空");
}
HttpRequest request = HttpRequest.post(uri);
@@ -39,7 +40,7 @@ public WxMediaImgUploadResult execute(String uri, File data, WxType wxType) thro
request.form("media", data);
HttpResponse response = request.send();
- response.charset(StringPool.UTF_8);
+ response.charset(StandardCharsets.UTF_8.name());
String responseContent = response.bodyText();
WxError error = WxError.fromJson(responseContent, WxType.MP);
if (error.getErrorCode() != 0) {
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeJoddHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeJoddHttpRequestExecutor.java
index 99621843db..32d3d3ca75 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeJoddHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeJoddHttpRequestExecutor.java
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.UUID;
/**
@@ -47,7 +48,7 @@ public File execute(String uri, WxMpQrCodeTicket ticket, WxType wxType) throws W
request.withConnectionProvider(requestHttp.getRequestHttpClient());
HttpResponse response = request.send();
- response.charset(StringPool.UTF_8);
+ response.charset(StandardCharsets.UTF_8.name());
String contentTypeHeader = response.header("Content-Type");
if (MimeTypes.MIME_TEXT_PLAIN.equals(contentTypeHeader)) {
String responseContent = response.bodyText();
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeRequestExecutor.java
index 0a65d2abc7..4ca5dbc0c1 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/qrcode/QrCodeRequestExecutor.java
@@ -37,7 +37,7 @@ public static RequestExecutor create(RequestHttp request
case OK_HTTP:
return new QrCodeOkhttpRequestExecutor(requestHttp);
default:
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("不支持的http框架").build());
+ throw new WxErrorException("不支持的http框架");
}
}
diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/voice/VoiceUploadApacheHttpRequestExecutor.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/voice/VoiceUploadApacheHttpRequestExecutor.java
index 3c733a126f..07af44b340 100644
--- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/voice/VoiceUploadApacheHttpRequestExecutor.java
+++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/requestexecuter/voice/VoiceUploadApacheHttpRequestExecutor.java
@@ -33,7 +33,7 @@ public VoiceUploadApacheHttpRequestExecutor(RequestHttp requestHttp) {
@Override
public Boolean execute(String uri, File data, WxType wxType) throws WxErrorException, IOException {
if (data == null) {
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("文件对象为空").build());
+ throw new WxErrorException("文件对象为空");
}
HttpPost httpPost = new HttpPost(uri);
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java
index 1f0a01b46e..938eb5c032 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java
@@ -3,6 +3,7 @@
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
import org.testng.annotations.*;
@@ -25,7 +26,7 @@ public synchronized T executeInternal(
RequestExecutor executor, String uri, E data)
throws WxErrorException {
log.info("Executed");
- throw new WxErrorException(WxError.builder().errorCode(-1).build());
+ throw new WxErrorException("something");
}
};
@@ -43,18 +44,15 @@ public void testRetry(WxMpService service) throws WxErrorException {
public void testRetryInThreadPool(final WxMpService service) throws InterruptedException, ExecutionException {
// 当线程池中的线程复用的时候,还是能保证相同的重试次数
ExecutorService executorService = Executors.newFixedThreadPool(1);
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- try {
- System.out.println("=====================");
- System.out.println(Thread.currentThread().getName() + ": testRetry");
- service.execute(null, (String)null, null);
- } catch (WxErrorException e) {
- throw new RuntimeException(e);
- } catch (RuntimeException e) {
- // OK
- }
+ Runnable runnable = () -> {
+ try {
+ System.out.println("=====================");
+ System.out.println(Thread.currentThread().getName() + ": testRetry");
+ service.execute(null, (String)null, null);
+ } catch (WxErrorException e) {
+ throw new WxRuntimeException(e);
+ } catch (RuntimeException e) {
+ // OK
}
};
Future> submit1 = executorService.submit(runnable);
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 b9424eb023..93f47a70f5 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
@@ -97,14 +97,11 @@ public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map co
}).end();
final WxMpXmlMessage m = new WxMpXmlMessage();
- Runnable r = new Runnable() {
- @Override
- public void run() {
- router.route(m);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
+ Runnable r = () -> {
+ router.route(m);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
}
};
for (int i = 0; i < 10; i++) {
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImplTest.java
index b20d3fe142..1bb8922271 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImplTest.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImplTest.java
@@ -82,15 +82,12 @@ public void refreshAccessTokenDuplicatelyTest() throws InterruptedException {
// 测试多线程刷新accessToken时是否重复刷新
wxService.getWxMpConfigStorage().expireAccessToken();
final Set set = Sets.newConcurrentHashSet();
- Runnable r = new Runnable() {
- @Override
- public void run() {
- try {
- String accessToken = wxService.getAccessToken();
- set.add(accessToken);
- } catch (WxErrorException e) {
- e.printStackTrace();
- }
+ Runnable r = () -> {
+ try {
+ String accessToken = wxService.getAccessToken();
+ set.add(accessToken);
+ } catch (WxErrorException e) {
+ e.printStackTrace();
}
};
diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java
index cc964e80fd..204515934b 100644
--- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java
+++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java
@@ -4,6 +4,7 @@
import java.io.InputStream;
import java.util.concurrent.locks.ReentrantLock;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,7 +24,7 @@ public class ApiTestModule implements Module {
public void configure(Binder binder) {
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
if (inputStream == null) {
- throw new RuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
+ throw new WxRuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
}
TestConfigStorage config = this.fromXml(TestConfigStorage.class, inputStream);
diff --git a/weixin-java-open/pom.xml b/weixin-java-open/pom.xml
index 19d188ac16..03f4e2c00d 100644
--- a/weixin-java-open/pom.xml
+++ b/weixin-java-open/pom.xml
@@ -7,7 +7,7 @@
com.github.binarywang
wx-java
- 3.9.2.B
+ 3.9.4.B
weixin-java-open
@@ -122,7 +122,7 @@
3.5.1
- cn.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
+ com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java
index d460152dfa..91b412f883 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java
@@ -8,6 +8,7 @@
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.crypto.SHA1;
import me.chanjar.weixin.common.util.http.URIUtil;
import me.chanjar.weixin.common.util.json.GsonParser;
@@ -384,7 +385,7 @@ public String getAuthorizerAccessToken(String appId, boolean forceRefresh) throw
config.updateAuthorizerRefreshToken(appId,wxOpenAuthorizerAccessToken.getAuthorizerRefreshToken());
return config.getAuthorizerAccessToken(appId);
} catch (InterruptedException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
} finally {
if (locked) {
lock.unlock();
@@ -488,7 +489,7 @@ private String openAccountServicePost(String appId, String appIdType, String req
result = maService.post(requestUrl, param.toString());
return result;
default:
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("appIdType类型异常").build());
+ throw new WxErrorException("appIdType类型异常");
}
}
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java
index 5efa429ade..ab0a9055be 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMpServiceImpl.java
@@ -1,9 +1,8 @@
package me.chanjar.weixin.open.api.impl;
import me.chanjar.weixin.common.error.WxErrorException;
-import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
-import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
+import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.open.api.WxOpenComponentService;
/**
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java
index eb4ffbfb2b..fa89d09377 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenServiceAbstractImpl.java
@@ -3,6 +3,7 @@
import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.open.api.WxOpenComponentService;
@@ -56,7 +57,7 @@ protected T execute(RequestExecutor executor, String uri, E data) t
return null;
} catch (IOException e) {
this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uri, data, e.getMessage());
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
}
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java
index bef7d16d26..7a41355920 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java
@@ -4,6 +4,7 @@
import com.thoughtworks.xstream.annotations.XStreamConverter;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
@@ -149,7 +150,7 @@ public static WxOpenXmlMessage fromEncryptedXml(InputStream is, WxOpenConfigStor
return fromEncryptedXml(IOUtils.toString(is, StandardCharsets.UTF_8),
wxOpenConfigStorage, timestamp, nonce, msgSignature);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
}
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeJoddHttpRequestExecutor.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeJoddHttpRequestExecutor.java
index 7f24674d9f..fc664483e6 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeJoddHttpRequestExecutor.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeJoddHttpRequestExecutor.java
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.UUID;
/**
@@ -49,7 +50,7 @@ public File execute(String uri, WxMaQrcodeParam qrcodeParam, WxType wxType) thro
request.withConnectionProvider(requestHttp.getRequestHttpClient());
HttpResponse response = request.send();
- response.charset(StringPool.UTF_8);
+ response.charset(StandardCharsets.UTF_8.name());
String contentTypeHeader = response.header("Content-Type");
if (MimeTypes.MIME_TEXT_PLAIN.equals(contentTypeHeader)) {
String responseContent = response.bodyText();
diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeRequestExecutor.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeRequestExecutor.java
index dfaec08565..ac02c1ec3d 100644
--- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeRequestExecutor.java
+++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/executor/MaQrCodeRequestExecutor.java
@@ -38,7 +38,7 @@ public static RequestExecutor create(RequestHttp requestH
case OK_HTTP:
return new MaQrCodeOkhttpRequestExecutor(requestHttp);
default:
- throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("不支持的http框架").build());
+ throw new WxErrorException("不支持的http框架");
}
}
diff --git a/weixin-java-pay/pom.xml b/weixin-java-pay/pom.xml
index 629c6fc654..d84db0f466 100644
--- a/weixin-java-pay/pom.xml
+++ b/weixin-java-pay/pom.xml
@@ -5,7 +5,7 @@
com.github.binarywang
wx-java
- 3.9.2.B
+ 3.9.4.B
4.0.0
@@ -102,7 +102,7 @@
3.5.1
- cn.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
+ com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/CombineTransactionsNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/CombineTransactionsNotifyResult.java
index 0f0196a8ce..dcfae88247 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/CombineTransactionsNotifyResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/CombineTransactionsNotifyResult.java
@@ -1,11 +1,9 @@
package com.github.binarywang.wxpay.bean.ecommerce;
-import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
-import java.util.List;
/**
* 合单支付 通知结果
@@ -24,337 +22,8 @@ public class CombineTransactionsNotifyResult implements Serializable {
private NotifyResponse rawData;
/**
- *
- * 字段名:合单商户appid
- * 变量名:combine_appid
- * 是否必填:是
- * 类型:string(32)
- * 描述:
- * 合单发起方的appid。(即电商平台appid)
- * 示例值:wxd678efh567hg6787
- *
- */
- @SerializedName(value = "combine_appid")
- private String combineAppid;
-
- /**
- *
- * 字段名:合单商户号
- * 变量名:combine_mchid
- * 是否必填:是
- * 类型:string(32)
- * 描述:
- * 合单发起方商户号。(即电商平台mchid)
- * 示例值:1900000109
- *
- */
- @SerializedName(value = "combine_mchid")
- private String combineMchid;
-
- /**
- *
- * 字段名:合单商户订单号
- * 变量名:combine_out_trade_no
- * 是否必填:是
- * 类型:string(32)
- * 描述:
- * 合单支付总订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一。
- * 示例值:P20150806125346
- *
- */
- @SerializedName(value = "combine_out_trade_no")
- private String combineOutTradeNo;
-
- /**
- *
- * 字段名:+场景信息
- * 变量名:scene_info
- * 是否必填:否
- * 类型:object
- * 描述:支付场景信息描述
- *
- */
- @SerializedName(value = "scene_info")
- private SceneInfo sceneInfo;
-
- /**
- *
- * 字段名:+子单信息
- * 变量名:sub_orders
- * 是否必填:是
- * 类型:array
- * 描述:
- * 最多支持子单条数:50
- *
- *
- */
- @SerializedName(value = "sub_orders")
- private List subOrders;
-
- /**
- *
- * 字段名:+支付者
- * 变量名:combine_payer_info
- * 是否必填:否
- * 类型:object
- * 描述:示例值:见请求示例
- *
- */
- @SerializedName(value = "combine_payer_info")
- private CombinePayerInfo combinePayerInfo;
-
- @Data
- @NoArgsConstructor
- public static class SubOrders implements Serializable {
- /**
- *
- * 字段名:子单商户号
- * 变量名:mchid
- * 是否必填:是
- * 类型:string(32)
- * 描述:
- * 子单发起方商户号,必须与发起方Appid有绑定关系。(即电商平台mchid)
- * 示例值:1900000109
- *
- */
- @SerializedName(value = "mchid")
- private String mchid;
-
- /**
- *
- * 字段名:交易类型
- * 变量名:trade_type
- * 是否必填:是
- * 类型:string (16)
- * 描述:
- * 枚举值:
- * NATIVE:扫码支付
- * JSAPI:公众号支付
- * APP:APP支付
- * MWEB:H5支付
- * 示例值: JSAPI
- *
- */
- @SerializedName(value = "trade_type")
- private String tradeType;
-
- /**
- *
- * 字段名:交易状态
- * 变量名:trade_state
- * 是否必填:是
- * 类型:string (32)
- * 描述:
- * 枚举值:
- * SUCCESS:支付成功
- * REFUND:转入退款
- * NOTPAY:未支付
- * CLOSED:已关闭
- * USERPAYING:用户支付中
- * PAYERROR:支付失败(其他原因,如银行返回失败)
- * 示例值: SUCCESS
- *
- */
- @SerializedName(value = "trade_state")
- private String tradeState;
-
- /**
- *
- * 字段名:付款银行
- * 变量名:bank_type
- * 是否必填:否
- * 类型:string(16)
- * 描述:
- * 银行类型,采用字符串类型的银行标识。
- * 示例值:CMC
- *
- */
- @SerializedName(value = "bank_type")
- private String bankType;
-
- /**
- *
- * 字段名:附加信息
- * 变量名:attach
- * 是否必填:是
- * 类型:string(128)
- * 描述:
- * 附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用。
- * 示例值:深圳分店
- *
- */
- @SerializedName(value = "attach")
- private String attach;
-
- /**
- *
- * 字段名:支付完成时间
- * 变量名:success_time
- * 是否必填:是
- * 类型:string(16)
- * 描述:
- * 订单支付时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss:sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss:sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
- * 示例值:2015-05-20T13:29:35.120+08:00
- *
- */
- @SerializedName(value = "success_time")
- private String successTime;
-
- /**
- *
- * 字段名:微信订单号
- * 变量名:transaction_id
- * 是否必填:是
- * 类型:string(32)
- * 描述:
- * 微信支付订单号。
- * 示例值: 1009660380201506130728806387
- *
- */
- @SerializedName(value = "transaction_id")
- private String transactionId;
-
- /**
- *
- * 字段名:子单商户订单号
- * 变量名:out_trade_no
- * 是否必填:是
- * 类型:string(32)
- * 描述:
- * 商户系统内部订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一。
- * 特殊规则:最小字符长度为6
- * 示例值:20150806125346
- *
- */
- @SerializedName(value = "out_trade_no")
- private String outTradeNo;
-
- /**
- *
- * 字段名:二级商户号
- * 变量名:sub_mchid
- * 是否必填:是
- * 类型:string(32)
- * 描述:
- * 二级商户商户号,由微信支付生成并下发。
- * 注意:仅适用于电商平台 服务商
- * 示例值:1900000109
- *
- */
- @SerializedName(value = "sub_mchid")
- private String subMchid;
-
- /**
- *
- * 字段名:+订单金额
- * 变量名:amount
- * 是否必填:是
- * 类型:object
- * 描述:订单金额信息
- *
- */
- @SerializedName(value = "amount")
- private Amount amount;
-
- }
-
- @Data
- @NoArgsConstructor
- public static class SceneInfo implements Serializable {
- /**
- *
- * 字段名:商户端设备号
- * 变量名:device_id
- * 是否必填:否
- * 类型:string(16)
- * 描述:
- * 终端设备号(门店号或收银设备ID)。
- * 特殊规则:长度最小7个字节
- * 示例值:POS1:1
- *
- */
- @SerializedName(value = "device_id")
- private String deviceId;
-
- }
-
- @Data
- @NoArgsConstructor
- public static class CombinePayerInfo implements Serializable {
- /**
- *
- * 字段名:用户标识
- * 变量名:openid
- * 是否必填:是
- * 类型:string(128)
- * 描述:
- * 使用合单appid获取的对应用户openid。是用户在商户appid下的唯一标识。
- * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
- *
- */
- @SerializedName(value = "openid")
- private String openid;
-
- }
-
- @Data
- @NoArgsConstructor
- public static class Amount implements Serializable {
- /**
- *
- * 字段名:标价金额
- * 变量名:total_amount
- * 是否必填:是
- * 类型:int64
- * 描述:
- * 子单金额,单位为分。
- * 示例值:100
- *
- */
- @SerializedName(value = "total_amount")
- private Integer totalAmount;
-
- /**
- *
- * 字段名:标价币种
- * 变量名:currency
- * 是否必填:是
- * 类型:string(8)
- * 描述:
- * 符合ISO 4217标准的三位字母代码,人民币:CNY。
- * 示例值:CNY
- *
- */
- @SerializedName(value = "currency")
- private String currency;
-
- /**
- *
- * 字段名:现金支付金额
- * 变量名:payer_amount
- * 是否必填:是
- * 类型:int64
- * 描述:
- * 订单现金支付金额。
- * 示例值:10
- *
- */
- @SerializedName(value = "payer_amount")
- private Integer payerAmount;
-
- /**
- *
- * 字段名:现金支付币种
- * 变量名:payer_currency
- * 是否必填:是
- * 类型:string(8)
- * 描述:
- * 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY。
- * 示例值: CNY
- *
- */
- @SerializedName(value = "payer_currency")
- private String payerCurrency;
- }
+ * 解密后的数据
+ */
+ private CombineTransactionsResult result;
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/CombineTransactionsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/CombineTransactionsResult.java
new file mode 100644
index 0000000000..f8d13db88d
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/CombineTransactionsResult.java
@@ -0,0 +1,353 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 合单支付 查询结果
+ *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/combine/chapter3_3.shtml
+ *
+ */
+@Data
+@NoArgsConstructor
+public class CombineTransactionsResult implements Serializable {
+
+ /**
+ *
+ * 字段名:合单商户appid
+ * 变量名:combine_appid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 合单发起方的appid。(即电商平台appid)
+ * 示例值:wxd678efh567hg6787
+ *
+ */
+ @SerializedName(value = "combine_appid")
+ private String combineAppid;
+
+ /**
+ *
+ * 字段名:合单商户号
+ * 变量名:combine_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 合单发起方商户号。(即电商平台mchid)
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "combine_mchid")
+ private String combineMchid;
+
+ /**
+ *
+ * 字段名:合单商户订单号
+ * 变量名:combine_out_trade_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 合单支付总订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一。
+ * 示例值:P20150806125346
+ *
+ */
+ @SerializedName(value = "combine_out_trade_no")
+ private String combineOutTradeNo;
+
+ /**
+ *
+ * 字段名:+场景信息
+ * 变量名:scene_info
+ * 是否必填:否
+ * 类型:object
+ * 描述:支付场景信息描述
+ *
+ */
+ @SerializedName(value = "scene_info")
+ private SceneInfo sceneInfo;
+
+ /**
+ *
+ * 字段名:+子单信息
+ * 变量名:sub_orders
+ * 是否必填:是
+ * 类型:array
+ * 描述:
+ * 最多支持子单条数:50
+ *
+ *
+ */
+ @SerializedName(value = "sub_orders")
+ private List subOrders;
+
+ /**
+ *
+ * 字段名:+支付者
+ * 变量名:combine_payer_info
+ * 是否必填:否
+ * 类型:object
+ * 描述:示例值:见请求示例
+ *
+ */
+ @SerializedName(value = "combine_payer_info")
+ private CombinePayerInfo combinePayerInfo;
+
+ @Data
+ @NoArgsConstructor
+ public static class SubOrders implements Serializable {
+ /**
+ *
+ * 字段名:子单商户号
+ * 变量名:mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 子单发起方商户号,必须与发起方Appid有绑定关系。(即电商平台mchid)
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "mchid")
+ private String mchid;
+
+ /**
+ *
+ * 字段名:交易类型
+ * 变量名:trade_type
+ * 是否必填:是
+ * 类型:string (16)
+ * 描述:
+ * 枚举值:
+ * NATIVE:扫码支付
+ * JSAPI:公众号支付
+ * APP:APP支付
+ * MWEB:H5支付
+ * 示例值: JSAPI
+ *
+ */
+ @SerializedName(value = "trade_type")
+ private String tradeType;
+
+ /**
+ *
+ * 字段名:交易状态
+ * 变量名:trade_state
+ * 是否必填:是
+ * 类型:string (32)
+ * 描述:
+ * 枚举值:
+ * SUCCESS:支付成功
+ * REFUND:转入退款
+ * NOTPAY:未支付
+ * CLOSED:已关闭
+ * USERPAYING:用户支付中
+ * PAYERROR:支付失败(其他原因,如银行返回失败)
+ * 示例值: SUCCESS
+ *
+ */
+ @SerializedName(value = "trade_state")
+ private String tradeState;
+
+ /**
+ *
+ * 字段名:付款银行
+ * 变量名:bank_type
+ * 是否必填:否
+ * 类型:string(16)
+ * 描述:
+ * 银行类型,采用字符串类型的银行标识。
+ * 示例值:CMC
+ *
+ */
+ @SerializedName(value = "bank_type")
+ private String bankType;
+
+ /**
+ *
+ * 字段名:附加信息
+ * 变量名:attach
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用。
+ * 示例值:深圳分店
+ *
+ */
+ @SerializedName(value = "attach")
+ private String attach;
+
+ /**
+ *
+ * 字段名:支付完成时间
+ * 变量名:success_time
+ * 是否必填:是
+ * 类型:string(16)
+ * 描述:
+ * 订单支付时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss:sss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss:sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+ * 示例值:2015-05-20T13:29:35.120+08:00
+ *
+ */
+ @SerializedName(value = "success_time")
+ private String successTime;
+
+ /**
+ *
+ * 字段名:微信订单号
+ * 变量名:transaction_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信支付订单号。
+ * 示例值: 1009660380201506130728806387
+ *
+ */
+ @SerializedName(value = "transaction_id")
+ private String transactionId;
+
+ /**
+ *
+ * 字段名:子单商户订单号
+ * 变量名:out_trade_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 商户系统内部订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一。
+ * 特殊规则:最小字符长度为6
+ * 示例值:20150806125346
+ *
+ */
+ @SerializedName(value = "out_trade_no")
+ private String outTradeNo;
+
+ /**
+ *
+ * 字段名:二级商户号
+ * 变量名:sub_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 二级商户商户号,由微信支付生成并下发。
+ * 注意:仅适用于电商平台 服务商
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "sub_mchid")
+ private String subMchid;
+
+ /**
+ *
+ * 字段名:+订单金额
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:object
+ * 描述:订单金额信息
+ *
+ */
+ @SerializedName(value = "amount")
+ private Amount amount;
+
+ }
+
+ @Data
+ @NoArgsConstructor
+ public static class SceneInfo implements Serializable {
+ /**
+ *
+ * 字段名:商户端设备号
+ * 变量名:device_id
+ * 是否必填:否
+ * 类型:string(16)
+ * 描述:
+ * 终端设备号(门店号或收银设备ID)。
+ * 特殊规则:长度最小7个字节
+ * 示例值:POS1:1
+ *
+ */
+ @SerializedName(value = "device_id")
+ private String deviceId;
+
+ }
+
+ @Data
+ @NoArgsConstructor
+ public static class CombinePayerInfo implements Serializable {
+ /**
+ *
+ * 字段名:用户标识
+ * 变量名:openid
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 使用合单appid获取的对应用户openid。是用户在商户appid下的唯一标识。
+ * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+ *
+ */
+ @SerializedName(value = "openid")
+ private String openid;
+
+ }
+
+ @Data
+ @NoArgsConstructor
+ public static class Amount implements Serializable {
+ /**
+ *
+ * 字段名:标价金额
+ * 变量名:total_amount
+ * 是否必填:是
+ * 类型:int64
+ * 描述:
+ * 子单金额,单位为分。
+ * 示例值:100
+ *
+ */
+ @SerializedName(value = "total_amount")
+ private Integer totalAmount;
+
+ /**
+ *
+ * 字段名:标价币种
+ * 变量名:currency
+ * 是否必填:是
+ * 类型:string(8)
+ * 描述:
+ * 符合ISO 4217标准的三位字母代码,人民币:CNY。
+ * 示例值:CNY
+ *
+ */
+ @SerializedName(value = "currency")
+ private String currency;
+
+ /**
+ *
+ * 字段名:现金支付金额
+ * 变量名:payer_amount
+ * 是否必填:是
+ * 类型:int64
+ * 描述:
+ * 订单现金支付金额。
+ * 示例值:10
+ *
+ */
+ @SerializedName(value = "payer_amount")
+ private Integer payerAmount;
+
+ /**
+ *
+ * 字段名:现金支付币种
+ * 变量名:payer_currency
+ * 是否必填:是
+ * 类型:string(8)
+ * 描述:
+ * 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY。
+ * 示例值: CNY
+ *
+ */
+ @SerializedName(value = "payer_currency")
+ private String payerCurrency;
+ }
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FinishOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FinishOrderRequest.java
new file mode 100644
index 0000000000..1b09ba6ffc
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/FinishOrderRequest.java
@@ -0,0 +1,81 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.*;
+
+import java.io.Serializable;
+
+/**
+ * 完结分账 对象
+ *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/profitsharing/chapter3_5.shtml
+ *
+ * @author: f00lish
+ * @date: 2020/09/12
+ */
+@Data
+@Builder
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public class FinishOrderRequest implements Serializable {
+
+ private static final long serialVersionUID = -8662837652326828377L;
+
+ /**
+ *
+ * 字段名:二级商户号
+ * 变量名:sub_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 分账出资的电商平台二级商户,填写微信支付分配的商户号。
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "sub_mchid")
+ private String subMchid;
+
+ /**
+ *
+ * 字段名:微信订单号
+ * 变量名:transaction_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信支付订单号。
+ * 示例值:4208450740201411110007820472
+ *
+ */
+ @SerializedName(value = "transaction_id")
+ private String transactionId;
+
+ /**
+ *
+ * 字段名:商户分账单号
+ * 变量名:out_order_no
+ * 是否必填:是
+ * 类型:string(64)
+ * 描述:
+ * 商户系统内部的分账单号,在商户系统内部唯一(单次分账、多次分账、完结分账应使用不同的商户分账单号),同一分账单号多次请求等同一次。
+ * 示例值:P20150806125346
+ *
+ */
+ @SerializedName(value = "out_order_no")
+ private String outOrderNo;
+
+ /**
+ *
+ * 字段名:分账描述
+ * 变量名:description
+ * 是否必填:是
+ * 类型:string(80)
+ * 描述:
+ * 分账的原因描述,分账账单中需要体现。
+ * 示例值:分给商户1900000109
+ *
+ */
+ @SerializedName(value = "description")
+ private String description;
+
+
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsNotifyResult.java
index abb4bfe735..03d9535fa8 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsNotifyResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsNotifyResult.java
@@ -1,11 +1,9 @@
package com.github.binarywang.wxpay.bean.ecommerce;
-import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
-import java.util.List;
/**
* 普通支付 通知结果
@@ -23,570 +21,7 @@ public class PartnerTransactionsNotifyResult implements Serializable {
private NotifyResponse rawData;
/**
- *
- * 字段名:服务商公众号ID
- * 变量名:sp_appid
- * 是否必填:是
- * 类型:string(32)
- * 描述:
- * 服务商申请的公众号或移动应用appid。
- * 示例值:wx8888888888888888
- *
+ * 解密后的数据
*/
- @SerializedName(value = "sp_appid")
- private String spAppid;
-
- /**
- *
- * 字段名:服务商户号
- * 变量名:sp_mchid
- * 是否必填:是
- * 类型:string(32)
- * 描述:
- * 服务商户号,由微信支付生成并下发
- * 示例值:1230000109
- *
- */
- @SerializedName(value = "sp_mchid")
- private String spMchid;
-
- /**
- *
- * 字段名:二级商户公众号ID
- * 变量名:sub_appid
- * 是否必填:否
- * 类型:string(32)
- * 描述:
- * 二级商户申请的公众号或移动应用appid。
- * 示例值:wxd678efh567hg6999
- *
- */
- @SerializedName(value = "sub_appid")
- private String subAppid;
-
- /**
- *
- * 字段名:二级商户号
- * 变量名:sub_mchid
- * 是否必填:是
- * 类型:string(32)
- * 描述:
- * 二级商户的商户号,有微信支付生成并下发。
- * 示例值:1900000109
- *
- */
- @SerializedName(value = "sub_mchid")
- private String subMchid;
-
- /**
- *
- * 字段名:+商户订单号
- * 变量名:out_trade_no
- * 是否必填:是
- * 类型:string(32)
- * 描述:商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一,详见【商户订单号】。
- * 特殊规则:最小字符长度为6
- * 示例值:1217752501201407033233368018
- *
- */
- @SerializedName(value = "out_trade_no")
- private String outTradeNo;
-
- /**
- *
- * 字段名:微信支付订单号
- * 变量名:transaction_id
- * 是否必填:否
- * 类型:string(32)
- * 描述:微信支付系统生成的订单号。
- * 示例值:1217752501201407033233368018
- *
- */
- @SerializedName(value = "transaction_id")
- private String transactionId;
-
- /**
- *
- * 字段名:交易类型
- * 变量名:trade_type
- * 是否必填:否
- * 类型:string(16)
- * 描述:交易类型,枚举值:
- * JSAPI:公众号支付
- * NATIVE:扫码支付
- * APP:APP支付
- * MICROPAY:付款码支付
- * MWEB:H5支付
- * FACEPAY:刷脸支付
- *
- * 示例值: MICROPAY
- *
- */
- @SerializedName(value = "trade_type")
- private String tradeType;
-
- /**
- *
- * 字段名:交易状态
- * 变量名:trade_state
- * 是否必填:是
- * 类型:string(32)
- * 描述:交易状态,枚举值:
- * SUCCESS:支付成功
- * REFUND:转入退款
- * NOTPAY:未支付
- * CLOSED:已关闭
- * REVOKED:已撤销(付款码支付)
- * USERPAYING:用户支付中(付款码支付)
- * PAYERROR:支付失败(其他原因,如银行返回失败)
- *
- * 示例值:SUCCESS
- *
- */
- @SerializedName(value = "trade_state")
- private String tradeState;
-
- /**
- *
- * 字段名:交易状态描述
- * 变量名:trade_state_desc
- * 是否必填:是
- * 类型:string(256)
- * 描述:交易状态描述
- * 示例值:支付失败,请重新下单支付
- *
- */
- @SerializedName(value = "trade_state_desc")
- private String tradeStateDesc;
-
- /**
- *
- * 字段名:付款银行
- * 变量名:bank_type
- * 是否必填:否
- * 类型:string(16)
- * 描述:银行类型,采用字符串类型的银行标识。
- * 示例值:CMC
- *
- */
- @SerializedName(value = "bank_type")
- private String bankType;
-
- /**
- *
- * 字段名:附加数据
- * 变量名:attach
- * 是否必填:否
- * 类型:string(128)
- * 描述:附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用
- * 示例值:自定义数据
- *
- */
- @SerializedName(value = "attach")
- private String attach;
-
- /**
- *
- * 字段名:支付完成时间
- * 变量名:success_time
- * 是否必填:否
- * 类型:string(64)
- * 描述:支付完成时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
- * 示例值:2018-06-08T10:34:56+08:00
- *
- */
- @SerializedName(value = "success_time")
- private String successTime;
-
- /**
- *
- * 字段名:+支付者
- * 变量名:combine_payer_info
- * 是否必填:否
- * 类型:object
- * 描述:示例值:见请求示例
- *
- */
- @SerializedName(value = "combine_payer_info")
- private CombinePayerInfo combinePayerInfo;
-
- /**
- *
- * 字段名:订单金额
- * 变量名:amount
- * 是否必填:是
- * 类型:object
- * 描述:订单金额信息
- *
- */
- @SerializedName(value = "amount")
- private Amount amount;
-
- /**
- *
- * 字段名:场景信息
- * 变量名:scene_info
- * 是否必填:否
- * 类型:object
- * 描述:支付场景信息描述
- *
- */
- @SerializedName(value = "scene_info")
- private SceneInfo sceneInfo;
-
- /**
- *
- * 字段名:优惠功能
- * 变量名:promotion_detail
- * 是否必填:否
- * 类型:array
- * 描述:优惠功能,享受优惠时返回该字段。
- *
- */
- @SerializedName(value = "promotion_detail")
- private List promotionDetails;
-
- @Data
- @NoArgsConstructor
- public static class SceneInfo implements Serializable {
- /**
- *
- * 字段名:商户端设备号
- * 变量名:device_id
- * 是否必填:否
- * 类型:string(16)
- * 描述:
- * 终端设备号(门店号或收银设备ID)。
- * 特殊规则:长度最小7个字节
- * 示例值:POS1:1
- *
- */
- @SerializedName(value = "device_id")
- private String deviceId;
-
- }
-
- @Data
- @NoArgsConstructor
- public static class CombinePayerInfo implements Serializable {
- /**
- *
- * 字段名:用户标识
- * 变量名:sp_openid
- * 是否必填:是
- * 类型:string(128)
- * 描述:
- * 用户在服务商appid下的唯一标识。
- * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
- *
- */
- @SerializedName(value = "sp_openid")
- private String spOpenid;
-
-
- /**
- *
- * 字段名:二级商户用户标识
- * 变量名:sub_openid
- * 是否必填:否
- * 类型:string(128)
- * 描述:
- * 用户在二级商户appid下的唯一标识。
- * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
- *
- */
- @SerializedName(value = "sub_openid")
- private String subOpenid;
-
- }
-
- @Data
- @NoArgsConstructor
- public static class Amount implements Serializable {
- /**
- *
- * 字段名:总金额
- * 变量名:total
- * 是否必填:否
- * 类型:int
- * 描述:
- * 订单总金额,单位为分
- * 示例值:100
- *
- */
- @SerializedName(value = "total")
- private Integer total;
-
-
- /**
- *
- * 字段名:用户支付金额
- * 变量名:payer_total
- * 是否必填:否
- * 类型:int
- * 描述:
- * 用户支付金额,单位为分。
- * 示例值:100
- *
- */
- @SerializedName(value = "payer_total")
- private Integer payerTotal;
-
-
- /**
- *
- * 字段名:货币类型
- * 变量名:currency
- * 是否必填:否
- * 类型:string(16)
- * 描述:
- * CNY:人民币,境内商户号仅支持人民币。
- * 示例值:CNY
- *
- */
- @SerializedName(value = "currency")
- private String currency;
-
-
- /**
- *
- * 字段名:用户支付币种
- * 变量名:payer_currency
- * 是否必填:否
- * 类型:string(8)
- * 描述:
- * 用户支付币种
- * 示例值: CNY
- *
- */
- @SerializedName(value = "payer_currency")
- private String payerCurrency;
- }
-
- @Data
- @NoArgsConstructor
- public static class PromotionDetail implements Serializable {
-
- /**
- *
- * 字段名:券ID
- * 变量名:coupon_id
- * 是否必填:是
- * 类型:string(32)
- * 描述: 券ID
- * 示例值:109519
- *
- */
- @SerializedName(value = "coupon_id")
- private String couponId;
-
- /**
- *
- * 字段名:优惠名称
- * 变量名:name
- * 是否必填:否
- * 类型:string(64)
- * 描述: 优惠名称
- * 示例值:单品惠-6
- *
- */
- @SerializedName(value = "name")
- private String name;
- /**
- *
- * 字段名:优惠范围
- * 变量名:scope
- * 是否必填:否
- * 类型:string(32)
- * 描述: 优惠名称
- * 示例值:
- * GLOBAL:全场代金券
- * SINGLE:单品优惠
- * 示例值:GLOBAL
- *
- */
- @SerializedName(value = "scope")
- private String scope;
-
- /**
- *
- * 字段名:优惠类型
- * 变量名:type
- * 是否必填:否
- * 类型:string(32)
- * 描述:
- * CASH:充值
- * NOCASH:预充值
- * 示例值:CASH
- *
- */
- @SerializedName(value = "type")
- private String type;
-
- /**
- *
- * 字段名:优惠券面额
- * 变量名:amount
- * 是否必填:是
- * 类型:int
- * 描述: 优惠券面额
- * 示例值:100
- *
- */
- @SerializedName(value = "amount")
- private Integer amount;
-
- /**
- *
- * 字段名:活动ID
- * 变量名:stock_id
- * 是否必填:否
- * 类型:string(32)
- * 描述:活动ID
- * 示例值:931386
- *
- */
- @SerializedName(value = "stock_id")
- private String stockId;
-
- /**
- *
- * 字段名:微信出资
- * 变量名:wechatpay_contribute
- * 是否必填:否
- * 类型:int
- * 描述:微信出资,单位为分
- * 示例值:0
- *
- */
- @SerializedName(value = "wechatpay_contribute")
- private Integer wechatpayContribute;
-
- /**
- *
- * 字段名:商户出资
- * 变量名:merchant_contribute
- * 是否必填:否
- * 类型:int
- * 描述:商户出资,单位为分
- * 示例值:0
- *
- */
- @SerializedName(value = "merchant_contribute")
- private Integer merchantContribute;
-
- /**
- *
- * 字段名:其他出资
- * 变量名:other_contribute
- * 是否必填:否
- * 类型:int
- * 描述:其他出资,单位为分
- * 示例值:0
- *
- */
- @SerializedName(value = "other_contribute")
- private Integer otherContribute;
-
- /**
- *
- * 字段名:优惠币种
- * 变量名:currency
- * 是否必填:否
- * 类型:String(16)
- * 描述:
- * CNY:人民币,境内商户号仅支持人民币。
- * 示例值:CNY
- *
- */
- @SerializedName(value = "currency")
- private String currency;
-
- /**
- *
- * 字段名:单品列表
- * 变量名:goods_detail
- * 是否必填:否
- * 类型:array
- * 描述:单品列表信息
- *
- */
- @SerializedName(value = "goods_detail")
- private List goodsDetails;
-
-
- }
-
- @Data
- @NoArgsConstructor
- public static class GoodsDetail implements Serializable {
-
- /**
- *
- * 字段名:商品编码
- * 变量名:goods_id
- * 是否必填:是
- * 类型:string(32)
- * 描述:商品编码
- * 示例值:M1006
- *
- */
- @SerializedName(value = "goods_id")
- private String goodsId;
-
- /**
- *
- * 字段名:商品数量
- * 变量名:quantity
- * 是否必填:是
- * 类型:int64
- * 描述:
- * 用户购买的数量
- * 示例值:1
- *
- */
- @SerializedName(value = "quantity")
- private Integer quantity;
-
- /**
- *
- * 字段名:商品单价
- * 变量名:unit_price
- * 是否必填:是
- * 类型:int64
- * 描述:
- * 商品单价,单位为分
- * 示例值:100
- *
- */
- @SerializedName(value = "unit_price")
- private Integer unitPrice;
-
- /**
- *
- * 字段名:商品优惠金额
- * 变量名:discount_amount
- * 是否必填:是
- * 类型:int
- * 描述:商品优惠金额
- * 示例值:0
- *
- */
- @SerializedName(value = "discount_amount")
- private Integer discountAmount;
-
- /**
- *
- * 字段名:商品备注
- * 变量名:goods_remark
- * 是否必填:否
- * 类型:string(128)
- * 描述:商品备注信息
- * 示例值:商品备注信息
- *
- */
- @SerializedName(value = "goods_remark")
- private String goodsRemark;
- }
-
+ private PartnerTransactionsResult result;
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsQueryRequest.java
new file mode 100644
index 0000000000..2b90e432bb
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsQueryRequest.java
@@ -0,0 +1,69 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@NoArgsConstructor
+public class PartnerTransactionsQueryRequest implements Serializable {
+
+
+ /**
+ *
+ * 字段名:服务商户号
+ * 变量名:sp_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 服务商户号,由微信支付生成并下发
+ * 示例值:1230000109
+ *
+ */
+ @SerializedName(value = "sp_mchid")
+ private String spMchid;
+
+ /**
+ *
+ * 字段名:二级商户号
+ * 变量名:sub_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 二级商户的商户号,有微信支付生成并下发。
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "sub_mchid")
+ private String subMchid;
+
+ /**
+ *
+ * 字段名:微信支付订单号
+ * 变量名:transaction_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信支付系统生成的订单号
+ * 示例值:1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "transaction_id")
+ private String transactionId;
+ /**
+ *
+ * 字段名:商户订单号
+ * 变量名:out_trade_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一,详见【商户订单号】。
+ * 特殊规则:最小字符长度为6
+ * 示例值:1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "out_trade_no")
+ private String outTradeNo;
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsResult.java
new file mode 100644
index 0000000000..9524627d79
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/PartnerTransactionsResult.java
@@ -0,0 +1,587 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 普通支付 查询结果
+ *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/e_transactions/chapter3_5.shtml
+ *
+ */
+@Data
+@NoArgsConstructor
+public class PartnerTransactionsResult implements Serializable {
+
+ /**
+ *
+ * 字段名:服务商公众号ID
+ * 变量名:sp_appid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 服务商申请的公众号或移动应用appid。
+ * 示例值:wx8888888888888888
+ *
+ */
+ @SerializedName(value = "sp_appid")
+ private String spAppid;
+
+ /**
+ *
+ * 字段名:服务商户号
+ * 变量名:sp_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 服务商户号,由微信支付生成并下发
+ * 示例值:1230000109
+ *
+ */
+ @SerializedName(value = "sp_mchid")
+ private String spMchid;
+
+ /**
+ *
+ * 字段名:二级商户公众号ID
+ * 变量名:sub_appid
+ * 是否必填:否
+ * 类型:string(32)
+ * 描述:
+ * 二级商户申请的公众号或移动应用appid。
+ * 示例值:wxd678efh567hg6999
+ *
+ */
+ @SerializedName(value = "sub_appid")
+ private String subAppid;
+
+ /**
+ *
+ * 字段名:二级商户号
+ * 变量名:sub_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 二级商户的商户号,有微信支付生成并下发。
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "sub_mchid")
+ private String subMchid;
+
+ /**
+ *
+ * 字段名:+商户订单号
+ * 变量名:out_trade_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一,详见【商户订单号】。
+ * 特殊规则:最小字符长度为6
+ * 示例值:1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "out_trade_no")
+ private String outTradeNo;
+
+ /**
+ *
+ * 字段名:微信支付订单号
+ * 变量名:transaction_id
+ * 是否必填:否
+ * 类型:string(32)
+ * 描述:微信支付系统生成的订单号。
+ * 示例值:1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "transaction_id")
+ private String transactionId;
+
+ /**
+ *
+ * 字段名:交易类型
+ * 变量名:trade_type
+ * 是否必填:否
+ * 类型:string(16)
+ * 描述:交易类型,枚举值:
+ * JSAPI:公众号支付
+ * NATIVE:扫码支付
+ * APP:APP支付
+ * MICROPAY:付款码支付
+ * MWEB:H5支付
+ * FACEPAY:刷脸支付
+ *
+ * 示例值: MICROPAY
+ *
+ */
+ @SerializedName(value = "trade_type")
+ private String tradeType;
+
+ /**
+ *
+ * 字段名:交易状态
+ * 变量名:trade_state
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:交易状态,枚举值:
+ * SUCCESS:支付成功
+ * REFUND:转入退款
+ * NOTPAY:未支付
+ * CLOSED:已关闭
+ * REVOKED:已撤销(付款码支付)
+ * USERPAYING:用户支付中(付款码支付)
+ * PAYERROR:支付失败(其他原因,如银行返回失败)
+ *
+ * 示例值:SUCCESS
+ *
+ */
+ @SerializedName(value = "trade_state")
+ private String tradeState;
+
+ /**
+ *
+ * 字段名:交易状态描述
+ * 变量名:trade_state_desc
+ * 是否必填:是
+ * 类型:string(256)
+ * 描述:交易状态描述
+ * 示例值:支付失败,请重新下单支付
+ *
+ */
+ @SerializedName(value = "trade_state_desc")
+ private String tradeStateDesc;
+
+ /**
+ *
+ * 字段名:付款银行
+ * 变量名:bank_type
+ * 是否必填:否
+ * 类型:string(16)
+ * 描述:银行类型,采用字符串类型的银行标识。
+ * 示例值:CMC
+ *
+ */
+ @SerializedName(value = "bank_type")
+ private String bankType;
+
+ /**
+ *
+ * 字段名:附加数据
+ * 变量名:attach
+ * 是否必填:否
+ * 类型:string(128)
+ * 描述:附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用
+ * 示例值:自定义数据
+ *
+ */
+ @SerializedName(value = "attach")
+ private String attach;
+
+ /**
+ *
+ * 字段名:支付完成时间
+ * 变量名:success_time
+ * 是否必填:否
+ * 类型:string(64)
+ * 描述:支付完成时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
+ * 示例值:2018-06-08T10:34:56+08:00
+ *
+ */
+ @SerializedName(value = "success_time")
+ private String successTime;
+
+ /**
+ *
+ * 字段名:+支付者
+ * 变量名:combine_payer_info
+ * 是否必填:否
+ * 类型:object
+ * 描述:示例值:见请求示例
+ *
+ */
+ @SerializedName(value = "combine_payer_info")
+ private CombinePayerInfo combinePayerInfo;
+
+ /**
+ *
+ * 字段名:订单金额
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:object
+ * 描述:订单金额信息
+ *
+ */
+ @SerializedName(value = "amount")
+ private Amount amount;
+
+ /**
+ *
+ * 字段名:场景信息
+ * 变量名:scene_info
+ * 是否必填:否
+ * 类型:object
+ * 描述:支付场景信息描述
+ *
+ */
+ @SerializedName(value = "scene_info")
+ private SceneInfo sceneInfo;
+
+ /**
+ *
+ * 字段名:优惠功能
+ * 变量名:promotion_detail
+ * 是否必填:否
+ * 类型:array
+ * 描述:优惠功能,享受优惠时返回该字段。
+ *
+ */
+ @SerializedName(value = "promotion_detail")
+ private List promotionDetails;
+
+ @Data
+ @NoArgsConstructor
+ public static class SceneInfo implements Serializable {
+ /**
+ *
+ * 字段名:商户端设备号
+ * 变量名:device_id
+ * 是否必填:否
+ * 类型:string(16)
+ * 描述:
+ * 终端设备号(门店号或收银设备ID)。
+ * 特殊规则:长度最小7个字节
+ * 示例值:POS1:1
+ *
+ */
+ @SerializedName(value = "device_id")
+ private String deviceId;
+
+ }
+
+ @Data
+ @NoArgsConstructor
+ public static class CombinePayerInfo implements Serializable {
+ /**
+ *
+ * 字段名:用户标识
+ * 变量名:sp_openid
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 用户在服务商appid下的唯一标识。
+ * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+ *
+ */
+ @SerializedName(value = "sp_openid")
+ private String spOpenid;
+
+
+ /**
+ *
+ * 字段名:二级商户用户标识
+ * 变量名:sub_openid
+ * 是否必填:否
+ * 类型:string(128)
+ * 描述:
+ * 用户在二级商户appid下的唯一标识。
+ * 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
+ *
+ */
+ @SerializedName(value = "sub_openid")
+ private String subOpenid;
+
+ }
+
+ @Data
+ @NoArgsConstructor
+ public static class Amount implements Serializable {
+ /**
+ *
+ * 字段名:总金额
+ * 变量名:total
+ * 是否必填:否
+ * 类型:int
+ * 描述:
+ * 订单总金额,单位为分
+ * 示例值:100
+ *
+ */
+ @SerializedName(value = "total")
+ private Integer total;
+
+
+ /**
+ *
+ * 字段名:用户支付金额
+ * 变量名:payer_total
+ * 是否必填:否
+ * 类型:int
+ * 描述:
+ * 用户支付金额,单位为分。
+ * 示例值:100
+ *
+ */
+ @SerializedName(value = "payer_total")
+ private Integer payerTotal;
+
+
+ /**
+ *
+ * 字段名:货币类型
+ * 变量名:currency
+ * 是否必填:否
+ * 类型:string(16)
+ * 描述:
+ * CNY:人民币,境内商户号仅支持人民币。
+ * 示例值:CNY
+ *
+ */
+ @SerializedName(value = "currency")
+ private String currency;
+
+
+ /**
+ *
+ * 字段名:用户支付币种
+ * 变量名:payer_currency
+ * 是否必填:否
+ * 类型:string(8)
+ * 描述:
+ * 用户支付币种
+ * 示例值: CNY
+ *
+ */
+ @SerializedName(value = "payer_currency")
+ private String payerCurrency;
+ }
+
+ @Data
+ @NoArgsConstructor
+ public static class PromotionDetail implements Serializable {
+
+ /**
+ *
+ * 字段名:券ID
+ * 变量名:coupon_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述: 券ID
+ * 示例值:109519
+ *
+ */
+ @SerializedName(value = "coupon_id")
+ private String couponId;
+
+ /**
+ *
+ * 字段名:优惠名称
+ * 变量名:name
+ * 是否必填:否
+ * 类型:string(64)
+ * 描述: 优惠名称
+ * 示例值:单品惠-6
+ *
+ */
+ @SerializedName(value = "name")
+ private String name;
+ /**
+ *
+ * 字段名:优惠范围
+ * 变量名:scope
+ * 是否必填:否
+ * 类型:string(32)
+ * 描述: 优惠名称
+ * 示例值:
+ * GLOBAL:全场代金券
+ * SINGLE:单品优惠
+ * 示例值:GLOBAL
+ *
+ */
+ @SerializedName(value = "scope")
+ private String scope;
+
+ /**
+ *
+ * 字段名:优惠类型
+ * 变量名:type
+ * 是否必填:否
+ * 类型:string(32)
+ * 描述:
+ * CASH:充值
+ * NOCASH:预充值
+ * 示例值:CASH
+ *
+ */
+ @SerializedName(value = "type")
+ private String type;
+
+ /**
+ *
+ * 字段名:优惠券面额
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:int
+ * 描述: 优惠券面额
+ * 示例值:100
+ *
+ */
+ @SerializedName(value = "amount")
+ private Integer amount;
+
+ /**
+ *
+ * 字段名:活动ID
+ * 变量名:stock_id
+ * 是否必填:否
+ * 类型:string(32)
+ * 描述:活动ID
+ * 示例值:931386
+ *
+ */
+ @SerializedName(value = "stock_id")
+ private String stockId;
+
+ /**
+ *
+ * 字段名:微信出资
+ * 变量名:wechatpay_contribute
+ * 是否必填:否
+ * 类型:int
+ * 描述:微信出资,单位为分
+ * 示例值:0
+ *
+ */
+ @SerializedName(value = "wechatpay_contribute")
+ private Integer wechatpayContribute;
+
+ /**
+ *
+ * 字段名:商户出资
+ * 变量名:merchant_contribute
+ * 是否必填:否
+ * 类型:int
+ * 描述:商户出资,单位为分
+ * 示例值:0
+ *
+ */
+ @SerializedName(value = "merchant_contribute")
+ private Integer merchantContribute;
+
+ /**
+ *
+ * 字段名:其他出资
+ * 变量名:other_contribute
+ * 是否必填:否
+ * 类型:int
+ * 描述:其他出资,单位为分
+ * 示例值:0
+ *
+ */
+ @SerializedName(value = "other_contribute")
+ private Integer otherContribute;
+
+ /**
+ *
+ * 字段名:优惠币种
+ * 变量名:currency
+ * 是否必填:否
+ * 类型:String(16)
+ * 描述:
+ * CNY:人民币,境内商户号仅支持人民币。
+ * 示例值:CNY
+ *
+ */
+ @SerializedName(value = "currency")
+ private String currency;
+
+ /**
+ *
+ * 字段名:单品列表
+ * 变量名:goods_detail
+ * 是否必填:否
+ * 类型:array
+ * 描述:单品列表信息
+ *
+ */
+ @SerializedName(value = "goods_detail")
+ private List goodsDetails;
+
+
+ }
+
+ @Data
+ @NoArgsConstructor
+ public static class GoodsDetail implements Serializable {
+
+ /**
+ *
+ * 字段名:商品编码
+ * 变量名:goods_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:商品编码
+ * 示例值:M1006
+ *
+ */
+ @SerializedName(value = "goods_id")
+ private String goodsId;
+
+ /**
+ *
+ * 字段名:商品数量
+ * 变量名:quantity
+ * 是否必填:是
+ * 类型:int64
+ * 描述:
+ * 用户购买的数量
+ * 示例值:1
+ *
+ */
+ @SerializedName(value = "quantity")
+ private Integer quantity;
+
+ /**
+ *
+ * 字段名:商品单价
+ * 变量名:unit_price
+ * 是否必填:是
+ * 类型:int64
+ * 描述:
+ * 商品单价,单位为分
+ * 示例值:100
+ *
+ */
+ @SerializedName(value = "unit_price")
+ private Integer unitPrice;
+
+ /**
+ *
+ * 字段名:商品优惠金额
+ * 变量名:discount_amount
+ * 是否必填:是
+ * 类型:int
+ * 描述:商品优惠金额
+ * 示例值:0
+ *
+ */
+ @SerializedName(value = "discount_amount")
+ private Integer discountAmount;
+
+ /**
+ *
+ * 字段名:商品备注
+ * 变量名:goods_remark
+ * 是否必填:否
+ * 类型:string(128)
+ * 描述:商品备注信息
+ * 示例值:商品备注信息
+ *
+ */
+ @SerializedName(value = "goods_remark")
+ private String goodsRemark;
+ }
+
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingQueryRequest.java
new file mode 100644
index 0000000000..c9e1aad2e8
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingQueryRequest.java
@@ -0,0 +1,54 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@NoArgsConstructor
+public class ProfitSharingQueryRequest implements Serializable {
+
+ /**
+ *
+ * 字段名:二级商户号
+ * 变量名:sub_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 分账出资的电商平台二级商户,填写微信支付分配的商户号。
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "sub_mchid")
+ private String subMchid;
+
+ /**
+ *
+ * 字段名:微信订单号
+ * 变量名:transaction_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信支付订单号。
+ * 示例值: 4208450740201411110007820472
+ *
+ */
+ @SerializedName(value = "transaction_id")
+ private String transactionId;
+
+ /**
+ *
+ * 字段名:商户分账单号
+ * 变量名:out_order_no
+ * 是否必填:是
+ * 类型:string(64)
+ * 描述:
+ * 商户系统内部的分账单号,在商户系统内部唯一(单次分账、多次分账、完结分账应使用不同的商户分账单号),同一分账单号多次请求等同一次。
+ * 示例值:P20150806125346
+ *
+ */
+ @SerializedName(value = "out_order_no")
+ private String outOrderNo;
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingResult.java
index 878311e6e2..37ff86c25a 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ProfitSharingResult.java
@@ -5,6 +5,7 @@
import lombok.NoArgsConstructor;
import java.io.Serializable;
+import java.util.List;
/**
* 请求分账 结果响应
@@ -72,4 +73,209 @@ public class ProfitSharingResult implements Serializable {
@SerializedName(value = "order_id")
private String orderId;
+ /**
+ *
+ * 字段名:分账单状态
+ * 变量名:status
+ * 是否必填:是
+ * 类型:string (64)
+ * 描述:
+ * 分账单状态,枚举值:
+ * ACCEPTED:受理成功
+ * PROCESSING:处理中
+ * FINISHED:分账成功
+ * CLOSED:处理失败,已关单
+ * 示例值:FINISHED
+ *
+ */
+ @SerializedName(value = "status")
+ private String status;
+
+ /**
+ *
+ * 字段名:分账接收方列表
+ * 变量名:receivers
+ * 是否必填:否
+ * 类型:array
+ * 描述:
+ * 分账接收方列表。当查询分账完结的执行结果时,不返回该字段
+ *
+ */
+ @SerializedName(value = "receivers")
+ private List receivers;
+ /**
+ *
+ * 字段名:关单原因
+ * 变量名:close_reason
+ * 是否必填:否
+ * 类型:string (32)
+ * 描述:
+ * 关单原因描述,当分账单状态status为CLOSED(处理失败,已关单)时,返回该字段。
+ * 枚举值:
+ * NO_AUTH:分账授权已解除
+ * 示例值:NO_AUTH
+ *
+ */
+ @SerializedName(value = "close_reason")
+ private String closeReason;
+
+ /**
+ *
+ * 字段名:分账完结金额
+ * 变量名:finish_amount
+ * 是否必填:否
+ * 类型:int
+ * 描述:
+ * 分账完结的分账金额,单位为分, 仅当查询分账完结的执行结果时,存在本字段。
+ * 示例值:100
+ *
+ */
+ @SerializedName(value = "finish_amount")
+ private Integer finishAmount;
+
+ /**
+ *
+ * 字段名:分账完结描述
+ * 变量名:finish_description
+ * 是否必填:否
+ * 类型:string (80)
+ * 描述:
+ * 分账完结的原因描述,仅当查询分账完结的执行结果时,存在本字段。
+ * 示例值:分账完结
+ *
+ */
+ @SerializedName(value = "finish_description")
+ private String finishDescription;
+
+ @Data
+ @NoArgsConstructor
+ public static class Receiver implements Serializable {
+
+ /**
+ *
+ * 字段名:分账接收商户号
+ * 变量名:receiver_mchid
+ * 是否必填:是
+ * 类型:string (32)
+ * 描述:
+ * 填写微信支付分配的商户号,仅支持通过添加分账接收方接口添加的接收方;电商平台商户已默认添加到分账接收方,无需重复添加。
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "receiver_mchid")
+ private String receiverMchid;
+
+ /**
+ *
+ * 字段名:分账金额
+ * 变量名:amount
+ * 是否必填:否
+ * 类型:int
+ * 描述:
+ * 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额。
+ * 示例值: 4208450740201411110007820472
+ *
+ */
+ @SerializedName(value = "amount")
+ private Integer amount;
+
+ /**
+ *
+ * 字段名:分账描述
+ * 变量名:description
+ * 是否必填:是
+ * 类型:string (80)
+ * 描述:
+ * 分账的原因描述,分账账单中需要体现。
+ * 示例值:分帐1900000110
+ *
+ */
+ @SerializedName(value = "description")
+ private String description;
+
+ /**
+ *
+ * 字段名:分账结果
+ * 变量名:result
+ * 是否必填:是
+ * 类型:string (32)
+ * 描述:
+ * 分账结果,枚举值:
+ * PENDING:待分账
+ * SUCCESS:分账成功
+ * ADJUST:分账失败待调账
+ * RETURNED:已转回分账方
+ * CLOSED:已关闭
+ * 示例值:SUCCESS
+ *
+ */
+ @SerializedName(value = "result")
+ private String result;
+
+ /**
+ *
+ * 字段名:完成时间
+ * 变量名:finish_time
+ * 是否必填:是
+ * 类型:string (64)
+ * 描述:
+ * 分账完成时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss.sss+TIMEZONE,YYYY-MM-DD表示年月日,
+ * T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区
+ * (+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。
+ * 示例值: 2015-05-20T13:29:35.120+08:00
+ *
+ */
+ @SerializedName(value = "finish_time")
+ private String finishTime;
+
+ /**
+ *
+ * 字段名:分账失败原因
+ * 变量名:fail_reason
+ * 是否必填:否
+ * 类型:string (32)
+ * 描述:
+ * 分账失败原因,当分账结果result为RETURNED(已转回分账方)或CLOSED(已关闭)时,返回该字段
+ * 枚举值:
+ * ACCOUNT_ABNORMAL:分账接收账户异常
+ * NO_RELATION:分账关系已解除
+ * RECEIVER_HIGH_RISK:高风险接收方
+ * 示例值:NO_RELATION
+ *
+ */
+ @SerializedName(value = "fail_reason")
+ private String failReason;
+
+ /**
+ *
+ * 字段名:分账接收方类型
+ * 变量名:type
+ * 是否必填:是
+ * 类型:string (32)
+ * 描述:
+ * 分账接收方类型,枚举值:
+ * MERCHANT_ID:商户
+ * PERSONAL_OPENID:个人
+ * 示例值:MERCHANT_ID
+ *
+ */
+ @SerializedName(value = "type")
+ private String type;
+
+ /**
+ *
+ * 字段名:分账接收方类型
+ * 变量名:receiver_account
+ * 是否必填:是
+ * 类型:string (64)
+ * 描述:
+ * 分账接收方账号:
+ * 类型是MERCHANT_ID时,是商户ID
+ * 类型是PERSONAL_OPENID时,是个人openid
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "receiver_account")
+ private String receiverAccount;
+ }
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java
new file mode 100644
index 0000000000..a2452a1bad
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundNotifyResult.java
@@ -0,0 +1,233 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 退款结果 查询结果
+ *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/refunds/chapter3_3.shtml
+ *
+ */
+@Data
+@NoArgsConstructor
+public class RefundNotifyResult implements Serializable {
+
+ /**
+ * 源数据
+ */
+ private NotifyResponse rawData;
+
+ /**
+ *
+ * 字段名:电商平台商户号
+ * 变量名:sp_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信支付分配给电商平台的商户号
+ * 示例值:1900000100
+ *
+ */
+ @SerializedName(value = "sp_mchid")
+ private String spMchid;
+
+ /**
+ *
+ * 字段名:二级商户号
+ * 变量名:sub_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 分账出资的电商平台二级商户,填写微信支付分配的商户号。
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "sub_mchid")
+ private String subMchid;
+
+ /**
+ *
+ * 字段名:商户订单号
+ * 变量名:out_trade_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 返回的商户订单号
+ * 示例值: 1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "out_trade_no")
+ private String outTradeNo;
+
+ /**
+ *
+ * 字段名:微信订单号
+ * 变量名:transaction_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信支付订单号
+ * 示例值: 1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "transaction_id")
+ private String transactionId;
+
+ /**
+ *
+ * 字段名:商户退款单号
+ * 变量名:out_refund_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 商户退款单号
+ * 示例值: 1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "out_refund_no")
+ private String outRefundNo;
+
+ /**
+ *
+ * 字段名:微信退款单号
+ * 变量名:refund_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信退款单号
+ * 示例值: 1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "refund_id")
+ private String refundId;
+
+ /**
+ *
+ * 字段名:退款状态
+ * 变量名:refund_status
+ * 是否必填:是
+ * 类型:string(16)
+ * 描述:
+ * 退款状态,枚举值:
+ * SUCCESS:退款成功
+ * CLOSE:退款关闭
+ * ABNORMAL:退款异常,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往【服务商平台—>交易中心】,手动处理此笔退款
+ * 示例值:SUCCESS
+ *
+ */
+ @SerializedName(value = "refund_status")
+ private String refundStatus;
+
+ /**
+ *
+ * 字段名:退款成功时间
+ * 变量名:success_time
+ * 是否必填:否
+ * 类型:string(64)
+ * 描述:
+ * 1、退款成功时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,
+ * 表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+ * 例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒。
+ * 2、当退款状态为退款成功时返回此参数。
+ * 示例值:2018-06-08T10:34:56+08:00
+ *
+ */
+ @SerializedName(value = "success_time")
+ private String successTime;
+
+ /**
+ *
+ * 字段名:退款入账账户
+ * 变量名:user_received_account
+ * 是否必填:是
+ * 类型:string(64)
+ * 描述:
+ * 取当前退款单的退款入账方。
+ * 退回银行卡:{银行名称}{卡类型}{卡尾号}
+ * 退回支付用户零钱: 支付用户零钱
+ * 退还商户: 商户基本账户、商户结算银行账户
+ * 退回支付用户零钱通:支付用户零钱通
+ * 示例值:招商银行信用卡0403
+ *
+ */
+ @SerializedName(value = "user_received_account")
+ private String userReceivedAccount;
+
+ /**
+ *
+ * 字段名:金额信息
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:object
+ * 描述:
+ * 金额信息
+ *
+ */
+ @SerializedName(value = "amount")
+ private Amount amount;
+
+ @Data
+ @NoArgsConstructor
+ public static class Amount implements Serializable {
+ /**
+ *
+ * 字段名:订单金额
+ * 变量名:total
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 订单总金额,单位为分,只能为整数,详见支付金额
+ * 示例值:999
+ *
+ */
+ @SerializedName(value = "total")
+ private Integer total;
+
+ /**
+ *
+ * 字段名:退款金额
+ * 变量名:refund
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 退款金额,币种的最小单位,只能为整数,不能超过原订单支付金额,如果有使用券,后台会按比例退。
+ * 示例值:999
+ *
+ */
+ @SerializedName(value = "refund")
+ private String refund;
+
+ /**
+ *
+ * 字段名:用户支付金额
+ * 变量名:payer_total
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 用户支付金额,单位为分。
+ * 示例值:100
+ *
+ */
+ @SerializedName(value = "payer_total")
+ private Integer payerTotal;
+
+ /**
+ *
+ * 字段名:用户退款金额
+ * 变量名:payer_refund
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 退款给用户的金额,不包含所有优惠券金额
+ * 示例值:999
+ *
+ */
+ @SerializedName(value = "payer_refund")
+ private String payerRefund;
+ }
+
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundQueryResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundQueryResult.java
new file mode 100644
index 0000000000..bbb30ea897
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundQueryResult.java
@@ -0,0 +1,325 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 查询退款结果
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/refunds/chapter3_2.shtml
+ */
+@Data
+@NoArgsConstructor
+public class RefundQueryResult implements Serializable {
+
+ /**
+ *
+ * 字段名:微信退款单号
+ * 变量名:refund_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信退款单号
+ * 示例值: 1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "refund_id")
+ private String refundId;
+
+ /**
+ *
+ * 字段名:商户退款单号
+ * 变量名:out_refund_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 商户退款单号
+ * 示例值: 1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "out_refund_no")
+ private String outRefundNo;
+
+ /**
+ *
+ * 字段名:微信订单号
+ * 变量名:transaction_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信支付订单号
+ * 示例值: 1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "transaction_id")
+ private String transactionId;
+
+ /**
+ *
+ * 字段名:商户订单号
+ * 变量名:out_trade_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 返回的商户订单号
+ * 示例值: 1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "out_trade_no")
+ private String outTradeNo;
+
+ /**
+ *
+ * 字段名:退款渠道
+ * 变量名:channel
+ * 是否必填:否
+ * 类型:string(16)
+ * 描述:
+ * ORIGINAL:原路退款
+ * BALANCE:退回到余额
+ * OTHER_BALANCE:原账户异常退到其他余额账户
+ * OTHER_BANKCARD:原银行卡异常退到其他银行卡
+ * 示例值: ORIGINAL
+ *
+ */
+ @SerializedName(value = "channel")
+ private String channel;
+
+ /**
+ *
+ * 字段名:退款入账账户
+ * 变量名:user_received_account
+ * 是否必填:是
+ * 类型:string(64)
+ * 描述:
+ * 取当前退款单的退款入账方。
+ * 退回银行卡:{银行名称}{卡类型}{卡尾号}
+ * 退回支付用户零钱: 支付用户零钱
+ * 退还商户: 商户基本账户、商户结算银行账户
+ * 退回支付用户零钱通:支付用户零钱通
+ * 示例值:招商银行信用卡0403
+ *
+ */
+ @SerializedName(value = "user_received_account")
+ private String userReceivedAccount;
+
+ /**
+ *
+ * 字段名:退款成功时间
+ * 变量名:success_time
+ * 是否必填:否
+ * 类型:string(64)
+ * 描述:
+ * 1、退款成功时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,
+ * 表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+ * 例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒。
+ * 2、当退款状态为退款成功时返回此参数。
+ * 示例值:2018-06-08T10:34:56+08:00
+ *
+ */
+ @SerializedName(value = "success_time")
+ private String successTime;
+
+ /**
+ *
+ * 字段名:退款创建时间
+ * 变量名:create_time
+ * 是否必填:是
+ * 类型:string(64)
+ * 描述:
+ * 1、退款受理时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,
+ * 表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。
+ * 例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒。
+ * 2、当退款状态为退款成功时返回此字段。
+ * 示例值:2018-06-08T10:34:56+08:00
+ *
+ */
+ @SerializedName(value = "create_time")
+ private String createTime;
+
+ /**
+ *
+ * 字段名:退款状态
+ * 变量名:status
+ * 是否必填:是
+ * 类型:string(16)
+ * 描述:
+ * 退款状态,枚举值:
+ * SUCCESS:退款成功
+ * REFUNDCLOSE:退款关闭
+ * PROCESSING:退款处理中
+ * ABNORMAL:退款异常,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往【服务商平台—>交易中心】,手动处理此笔退款
+ * 示例值:SUCCESS
+ *
+ */
+ @SerializedName(value = "status")
+ private String status;
+
+ /**
+ *
+ * 字段名:金额信息
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:object
+ * 描述:
+ * 金额信息
+ *
+ */
+ @SerializedName(value = "amount")
+ private Amount amount;
+
+ /**
+ *
+ * 字段名:营销详情
+ * 变量名:promotion_detail
+ * 是否必填:否
+ * 类型:array
+ * 描述:
+ * 优惠退款信息
+ *
+ */
+ public List promotionDetails;
+
+ @Data
+ @NoArgsConstructor
+ public static class Amount implements Serializable {
+
+ /**
+ *
+ * 字段名:退款金额
+ * 变量名:refund
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 退款金额,币种的最小单位,只能为整数,不能超过原订单支付金额。
+ * 示例值:888
+ *
+ */
+ @SerializedName(value = "refund")
+ private String refund;
+
+ /**
+ *
+ * 字段名:用户退款金额
+ * 变量名:payer_refund
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 退款给用户的金额,不包含所有优惠券金额。
+ * 示例值:888
+ *
+ */
+ @SerializedName(value = "payer_refund")
+ private String payerRefund;
+
+ /**
+ *
+ * 字段名:优惠退款金额
+ * 变量名:discount_refund
+ * 是否必填:否
+ * 类型:int
+ * 描述:
+ * 优惠券的退款金额,原支付单的优惠按比例退款。
+ * 示例值:888
+ *
+ */
+ @SerializedName(value = "discount_refund")
+ private Integer discountRefund;
+
+
+ /**
+ *
+ * 字段名:退款币种
+ * 变量名:currency
+ * 是否必填:否
+ * 类型:string(18)
+ * 描述:
+ * 符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY 。
+ * 示例值: CNY
+ *
+ */
+ @SerializedName(value = "currency")
+ private String currency;
+
+ }
+
+ @Data
+ @NoArgsConstructor
+ public static class PromotionDetail implements Serializable {
+
+ /**
+ *
+ * 字段名:券ID
+ * 变量名:promotion_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:券或者立减优惠id 。
+ * 示例值:109519
+ *
+ */
+ @SerializedName(value = "promotion_id")
+ private String promotionId;
+
+ /**
+ *
+ * 字段名:优惠范围
+ * 变量名:scope
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述: 优惠范围
+ * 枚举值:
+ * GLOBAL:全场代金券
+ * SINGLE:单品优惠
+ * 示例值:GLOBAL
+ *
+ */
+ @SerializedName(value = "scope")
+ private String scope;
+
+ /**
+ *
+ * 字段名:优惠类型
+ * 变量名:type
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 枚举值:
+ * COUPON:充值型代金券,商户需要预先充值营销经费
+ * DISCOUNT:免充值型优惠券,商户不需要预先充值营销经费
+ * 示例值:DISCOUNT
+ *
+ */
+ @SerializedName(value = "type")
+ private String type;
+
+ /**
+ *
+ * 字段名:优惠券面额
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:int
+ * 描述: 用户享受优惠的金额(优惠券面额=微信出资金额+商家出资金额+其他出资方金额 )。
+ * 示例值:5
+ *
+ */
+ @SerializedName(value = "amount")
+ private Integer amount;
+
+ /**
+ *
+ * 字段名:优惠退款金额
+ * 变量名:refund_amount
+ * 是否必填:是
+ * 类型:int
+ * 描述: 代金券退款金额<=退款金额,退款金额-代金券或立减优惠退款金额为现金,说明详见《代金券或立减优惠》。
+ * 示例值:100
+ *
+ */
+ @SerializedName(value = "refund_amount")
+ private Integer refundAmount;
+
+ }
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java
new file mode 100644
index 0000000000..9277b35573
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsRequest.java
@@ -0,0 +1,206 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+/**
+ * @author: f00lish
+ * @date: 2020/09/17
+ */
+
+import com.google.gson.annotations.SerializedName;
+import lombok.*;
+
+import java.io.Serializable;
+
+/**
+ * 退款申请
+ * *
+ * * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/refunds/chapter3_1.shtml
+ * *
+ * @author: f00lish
+ * @date: 2020/09/14
+ */
+@Data
+@Builder
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public class RefundsRequest implements Serializable {
+ private static final long serialVersionUID = -3186851559004865784L;
+
+ /**
+ *
+ * 字段名:二级商户号
+ * 变量名:sub_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信支付分配二级商户的商户号。
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "sub_mchid")
+ private String subMchid;
+
+ /**
+ *
+ * 字段名:电商平台APPID
+ * 变量名:sp_appid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 电商平台在微信公众平台申请服务号对应的APPID,申请商户功能的时候微信支付会配置绑定关系。
+ * 示例值:wx8888888888888888
+ *
+ */
+ @SerializedName(value = "sp_appid")
+ private String spAppid;
+
+ /**
+ *
+ * 字段名:二级商户APPID
+ * 变量名:sub_appid
+ * 是否必填:否
+ * 类型:string(32)
+ * 描述:
+ * 二级商户在微信申请公众号成功后分配的帐号ID,需要电商平台侧配置绑定关系才能传参。
+ * 示例值:wxd678efh567hg6999
+ *
+ */
+ @SerializedName(value = "sub_appid")
+ private String subAppid;
+
+ /**
+ *
+ * 字段名:微信订单号
+ * 变量名:transaction_id
+ * 是否必填:与out_order_no二选一
+ * 类型:string(32)
+ * 描述:
+ * 微信支付订单号。
+ * 示例值:4208450740201411110007820472
+ *
+ */
+ @SerializedName(value = "transaction_id")
+ private String transactionId;
+
+ /**
+ *
+ * 字段名:商户订单号
+ * 变量名:out_order_no
+ * 是否必填:与transaction_id二选一
+ * 类型:string(64)
+ * 描述:
+ * 原支付交易对应的商户订单号。
+ * 示例值:P20150806125346
+ *
+ */
+ @SerializedName(value = "out_order_no")
+ private String outOrderNo;
+
+ /**
+ *
+ * 字段名:商户退款单号
+ * 变量名:out_refund_no
+ * 是否必填:是
+ * 类型:string(64)
+ * 描述:
+ * 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@,同一退款单号多次请求只退一笔。
+ * 示例值:1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "out_refund_no")
+ private String outRefundNo;
+
+ /**
+ *
+ * 字段名:退款原因
+ * 变量名:reason
+ * 是否必填:是
+ * 类型:string(80)
+ * 描述:
+ * 若商户传入,会在下发给用户的退款消息中体现退款原因。
+ * 注意:若订单退款金额≤1元,且属于部分退款,则不会在退款消息中体现退款原因
+ * 示例值:商品已售完
+ *
+ */
+ @SerializedName(value = "reason")
+ private String reason;
+
+ /**
+ *
+ * 字段名:订单金额
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:object
+ * 描述:
+ * 订单金额信息
+ *
+ */
+ @SerializedName(value = "amount")
+ private Amount amount;
+
+ /**
+ *
+ * 字段名:退款结果回调url
+ * 变量名:notify_url
+ * 是否必填:是
+ * 类型:string(256)
+ * 描述:
+ * 异步接收微信支付退款结果通知的回调地址,通知url必须为外网可访问的url,不能携带参数。 如果参数中传了notify_url,则商户平台上配置的回调地址将不会生效,优先回调当前传的地址。
+ * 示例值:https://weixin.qq.com
+ *
+ */
+ @SerializedName(value = "notify_url")
+ private String notifyUrl;
+
+ @Data
+ @Builder
+ @NoArgsConstructor(access = AccessLevel.PRIVATE)
+ @AllArgsConstructor(access = AccessLevel.PRIVATE)
+ public static class Amount implements Serializable {
+
+ private static final long serialVersionUID = 7383027142329410399L;
+
+ /**
+ *
+ * 字段名:退款金额
+ * 变量名:refund
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 退款金额,币种的最小单位,只能为整数,不能超过原订单支付金额。
+ * 示例值:888
+ *
+ */
+ @SerializedName(value = "refund")
+ private Integer refund;
+
+ /**
+ *
+ * 字段名:原订单金额
+ * 变量名:total
+ * 是否必填:是
+ * 类型:int64
+ * 描述:
+ * 订单总金额,单位为分。
+ * 示例值:888
+ *
+ */
+ @SerializedName(value = "total")
+ private Integer total;
+
+ /**
+ *
+ * 字段名:币类型
+ * 变量名:currency
+ * 是否必填:否
+ * 类型:string(18)
+ * 描述:
+ * 符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY。
+ * 示例值:CNY
+ *
+ */
+ @SerializedName(value = "currency")
+ private String currency;
+
+ }
+
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java
new file mode 100644
index 0000000000..9ba480104b
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/RefundsResult.java
@@ -0,0 +1,247 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+/**
+ * @author: f00lish
+ * @date: 2020/09/17
+ */
+
+import com.google.gson.annotations.SerializedName;
+import lombok.*;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 退款结果
+ * *
+ * * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/refunds/chapter3_1.shtml
+ * *
+ * @author: f00lish
+ * @date: 2020/09/14
+ */
+@Data
+@Builder
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public class RefundsResult implements Serializable {
+ private static final long serialVersionUID = -3186851559004865784L;
+
+ /**
+ *
+ * 字段名:微信退款单号
+ * 变量名:refund_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 微信支付退款订单号。
+ * 示例值:1217752501201407033233368018
+ *
+ */
+ @SerializedName(value = "refund_id")
+ private String refundId;
+
+ /**
+ *
+ * 字段名:商户订单号
+ * 变量名:out_order_no
+ * 是否必填:与transaction_id二选一
+ * 类型:string(64)
+ * 描述:
+ * 原支付交易对应的商户订单号。
+ * 示例值:P20150806125346
+ *
+ */
+ @SerializedName(value = "out_order_no")
+ private String outOrderNo;
+
+ /**
+ *
+ * 字段名:退款创建时间
+ * 变量名:create_time
+ * 是否必填:是
+ * 类型:string(64)
+ * 描述:
+ * 退款受理时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒。
+ * 示例值:2018-06-08T10:34:56+08:00
+ *
+ */
+ @SerializedName(value = "create_time")
+ private Date createTime;
+
+ /**
+ *
+ * 字段名:订单金额
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:object
+ * 描述:
+ * 订单金额信息
+ *
+ */
+ @SerializedName(value = "amount")
+ private Amount amount;
+
+ /**
+ *
+ * 字段名:优惠退款详情
+ * 变量名:promotion_detail
+ * 是否必填:否
+ * 类型:array
+ * 描述:
+ * 优惠退款功能信息
+ *
+ */
+ @SerializedName(value = "promotion_detail")
+ private PromotionDetail[] promotionDetail;
+
+ @Data
+ @Builder
+ @NoArgsConstructor(access = AccessLevel.PRIVATE)
+ @AllArgsConstructor(access = AccessLevel.PRIVATE)
+ public static class Amount implements Serializable {
+
+ private static final long serialVersionUID = 7383027142329410399L;
+
+ /**
+ *
+ * 字段名:退款金额
+ * 变量名:refund
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 退款金额,币种的最小单位,只能为整数,不能超过原订单支付金额。
+ * 示例值:888
+ *
+ */
+ @SerializedName(value = "refund")
+ private Integer refund;
+
+ /**
+ *
+ * 字段名:用户退款金额
+ * 变量名:payer_refund
+ * 是否必填:是
+ * 类型:int64
+ * 描述:
+ * 退款给用户的金额,不包含所有优惠券金额。
+ * 示例值:888
+ *
+ */
+ @SerializedName(value = "payer_refund")
+ private Integer payerRefund;
+
+ /**
+ *
+ * 字段名:优惠退款金额
+ * 变量名:discount_refund
+ * 是否必填:否
+ * 类型:int64
+ * 描述:
+ * 优惠券的退款金额,原支付单的优惠按比例退款。
+ * 示例值:888
+ *
+ */
+ @SerializedName(value = "discount_refund")
+ private Integer discountRefund;
+
+ /**
+ *
+ * 字段名:币类型
+ * 变量名:currency
+ * 是否必填:否
+ * 类型:string(18)
+ * 描述:
+ * 符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY。
+ * 示例值:CNY
+ *
+ */
+ @SerializedName(value = "currency")
+ private String currency;
+
+ }
+
+ @Data
+ @Builder
+ @NoArgsConstructor(access = AccessLevel.PRIVATE)
+ @AllArgsConstructor(access = AccessLevel.PRIVATE)
+ public static class PromotionDetail implements Serializable {
+
+ private static final long serialVersionUID = 7383027142329410399L;
+
+ /**
+ *
+ * 字段名:券ID
+ * 变量名:promotion_id
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 券或者立减优惠id。
+ * 示例值:109519
+ *
+ */
+ @SerializedName(value = "promotion_id")
+ private String promotionId;
+
+ /**
+ *
+ * 字段名:优惠范围
+ * 变量名:scope
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 枚举值:
+ * GLOBAL:全场代金券
+ * SINGLE:单品优惠
+ * 示例值:SINGLE
+ *
+ */
+ @SerializedName(value = "scope")
+ private String scope;
+
+ /**
+ *
+ * 字段名:优惠类型
+ * 变量名:type
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 枚举值:
+ * COUPON:充值型代金券,商户需要预先充值营销经费
+ * DISCOUNT:免充值型优惠券,商户不需要预先充值营销经费
+ * 示例值:DISCOUNT
+ *
+ */
+ @SerializedName(value = "type")
+ private String type;
+
+ /**
+ *
+ * 字段名:优惠券面额
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 用户享受优惠的金额(优惠券面额=微信出资金额+商家出资金额+其他出资方金额 )。
+ * 示例值:5
+ *
+ */
+ @SerializedName(value = "amount")
+ private Integer amount;
+
+ /**
+ *
+ * 字段名:优惠退款金额
+ * 变量名:refund_amount
+ * 是否必填:是
+ * 类型:int
+ * 描述:
+ * 代金券退款金额<=退款金额,退款金额-代金券或立减优惠退款金额为现金,说明详见《代金券或立减优惠》https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_1 。
+ * 示例值:CNY
+ *
+ */
+ @SerializedName(value = "refund_amount")
+ private Integer refundAmount;
+
+ }
+
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java
index ee78119871..f2110cc5d8 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/ReturnOrdersResult.java
@@ -72,7 +72,7 @@ public class ReturnOrdersResult implements Serializable {
*
*/
@SerializedName(value = "out_return_no")
- private String R20190516001;
+ private String outReturnNo;
/**
*
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SettlementRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SettlementRequest.java
new file mode 100644
index 0000000000..81e4bb5cc6
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SettlementRequest.java
@@ -0,0 +1,114 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.github.binarywang.wxpay.v3.SpecEncrypt;
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ *
+ * 普通服务商(支付机构、银行不可用),可使用本接口修改其进件、已签约的特约商户-结算账户信息。
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter3_4.shtml
+ *
+ */
+@Data
+@NoArgsConstructor
+public class SettlementRequest implements Serializable {
+
+ /**
+ *
+ * 字段名:账户类型
+ * 变量名:account_type
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 根据特约商户号的主体类型,可选择的账户类型如下:
+ * 1、小微主体:经营者个人银行卡
+ * 2、个体工商户主体:经营者个人银行卡/ 对公银行账户
+ * 3、企业主体:对公银行账户
+ * 4、党政、机关及事业单位主体:对公银行账户
+ * 5、其他组织主体:对公银行账户
+ * 枚举值:
+ * ACCOUNT_TYPE_BUSINESS:对公银行账户
+ * ACCOUNT_TYPE_PRIVATE:经营者个人银行卡
+ * 示例值:ACCOUNT_TYPE_BUSINESS
+ *
+ */
+ @SerializedName(value = "account_type")
+ private String accountType;
+
+ /**
+ *
+ * 字段名:开户银行
+ * 变量名:account_bank
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 请填写开户银行名称,详细参见《开户银行对照表》https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter4_1.shtml。
+ * 示例值:工商银行
+ *
+ */
+ @SerializedName(value = "account_bank")
+ private String accountBank;
+
+ /**
+ *
+ * 字段名:开户银行省市编码
+ * 变量名:bank_address_code
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 需至少精确到市,详细参见《省市区编号对照表》。
+ * 示例值:110000
+ *
+ */
+ @SerializedName(value = "bank_address_code")
+ private String bankAddressCode;
+
+ /**
+ *
+ * 字段名:开户银行全称(含支行)
+ * 变量名:bank_name
+ * 是否必填:否
+ * 类型:string(128)
+ * 描述:
+ * 若开户银行为“其他银行”,则需二选一填写“开户银行全称(含支行)”或“开户银行联行号”。
+ * 填写银行全称,如"深圳农村商业银行XXX支行" ,详细参见开户银行全称(含支行)对照表。
+ * 示例值:施秉县农村信用合作联社城关信用社
+ *
+ */
+ @SerializedName(value = "bank_name")
+ private String bankName;
+
+ /**
+ *
+ * 字段名:开户银行联行号
+ * 变量名:bank_branch_id
+ * 是否必填:否
+ * 类型:string(128)
+ * 描述:
+ * 若开户银行为“其他银行”,则需二选一填写“开户银行全称(含支行)”或“开户银行联行号”。
+ * 填写银行联行号,详细参见《开户银行全称(含支行)对照表》。
+ * 示例值:402713354941
+ *
+ */
+ @SerializedName(value = "bank_branch_id")
+ private String bankBranchId;
+
+ /**
+ *
+ * 字段名:银行账号
+ * 变量名:account_number
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 1、数字,长度遵循系统支持的对公/对私卡号长度要求
+ * 2、该字段需进行加密处理,加密方法详见《敏感信息加密说明》。(提醒:必须在HTTP头中上送Wechatpay-Serial)
+ *
+ */
+ @SpecEncrypt
+ @SerializedName(value = "account_number")
+ private String accountNumber;
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SettlementResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SettlementResult.java
new file mode 100644
index 0000000000..50dfbea77b
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SettlementResult.java
@@ -0,0 +1,106 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 查询结算账户结果
+ *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter3_5.shtml
+ *
+ */
+@Data
+@NoArgsConstructor
+public class SettlementResult implements Serializable {
+ /**
+ *
+ * 字段名:账户类型
+ * 变量名:account_type
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 枚举值:
+ * ACCOUNT_TYPE_BUSINESS:对公银行账户
+ * ACCOUNT_TYPE_PRIVATE:经营者个人银行卡
+ * 示例值:ACCOUNT_TYPE_BUSINESS
+ *
+ */
+ @SerializedName(value = "account_type")
+ private String accountType;
+
+ /**
+ *
+ * 字段名:开户银行
+ * 变量名:account_bank
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 返回特约商户的结算账户-开户银行全称。
+ * 示例值:工商银行
+ *
+ */
+ @SerializedName(value = "account_bank")
+ private String accountBank;
+
+ /**
+ *
+ * 字段名:开户银行全称(含支行)
+ * 变量名:bank_name
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 返回特约商户的结算账户-开户银行全称(含支行)。
+ * 示例值:施秉县农村信用合作联社城关信用社
+ *
+ */
+ @SerializedName(value = "bank_name")
+ private String bankName;
+
+ /**
+ *
+ * 字段名:开户银行联行号
+ * 变量名:bank_branch_id
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 返回特约商户的结算账户-联行号。
+ * 示例值:402713354941
+ *
+ */
+ @SerializedName(value = "bank_branch_id")
+ private String bankBranchId;
+
+ /**
+ *
+ * 字段名:银行账号
+ * 变量名:account_number
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 返回特约商户的结算账户-银行账号,掩码显示。
+ * 示例值:62*************78
+ *
+ */
+ @SerializedName(value = "account_number")
+ private String accountNumber;
+
+ /**
+ *
+ * 字段名:汇款验证结果
+ * 变量名:verify_result
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 返回特约商户的结算账户-汇款验证结果。
+ * VERIFYING:系统汇款验证中,商户可发起提现尝试。
+ * VERIFY_SUCCESS:系统成功汇款,该账户可正常发起提现。
+ * VERIFY_FAIL:系统汇款失败,该账户无法发起提现,请检查修改。
+ * 示例值:VERIFY_SUCCESS
+ *
+ */
+ @SerializedName(value = "verify_result")
+ private String verifyResult;
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawRequest.java
new file mode 100644
index 0000000000..0b836366d4
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawRequest.java
@@ -0,0 +1,91 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 电商平台提现
+ *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_5.shtml
+ *
+ */
+@Data
+@NoArgsConstructor
+public class SpWithdrawRequest implements Serializable {
+ /**
+ *
+ * 字段名:商户提现单号
+ * 变量名:out_request_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 商户提现单号,由商户自定义生成。
+ * 示例值:20190611222222222200000000012122
+ *
+ */
+ @SerializedName(value = "out_request_no")
+ private String outRequestNo;
+
+ /**
+ *
+ * 字段名:提现金额
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:int64
+ * 描述:
+ * 提现金额,单位:分(RMB)
+ * 示例值:1
+ *
+ */
+ @SerializedName(value = "amount")
+ private Integer amount;
+
+ /**
+ *
+ * 字段名:备注
+ * 变量名:remark
+ * 是否必填:否
+ * 类型:string(56)
+ * 描述:
+ * 商户对提现单的备注
+ * 示例值:交易提现
+ *
+ */
+ @SerializedName(value = "remark")
+ private String remark;
+
+ /**
+ *
+ * 字段名:银行附言
+ * 变量名:bank_memo
+ * 是否必填:否
+ * 类型:string(32)
+ * 描述:
+ * 展示在收款银行系统中的附言,数字、字母最长32个汉字(能否成功展示依赖银行系统支持)。
+ * 示例值:xx平台提现
+ *
+ */
+ @SerializedName(value = "bank_memo")
+ private String bankMemo;
+
+ /**
+ *
+ * 字段名:账户类型
+ * 变量名:account_type
+ * 是否必填:是
+ * 类型:string(16)
+ * 描述:
+ * 枚举值:
+ * BASIC:基本账户
+ * OPERATION:运营账户
+ * FEES:手续费账户
+ * 示例值:BASIC
+ *
+ */
+ @SerializedName(value = "account_type")
+ private String accountType;
+
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawResult.java
new file mode 100644
index 0000000000..b18e246677
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SpWithdrawResult.java
@@ -0,0 +1,46 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 电商平台提现 结果
+ *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_5.shtml
+ *
+ */
+@Data
+@NoArgsConstructor
+public class SpWithdrawResult implements Serializable {
+
+ /**
+ *
+ * 字段名:微信支付提现单号
+ * 变量名:withdraw_id
+ * 是否必填:否 (文档里面是【否】,理论上应该都有值)
+ * 类型:string(128)
+ * 描述:
+ * 微信支付系统生成的提现单号。
+ * 示例值:12321937198237912739132791732912793127931279317929791239112123
+ *
+ */
+ @SerializedName(value = "withdraw_id")
+ private String withdrawId;
+
+ /**
+ *
+ * 字段名:商户提现单号
+ * 变量名:out_request_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 必须是字母数字
+ * 示例值: 20190611222222222200000000012122
+ *
+ */
+ @SerializedName(value = "out_request_no")
+ private String outRequestNo;
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawRequest.java
new file mode 100644
index 0000000000..3c74db24c9
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawRequest.java
@@ -0,0 +1,89 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 二级商户账户余额提现
+ *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/combine/chapter3_3.shtml
+ *
+ */
+@Data
+@NoArgsConstructor
+public class SubWithdrawRequest implements Serializable {
+
+ /**
+ *
+ * 字段名:二级商户号
+ * 变量名:sub_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 电商平台二级商户号,由微信支付生成并下发。
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "sub_mchid")
+ private String subMchid;
+
+ /**
+ *
+ * 字段名:商户提现单号
+ * 变量名:out_request_no
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 必须是字母数字
+ * 示例值: 20190611222222222200000000012122
+ *
+ */
+ @SerializedName(value = "out_request_no")
+ private String outRequestNo;
+
+ /**
+ *
+ * 字段名:提现金额
+ * 变量名:amount
+ * 是否必填:是
+ * 类型:int64
+ * 描述:
+ * 提现金额(单位:分)
+ * 示例值:100
+ *
+ */
+ @SerializedName(value = "amount")
+ private Integer amount;
+
+ /**
+ *
+ * 字段名:备注
+ * 变量名:remark
+ * 是否必填:否
+ * 类型:string(56)
+ * 描述:
+ * 商户对提现单的备注
+ * 示例值:交易提现
+ *
+ */
+ @SerializedName(value = "remark")
+ private String remark;
+
+ /**
+ *
+ * 字段名:银行附言
+ * 变量名:bank_memo
+ * 是否必填:否
+ * 类型:string(32)
+ * 描述:
+ * 展示在收款银行系统中的附言,数字、字母最长32个汉字(能否成功展示依赖银行系统支持)。
+ * 示例值:微信支付提现
+ *
+ */
+ @SerializedName(value = "bank_memo")
+ private String bankMemo;
+
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawResult.java
new file mode 100644
index 0000000000..21213dd42d
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/ecommerce/SubWithdrawResult.java
@@ -0,0 +1,60 @@
+package com.github.binarywang.wxpay.bean.ecommerce;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 二级商户账户余额提现 结果
+ *
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_2.shtml
+ *
+ */
+@Data
+@NoArgsConstructor
+public class SubWithdrawResult implements Serializable {
+
+ /**
+ *
+ * 字段名:二级商户号
+ * 变量名:sub_mchid
+ * 是否必填:是
+ * 类型:string(32)
+ * 描述:
+ * 电商平台二级商户号,由微信支付生成并下发。
+ * 示例值:1900000109
+ *
+ */
+ @SerializedName(value = "sub_mchid")
+ private String subMchid;
+
+ /**
+ *
+ * 字段名:微信支付提现单号
+ * 变量名:withdraw_id
+ * 是否必填:是
+ * 类型:string(128)
+ * 描述:
+ * 电商平台提交二级商户提现申请后,由微信支付返回的申请单号,作为查询申请状态的唯一标识。
+ * 示例值: 12321937198237912739132791732912793127931279317929791239112123
+ *
+ */
+ @SerializedName(value = "withdraw_id")
+ private String withdrawId;
+
+ /**
+ *
+ * 字段名:商户提现单号
+ * 变量名:out_request_no
+ * 是否必填:否
+ * 类型:string(32)
+ * 描述:
+ * 必须是字母数字
+ * 示例值: 20190611222222222200000000012122
+ *
+ */
+ @SerializedName(value = "out_request_no")
+ private String outRequestNo;
+}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnQueryRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnQueryRequest.java
index 734c805401..d3c7816027 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnQueryRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingReturnQueryRequest.java
@@ -72,6 +72,11 @@ protected void checkConstraints() throws WxPayException {
this.setSignType(WxPayConstants.SignType.HMAC_SHA256);
}
+ @Override
+ protected boolean ignoreSubAppId() {
+ return true;
+ }
+
@Override
protected void storeMap(Map map) {
map.put("order_id", orderId);
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/BaseWxPayRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/BaseWxPayRequest.java
index f19935e7e1..394bc8969b 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/BaseWxPayRequest.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/BaseWxPayRequest.java
@@ -9,6 +9,7 @@
import lombok.Data;
import lombok.experimental.Accessors;
import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.BeanUtils;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
@@ -246,7 +247,7 @@ private String toFastXml() {
return document.asXML();
} catch (Exception e) {
- throw new RuntimeException("generate xml error", e);
+ throw new WxRuntimeException("generate xml error", e);
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java
index 51865664f4..d83e3d06a5 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java
@@ -11,6 +11,7 @@
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.Data;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import org.apache.commons.lang3.StringUtils;
@@ -139,7 +140,7 @@ public static T fromXML(String xmlString, Class c
t.loadXml(doc);
return (T) t;
} catch (Exception e) {
- throw new RuntimeException("parse xml error", e);
+ throw new WxRuntimeException("parse xml error", e);
}
}
XStream xstream = XStreamInitializer.getInstance();
@@ -243,7 +244,7 @@ public String toString() {
*/
public Map toMap() {
if (StringUtils.isBlank(this.xmlString)) {
- throw new RuntimeException("xml数据有问题,请核实!");
+ throw new WxRuntimeException("xml数据有问题,请核实!");
}
Map result = Maps.newHashMap();
@@ -258,7 +259,7 @@ public Map toMap() {
result.put(list.item(i).getNodeName(), list.item(i).getTextContent());
}
} catch (XPathExpressionException e) {
- throw new RuntimeException("非法的xml文本内容:" + xmlString);
+ throw new WxRuntimeException("非法的xml文本内容:" + xmlString);
}
return result;
@@ -282,7 +283,7 @@ protected Document openXML(String content) {
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
return factory.newDocumentBuilder().parse(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)));
} catch (Exception e) {
- throw new RuntimeException("非法的xml文本内容:\n" + this.xmlString, e);
+ throw new WxRuntimeException("非法的xml文本内容:\n" + this.xmlString, e);
}
}
@@ -302,7 +303,7 @@ protected String getXmlValue(String... path) {
.compile(expression)
.evaluate(doc, XPathConstants.STRING);
} catch (XPathExpressionException e) {
- throw new RuntimeException("未找到相应路径的文本:" + expression);
+ throw new WxRuntimeException("未找到相应路径的文本:" + expression);
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java
index 90997fb375..c0bc6444fe 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EcommerceService.java
@@ -97,6 +97,18 @@ public interface EcommerceService {
*/
CombineTransactionsNotifyResult parseCombineNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
+ /**
+ *
+ * 合单查询订单API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/combine/chapter3_3.shtml
+ *
+ *
+ * @param outTradeNo 合单商户订单号
+ * @return 支付订单信息
+ * @throws WxPayException the wx pay exception
+ */
+ CombineTransactionsResult queryCombineTransactions(String outTradeNo) throws WxPayException;
+
/**
*
* 服务商模式普通支付API(APP支付、JSAPI支付、H5支付、NATIVE支付).
@@ -139,6 +151,18 @@ public interface EcommerceService {
*/
PartnerTransactionsNotifyResult parsePartnerNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
+ /**
+ *
+ * 普通查询订单API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/e_transactions/chapter3_5.shtml
+ *
+ *
+ * @param request 商户订单信息
+ * @return 支付订单信息
+ * @throws WxPayException the wx pay exception
+ */
+ PartnerTransactionsResult queryPartnerTransactions(PartnerTransactionsQueryRequest request) throws WxPayException;
+
/**
*
* 服务商账户实时余额
@@ -201,6 +225,18 @@ public interface EcommerceService {
*/
ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException;
+ /**
+ *
+ * 查询分账结果API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/profitsharing/chapter3_2.shtml
+ *
+ *
+ * @param request 查询分账请求
+ * @return 返回数据 profit sharing result
+ * @throws WxPayException the wx pay exception
+ */
+ ProfitSharingResult queryProfitSharing(ProfitSharingQueryRequest request) throws WxPayException;
+
/**
*
* 请求分账回退API
@@ -213,4 +249,115 @@ public interface EcommerceService {
*/
ReturnOrdersResult returnOrders(ReturnOrdersRequest request) throws WxPayException;
+ /**
+ *
+ * 完结分账API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/profitsharing/chapter3_5.shtml
+ *
+ *
+ * @param request 完结分账请求
+ * @return 返回数据 return orders result
+ * @throws WxPayException the wx pay exception
+ */
+ ProfitSharingResult finishOrder(FinishOrderRequest request) throws WxPayException;
+
+ /**
+ *
+ * 退款申请API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/refunds/chapter3_1.shtml
+ *
+ *
+ * @param request 退款请求
+ * @return 返回数据 return refunds result
+ * @throws WxPayException the wx pay exception
+ */
+ RefundsResult refunds(RefundsRequest request) throws WxPayException;
+
+ /**
+ *
+ * 查询退款API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/refunds/chapter3_2.shtml
+ *
+ *
+ * @param subMchid 二级商户号
+ * @param refundId 微信退款单号
+ * @return 返回数据 return refunds result
+ * @throws WxPayException the wx pay exception
+ */
+ RefundQueryResult queryRefundByRefundId(String subMchid, String refundId) throws WxPayException;
+
+ /**
+ *
+ * 查询退款API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/refunds/chapter3_2.shtml
+ *
+ *
+ * @param subMchid 二级商户号
+ * @param outRefundNo 商户退款单号
+ * @return 返回数据 return refunds result
+ * @throws WxPayException the wx pay exception
+ */
+ RefundQueryResult queryRefundByOutRefundNo(String subMchid, String outRefundNo) throws WxPayException;
+
+ /**
+ *
+ * 退款通知回调数据处理
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/refunds/chapter3_3.shtml
+ *
+ *
+ * @param notifyData 通知数据
+ * @param header 通知头部数据,不传则表示不校验头
+ * @return 解密后通知数据 partner refund notify result
+ * @throws WxPayException the wx pay exception
+ */
+ RefundNotifyResult parseRefundNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
+
+ /**
+ *
+ * 二级商户账户余额提现API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_2.shtml
+ *
+ *
+ * @param request 提现请求
+ * @return 返回数据 return withdraw result
+ * @throws WxPayException the wx pay exception
+ */
+ SubWithdrawResult subWithdraw(SubWithdrawRequest request) throws WxPayException;
+
+ /**
+ *
+ * 电商平台提现API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_5.shtml
+ *
+ *
+ * @param request 提现请求
+ * @return 返回数据 return withdraw result
+ * @throws WxPayException the wx pay exception
+ */
+ SpWithdrawResult spWithdraw(SpWithdrawRequest request) throws WxPayException;
+
+ /**
+ *
+ * 修改结算帐号API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter3_4.shtml
+ *
+ *
+ * @param subMchid 二级商户号。
+ * @param request 结算帐号
+ * @throws WxPayException the wx pay exception
+ */
+ void modifySettlement(String subMchid, SettlementRequest request) throws WxPayException;
+
+ /**
+ *
+ * 查询结算账户API
+ * 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter3_5.shtml
+ *
+ *
+ * @param subMchid 二级商户号。
+ * @return 返回数据 return settlement result
+ * @throws WxPayException the wx pay exception
+ */
+ SettlementResult querySettlement(String subMchid) throws WxPayException;
+
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java
index b5012643ca..15ca423a29 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java
@@ -23,6 +23,7 @@
import com.google.common.base.Joiner;
import com.google.common.collect.Maps;
import jodd.io.ZipUtil;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -409,7 +410,7 @@ public Map getPayInfo(WxPayUnifiedOrderRequest request) throws W
WxPayUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request);
String prepayId = unifiedOrderResult.getPrepayId();
if (StringUtils.isBlank(prepayId)) {
- throw new RuntimeException(String.format("无法获取prepay id,错误代码: '%s',信息:%s。",
+ throw new WxRuntimeException(String.format("无法获取prepay id,错误代码: '%s',信息:%s。",
unifiedOrderResult.getErrCode(), unifiedOrderResult.getErrCodeDes()));
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java
index b792771a1f..eefc7a2648 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImpl.java
@@ -20,6 +20,7 @@
@RequiredArgsConstructor
public class EcommerceServiceImpl implements EcommerceService {
+
private static final Gson GSON = new GsonBuilder().create();
private final WxPayService payService;
@@ -73,14 +74,24 @@ public CombineTransactionsNotifyResult parseCombineNotifyResult(String notifyDat
String apiV3Key = this.payService.getConfig().getApiV3Key();
try {
String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key);
- CombineTransactionsNotifyResult notifyResult = GSON.fromJson(result, CombineTransactionsNotifyResult.class);
+ CombineTransactionsResult transactionsResult = GSON.fromJson(result, CombineTransactionsResult.class);
+
+ CombineTransactionsNotifyResult notifyResult = new CombineTransactionsNotifyResult();
notifyResult.setRawData(response);
+ notifyResult.setResult(transactionsResult);
return notifyResult;
} catch (GeneralSecurityException | IOException e) {
throw new WxPayException("解析报文异常!", e);
}
}
+ @Override
+ public CombineTransactionsResult queryCombineTransactions(String outTradeNo) throws WxPayException {
+ String url = String.format("%s/v3/combine-transactions/out-trade-no/%s", this.payService.getPayBaseUrl(), outTradeNo);
+ String response = this.payService.getV3(URI.create(url));
+ return GSON.fromJson(response, CombineTransactionsResult.class);
+ }
+
@Override
public TransactionsResult partner(TradeTypeEnum tradeType, PartnerTransactionsRequest request) throws WxPayException {
String url = this.payService.getPayBaseUrl() + tradeType.getPartnerUrl();
@@ -108,14 +119,29 @@ public PartnerTransactionsNotifyResult parsePartnerNotifyResult(String notifyDat
String apiV3Key = this.payService.getConfig().getApiV3Key();
try {
String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key);
- PartnerTransactionsNotifyResult notifyResult = GSON.fromJson(result, PartnerTransactionsNotifyResult.class);
+ PartnerTransactionsResult transactionsResult = GSON.fromJson(result, PartnerTransactionsResult.class);
+
+ PartnerTransactionsNotifyResult notifyResult = new PartnerTransactionsNotifyResult();
notifyResult.setRawData(response);
+ notifyResult.setResult(transactionsResult);
return notifyResult;
} catch (GeneralSecurityException | IOException e) {
throw new WxPayException("解析报文异常!", e);
}
}
+ @Override
+ public PartnerTransactionsResult queryPartnerTransactions(PartnerTransactionsQueryRequest request) throws WxPayException {
+ String url = String.format("%s/v3/pay/partner/transactions/out-trade-no/%s", this.payService.getPayBaseUrl(), request.getOutTradeNo());
+ if (Objects.isNull(request.getOutTradeNo())) {
+ url = String.format("%s/v3/pay/partner/transactions/id/%s", this.payService.getPayBaseUrl(), request.getTransactionId());
+ }
+ String query = String.format("?sp_mchid=%s&sub_mchid=%s", request.getSpMchid(), request.getSubMchid());
+ URI uri = URI.create(url + query);
+ String response = this.payService.getV3(uri);
+ return GSON.fromJson(response, PartnerTransactionsResult.class);
+ }
+
@Override
public FundBalanceResult spNowBalance(SpAccountTypeEnum accountType) throws WxPayException {
String url = String.format("%s/v3/merchant/fund/balance/%s", this.payService.getPayBaseUrl(), accountType);
@@ -155,6 +181,14 @@ public ProfitSharingResult profitSharing(ProfitSharingRequest request) throws Wx
return GSON.fromJson(response, ProfitSharingResult.class);
}
+ @Override
+ public ProfitSharingResult queryProfitSharing(ProfitSharingQueryRequest request) throws WxPayException {
+ String url = String.format("%s/v3/ecommerce/profitsharing/orders?sub_mchid=%s&transaction_id=%s&out_order_no=%s",
+ this.payService.getPayBaseUrl(), request.getSubMchid(), request.getTransactionId(), request.getOutOrderNo());
+ String response = this.payService.getV3(URI.create(url));
+ return GSON.fromJson(response, ProfitSharingResult.class);
+ }
+
@Override
public ReturnOrdersResult returnOrders(ReturnOrdersRequest request) throws WxPayException {
String url = String.format("%s/v3/ecommerce/profitsharing/returnorders", this.payService.getPayBaseUrl());
@@ -162,6 +196,89 @@ public ReturnOrdersResult returnOrders(ReturnOrdersRequest request) throws WxPay
return GSON.fromJson(response, ReturnOrdersResult.class);
}
+ @Override
+ public ProfitSharingResult finishOrder(FinishOrderRequest request) throws WxPayException {
+ String url = String.format("%s/v3/ecommerce/profitsharing/finish-order", this.payService.getPayBaseUrl());
+ String response = this.payService.postV3(url, GSON.toJson(request));
+ return GSON.fromJson(response, ProfitSharingResult.class);
+ }
+
+ @Override
+ public RefundsResult refunds(RefundsRequest request) throws WxPayException {
+ String url = String.format("%s/v3/ecommerce/refunds/apply", this.payService.getPayBaseUrl());
+ String response = this.payService.postV3(url, GSON.toJson(request));
+ return GSON.fromJson(response, RefundsResult.class);
+ }
+
+ @Override
+ public RefundQueryResult queryRefundByRefundId(String subMchid, String refundId) throws WxPayException {
+ String url = String.format("%s/v3/ecommerce/refunds/id/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), refundId, subMchid);
+ String response = this.payService.getV3(URI.create(url));
+ return GSON.fromJson(response, RefundQueryResult.class);
+ }
+
+ @Override
+ public RefundQueryResult queryRefundByOutRefundNo(String subMchid, String outRefundNo) throws WxPayException {
+ String url = String.format("%s/v3/ecommerce/applyments/out-request-no/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), outRefundNo, subMchid);
+ String response = this.payService.getV3(URI.create(url));
+ return GSON.fromJson(response, RefundQueryResult.class);
+ }
+
+ @Override
+ public RefundNotifyResult parseRefundNotifyResult(String notifyData, SignatureHeader header) throws WxPayException {
+ if(Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)){
+ throw new WxPayException("非法请求,头部信息验证失败");
+ }
+ NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class);
+ NotifyResponse.Resource resource = response.getResource();
+ String cipherText = resource.getCiphertext();
+ String associatedData = resource.getAssociatedData();
+ String nonce = resource.getNonce();
+ String apiV3Key = this.payService.getConfig().getApiV3Key();
+ try {
+ String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key);
+ RefundNotifyResult notifyResult = GSON.fromJson(result, RefundNotifyResult.class);
+ notifyResult.setRawData(response);
+ return notifyResult;
+ } catch (GeneralSecurityException | IOException e) {
+ throw new WxPayException("解析报文异常!", e);
+ }
+ }
+
+ @Override
+ public SubWithdrawResult subWithdraw(SubWithdrawRequest request) throws WxPayException {
+ String url = String.format("%s/v3/ecommerce/fund/withdraw", this.payService.getPayBaseUrl());
+ String response = this.payService.postV3(url, GSON.toJson(request));
+ return GSON.fromJson(response, SubWithdrawResult.class);
+ }
+
+ @Override
+ public SpWithdrawResult spWithdraw(SpWithdrawRequest request) throws WxPayException {
+ String url = String.format("%s/v3/merchant/fund/withdraw", this.payService.getPayBaseUrl());
+ String response = this.payService.postV3(url, GSON.toJson(request));
+ return GSON.fromJson(response, SpWithdrawResult.class);
+ }
+
+ @Override
+ public void modifySettlement(String subMchid, SettlementRequest request) throws WxPayException {
+ String url = String.format("%s/v3/apply4sub/sub_merchants/%s/modify-settlement", this.payService.getPayBaseUrl(), subMchid);
+ RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
+ this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
+ }
+
+ @Override
+ public SettlementResult querySettlement(String subMchid) throws WxPayException {
+ String url = String.format("%s/v3/apply4sub/sub_merchants/%s/settlement", this.payService.getPayBaseUrl(), subMchid);
+ String response = this.payService.getV3(URI.create(url));
+ return GSON.fromJson(response, SettlementResult.class);
+ }
+
+ /**
+ * 校验通知签名
+ * @param header 通知头信息
+ * @param data 通知数据
+ * @return true:校验通过 false:校验不通过
+ */
private boolean verifyNotifySign(SignatureHeader header, String data) {
String beforeSign = String.format("%s\n%s\n%s\n",
header.getTimeStamp(),
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java
index a490108146..e93e3cd78b 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/AutoUpdateCertificatesVerifier.java
@@ -10,6 +10,7 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
@@ -94,7 +95,7 @@ public AutoUpdateCertificatesVerifier(Credentials credentials, byte[] apiV3Key,
autoUpdateCert();
instant = Instant.now();
} catch (IOException | GeneralSecurityException e) {
- throw new RuntimeException(e);
+ throw new WxRuntimeException(e);
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/CertificatesVerifier.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/CertificatesVerifier.java
index 7239d9e64d..9ca8b5b836 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/CertificatesVerifier.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/CertificatesVerifier.java
@@ -1,5 +1,7 @@
package com.github.binarywang.wxpay.v3.auth;
+import me.chanjar.weixin.common.error.WxRuntimeException;
+
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
@@ -30,11 +32,11 @@ private boolean verify(X509Certificate certificate, byte[] message, String signa
sign.update(message);
return sign.verify(Base64.getDecoder().decode(signature));
} catch (NoSuchAlgorithmException e) {
- throw new RuntimeException("当前Java环境不支持SHA256withRSA", e);
+ throw new WxRuntimeException("当前Java环境不支持SHA256withRSA", e);
} catch (SignatureException e) {
- throw new RuntimeException("签名验证过程发生了错误", e);
+ throw new WxRuntimeException("签名验证过程发生了错误", e);
} catch (InvalidKeyException e) {
- throw new RuntimeException("无效的证书", e);
+ throw new WxRuntimeException("无效的证书", e);
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/PrivateKeySigner.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/PrivateKeySigner.java
index 37ec51cf58..183e46e260 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/PrivateKeySigner.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/auth/PrivateKeySigner.java
@@ -1,5 +1,7 @@
package com.github.binarywang.wxpay.v3.auth;
+import me.chanjar.weixin.common.error.WxRuntimeException;
+
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
@@ -27,11 +29,11 @@ public SignatureResult sign(byte[] message) {
return new SignatureResult(
Base64.getEncoder().encodeToString(sign.sign()), certificateSerialNumber);
} catch (NoSuchAlgorithmException e) {
- throw new RuntimeException("当前Java环境不支持SHA256withRSA", e);
+ throw new WxRuntimeException("当前Java环境不支持SHA256withRSA", e);
} catch (SignatureException e) {
- throw new RuntimeException("签名计算失败", e);
+ throw new WxRuntimeException("签名计算失败", e);
} catch (InvalidKeyException e) {
- throw new RuntimeException("无效的私钥", e);
+ throw new WxRuntimeException("无效的私钥", e);
}
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/PemUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/PemUtils.java
index bf4d2657b5..c039ccb636 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/PemUtils.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/PemUtils.java
@@ -1,5 +1,7 @@
package com.github.binarywang.wxpay.v3.util;
+import me.chanjar.weixin.common.error.WxRuntimeException;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -35,11 +37,11 @@ public static PrivateKey loadPrivateKey(InputStream inputStream) {
return kf.generatePrivate(
new PKCS8EncodedKeySpec(Base64.getDecoder().decode(privateKey)));
} catch (NoSuchAlgorithmException e) {
- throw new RuntimeException("当前Java环境不支持RSA", e);
+ throw new WxRuntimeException("当前Java环境不支持RSA", e);
} catch (InvalidKeySpecException e) {
- throw new RuntimeException("无效的密钥格式");
+ throw new WxRuntimeException("无效的密钥格式");
} catch (IOException e) {
- throw new RuntimeException("无效的密钥");
+ throw new WxRuntimeException("无效的密钥");
}
}
@@ -50,11 +52,11 @@ public static X509Certificate loadCertificate(InputStream inputStream) {
cert.checkValidity();
return cert;
} catch (CertificateExpiredException e) {
- throw new RuntimeException("证书已过期", e);
+ throw new WxRuntimeException("证书已过期", e);
} catch (CertificateNotYetValidException e) {
- throw new RuntimeException("证书尚未生效", e);
+ throw new WxRuntimeException("证书尚未生效", e);
} catch (CertificateException e) {
- throw new RuntimeException("无效的证书", e);
+ throw new WxRuntimeException("无效的证书", e);
}
}
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java
index d88c67e419..287ac11fcf 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/RsaCryptoUtil.java
@@ -2,6 +2,7 @@
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.v3.SpecEncrypt;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
@@ -70,7 +71,7 @@ public static String encryptOAEP(String message, X509Certificate certificate)
byte[] ciphertext = cipher.doFinal(data);
return Base64.getEncoder().encodeToString(ciphertext);
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
- throw new RuntimeException("当前Java环境不支持RSA v1.5/OAEP", e);
+ throw new WxRuntimeException("当前Java环境不支持RSA v1.5/OAEP", e);
} catch (InvalidKeyException e) {
throw new IllegalArgumentException("无效的证书", e);
} catch (IllegalBlockSizeException | BadPaddingException e) {
@@ -87,7 +88,7 @@ public static String decryptOAEP(String ciphertext, PrivateKey privateKey)
byte[] data = Base64.getDecoder().decode(ciphertext);
return new String(cipher.doFinal(data), StandardCharsets.UTF_8);
} catch (NoSuchPaddingException | NoSuchAlgorithmException e) {
- throw new RuntimeException("当前Java环境不支持RSA v1.5/OAEP", e);
+ throw new WxRuntimeException("当前Java环境不支持RSA v1.5/OAEP", e);
} catch (InvalidKeyException e) {
throw new IllegalArgumentException("无效的私钥", e);
} catch (BadPaddingException | IllegalBlockSizeException e) {
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/SignUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/SignUtils.java
index 275a8d51ba..fff68ce280 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/SignUtils.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/SignUtils.java
@@ -1,12 +1,14 @@
package com.github.binarywang.wxpay.v3.util;
+import me.chanjar.weixin.common.error.WxRuntimeException;
+
import java.security.*;
import java.util.Base64;
import java.util.Random;
public class SignUtils {
- public static String sign(String string, PrivateKey privateKey){
+ public static String sign(String string, PrivateKey privateKey) {
try {
Signature sign = Signature.getInstance("SHA256withRSA");
sign.initSign(privateKey);
@@ -14,23 +16,24 @@ public static String sign(String string, PrivateKey privateKey){
return Base64.getEncoder().encodeToString(sign.sign());
} catch (NoSuchAlgorithmException e) {
- throw new RuntimeException("当前Java环境不支持SHA256withRSA", e);
+ throw new WxRuntimeException("当前Java环境不支持SHA256withRSA", e);
} catch (SignatureException e) {
- throw new RuntimeException("签名计算失败", e);
+ throw new WxRuntimeException("签名计算失败", e);
} catch (InvalidKeyException e) {
- throw new RuntimeException("无效的私钥", e);
+ throw new WxRuntimeException("无效的私钥", e);
}
}
/**
* 随机生成32位字符串.
*/
- public static String genRandomStr(){
+ public static String genRandomStr() {
return genRandomStr(32);
}
/**
* 生成随机字符串
+ *
* @param length 字符串长度
* @return
*/
diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImplTest.java
new file mode 100644
index 0000000000..b56084466b
--- /dev/null
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImplTest.java
@@ -0,0 +1,78 @@
+package com.github.binarywang.wxpay.service.impl;
+
+import com.github.binarywang.wxpay.bean.ecommerce.PartnerTransactionsQueryRequest;
+import com.github.binarywang.wxpay.bean.ecommerce.PartnerTransactionsResult;
+import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.WxPayService;
+import com.github.binarywang.wxpay.testbase.ApiTestModule;
+import com.google.inject.Inject;
+import lombok.extern.slf4j.Slf4j;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+import java.nio.charset.StandardCharsets;
+
+@Slf4j
+@Test
+@Guice(modules = ApiTestModule.class)
+public class EcommerceServiceImplTest {
+
+ @Inject
+ private WxPayService wxPayService;
+
+ @Test
+ public void testNotifySign(){
+ //通知报文主体
+ String notifyData = "";
+ //请求头 Wechatpay-Timestamp
+ String timeStamp = "";
+ //请求头 Wechatpay-Nonce
+ String nonce = "";
+ //请求头 Wechatpay-Signature
+ String signed = "";
+ //请求头 Wechatpay-Serial
+ String serialNo = "";
+
+ SignatureHeader header = new SignatureHeader();
+ header.setNonce(nonce);
+ header.setSerialNo(serialNo);
+ header.setTimeStamp(timeStamp);
+ header.setSigned(signed);
+
+ String beforeSign = String.format("%s\n%s\n%s\n",
+ header.getTimeStamp(),
+ header.getNonce(),
+ notifyData);
+ boolean signResult = wxPayService.getConfig().getVerifier().verify(header.getSerialNo(),
+ beforeSign.getBytes(StandardCharsets.UTF_8), header.getSigned());
+ log.info("签名结果:{} \nheader:{} \ndata:{}", signResult, header, notifyData);
+ }
+
+ @Test
+ public void testQueryPartnerTransactions() throws WxPayException {
+ PartnerTransactionsQueryRequest request = new PartnerTransactionsQueryRequest();
+ //服务商商户号
+ request.setSpMchid("");
+ //二级商户号
+ request.setSubMchid("");
+ //商户订单号
+ request.setOutTradeNo("");
+ //微信订单号
+ request.setTransactionId("");
+ wxPayService.getEcommerceService().queryPartnerTransactions(request);
+ }
+
+ @Test
+ public void testSubNowBalance() throws WxPayException {
+ String subMchid = "";
+ wxPayService.getEcommerceService().subNowBalance(subMchid);
+ }
+
+ @Test
+ public void testSubDayEndBalance() throws WxPayException {
+ String subMchid = "";
+ String date = "";
+ wxPayService.getEcommerceService().subDayEndBalance(subMchid,date);
+ }
+}
diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/ApiTestModule.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/ApiTestModule.java
index b29b1af16c..7155b544b6 100644
--- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/ApiTestModule.java
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/testbase/ApiTestModule.java
@@ -6,6 +6,7 @@
import com.google.inject.Binder;
import com.google.inject.Module;
import com.thoughtworks.xstream.XStream;
+import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -24,7 +25,7 @@ public class ApiTestModule implements Module {
public void configure(Binder binder) {
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
if (inputStream == null) {
- throw new RuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
+ throw new WxRuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
}
XmlWxPayConfig config = this.fromXml(XmlWxPayConfig.class, inputStream);