@Test public void testCreateGrouponCard() throws WxErrorException { BaseInfo base = new BaseInfo(); base.setLogoUrl("http: base.setBrandName("测试优惠券"); base.setCodeType("CODE_TYPE_QRCODE"); base.setTitle("测试标题"); base.setColor("Color010"); base.setNotice("测试Notice"); base.setServicePhone("020-88888888"); base.setDescription("不可与其他优惠同享\\n如需团购券发票，请在消费时向商户提出\\n店内均可使用，仅限堂食"); DateInfo info = new DateInfo(); info.setType("DATE_TYPE_FIX_TERM"); info.setFixedBeginTerm(0); info.setFixedTerm(30); base.setDateInfo(info); Sku sku = new Sku(); sku.setQuantity(100); base.setSku(sku); base.setGetLimit(1); base.setCanShare(true); base.setCanGiveFriend(true); base.setUseAllLocations(true); base.setCenterTitle("顶部居中按钮"); base.setCenterSubTitle("按钮下方的wording"); base.setCenterUrl("www.qq.com"); base.setCustomUrl("http: base.setCustomUrlName("立即使用"); base.setCustomUrlSubTitle("副标题tip"); base.setPromotionUrlName("更多优惠"); base.setPromotionUrl("http: base.setLocationIdList("1234"); WxMpCardCreateMessage grouponMessage = new WxMpCardCreateMessage(); GrouponCardCreateRequest grouponCardCreateRequest = new GrouponCardCreateRequest(); GrouponCard grouponCard = new GrouponCard(); grouponCard.setBaseInfo(base); grouponCard.setDealDetail("deal detail"); grouponCardCreateRequest.setGroupon(grouponCard); grouponMessage.setCardCreateRequest(grouponCardCreateRequest); System.out.println(this.wxService.getCardService().createCard(grouponMessage)); WxMpCardCreateMessage cashMessage = new WxMpCardCreateMessage(); CashCardCreateRequest cashCardCreateRequest = new CashCardCreateRequest(); CashCard cashCard = new CashCard(); cashCard.setBaseInfo(base); cashCard.setLeastCost(1000); cashCard.setReduceCost(100); cashCardCreateRequest.setCash(cashCard); cashMessage.setCardCreateRequest(cashCardCreateRequest); System.out.println(this.wxService.getCardService().createCard(cashMessage)); WxMpCardCreateMessage discountMessage = new WxMpCardCreateMessage(); DiscountCardCreateRequest discountCardCreateRequest = new DiscountCardCreateRequest(); DiscountCard discountCard = new DiscountCard(); discountCard.setBaseInfo(base); discountCard.setDiscount(30); discountCardCreateRequest.setDiscount(discountCard); discountMessage.setCardCreateRequest(discountCardCreateRequest); System.out.println(this.wxService.getCardService().createCard(discountMessage)); WxMpCardCreateMessage giftMessage = new WxMpCardCreateMessage(); GiftCardCreateRequest giftCardCreateRequest = new GiftCardCreateRequest(); GiftCard giftCard = new GiftCard(); giftCard.setBaseInfo(base); giftCard.setGift("星巴克雪瑞纳咖啡大杯"); giftCardCreateRequest.setGift(giftCard); giftMessage.setCardCreateRequest(giftCardCreateRequest); System.out.println(this.wxService.getCardService().createCard(giftMessage)); WxMpCardCreateMessage generalMessage = new WxMpCardCreateMessage(); GeneralCardCreateRequest generalCardCreateRequest = new GeneralCardCreateRequest(); GeneralCard generalCard = new GeneralCard(); generalCard.setBaseInfo(base); generalCard.setDefaultDetail("音乐木盒"); generalCardCreateRequest.setGeneralCoupon(generalCard); generalMessage.setCardCreateRequest(generalCardCreateRequest); System.out.println(this.wxService.getCardService().createCard(generalMessage)); }
@Override public WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage) throws WxErrorException { String response = this.wxMpService.post(CARD_CREATE, GSON.toJson(cardCreateMessage)); return WxMpCardCreateResult.fromJson(response); }
WxMpCardServiceImpl implements WxMpCardService { @Override public WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage) throws WxErrorException { String response = this.wxMpService.post(CARD_CREATE, GSON.toJson(cardCreateMessage)); return WxMpCardCreateResult.fromJson(response); } }
WxMpCardServiceImpl implements WxMpCardService { @Override public WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage) throws WxErrorException { String response = this.wxMpService.post(CARD_CREATE, GSON.toJson(cardCreateMessage)); return WxMpCardCreateResult.fromJson(response); } WxMpCardServiceImpl(WxMpService wxMpService); }
WxMpCardServiceImpl implements WxMpCardService { @Override public WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage) throws WxErrorException { String response = this.wxMpService.post(CARD_CREATE, GSON.toJson(cardCreateMessage)); return WxMpCardCreateResult.fromJson(response); } WxMpCardServiceImpl(WxMpService wxMpService); @Override WxMpService getWxMpService(); @Override String getCardApiTicket(); @Override String getCardApiTicket(boolean forceRefresh); @Override WxCardApiSignature createCardApiSignature(String... optionalSignParam); @Override String decryptCardCode(String encryptCode); @Override WxMpCardResult queryCardCode(String cardId, String code, boolean checkConsume); @Override String consumeCardCode(String code); @Override String consumeCardCode(String code, String cardId); @Override void markCardCode(String code, String cardId, String openId, boolean isMark); @Override String getCardDetail(String cardId); @Override String addTestWhiteList(String openid); @Override WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage); @Override WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr); @Override WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn); @Override WxMpCardLandingPageCreateResult createLandingPage(WxMpCardLandingPageCreateRequest request); @Override String unavailableCardCode(String cardId, String code, String reason); @Override WxMpCardDeleteResult deleteCard(String cardId); }
WxMpCardServiceImpl implements WxMpCardService { @Override public WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage) throws WxErrorException { String response = this.wxMpService.post(CARD_CREATE, GSON.toJson(cardCreateMessage)); return WxMpCardCreateResult.fromJson(response); } WxMpCardServiceImpl(WxMpService wxMpService); @Override WxMpService getWxMpService(); @Override String getCardApiTicket(); @Override String getCardApiTicket(boolean forceRefresh); @Override WxCardApiSignature createCardApiSignature(String... optionalSignParam); @Override String decryptCardCode(String encryptCode); @Override WxMpCardResult queryCardCode(String cardId, String code, boolean checkConsume); @Override String consumeCardCode(String code); @Override String consumeCardCode(String code, String cardId); @Override void markCardCode(String code, String cardId, String openId, boolean isMark); @Override String getCardDetail(String cardId); @Override String addTestWhiteList(String openid); @Override WxMpCardCreateResult createCard(WxMpCardCreateMessage cardCreateMessage); @Override WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr); @Override WxMpCardQrcodeCreateResult createQrcodeCard(String cardId, String outerStr, int expiresIn); @Override WxMpCardLandingPageCreateResult createLandingPage(WxMpCardLandingPageCreateRequest request); @Override String unavailableCardCode(String cardId, String code, String reason); @Override WxMpCardDeleteResult deleteCard(String cardId);  }