mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
新增卡券相关接口6个
1. getCardApiTicket获得卡券的api_ticket 2. createCardApiSignature创建调用卡券api时的签名 3. decryptCardCode卡券code解码 4. queryCardCode卡券code查询 5. consumeCardCode卡券核销 6. markCardCode卡券mark接口
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package me.chanjar.weixin.mp.util.json;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.mp.bean.WxMpCard;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by YuJian on 15/11/11.
|
||||
*
|
||||
* @author YuJian
|
||||
* @version 15/11/11
|
||||
*/
|
||||
public class WxMpCardGsonAdapter implements JsonDeserializer<WxMpCard> {
|
||||
|
||||
@Override
|
||||
public WxMpCard deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext
|
||||
jsonDeserializationContext) throws JsonParseException {
|
||||
WxMpCard card = new WxMpCard();
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
|
||||
card.setCardId(GsonHelper.getString(jsonObject, "card_id"));
|
||||
card.setBeginTime(GsonHelper.getLong(jsonObject, "begin_time"));
|
||||
card.setEndTime(GsonHelper.getLong(jsonObject, "end_time"));
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package me.chanjar.weixin.mp.util.json;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.mp.bean.WxMpCard;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by YuJian on 15/11/11.
|
||||
*
|
||||
* @author YuJian
|
||||
* @version 15/11/11
|
||||
*/
|
||||
public class WxMpCardResultGsonAdapter implements JsonDeserializer<WxMpCardResult> {
|
||||
@Override
|
||||
public WxMpCardResult deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
||||
WxMpCardResult cardResult = new WxMpCardResult();
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
|
||||
cardResult.setOpenId(GsonHelper.getString(jsonObject, "openid"));
|
||||
cardResult.setErrorCode(GsonHelper.getString(jsonObject, "errcode"));
|
||||
cardResult.setErrorMsg(GsonHelper.getString(jsonObject, "errmsg"));
|
||||
cardResult.setCanConsume(GsonHelper.getBoolean(jsonObject, "can_consume"));
|
||||
cardResult.setUserCardStatus(GsonHelper.getString(jsonObject, "user_card_status"));
|
||||
|
||||
WxMpCard card = WxMpGsonBuilder.INSTANCE.create().fromJson(jsonObject.get("card"),
|
||||
new TypeToken<WxMpCard>() {
|
||||
}.getType());
|
||||
|
||||
cardResult.setCard(card);
|
||||
|
||||
return cardResult;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,8 @@ public class WxMpGsonBuilder {
|
||||
INSTANCE.registerTypeAdapter(WxMpMaterialNewsBatchGetResult.WxMaterialNewsBatchGetNewsItem.class, new WxMpMaterialNewsBatchGetGsonItemAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpMaterialFileBatchGetResult.class, new WxMpMaterialFileBatchGetGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpMaterialFileBatchGetResult.WxMaterialFileBatchGetNewsItem.class, new WxMpMaterialFileBatchGetGsonItemAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpCardResult.class, new WxMpCardResultGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMpCard.class, new WxMpCardGsonAdapter());
|
||||
}
|
||||
|
||||
public static Gson create() {
|
||||
|
||||
Reference in New Issue
Block a user