
org.jeewx.api.coupon.JwCardManageAPITest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weixin4j Show documentation
Show all versions of weixin4j Show documentation
微信和钉钉开发SDK,主要提供微信、企业微信、钉钉的JAVA封装,降低集成难度,让API变简单
The newest version!
package org.jeewx.api.coupon;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.jeewx.api.core.common.AccessToken;
import org.jeewx.api.core.exception.WexinReqException;
import org.jeewx.api.coupon.manage.JwCardManageAPI;
import org.jeewx.api.coupon.manage.model.BatchGetCardRtnInfo;
import org.jeewx.api.coupon.manage.model.CardUpdate;
import org.jeewx.api.coupon.manage.model.CommCardRtnInfo;
import org.jeewx.api.coupon.manage.model.DelRtnInfo;
import org.jeewx.api.coupon.manage.model.GetCardDetailRtnInfo;
import org.jeewx.api.coupon.manage.model.GetCardRtnInfo;
import org.jeewx.api.coupon.qrcode.JwQrcodeAPI;
import org.jeewx.api.coupon.qrcode.model.GetticketRtn;
/**
* 测试卡券管理
* @author mcl
* @version v1.0
*/
public class JwCardManageAPITest {
private static String appid = "wxd2b52b8f4bd5af7f";
private static String appscret = "1b982dba2c3f853c3396babcdfa6cb1e";
/**
* 测试卡券管理
*/
public static void main1(String[] args) {
AccessToken atoken = new AccessToken(appid, appscret);
String newAccessToken = atoken.getNewAccessToken();
//获取所有卡券ID(此方法适合数量不超过50个的)
List ls = getCardList(newAccessToken);
for(String p:ls){
//根据卡券ID,获取卡券详细
GetCardDetailRtnInfo rtnInfo = JwCardManageAPI.doGetCardDetail(newAccessToken, p);
if(rtnInfo.getCard().getCard_type().equals("CASH")){
System.out.println(rtnInfo.getCard().getCash().getReduce_cost()/100);
}
}
//1.0批量获取卡券
// doBatchGetCardTest(newAccessToken);
// //2.0删除卡券
// doDelCardTest(newAccessToken);
// //3.0获取卡券详细信息
// doGetCardDetailTest(newAccessToken);
// //4.0获取卡券信息
// doGetCardTest(newAccessToken);
// //5.0更新卡券库存
// doModifystockCardTest(newAccessToken);
// //6.0设置卡券失效状态
// doUnavailableCodeTest(newAccessToken);
// //7.0更新卡券信息
// doUpdateCardTest(newAccessToken);
// //8.0更新卡券code
// doUpdateCodeTest(newAccessToken);
}
/**
* 测试卡券管理
*/
public static void main(String[] args) {
AccessToken atoken = new AccessToken(appid, appscret);
String newAccessToken = atoken.getNewAccessToken();
try {
GetticketRtn s = JwQrcodeAPI.doGetticket(newAccessToken);
System.out.println(s.getTicket());
} catch (WexinReqException e) {
e.printStackTrace();
}
}
public static List getCardList(String newAccessToken){
BatchGetCardRtnInfo rtnInfo = null;
rtnInfo = JwCardManageAPI.doBatchGetCard(newAccessToken, 0, 50);
if(Integer.parseInt(rtnInfo.getErrcode()) == 0){
//System.out.println("JwCardManageAPI.doBatchGetCard["+i+"]" + ":成功");
System.out.println("");
System.out.println("接口调用成功: card_id_list: "+rtnInfo.getCard_id_list());
return rtnInfo.getCard_id_list();
}else{
System.out.println("接口调用失败:"+"["+rtnInfo.getErrmsg()+"]");
return null;
}
}
public static boolean doBatchGetCardTest(String newAccessToken) {
BatchGetCardRtnInfo rtnInfo = null;
Map onecase = null;
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy