/// <summary> /// 创建卡券 /// </summary> /// <param name="accessToken"></param> /// <param name="cardType">卡券类型</param> /// <param name="data">创建卡券需要的数据,格式可以看CardCreateData.cs</param> /// <returns></returns> public static CardCreateResultJson CreateCard(string accessToken, CardType cardType, object data) { var urlFormat = string.Format("https://api.weixin.qq.com/card/create?access_token={0}", accessToken); BaseCardCreateInfo cardData = null; return(CommonJsonSend.Send <CardCreateResultJson>(null, urlFormat, cardData)); }
/// <summary> /// 创建卡券 /// </summary> /// <param name="accessToken"></param> /// <param name="cardType">卡券类型</param> /// <param name="data">创建卡券需要的数据,格式可以看CardCreateData.cs</param> /// <returns></returns> public static CardCreateResultJson CreateCard(string accessToken, CardType cardType, object data) { var urlFormat = string.Format("https://api.weixin.qq.com/card/create?access_token={0}", accessToken); BaseCardCreateInfo cardData = null; switch (cardType) { case CardType.GENERAL_COUPON: cardData = new BaseCardCreateInfo() { card = new Card_GeneralCoupon() { card_type = cardType, general_coupon = data as Card_GeneralCouponData } }; break; case CardType.GROUPON: cardData = new BaseCardCreateInfo() { card = new Card_Groupon() { card_type = cardType, groupon = data as Card_GrouponData } }; break; case CardType.GIFT: cardData = new BaseCardCreateInfo() { card = new Card_Gift() { card_type = cardType, gift = data as Card_GiftData } }; break; case CardType.CASH: cardData = new BaseCardCreateInfo() { card = new Card_Cash() { card_type = cardType, cash = data as Card_CashData } }; break; case CardType.DISCOUNT: cardData = new BaseCardCreateInfo() { card = new Card_DisCount() { card_type = cardType, discount = data as Card_DisCountData } }; break; case CardType.MEMBER_CARD: cardData = new BaseCardCreateInfo() { card = new Card_MemberCard() { card_type = cardType, member_card = data as Card_MemberCardData } }; break; case CardType.SCENIC_TICKET: cardData = new BaseCardCreateInfo() { card = new Card_ScenicTicket() { card_type = cardType, scenic_ticket = data as Card_ScenicTicketData } }; break; case CardType.MOVIE_TICKET: cardData = new BaseCardCreateInfo() { card = new Card_MovieTicket() { card_type = cardType, movie_ticket = data as Card_MovieTicketData } }; break; case CardType.BOARDING_PASS: cardData = new BaseCardCreateInfo() { card = new Card_BoardingPass() { card_type = cardType, boarding_pass = data as Card_BoardingPassData } }; break; case CardType.LUCKY_MONEY: cardData = new BaseCardCreateInfo() { card = new Card_LuckyMoney() { card_type = cardType, lucky_money = data as Card_LuckyMoneyData } }; break; default: break; } return(CommonJsonSend.Send <CardCreateResultJson>(accessToken, urlFormat, cardData)); }
/// <summary> /// 创建卡券 /// </summary> /// <param name="accessToken"></param> /// <param name="cardType">卡券类型</param> /// <param name="data">创建卡券需要的数据,格式可以看CardCreateData.cs</param> /// <returns></returns> public static CardCreateResultJson CreateCard(string accessToken, CardType cardType, object data) { var urlFormat = string.Format("https://api.weixin.qq.com/card/create?access_token={0}", accessToken); BaseCardCreateInfo cardData = null; switch (cardType) { case CardType.GENERAL_COUPON: cardData = new BaseCardCreateInfo() { card = new Card_GeneralCoupon() { card_type = cardType, general_coupon = data as Card_GeneralCouponData } }; break; case CardType.GROUPON: cardData = new BaseCardCreateInfo() { card = new Card_Groupon() { card_type = cardType, groupon = data as Card_GrouponData } }; break; case CardType.GIFT: cardData = new BaseCardCreateInfo() { card = new Card_Gift() { card_type = cardType, gift = data as Card_GiftData } }; break; case CardType.CASH: cardData = new BaseCardCreateInfo() { card = new Card_Cash() { card_type = cardType, cash = data as Card_CashData } }; break; case CardType.DISCOUNT: cardData = new BaseCardCreateInfo() { card = new Card_DisCount() { card_type = cardType, discount = data as Card_DisCountData } }; break; case CardType.MEMBER_CARD: cardData = new BaseCardCreateInfo() { card = new Card_MemberCard() { card_type = cardType, member_card = data as Card_MemberCardData } }; break; case CardType.SCENIC_TICKET: cardData = new BaseCardCreateInfo() { card = new Card_ScenicTicket() { card_type = cardType, scenic_ticket = data as Card_ScenicTicketData } }; break; case CardType.MOVIE_TICKET: cardData = new BaseCardCreateInfo() { card = new Card_MovieTicket() { card_type = cardType, movie_ticket = data as Card_MovieTicketData } }; break; case CardType.BOARDING_PASS: cardData = new BaseCardCreateInfo() { card = new Card_BoardingPass() { card_type = cardType, boarding_pass = data as Card_BoardingPassData } }; break; case CardType.LUCKY_MONEY: cardData = new BaseCardCreateInfo() { card = new Card_LuckyMoney() { card_type = cardType, lucky_money = data as Card_LuckyMoneyData } }; break; default: break; } return CommonJsonSend.Send<CardCreateResultJson>(accessToken, urlFormat, cardData); }