Skip to content

Commit 3cd7749

Browse files
authored
Merge pull request #3 from Wechat-Group/develop
Develop
2 parents 991f39e + cc83bcb commit 3cd7749

File tree

24 files changed

+588
-34
lines changed

24 files changed

+588
-34
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>wx-java</artifactId>
9-
<version>3.9.1.B</version>
9+
<version>3.9.2.B</version>
1010
<packaging>pom</packaging>
1111
<name>WxJava - Weixin/Wechat Java SDK</name>
1212
<description>微信开发Java SDK</description>

spring-boot-starters/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>wx-java</artifactId>
9-
<version>3.9.1.B</version>
9+
<version>3.9.2.B</version>
1010
</parent>
1111
<packaging>pom</packaging>
1212
<artifactId>wx-java-spring-boot-starters</artifactId>

spring-boot-starters/wx-java-miniapp-spring-boot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>wx-java-spring-boot-starters</artifactId>
77
<groupId>com.github.binarywang</groupId>
8-
<version>3.9.1.B</version>
8+
<version>3.9.2.B</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>wx-java-spring-boot-starters</artifactId>
77
<groupId>com.github.binarywang</groupId>
8-
<version>3.9.1.B</version>
8+
<version>3.9.2.B</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

spring-boot-starters/wx-java-open-spring-boot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>wx-java-spring-boot-starters</artifactId>
77
<groupId>com.github.binarywang</groupId>
8-
<version>3.9.1.B</version>
8+
<version>3.9.2.B</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

spring-boot-starters/wx-java-pay-spring-boot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>wx-java-spring-boot-starters</artifactId>
77
<groupId>com.github.binarywang</groupId>
8-
<version>3.9.1.B</version>
8+
<version>3.9.2.B</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

weixin-graal/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>wx-java</artifactId>
9-
<version>3.9.1.B</version>
9+
<version>3.9.2.B</version>
1010
</parent>
1111

1212
<artifactId>weixin-graal</artifactId>

weixin-java-common/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>wx-java</artifactId>
9-
<version>3.9.1.B</version>
9+
<version>3.9.2.B</version>
1010
</parent>
1111

1212
<artifactId>weixin-java-common</artifactId>

weixin-java-cp/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.github.binarywang</groupId>
99
<artifactId>wx-java</artifactId>
10-
<version>3.9.1.B</version>
10+
<version>3.9.2.B</version>
1111
</parent>
1212

1313
<artifactId>weixin-java-cp</artifactId>

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMessageService.java

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
55
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
66
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
7+
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
78

89
/**
910
* 消息推送接口.
@@ -24,6 +25,21 @@ public interface WxCpMessageService {
2425
*/
2526
WxCpMessageSendResult send(WxCpMessage message) throws WxErrorException;
2627

28+
/**
29+
* <pre>
30+
* 查询应用消息发送统计
31+
* 请求方式:POST(HTTPS)
32+
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/message/get_statistics?access_token=ACCESS_TOKEN
33+
*
34+
* 详情请见: https://work.weixin.qq.com/api/doc/90000/90135/92369
35+
* </pre>
36+
*
37+
* @param timeType 查询哪天的数据,0:当天;1:昨天。默认为0。
38+
* @return 统计结果
39+
* @throws WxErrorException the wx error exception
40+
*/
41+
WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException;
42+
2743
/**
2844
* <pre>
2945
* 互联企业的应用支持推送文本、图片、视频、文件、图文等类型。

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package me.chanjar.weixin.cp.api.impl;
22

3+
import com.google.common.collect.ImmutableMap;
34
import lombok.RequiredArgsConstructor;
45
import me.chanjar.weixin.common.error.WxErrorException;
56
import me.chanjar.weixin.cp.api.WxCpMessageService;
67
import me.chanjar.weixin.cp.api.WxCpService;
78
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
89
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
910
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
10-
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
11+
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
12+
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Message;
13+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
1114

1215
/**
1316
* 消息推送接口实现类.
@@ -27,7 +30,13 @@ public WxCpMessageSendResult send(WxCpMessage message) throws WxErrorException {
2730
}
2831

2932
return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
30-
.getApiUrl(WxCpApiPathConsts.Message.MESSAGE_SEND), message.toJson()));
33+
.getApiUrl(Message.MESSAGE_SEND), message.toJson()));
34+
}
35+
36+
@Override
37+
public WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException {
38+
return WxCpMessageSendStatistics.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(Message.GET_STATISTICS),
39+
WxCpGsonBuilder.create().toJson(ImmutableMap.of("time_type", timeType))));
3140
}
3241

3342
@Override
@@ -38,6 +47,6 @@ public WxCpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message
3847
}
3948

4049
return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
41-
.getApiUrl(WxCpApiPathConsts.Message.LINKEDCORP_MESSAGE_SEND), message.toJson()));
50+
.getApiUrl(Message.LINKEDCORP_MESSAGE_SEND), message.toJson()));
4251
}
4352
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package me.chanjar.weixin.cp.bean.message;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
6+
7+
import java.util.List;
8+
9+
/**
10+
* 应用消息发送统计信息.
11+
*
12+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
13+
* @date 2020-09-13
14+
*/
15+
@Data
16+
public class WxCpMessageSendStatistics {
17+
public static WxCpMessageSendStatistics fromJson(String json) {
18+
return WxCpGsonBuilder.create().fromJson(json, WxCpMessageSendStatistics.class);
19+
}
20+
21+
private List<StatisticItem> statistics;
22+
23+
@Data
24+
public static class StatisticItem {
25+
/**
26+
* 应用名
27+
*/
28+
@SerializedName("app_name")
29+
private String appName;
30+
31+
/**
32+
* 应用id
33+
*/
34+
@SerializedName("agentid")
35+
private Integer agentId;
36+
37+
/**
38+
* 发消息成功人次
39+
*/
40+
@SerializedName("count")
41+
private Integer count;
42+
}
43+
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public static class Message {
3636
*/
3737
public static final String MESSAGE_SEND = "/cgi-bin/message/send";
3838

39+
/**
40+
* 查询应用消息发送统计
41+
*/
42+
public static final String GET_STATISTICS = "/cgi-bin/message/get_statistics";
43+
3944
/**
4045
* 互联企业发送应用消息
4146
*/

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImplTest.java

+18-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
1313
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
1414
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
15+
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
1516
import org.testng.annotations.AfterTest;
1617
import org.testng.annotations.BeforeTest;
1718
import org.testng.annotations.Guice;
@@ -20,6 +21,7 @@
2021
import static com.github.dreamhead.moco.Moco.file;
2122
import static com.github.dreamhead.moco.MocoJsonRunner.jsonHttpServer;
2223
import static me.chanjar.weixin.cp.api.ApiTestModuleWithMockServer.mockServerPort;
24+
import static org.assertj.core.api.Assertions.assertThat;
2325
import static org.testng.Assert.assertNotNull;
2426

2527
/**
@@ -29,8 +31,8 @@
2931
* @date 2020-08-30
3032
*/
3133
@Test
32-
@Guice(modules = ApiTestModuleWithMockServer.class)
33-
//@Guice(modules = ApiTestModule.class)
34+
//@Guice(modules = ApiTestModuleWithMockServer.class)
35+
@Guice(modules = ApiTestModule.class)
3436
public class WxCpMessageServiceImplTest {
3537
@Inject
3638
protected WxCpService wxService;
@@ -154,11 +156,24 @@ public void testSendMessage_miniProgram_notice() throws WxErrorException {
154156
}
155157

156158
@Test
157-
public void testLinkedCorpMessageSend() throws WxErrorException {
159+
public void testSendLinkedCorpMessage() throws WxErrorException {
158160
this.wxService.getMessageService().sendLinkedCorpMessage(WxCpLinkedCorpMessage.builder()
159161
.msgType(WxConsts.KefuMsgType.TEXT)
160162
.toUsers(new String[]{configStorage.getUserId()})
161163
.content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>")
162164
.build());
163165
}
166+
167+
@Test
168+
public void testSend() {
169+
// see other test methods
170+
}
171+
172+
@Test
173+
public void testGetStatistics() throws WxErrorException {
174+
final WxCpMessageSendStatistics statistics = this.wxService.getMessageService().getStatistics(1);
175+
assertNotNull(statistics);
176+
assertThat(statistics.getStatistics()).isNotNull();
177+
}
178+
164179
}

weixin-java-miniapp/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.github.binarywang</groupId>
99
<artifactId>wx-java</artifactId>
10-
<version>3.9.1.B</version>
10+
<version>3.9.2.B</version>
1111
</parent>
1212

1313
<artifactId>weixin-java-miniapp</artifactId>

weixin-java-mp/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.github.binarywang</groupId>
99
<artifactId>wx-java</artifactId>
10-
<version>3.9.1.B</version>
10+
<version>3.9.2.B</version>
1111
</parent>
1212

1313
<artifactId>weixin-java-mp</artifactId>

weixin-java-open/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.github.binarywang</groupId>
99
<artifactId>wx-java</artifactId>
10-
<version>3.9.1.B</version>
10+
<version>3.9.2.B</version>
1111
</parent>
1212

1313
<artifactId>weixin-java-open</artifactId>

weixin-java-pay/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.github.binarywang</groupId>
77
<artifactId>wx-java</artifactId>
8-
<version>3.9.1.B</version>
8+
<version>3.9.2.B</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.github.binarywang.wxpay.bean.ecommerce;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.NoArgsConstructor;
6+
7+
/**
8+
* @author: f00lish
9+
* @date: 2020/09/12
10+
*/
11+
@Data
12+
@NoArgsConstructor
13+
public class FundBalanceResult {
14+
/**
15+
* <pre>
16+
* 字段名:二级商户号
17+
* 变量名:sub_mchid
18+
* 是否必填:是
19+
* 类型:string(32)
20+
* 描述:
21+
* 电商平台二级商户号,由微信支付生成并下发。
22+
* 示例值:1900000109
23+
* </pre>
24+
*/
25+
@SerializedName("sub_mchid")
26+
private String subMchid;
27+
28+
/**
29+
* <pre>
30+
* 字段名:可用余额
31+
* 变量名:available_amount
32+
* 是否必填:是
33+
* 类型:int64
34+
* 描述:
35+
* 可用余额(单位:分),此余额可做提现操作。
36+
* 示例值:100
37+
* </pre>
38+
*/
39+
@SerializedName("available_amount")
40+
private Integer availableAmount;
41+
42+
/**
43+
* <pre>
44+
* 字段名:不可用余额
45+
* 变量名:pending_amount
46+
* 是否必填:否
47+
* 类型:int64
48+
* 描述:
49+
* 不可用余额(单位:分)。
50+
* 示例值:100
51+
* </pre>
52+
*/
53+
@SerializedName("pending_amount")
54+
private Integer pendingAmount;
55+
56+
57+
}

0 commit comments

Comments
 (0)