Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #3

Merged
merged 4 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
<packaging>pom</packaging>
<name>WxJava - Weixin/Wechat Java SDK</name>
<description>微信开发Java SDK</description>
Expand Down
2 changes: 1 addition & 1 deletion spring-boot-starters/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>
<packaging>pom</packaging>
<artifactId>wx-java-spring-boot-starters</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion weixin-graal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>

<artifactId>weixin-graal</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion weixin-java-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>

<artifactId>weixin-java-common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion weixin-java-cp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>

<artifactId>weixin-java-cp</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;

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

/**
* <pre>
* 查询应用消息发送统计
* 请求方式:POST(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/message/get_statistics?access_token=ACCESS_TOKEN
*
* 详情请见: https://work.weixin.qq.com/api/doc/90000/90135/92369
* </pre>
*
* @param timeType 查询哪天的数据,0:当天;1:昨天。默认为0。
* @return 统计结果
* @throws WxErrorException the wx error exception
*/
WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException;

/**
* <pre>
* 互联企业的应用支持推送文本、图片、视频、文件、图文等类型。
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package me.chanjar.weixin.cp.api.impl;

import com.google.common.collect.ImmutableMap;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpMessageService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Message;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

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

return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
.getApiUrl(WxCpApiPathConsts.Message.MESSAGE_SEND), message.toJson()));
.getApiUrl(Message.MESSAGE_SEND), message.toJson()));
}

@Override
public WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorException {
return WxCpMessageSendStatistics.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage().getApiUrl(Message.GET_STATISTICS),
WxCpGsonBuilder.create().toJson(ImmutableMap.of("time_type", timeType))));
}

@Override
Expand All @@ -38,6 +47,6 @@ public WxCpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message
}

return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
.getApiUrl(WxCpApiPathConsts.Message.LINKEDCORP_MESSAGE_SEND), message.toJson()));
.getApiUrl(Message.LINKEDCORP_MESSAGE_SEND), message.toJson()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package me.chanjar.weixin.cp.bean.message;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.util.List;

/**
* 应用消息发送统计信息.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* @date 2020-09-13
*/
@Data
public class WxCpMessageSendStatistics {
public static WxCpMessageSendStatistics fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpMessageSendStatistics.class);
}

private List<StatisticItem> statistics;

@Data
public static class StatisticItem {
/**
* 应用名
*/
@SerializedName("app_name")
private String appName;

/**
* 应用id
*/
@SerializedName("agentid")
private Integer agentId;

/**
* 发消息成功人次
*/
@SerializedName("count")
private Integer count;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public static class Message {
*/
public static final String MESSAGE_SEND = "/cgi-bin/message/send";

/**
* 查询应用消息发送统计
*/
public static final String GET_STATISTICS = "/cgi-bin/message/get_statistics";

/**
* 互联企业发送应用消息
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Guice;
Expand All @@ -20,6 +21,7 @@
import static com.github.dreamhead.moco.Moco.file;
import static com.github.dreamhead.moco.MocoJsonRunner.jsonHttpServer;
import static me.chanjar.weixin.cp.api.ApiTestModuleWithMockServer.mockServerPort;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertNotNull;

/**
Expand All @@ -29,8 +31,8 @@
* @date 2020-08-30
*/
@Test
@Guice(modules = ApiTestModuleWithMockServer.class)
//@Guice(modules = ApiTestModule.class)
//@Guice(modules = ApiTestModuleWithMockServer.class)
@Guice(modules = ApiTestModule.class)
public class WxCpMessageServiceImplTest {
@Inject
protected WxCpService wxService;
Expand Down Expand Up @@ -154,11 +156,24 @@ public void testSendMessage_miniProgram_notice() throws WxErrorException {
}

@Test
public void testLinkedCorpMessageSend() throws WxErrorException {
public void testSendLinkedCorpMessage() throws WxErrorException {
this.wxService.getMessageService().sendLinkedCorpMessage(WxCpLinkedCorpMessage.builder()
.msgType(WxConsts.KefuMsgType.TEXT)
.toUsers(new String[]{configStorage.getUserId()})
.content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>")
.build());
}

@Test
public void testSend() {
// see other test methods
}

@Test
public void testGetStatistics() throws WxErrorException {
final WxCpMessageSendStatistics statistics = this.wxService.getMessageService().getStatistics(1);
assertNotNull(statistics);
assertThat(statistics.getStatistics()).isNotNull();
}

}
2 changes: 1 addition & 1 deletion weixin-java-miniapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>

<artifactId>weixin-java-miniapp</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion weixin-java-mp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>

<artifactId>weixin-java-mp</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion weixin-java-open/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>

<artifactId>weixin-java-open</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion weixin-java-pay/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.9.1.B</version>
<version>3.9.2.B</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.github.binarywang.wxpay.bean.ecommerce;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* @author: f00lish
* @date: 2020/09/12
*/
@Data
@NoArgsConstructor
public class FundBalanceResult {
/**
* <pre>
* 字段名:二级商户号
* 变量名:sub_mchid
* 是否必填:是
* 类型:string(32)
* 描述:
* 电商平台二级商户号,由微信支付生成并下发。
* 示例值:1900000109
* </pre>
*/
@SerializedName("sub_mchid")
private String subMchid;

/**
* <pre>
* 字段名:可用余额
* 变量名:available_amount
* 是否必填:是
* 类型:int64
* 描述:
* 可用余额(单位:分),此余额可做提现操作。
* 示例值:100
* </pre>
*/
@SerializedName("available_amount")
private Integer availableAmount;

/**
* <pre>
* 字段名:不可用余额
* 变量名:pending_amount
* 是否必填:否
* 类型:int64
* 描述:
* 不可用余额(单位:分)。
* 示例值:100
* </pre>
*/
@SerializedName("pending_amount")
private Integer pendingAmount;


}
Loading