mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-02-18 06:06:23 +08:00
#900 增加新增团购券、现金抵扣券、折扣券、兑换券以及普通优惠券的接口
This commit is contained in:
@@ -2,9 +2,7 @@ package me.chanjar.weixin.mp.api;
|
||||
|
||||
import me.chanjar.weixin.common.bean.WxCardApiSignature;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.bean.card.WxMpCardLandingPageCreateRequest;
|
||||
import me.chanjar.weixin.mp.bean.card.WxMpCardLandingPageCreateResult;
|
||||
import me.chanjar.weixin.mp.bean.card.WxMpCardQrcodeCreateResult;
|
||||
import me.chanjar.weixin.mp.bean.card.*;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
|
||||
|
||||
/**
|
||||
@@ -14,6 +12,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
|
||||
* @author yuanqixun 2018-08-29
|
||||
*/
|
||||
public interface WxMpCardService {
|
||||
String CARD_CREATE = "https://api.weixin.qq.com/card/create";
|
||||
String CARD_GET = "https://api.weixin.qq.com/card/get";
|
||||
String CARD_GET_TICKET = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=wx_card";
|
||||
String CARD_CODE_DECRYPT = "https://api.weixin.qq.com/card/code/decrypt";
|
||||
@@ -142,6 +141,14 @@ public interface WxMpCardService {
|
||||
*/
|
||||
String addTestWhiteList(String openid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cardCreateMessage
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 创建卡券二维码
|
||||
*
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import me.chanjar.weixin.mp.bean.card.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -22,9 +23,6 @@ import me.chanjar.weixin.common.util.crypto.SHA1;
|
||||
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
|
||||
import me.chanjar.weixin.mp.api.WxMpCardService;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.card.WxMpCardLandingPageCreateRequest;
|
||||
import me.chanjar.weixin.mp.bean.card.WxMpCardLandingPageCreateResult;
|
||||
import me.chanjar.weixin.mp.bean.card.WxMpCardQrcodeCreateResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
|
||||
import me.chanjar.weixin.mp.enums.TicketType;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
@@ -265,6 +263,13 @@ public class WxMpCardServiceImpl implements WxMpCardService {
|
||||
return respone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage) throws WxErrorException {
|
||||
|
||||
String response = this.wxMpService.post(CARD_CREATE, GSON.toJson(cardCreateMessage));
|
||||
return WxMpCardCreateResult.fromJson(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建卡券二维码.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public class Card implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3697110761983756780L;
|
||||
|
||||
/**
|
||||
* 基本信息.
|
||||
*/
|
||||
@SerializedName("base_info")
|
||||
private BaseInfo baseInfo;
|
||||
|
||||
/**
|
||||
* 创建优惠券特有的高级字段.
|
||||
*/
|
||||
@SerializedName("advanced_info")
|
||||
private AdvancedInfo advancedInfo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public class CardCreateRequest implements Serializable {
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public final class CashCard extends Card implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6965491956462769745L;
|
||||
|
||||
/**
|
||||
* 代金券专用,表示起用金额(单位为分),如果无起用门槛则填0
|
||||
*/
|
||||
@SerializedName("least_cost")
|
||||
private int leastCost;
|
||||
|
||||
/**
|
||||
* 代金券专用,表示减免金额。(单位为分)
|
||||
*/
|
||||
@SerializedName("reduce_cost")
|
||||
private int reduceCost;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static CashCard fromJson(String json) {
|
||||
return WxMpGsonBuilder.create().fromJson(json, CashCard.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public class CashCardCreateRequest extends CardCreateRequest implements Serializable {
|
||||
@SerializedName("card_type")
|
||||
private String cardType = "CASH";
|
||||
|
||||
private CashCard cash;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public final class DiscountCard extends Card implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1704610082472315077L;
|
||||
|
||||
/**
|
||||
* 折扣券专用,表示打折额度(百分比)。填30就是七折。
|
||||
*/
|
||||
private int discount;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static DiscountCard fromJson(String json) {
|
||||
return WxMpGsonBuilder.create().fromJson(json, DiscountCard.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public class DiscountCardCreateRequest extends CardCreateRequest implements Serializable {
|
||||
@SerializedName("card_type")
|
||||
private String cardType = "DISCOUNT";
|
||||
|
||||
private DiscountCard discount;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public final class GeneralCard extends Card implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1577656733441132585L;
|
||||
|
||||
/**
|
||||
* 兑换券专用,填写兑换内容的名称。
|
||||
*/
|
||||
@SerializedName("default_detail")
|
||||
private String defaultDetail;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static GeneralCard fromJson(String json) {
|
||||
return WxMpGsonBuilder.create().fromJson(json, GeneralCard.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public class GeneralCardCreateRequest extends CardCreateRequest implements Serializable {
|
||||
@SerializedName("card_type")
|
||||
private String cardType = "GENERAL_COUPON";
|
||||
|
||||
@SerializedName("general_coupon")
|
||||
private GeneralCard generalCoupon;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public final class GiftCard extends Card implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6168739707511792266L;
|
||||
|
||||
/**
|
||||
* 兑换券专用,填写兑换内容的名称。
|
||||
*/
|
||||
private String gift;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static GiftCard fromJson(String json) {
|
||||
return WxMpGsonBuilder.create().fromJson(json, GiftCard.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public class GiftCardCreateRequest extends CardCreateRequest implements Serializable {
|
||||
@SerializedName("card_type")
|
||||
private String cardType = "GIFT";
|
||||
|
||||
private GiftCard gift;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public final class GrouponCard extends Card implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3221312561666697005L;
|
||||
|
||||
/**
|
||||
* 团购券专用,团购详情
|
||||
*/
|
||||
@SerializedName("deal_detail")
|
||||
private String dealDetail;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static GrouponCard fromJson(String json) {
|
||||
return WxMpGsonBuilder.create().fromJson(json, GrouponCard.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author leeis
|
||||
* @Date 2018/12/29
|
||||
*/
|
||||
@Data
|
||||
public class GrouponCardCreateRequest extends CardCreateRequest implements Serializable {
|
||||
@SerializedName("card_type")
|
||||
private String cardType = "GROUPON";
|
||||
|
||||
private GrouponCard groupon;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package me.chanjar.weixin.mp.bean.card;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public final class WxMpCardCreateMessage implements Serializable {
|
||||
|
||||
@SerializedName("card")
|
||||
private CardCreateRequest cardCreateRequest;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WxMpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static WxMpCardCreateMessage fromJson(String json) {
|
||||
return WxMpGsonBuilder.create().fromJson(json, WxMpCardCreateMessage.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user