Skip to content

Commit fd508b2

Browse files
committed
Merge branch 'develop' of github.com:Wechat-Group/weixin-java-tools into develop
* 'develop' of github.com:Wechat-Group/weixin-java-tools: 发布临时测试版本2.7.6.BETA binarywang#178 实现查询代金券批次和信息的接口 增加会员卡管理服务的`更新会员信息`接口的实现 (binarywang#283) binarywang#281 消息路由器增加对EventKey正则表达式匹配的支持 binarywang#178 实现发送代金券接口 新增会员卡相关接口 (binarywang#280) binarywang#279 统一下单接口参数对象WxPayUnifiedOrderRequest增加fingerprint属性 update travis settings
2 parents a956dbd + 66c7ae3 commit fd508b2

38 files changed

Lines changed: 2983 additions & 86 deletions

.travis.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
language: java
2-
sudo: false
3-
install: true
4-
addons:
5-
sonarcloud:
6-
token:
7-
secure: "834110c7191f97ecb226970c46dcaff8e681da5a"
2+
#sudo: false
3+
#install: true
4+
#addons:
5+
# sonarcloud:
6+
# token:
7+
# secure: "834110c7191f97ecb226970c46dcaff8e681da5a"
88

99
jdk:
1010
- oraclejdk8
11-
#script: "mvn clean package -Dmaven.test.skip=true"
11+
script: "mvn clean package -Dmaven.test.skip=true"
1212

13-
script:
14-
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar
13+
#script:
14+
# - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar
1515

1616
branches:
1717
only:
@@ -20,7 +20,7 @@ branches:
2020
cache:
2121
directories:
2222
- '$HOME/.m2/repository'
23-
- '$HOME/.sonar/cache'
23+
# - '$HOME/.sonar/cache'
2424

2525
notifications:
2626
email:

pom.xml

Lines changed: 1 addition & 1 deletion
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>weixin-java-parent</artifactId>
9-
<version>2.7.5.BETA</version>
9+
<version>2.7.6.BETA</version>
1010
<packaging>pom</packaging>
1111
<name>WeiXin Java Tools - Parent</name>
1212
<description>微信公众号、企业号上级POM</description>

weixin-java-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.github.binarywang</groupId>
99
<artifactId>weixin-java-parent</artifactId>
10-
<version>2.7.5.BETA</version>
10+
<version>2.7.6.BETA</version>
1111
</parent>
1212

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

weixin-java-cp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.github.binarywang</groupId>
99
<artifactId>weixin-java-parent</artifactId>
10-
<version>2.7.5.BETA</version>
10+
<version>2.7.6.BETA</version>
1111
</parent>
1212

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

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/message/WxCpMessageRouterRule.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import me.chanjar.weixin.cp.api.WxCpService;
77
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
88
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;
9+
import org.apache.commons.lang3.StringUtils;
910

1011
import java.util.ArrayList;
1112
import java.util.HashMap;
@@ -27,6 +28,8 @@ public class WxCpMessageRouterRule {
2728

2829
private String eventKey;
2930

31+
private String eventKeyRegex;
32+
3033
private String content;
3134

3235
private String rContent;
@@ -95,6 +98,14 @@ public WxCpMessageRouterRule eventKey(String eventKey) {
9598
return this;
9699
}
97100

101+
/**
102+
* 如果eventKey匹配该正则表达式
103+
*/
104+
public WxCpMessageRouterRule eventKeyRegex(String regex) {
105+
this.eventKeyRegex = regex;
106+
return this;
107+
}
108+
98109
/**
99110
* 如果content等于某值
100111
*
@@ -207,17 +218,17 @@ protected boolean test(WxCpXmlMessage wxMessage) {
207218
&&
208219
(this.agentId == null || this.agentId.equals(wxMessage.getAgentId()))
209220
&&
210-
(this.msgType == null || this.msgType.equals(wxMessage.getMsgType()))
221+
(this.msgType == null || this.msgType.equalsIgnoreCase(wxMessage.getMsgType()))
222+
&&
223+
(this.event == null || this.event.equalsIgnoreCase(wxMessage.getEvent()))
211224
&&
212-
(this.event == null || this.event.equals(wxMessage.getEvent()))
225+
(this.eventKey == null || this.eventKey.equalsIgnoreCase(wxMessage.getEventKey()))
213226
&&
214-
(this.eventKey == null || this.eventKey.equals(wxMessage.getEventKey()))
227+
(this.eventKeyRegex == null || Pattern.matches(this.eventKeyRegex, StringUtils.trimToEmpty(wxMessage.getEventKey())))
215228
&&
216-
(this.content == null || this.content
217-
.equals(wxMessage.getContent() == null ? null : wxMessage.getContent().trim()))
229+
(this.content == null || this.content.equals(StringUtils.trimToNull(wxMessage.getContent())))
218230
&&
219-
(this.rContent == null || Pattern
220-
.matches(this.rContent, wxMessage.getContent() == null ? "" : wxMessage.getContent().trim()))
231+
(this.rContent == null || Pattern.matches(this.rContent, StringUtils.trimToEmpty(wxMessage.getContent())))
221232
&&
222233
(this.matcher == null || this.matcher.match(wxMessage))
223234
;

weixin-java-miniapp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.github.binarywang</groupId>
99
<artifactId>weixin-java-parent</artifactId>
10-
<version>2.7.5.BETA</version>
10+
<version>2.7.6.BETA</version>
1111
</parent>
1212
<artifactId>weixin-java-miniapp</artifactId>
1313
<name>WeiXin Java Tools - MiniApp</name>

weixin-java-mp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.github.binarywang</groupId>
99
<artifactId>weixin-java-parent</artifactId>
10-
<version>2.7.5.BETA</version>
10+
<version>2.7.6.BETA</version>
1111
</parent>
1212
<artifactId>weixin-java-mp</artifactId>
1313
<name>WeiXin Java Tools - MP</name>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package me.chanjar.weixin.mp.api;
2+
3+
import me.chanjar.weixin.common.exception.WxErrorException;
4+
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardActivatedMessage;
5+
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateMessage;
6+
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateResult;
7+
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult;
8+
9+
/**
10+
* 会员卡相关接口
11+
*
12+
* @author YuJian(mgcnrx11@gmail.com)
13+
* @version 2017/7/8
14+
*/
15+
public interface WxMpMemberCardService {
16+
17+
/**
18+
* 得到WxMpService
19+
*/
20+
WxMpService getWxMpService();
21+
22+
/**
23+
* 会员卡激活接口
24+
*
25+
* @param activatedMessage 激活所需参数
26+
* @return 调用返回的JSON字符串。
27+
* @throws WxErrorException 接口调用失败抛出的异常
28+
*/
29+
String activateMemberCard(WxMpMemberCardActivatedMessage activatedMessage) throws WxErrorException;
30+
31+
/**
32+
* 拉取会员信息接口
33+
*
34+
* @param cardId 会员卡的CardId,微信分配
35+
* @param code 领取会员的会员卡Code
36+
* @return 会员信息的结果对象
37+
* @throws WxErrorException 接口调用失败抛出的异常
38+
*/
39+
WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code) throws WxErrorException;
40+
41+
/**
42+
* 当会员持卡消费后,支持开发者调用该接口更新会员信息。会员卡交易后的每次信息变更需通过该接口通知微信,便于后续消息通知及其他扩展功能。
43+
*
44+
* 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。同时传入add_bonus和bonus时
45+
* add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。
46+
* 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。
47+
*
48+
* @param updateUserMessage 更新会员信息所需字段消息
49+
* @return 调用返回的JSON字符串。
50+
* @throws WxErrorException 接口调用失败抛出的异常
51+
*/
52+
WxMpMemberCardUpdateResult updateUserMemberCard(WxMpMemberCardUpdateMessage updateUserMessage) throws WxErrorException;
53+
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouterRule.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import me.chanjar.weixin.common.session.WxSessionManager;
66
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
77
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
8+
import org.apache.commons.lang3.StringUtils;
89

910
import java.util.ArrayList;
1011
import java.util.HashMap;
@@ -26,6 +27,8 @@ public class WxMpMessageRouterRule {
2627

2728
private String eventKey;
2829

30+
private String eventKeyRegex;
31+
2932
private String content;
3033

3134
private String rContent;
@@ -74,6 +77,14 @@ public WxMpMessageRouterRule eventKey(String eventKey) {
7477
return this;
7578
}
7679

80+
/**
81+
* 如果eventKey匹配该正则表达式
82+
*/
83+
public WxMpMessageRouterRule eventKeyRegex(String regex) {
84+
this.eventKeyRegex = regex;
85+
return this;
86+
}
87+
7788
/**
7889
* 如果content等于某值
7990
*/
@@ -170,17 +181,17 @@ protected boolean test(WxMpXmlMessage wxMessage) {
170181
return
171182
(this.fromUser == null || this.fromUser.equals(wxMessage.getFromUser()))
172183
&&
173-
(this.msgType == null || this.msgType.toLowerCase().equals((wxMessage.getMsgType() == null ? null : wxMessage.getMsgType().toLowerCase())))
184+
(this.msgType == null || this.msgType.equalsIgnoreCase(wxMessage.getMsgType()))
185+
&&
186+
(this.event == null || this.event.equalsIgnoreCase(wxMessage.getEvent()))
174187
&&
175-
(this.event == null || this.event.toLowerCase().equals((wxMessage.getEvent() == null ? null : wxMessage.getEvent().toLowerCase())))
188+
(this.eventKey == null || this.eventKey.equalsIgnoreCase(wxMessage.getEventKey()))
176189
&&
177-
(this.eventKey == null || this.eventKey.toLowerCase().equals((wxMessage.getEventKey() == null ? null : wxMessage.getEventKey().toLowerCase())))
190+
(this.eventKeyRegex == null || Pattern.matches(this.eventKeyRegex, StringUtils.trimToEmpty(wxMessage.getEventKey())))
178191
&&
179-
(this.content == null || this.content
180-
.equals(wxMessage.getContent() == null ? null : wxMessage.getContent().trim()))
192+
(this.content == null || this.content.equals(StringUtils.trimToNull(wxMessage.getContent())))
181193
&&
182-
(this.rContent == null || Pattern
183-
.matches(this.rContent, wxMessage.getContent() == null ? "" : wxMessage.getContent().trim()))
194+
(this.rContent == null || Pattern.matches(this.rContent, StringUtils.trimToEmpty(wxMessage.getContent())))
184195
&&
185196
(this.matcher == null || this.matcher.match(wxMessage))
186197
;

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,13 @@ public interface WxMpService {
434434
*/
435435
WxMpShakeService getShakeService();
436436

437+
/**
438+
* 返回会员卡相关接口方法的实现类对象,以方便调用其各个接口
439+
*
440+
* @return WxMpMemberCardService
441+
*/
442+
WxMpMemberCardService getMemberCardService();
443+
437444
/**
438445
* 初始化http请求对象
439446
*/

0 commit comments

Comments
 (0)