* 1、增加卡券失效接口;修复会员卡是否支持微信支付和会员卡二维码的属性问题;master
@@ -10,7 +10,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpCardResult; | |||||
/** | /** | ||||
* 卡券相关接口 | * 卡券相关接口 | ||||
* | * | ||||
* @author YuJian(mgcnrx11@hotmail.com) on 01/11/2016 | |||||
* @author YuJian(mgcnrx11 @ hotmail.com) on 01/11/2016 | |||||
* @author yuanqixun 2018-08-29 | * @author yuanqixun 2018-08-29 | ||||
*/ | */ | ||||
public interface WxMpCardService { | public interface WxMpCardService { | ||||
@@ -23,6 +23,10 @@ public interface WxMpCardService { | |||||
String CARD_TEST_WHITELIST = "https://api.weixin.qq.com/card/testwhitelist/set"; | String CARD_TEST_WHITELIST = "https://api.weixin.qq.com/card/testwhitelist/set"; | ||||
String CARD_QRCODE_CREAET = "https://api.weixin.qq.com/card/qrcode/create"; | String CARD_QRCODE_CREAET = "https://api.weixin.qq.com/card/qrcode/create"; | ||||
String CARD_LANDING_PAGE_CREAET = "https://api.weixin.qq.com/card/landingpage/create"; | String CARD_LANDING_PAGE_CREAET = "https://api.weixin.qq.com/card/landingpage/create"; | ||||
/** | |||||
* 将用户的卡券设置为失效状态 | |||||
*/ | |||||
String CARD_CODE_UNAVAILABLE = "https://api.weixin.qq.com/card/code/unavailable"; | |||||
/** | /** | ||||
* 得到WxMpService | * 得到WxMpService | ||||
@@ -132,6 +136,7 @@ public interface WxMpCardService { | |||||
/** | /** | ||||
* 添加测试白名单 | * 添加测试白名单 | ||||
* | |||||
* @param openid 用户的openid | * @param openid 用户的openid | ||||
* @return | * @return | ||||
*/ | */ | ||||
@@ -139,7 +144,8 @@ public interface WxMpCardService { | |||||
/** | /** | ||||
* 创建卡券二维码 | * 创建卡券二维码 | ||||
* @param cardId 卡券编号 | |||||
* | |||||
* @param cardId 卡券编号 | |||||
* @param outerStr 二维码标识 | * @param outerStr 二维码标识 | ||||
* @return WxMpCardQrcodeCreateResult | * @return WxMpCardQrcodeCreateResult | ||||
*/ | */ | ||||
@@ -147,18 +153,33 @@ public interface WxMpCardService { | |||||
/** | /** | ||||
* 创建卡券二维码 | * 创建卡券二维码 | ||||
* @param cardId 卡券编号 | |||||
* @param outerStr 二维码标识 | |||||
* | |||||
* @param cardId 卡券编号 | |||||
* @param outerStr 二维码标识 | |||||
* @param expiresIn 失效时间,单位秒,不填默认365天 | * @param expiresIn 失效时间,单位秒,不填默认365天 | ||||
* @return WxMpCardQrcodeCreateResult | * @return WxMpCardQrcodeCreateResult | ||||
*/ | */ | ||||
WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr,int expiresIn) throws WxErrorException; | |||||
WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn) throws WxErrorException; | |||||
/** | /** | ||||
* 创建卡券货架 | * 创建卡券货架 | ||||
* | |||||
* @param createRequest 货架创建参数 | * @param createRequest 货架创建参数 | ||||
* @return | * @return | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
WxMpCardLandingPageCreateResult createLandingPage(WxMpCardLandingPageCreateRequest createRequest) throws WxErrorException; | WxMpCardLandingPageCreateResult createLandingPage(WxMpCardLandingPageCreateRequest createRequest) throws WxErrorException; | ||||
/** | |||||
* 将用户的卡券设置为失效状态 | |||||
* 详见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025272&anchor=9 | |||||
* | |||||
* @param cardId 卡券编号 | |||||
* @param code 用户会员卡号 | |||||
* @param reason 设置为失效的原因 | |||||
* @return | |||||
* @throws WxErrorException | |||||
*/ | |||||
String unavailableCardCode(String cardId, String code, String reason) throws WxErrorException; | |||||
} | } |
@@ -15,6 +15,7 @@ import me.chanjar.weixin.mp.bean.card.WxMpCardLandingPageCreateResult; | |||||
import me.chanjar.weixin.mp.bean.card.WxMpCardQrcodeCreateResult; | import me.chanjar.weixin.mp.bean.card.WxMpCardQrcodeCreateResult; | ||||
import me.chanjar.weixin.mp.bean.result.WxMpCardResult; | import me.chanjar.weixin.mp.bean.result.WxMpCardResult; | ||||
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
@@ -267,8 +268,9 @@ public class WxMpCardServiceImpl implements WxMpCardService { | |||||
/** | /** | ||||
* 创建卡券二维码 | * 创建卡券二维码 | ||||
* @param cardId 卡券编号 | |||||
* @param outerStr 二维码标识 | |||||
* | |||||
* @param cardId 卡券编号 | |||||
* @param outerStr 二维码标识 | |||||
* @param expiresIn 失效时间,单位秒,不填默认365天 | * @param expiresIn 失效时间,单位秒,不填默认365天 | ||||
* @return | * @return | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
@@ -301,4 +303,26 @@ public class WxMpCardServiceImpl implements WxMpCardService { | |||||
String response = this.wxMpService.post(CARD_LANDING_PAGE_CREAET, GSON.toJson(request)); | String response = this.wxMpService.post(CARD_LANDING_PAGE_CREAET, GSON.toJson(request)); | ||||
return WxMpCardLandingPageCreateResult.fromJson(response); | return WxMpCardLandingPageCreateResult.fromJson(response); | ||||
} | } | ||||
/** | |||||
* 将用户的卡券设置为失效状态 | |||||
* 详见:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025272&anchor=9 | |||||
* | |||||
* @param cardId 卡券编号 | |||||
* @param code 用户会员卡号 | |||||
* @param reason 设置为失效的原因 | |||||
* @return | |||||
* @throws WxErrorException | |||||
*/ | |||||
@Override | |||||
public String unavailableCardCode(String cardId, String code, String reason) throws WxErrorException { | |||||
if (StringUtils.isAnyBlank(cardId, code, reason)) | |||||
throw new WxErrorException(WxError.builder().errorCode(41012).errorMsg("参数不完整").build()); | |||||
JsonObject jsonRequest = new JsonObject(); | |||||
jsonRequest.addProperty("card_id", cardId); | |||||
jsonRequest.addProperty("code", code); | |||||
jsonRequest.addProperty("reason", reason); | |||||
String response = this.wxMpService.post(CARD_CODE_UNAVAILABLE, GSON.toJson(jsonRequest)); | |||||
return response; | |||||
} | |||||
} | } |
@@ -56,6 +56,12 @@ public class AdvancedInfo implements Serializable { | |||||
@SerializedName("time_limit") | @SerializedName("time_limit") | ||||
private TimeLimit timeLimit; | private TimeLimit timeLimit; | ||||
/** | |||||
* 是否可以分享朋友 | |||||
*/ | |||||
@SerializedName("share_friends") | |||||
private Boolean shareFriends; | |||||
public void addBusinessService(BusinessServiceType businessServiceType) { | public void addBusinessService(BusinessServiceType businessServiceType) { | ||||
if (businessServiceType != null) { | if (businessServiceType != null) { | ||||
if (businessServiceList == null) | if (businessServiceList == null) | ||||
@@ -34,6 +34,12 @@ public class BaseInfo implements Serializable { | |||||
@SerializedName("pay_info") | @SerializedName("pay_info") | ||||
private PayInfo payInfo; | private PayInfo payInfo; | ||||
/** | |||||
* 是否设置该会员卡中部的按钮同时支持微信支付刷卡和会员卡二维码 | |||||
*/ | |||||
@SerializedName("is_pay_and_qrcode") | |||||
private boolean isPayAndQrcode; | |||||
/** | /** | ||||
* 商户名字,字数上限为12个汉字 | * 商户名字,字数上限为12个汉字 | ||||
*/ | */ | ||||
@@ -21,12 +21,6 @@ public class SwipeCard implements Serializable { | |||||
@SerializedName("is_swipe_card") | @SerializedName("is_swipe_card") | ||||
private boolean isSwipeCard; | private boolean isSwipeCard; | ||||
/** | |||||
* 是否设置该会员卡中部的按钮同时支持微信支付刷卡和会员卡二维码 | |||||
*/ | |||||
@SerializedName("is_pay_and_qrcode") | |||||
private boolean isPayAndQrcode; | |||||
public String toString() { | public String toString() { | ||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); | return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); | ||||
} | } | ||||
@@ -91,4 +91,13 @@ public class WxMpCardServiceImplTest { | |||||
System.out.println(result); | System.out.println(result); | ||||
} | } | ||||
@Test | |||||
public void testUnavailableCardCode() throws Exception { | |||||
String cardId = "p2iQk1luzj50RHue6yeTPQpAx_Z4"; | |||||
String code = "134905347310"; | |||||
String reason = "换成新卡了"; | |||||
String result = this.wxService.getCardService().unavailableCardCode(cardId, code, reason); | |||||
assertNotNull(result); | |||||
System.out.println(result); | |||||
} | |||||
} | } |