public interface WxMpCardService
提供微信卡券的创建、查询、核销、管理等功能。 支持卡券API签名生成、卡券Code解码、卡券核销、库存管理等功能。
详情请见:卡券开发文档
WxMpService getWxMpService()
获取WxMpService实例
String getCardApiTicket() throws WxErrorException
获得卡券api_ticket,不强制刷新卡券api_ticket
WxErrorException - 微信API调用异常,可能包括:
getCardApiTicket(boolean)String getCardApiTicket(boolean forceRefresh) throws WxErrorException
获得卡券api_ticket 获得时会检查卡券apiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干
forceRefresh - 强制刷新,如果为true则强制刷新api_ticketWxErrorException - 微信API调用异常,可能包括:
WxCardApiSignature createCardApiSignature(String... optionalSignParam) throws WxErrorException
创建调用卡券api时所需要的签名
optionalSignParam - 参与签名的参数数组。可以为下列字段:app_id, card_id, card_type, code, openid, location_id
注意:当做wx.chooseCard调用时,必须传入app_id参与签名,否则会造成签名失败导致拉取卡券列表为空WxErrorException - 微信API调用异常,可能包括:
String decryptCardCode(String encryptCode) throws WxErrorException
卡券Code解码
encryptCode - 加密Code,通过JSSDK的chooseCard接口获得WxErrorException - 微信API调用异常,可能包括:
WxMpCardResult queryCardCode(String cardId, String code, boolean checkConsume) throws WxErrorException
卡券Code查询
cardId - 卡券ID代表一类卡券code - 单张卡券的唯一标准checkConsume - 是否校验code核销状态,填入true和false时的code异常状态返回数据不同WxErrorException - 微信API调用异常,可能包括:
String consumeCardCode(String code) throws WxErrorException
卡券Code核销。核销失败会抛出异常
code - 单张卡券的唯一标准WxErrorException - 微信API调用异常,可能包括:
String consumeCardCode(String code, String cardId) throws WxErrorException
卡券Code核销。核销失败会抛出异常
code - 单张卡券的唯一标准cardId - 当自定义Code卡券时需要传入card_idWxErrorException - 微信API调用异常,可能包括:
void markCardCode(String code, String cardId, String openId, boolean isMark) throws WxErrorException
卡券Mark接口 开发者在帮助消费者核销卡券之前,必须帮助先将此code(卡券串码)与一个openid绑定(即mark住), 才能进一步调用核销接口,否则报错。
code - 卡券的code码cardId - 卡券的IDopenId - 用券用户的openidisMark - 是否要mark(占用)这个code,填写true或者false,表示占用或解除占用WxErrorException - 微信API调用异常,可能包括:
String getCardDetail(String cardId) throws WxErrorException
查看卡券详情接口
cardId - 卡券的IDWxErrorException - 微信API调用异常,可能包括:
String addTestWhiteList(String openid) throws WxErrorException
添加测试白名单
openid - 用户的openidWxErrorException - 微信API调用异常,可能包括:
WxMpCardCreateResult createCard(WxMpCardCreateRequest cardCreateMessage) throws WxErrorException
创建卡券
cardCreateRequest - 卡券创建请求对象WxErrorException - 微信API调用异常,可能包括:
WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr) throws WxErrorException
创建卡券二维码
cardId - 卡券编号outerStr - 二维码标识WxErrorException - 微信API调用异常,可能包括:
WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn) throws WxErrorException
创建卡券二维码
cardId - 卡券编号outerStr - 用户首次领卡时,会通过 领取事件推送 给商户; 对于会员卡的二维码,用户每次扫码打开会员卡后点击任何url,会将该值拼入url中,方便开发者定位扫码来源expiresIn - 指定二维码的有效时间,范围是60 ~ 1800秒。不填默认为365天有效WxErrorException - 微信API调用异常,可能包括:
WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn, String openid, String code, boolean isUniqueCode) throws WxErrorException
创建卡券二维码
cardId - 卡券编号outerStr - 用户首次领卡时,会通过 领取事件推送 给商户; 对于会员卡的二维码,用户每次扫码打开会员卡后点击任何url,会将该值拼入url中,方便开发者定位扫码来源expiresIn - 指定二维码的有效时间,范围是60 ~ 1800秒。不填默认为365天有效openid - 指定领取者的openid,只有该用户能领取。bind_openid字段为true的卡券必须填写,非指定openid不必填写code - 卡券Code码,use_custom_code字段为true的卡券必须填写,非自定义code和导入code模式的卡券不必填写isUniqueCode - 指定下发二维码,生成的二维码随机分配一个code,领取后不可再次扫描。填写true或false。默认false,注意填写该字段时,卡券须通过审核且库存不为0WxErrorException - 微信API调用异常,可能包括:
WxMpCardLandingPageCreateResult createLandingPage(WxMpCardLandingPageCreateRequest createRequest) throws WxErrorException
创建卡券货架
createRequest - 货架创建参数WxErrorException - 微信API调用异常,可能包括:
String unavailableCardCode(String cardId, String code, String reason) throws WxErrorException
将用户的卡券设置为失效状态
cardId - 卡券编号code - 用户会员卡号reason - 设置为失效的原因WxErrorException - 微信API调用异常,可能包括:
WxMpCardDeleteResult deleteCard(String cardId) throws WxErrorException
删除卡券接口
cardId - 卡券idWxErrorException - 微信API调用异常,可能包括:
WxMpCardCodeDepositResult cardCodeDeposit(String cardId, List<String> codeList) throws WxErrorException
导入自定义code(仅对自定义code商户)
cardId - 卡券idcodeList - 需导入微信卡券后台的自定义code,上限为100个WxErrorException - 微信API调用异常,可能包括:
WxMpCardCodeDepositCountResult cardCodeDepositCount(String cardId) throws WxErrorException
查询导入code数目接口
cardId - 卡券idWxErrorException - 微信API调用异常,可能包括:
WxMpCardCodeCheckcodeResult cardCodeCheckcode(String cardId, List<String> codeList) throws WxErrorException
核查code接口
cardId - 卡券idcodeList - 已经微信卡券后台的自定义code,上限为100个WxErrorException - 微信API调用异常,可能包括:
WxMpCardMpnewsGethtmlResult cardMpnewsGethtml(String cardId) throws WxErrorException
图文消息群发卡券获取内嵌html
cardId - 卡券idWxErrorException - 微信API调用异常,可能包括:
void cardModifyStock(String cardId, Integer changeValue) throws WxErrorException
修改库存接口
cardId - 卡券IDchangeValue - 库存变更值,负值为减少库存WxErrorException - 微信API调用异常,可能包括:
void cardCodeUpdate(String cardId, String oldCode, String newCode) throws WxErrorException
更改Code接口
cardId - 卡券IDoldCode - 需变更的Code码newCode - 变更后的有效Code码WxErrorException - 微信API调用异常,可能包括:
void cardPaycellSet(String cardId, Boolean isOpen) throws WxErrorException
设置买单接口
cardId - 卡券IDisOpen - 是否开启买单功能,填true/falseWxErrorException - 微信API调用异常,可能包括:
void cardSelfConsumeCellSet(String cardId, Boolean isOpen, Boolean needVerifyCod, Boolean needRemarkAmount) throws WxErrorException
设置自助核销
cardId - 卡券IDisOpen - 是否开启自助核销功能needVerifyCod - 用户核销时是否需要输入验证码, 填true/false, 默认为falseneedRemarkAmount - 用户核销时是否需要备注核销金额, 填true/false, 默认为falseWxErrorException - 微信API调用异常,可能包括:
WxUserCardListResult getUserCardList(String openId, String cardId) throws WxErrorException
获取用户已领取卡券接口
openId - 需要查询的用户openidcardId - 卡券ID。不填写时默认查询当前appid下的卡券WxErrorException - 微信API调用异常,可能包括:
Copyright © 2026. All rights reserved.