forked from binarywang/WxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:Wechat-Group/weixin-java-tools i…
…nto 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
- Loading branch information
Showing
38 changed files
with
2,983 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMemberCardService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package me.chanjar.weixin.mp.api; | ||
|
||
import me.chanjar.weixin.common.exception.WxErrorException; | ||
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardActivatedMessage; | ||
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateMessage; | ||
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateResult; | ||
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult; | ||
|
||
/** | ||
* 会员卡相关接口 | ||
* | ||
* @author YuJian([email protected]) | ||
* @version 2017/7/8 | ||
*/ | ||
public interface WxMpMemberCardService { | ||
|
||
/** | ||
* 得到WxMpService | ||
*/ | ||
WxMpService getWxMpService(); | ||
|
||
/** | ||
* 会员卡激活接口 | ||
* | ||
* @param activatedMessage 激活所需参数 | ||
* @return 调用返回的JSON字符串。 | ||
* @throws WxErrorException 接口调用失败抛出的异常 | ||
*/ | ||
String activateMemberCard(WxMpMemberCardActivatedMessage activatedMessage) throws WxErrorException; | ||
|
||
/** | ||
* 拉取会员信息接口 | ||
* | ||
* @param cardId 会员卡的CardId,微信分配 | ||
* @param code 领取会员的会员卡Code | ||
* @return 会员信息的结果对象 | ||
* @throws WxErrorException 接口调用失败抛出的异常 | ||
*/ | ||
WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code) throws WxErrorException; | ||
|
||
/** | ||
* 当会员持卡消费后,支持开发者调用该接口更新会员信息。会员卡交易后的每次信息变更需通过该接口通知微信,便于后续消息通知及其他扩展功能。 | ||
* | ||
* 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。同时传入add_bonus和bonus时 | ||
* add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。 | ||
* 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。 | ||
* | ||
* @param updateUserMessage 更新会员信息所需字段消息 | ||
* @return 调用返回的JSON字符串。 | ||
* @throws WxErrorException 接口调用失败抛出的异常 | ||
*/ | ||
WxMpMemberCardUpdateResult updateUserMemberCard(WxMpMemberCardUpdateMessage updateUserMessage) throws WxErrorException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpMemberCardServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package me.chanjar.weixin.mp.api.impl; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParser; | ||
import com.google.gson.reflect.TypeToken; | ||
import me.chanjar.weixin.common.exception.WxErrorException; | ||
import me.chanjar.weixin.mp.api.WxMpMemberCardService; | ||
import me.chanjar.weixin.mp.api.WxMpService; | ||
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardActivatedMessage; | ||
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateMessage; | ||
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUpdateResult; | ||
import me.chanjar.weixin.mp.bean.membercard.WxMpMemberCardUserInfoResult; | ||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* 会员卡相关接口的实现类 | ||
* | ||
* @author YuJian([email protected]) | ||
* @version 2017/7/8 | ||
*/ | ||
public class WxMpMemberCardServiceImpl implements WxMpMemberCardService { | ||
|
||
private final Logger log = LoggerFactory.getLogger(WxMpMemberCardServiceImpl.class); | ||
|
||
private static final String MEMBER_CARD_ACTIVATE = "https://api.weixin.qq.com/card/membercard/activate"; | ||
private static final String MEMBER_CARD_USER_INFO_GET = "https://api.weixin.qq.com/card/membercard/userinfo/get"; | ||
private static final String MEMBER_CARD_UPDATE_USER = "https://api.weixin.qq.com/card/membercard/updateuser"; | ||
|
||
private WxMpService wxMpService; | ||
|
||
private static final Gson GSON = new Gson(); | ||
|
||
WxMpMemberCardServiceImpl(WxMpService wxMpService) { | ||
this.wxMpService = wxMpService; | ||
} | ||
|
||
/** | ||
* 得到WxMpService | ||
*/ | ||
@Override | ||
public WxMpService getWxMpService() { | ||
return this.wxMpService; | ||
} | ||
|
||
/** | ||
* 会员卡激活接口 | ||
* | ||
* @param activatedMessage 激活所需参数 | ||
* @return 调用返回的JSON字符串。 | ||
* @throws WxErrorException 接口调用失败抛出的异常 | ||
*/ | ||
@Override | ||
public String activateMemberCard(WxMpMemberCardActivatedMessage activatedMessage) throws WxErrorException { | ||
return this.wxMpService.post(MEMBER_CARD_ACTIVATE, GSON.toJson(activatedMessage)); | ||
} | ||
|
||
/** | ||
* 拉取会员信息接口 | ||
* | ||
* @param cardId 会员卡的CardId,微信分配 | ||
* @param code 领取会员的会员卡Code | ||
* @return 会员信息的结果对象 | ||
* @throws WxErrorException 接口调用失败抛出的异常 | ||
*/ | ||
@Override | ||
public WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code) throws WxErrorException { | ||
JsonObject jsonObject = new JsonObject(); | ||
jsonObject.addProperty("card_id", cardId); | ||
jsonObject.addProperty("code",code); | ||
|
||
String responseContent = this.getWxMpService().post(MEMBER_CARD_USER_INFO_GET, jsonObject.toString()); | ||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||
return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement, | ||
new TypeToken<WxMpMemberCardUserInfoResult>() { | ||
}.getType()); | ||
} | ||
|
||
/** | ||
* 当会员持卡消费后,支持开发者调用该接口更新会员信息。会员卡交易后的每次信息变更需通过该接口通知微信,便于后续消息通知及其他扩展功能。 | ||
* | ||
* 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。同时传入add_bonus和bonus时 | ||
* add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。 | ||
* 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。 | ||
* | ||
* @param updateUserMessage 更新会员信息所需字段消息 | ||
* @return 调用返回的JSON字符串。 | ||
* @throws WxErrorException 接口调用失败抛出的异常 | ||
*/ | ||
@Override | ||
public WxMpMemberCardUpdateResult updateUserMemberCard(WxMpMemberCardUpdateMessage updateUserMessage) | ||
throws WxErrorException { | ||
|
||
String responseContent = this.getWxMpService().post(MEMBER_CARD_UPDATE_USER, GSON.toJson(updateUserMessage)); | ||
|
||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent); | ||
return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement, | ||
new TypeToken<WxMpMemberCardUpdateResult>() { | ||
}.getType()); | ||
} | ||
} |
Oops, something went wrong.