mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
✨ #1188 增加获取会员卡开卡链接的接口
This commit is contained in:
parent
a19236b120
commit
a72cdde584
@ -93,6 +93,16 @@ public interface WxMpMemberCardService {
|
|||||||
*/
|
*/
|
||||||
ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException;
|
ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取开卡组件链接接口
|
||||||
|
*
|
||||||
|
* @param cardId 会员卡的CardId,微信分配
|
||||||
|
* @param outStr 会员卡设置商户的渠道
|
||||||
|
* @return 会员卡开卡插件参数结果对象
|
||||||
|
* @throws WxErrorException 接口调用失败抛出的异常
|
||||||
|
*/
|
||||||
|
String getActivatePluginUrl(String cardId, String outStr) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新会员卡信息.
|
* 更新会员卡信息.
|
||||||
*
|
*
|
||||||
|
@ -248,26 +248,30 @@ public class WxMpMemberCardServiceImpl implements WxMpMemberCardService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException {
|
public ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException {
|
||||||
|
String url = this.getActivatePluginUrl(cardId, outStr);
|
||||||
|
try {
|
||||||
|
String decodedUrl = URLDecoder.decode(url, "UTF-8");
|
||||||
|
Map<String, String> resultMap = parseRequestUrl(decodedUrl);
|
||||||
|
ActivatePluginParam activatePluginParam = new ActivatePluginParam();
|
||||||
|
activatePluginParam.setEncryptCardId(resultMap.get("encrypt_card_id"));
|
||||||
|
activatePluginParam.setOuterStr(resultMap.get("outer_str"));
|
||||||
|
activatePluginParam.setBiz(resultMap.get("biz") + "==");
|
||||||
|
return activatePluginParam;
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getActivatePluginUrl(String cardId, String outStr) throws WxErrorException {
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
params.addProperty("card_id", cardId);
|
params.addProperty("card_id", cardId);
|
||||||
params.addProperty("outer_str", outStr);
|
params.addProperty("outer_str", outStr);
|
||||||
String response = this.wxMpService.post(WxMpApiUrl.MemberCard.MEMBER_CARD_ACTIVATE_URL, GSON.toJson(params));
|
String response = this.wxMpService.post(WxMpApiUrl.MemberCard.MEMBER_CARD_ACTIVATE_URL, GSON.toJson(params));
|
||||||
ActivatePluginParamResult result = GSON.fromJson(response, ActivatePluginParamResult.class);
|
ActivatePluginParamResult result = GSON.fromJson(response, ActivatePluginParamResult.class);
|
||||||
if (0 == result.getErrcode()) {
|
return result.getUrl();
|
||||||
String url = result.getUrl();
|
|
||||||
try {
|
|
||||||
String decodedUrl = URLDecoder.decode(url, "UTF-8");
|
|
||||||
Map<String, String> resultMap = parseRequestUrl(decodedUrl);
|
|
||||||
ActivatePluginParam activatePluginParam = new ActivatePluginParam();
|
|
||||||
activatePluginParam.setEncryptCardId(resultMap.get("encrypt_card_id"));
|
|
||||||
activatePluginParam.setOuterStr(resultMap.get("outer_str"));
|
|
||||||
activatePluginParam.setBiz(resultMap.get("biz") + "==");
|
|
||||||
return activatePluginParam;
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user