mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-02-17 05:48:12 +08:00
1、增加卡券的api_ticket,区分jsapi_ticket,二者的获取逻辑不同;
2、增加小程序审核事件及审核事件推送消息SuccTime和Reason两个字段; 3、增加开放平台获取会员卡开卡插件参数接口。 4、增加开放平台手机端预授权接口实现;
This commit is contained in:
@@ -24,6 +24,11 @@ public interface WxMpMemberCardService {
|
||||
*/
|
||||
String MEMBER_CARD_ACTIVATEUSERFORM = "https://api.weixin.qq.com/card/membercard/activateuserform/set";
|
||||
|
||||
/**
|
||||
* 获取会员卡开卡插件参数
|
||||
*/
|
||||
String MEMBER_CARD_ACTIVATE_URL = "https://api.weixin.qq.com/card/membercard/activate/geturl";
|
||||
|
||||
/**
|
||||
* 得到WxMpService
|
||||
*/
|
||||
@@ -88,4 +93,13 @@ public interface WxMpMemberCardService {
|
||||
*/
|
||||
MemberCardActivateUserFormResult setActivateUserForm(MemberCardActivateUserFormRequest userFormRequest) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取会员卡开卡插件参数(跳转型开卡组件需要参数)
|
||||
*
|
||||
* @param cardId
|
||||
* @param outStr
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 会员卡相关接口的实现类
|
||||
*
|
||||
@@ -237,7 +242,7 @@ public class WxMpMemberCardServiceImpl implements WxMpMemberCardService {
|
||||
jsonObject.addProperty("code", code);
|
||||
|
||||
String responseContent = this.getWxMpService().post(MEMBER_CARD_USER_INFO_GET, jsonObject.toString());
|
||||
log.debug("{}",responseContent);
|
||||
log.debug("{}", responseContent);
|
||||
JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
|
||||
return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement,
|
||||
new TypeToken<WxMpMemberCardUserInfoResult>() {
|
||||
@@ -280,4 +285,91 @@ public class WxMpMemberCardServiceImpl implements WxMpMemberCardService {
|
||||
return MemberCardActivateUserFormResult.fromJson(responseContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员卡开卡插件参数(跳转型开卡组件需要参数)
|
||||
*
|
||||
* @param outStr
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
public ActivatePluginParam getActivatePluginParam(String cardId, String outStr) throws WxErrorException {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("card_id", cardId);
|
||||
params.addProperty("outer_str", outStr);
|
||||
String response = this.wxMpService.post(MEMBER_CARD_ACTIVATE_URL, GSON.toJson(params));
|
||||
ActivatePluginParamResult result = GSON.fromJson(response, ActivatePluginParamResult.class);
|
||||
if (0 == result.getErrcode()) {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 去掉url中的路径,留下请求参数部分
|
||||
*
|
||||
* @param strURL url地址
|
||||
* @return url请求参数部分
|
||||
*/
|
||||
private static String truncateUrlPage(String strURL) {
|
||||
String strAllParam = null;
|
||||
String[] arrSplit = null;
|
||||
arrSplit = strURL.split("[?]");
|
||||
if (strURL.length() > 1) {
|
||||
if (arrSplit.length > 1) {
|
||||
if (arrSplit[1] != null) {
|
||||
strAllParam = arrSplit[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return strAllParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析出url参数中的键值对
|
||||
* 如 "index.jsp?Action=del&id=123",解析出Action:del,id:123存入map中
|
||||
*
|
||||
* @param URL url地址
|
||||
* @return url请求参数部分
|
||||
*/
|
||||
public static Map<String, String> parseRequestUrl(String URL) {
|
||||
Map<String, String> mapRequest = new HashMap<String, String>();
|
||||
|
||||
String[] arrSplit = null;
|
||||
|
||||
String strUrlParam = truncateUrlPage(URL);
|
||||
if (strUrlParam == null) {
|
||||
return mapRequest;
|
||||
}
|
||||
arrSplit = strUrlParam.split("[&]");
|
||||
for (String strSplit : arrSplit) {
|
||||
String[] arrSplitEqual = null;
|
||||
arrSplitEqual = strSplit.split("[=]");
|
||||
|
||||
//解析出键值
|
||||
if (arrSplitEqual.length > 1) {
|
||||
//正确解析
|
||||
mapRequest.put(arrSplitEqual[0], arrSplitEqual[1]);
|
||||
|
||||
} else {
|
||||
if (arrSplitEqual[0] != "") {
|
||||
//只有参数没有值,不加入
|
||||
mapRequest.put(arrSplitEqual[0], "");
|
||||
}
|
||||
}
|
||||
}
|
||||
return mapRequest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.chanjar.weixin.mp.bean.membercard;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yqx
|
||||
* @date 2018/9/19
|
||||
*/
|
||||
@Data
|
||||
public class ActivatePluginParam {
|
||||
|
||||
@SerializedName("encrypt_card_id")
|
||||
String encryptCardId;
|
||||
|
||||
@SerializedName("outer_str")
|
||||
String outerStr;
|
||||
|
||||
@SerializedName("biz")
|
||||
String biz;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package me.chanjar.weixin.mp.bean.membercard;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yqx
|
||||
* @date 2018/9/19
|
||||
*/
|
||||
@Data
|
||||
public class ActivatePluginParamResult {
|
||||
|
||||
private int errcode;
|
||||
|
||||
private String errmsg;
|
||||
|
||||
private String url;
|
||||
|
||||
}
|
||||
@@ -541,6 +541,21 @@ public class WxMpXmlMessage implements Serializable {
|
||||
@XStreamAlias("DeviceStatus")
|
||||
private Integer deviceStatus;
|
||||
|
||||
///////////////////////////////////////
|
||||
// 小程序 审核事件
|
||||
///////////////////////////////////////
|
||||
/**
|
||||
* 审核成功时的时间(整形),时间戳
|
||||
*/
|
||||
@XStreamAlias("SuccTime")
|
||||
private Long succTime;
|
||||
|
||||
/**
|
||||
* 审核失败的原因
|
||||
*/
|
||||
@XStreamAlias("Reason")
|
||||
private String reason;
|
||||
|
||||
public static WxMpXmlMessage fromXml(String xml) {
|
||||
//修改微信变态的消息内容格式,方便解析
|
||||
xml = xml.replace("</PicList><PicList>", "");
|
||||
|
||||
Reference in New Issue
Block a user