🆕 #1328 微信卡劵增加用户已领取卡券列表接口

* 微信公众号,功能新增,微信卡券
添加用户已领取卡券接口

* 添加用户已领取卡券接口测试代码
This commit is contained in:
yang229
2019-12-22 16:06:36 +08:00
committed by Binary Wang
parent 8c514a7850
commit 5761226887
6 changed files with 107 additions and 0 deletions

View File

@@ -283,4 +283,15 @@ public interface WxMpCardService {
void cardSelfConsumeCellSet(String cardId, Boolean isOpen,
Boolean needVerifyCod, Boolean needRemarkAmount) throws WxErrorException;
/**
* 获取用户已领取卡券接口
* https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Managing_Coupons_Vouchers_and_Cards.html#1
*
* @param openId 需要查询的用户openid
* @param cardId 卡券ID。不填写时默认查询当前appid下的卡券
* @return
* @throws WxErrorException
*/
WxUserCardListResult getUserCardList(String openId, String cardId) throws WxErrorException;
}

View File

@@ -351,6 +351,16 @@ public class WxMpCardServiceImpl implements WxMpCardService {
}
@Override
public WxUserCardListResult getUserCardList(String openId, String cardId) throws WxErrorException {
JsonObject param = new JsonObject();
param.addProperty("openid", openId);
param.addProperty("card_id", cardId);
String response = this.wxMpService.post(WxMpApiUrl.Card.CARD_USER_CARD_LIST, param.toString());
return WxUserCardListResult.fromJson(response);
}
private void checkCardId(String cardId) throws WxErrorException {
if (StringUtils.isEmpty(cardId)) {
throw new WxErrorException(WxError.builder().errorCode(41012).errorMsg("cardId不能为空").build());