/// <summary> /// 创建领取卡券的二维码。 /// </summary> /// <param name="model">创建领取卡券二维码模型。</param> /// <returns>创建领取卡券二维码结果。</returns> public CreateCardQrCodeResult CreateQrCode(CreateCardQrCodeModel model) { var url = "https://api.weixin.qq.com/card/qrcode/create?access_token=" + _accountModel.GetAccessToken(); dynamic cardData = new ExpandoObject(); if (!string.IsNullOrWhiteSpace(model.OpenId)) { cardData.openid = model.OpenId; } if (!string.IsNullOrWhiteSpace(model.Code)) { cardData.code = model.Code; } cardData.card_id = model.CardId; if (model.ExpireSeconds.HasValue) { cardData.expire_seconds = 60; } cardData.is_unique_code = model.IsUniqueCode; cardData.outer_id = model.OuterId; var content = WeiXinHttpHelper.PostString(url, new { action_name = "QR_CARD", action_info = new { card = cardData } }); var ticket = JObject.Parse(content).Value <string>("ticket"); return(new CreateCardQrCodeResult { QrCodeUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + ticket, Ticket = ticket }); }
/// <summary> /// 创建领取卡券的二维码。 /// </summary> /// <param name="model">创建领取卡券二维码模型。</param> /// <returns>创建领取卡券二维码结果。</returns> public CreateCardQrCodeResult CreateQrCode(CreateCardQrCodeModel model) { var url = "https://api.weixin.qq.com/card/qrcode/create?access_token=" + _accountModel.GetAccessToken(); dynamic cardData = new ExpandoObject(); if (!string.IsNullOrWhiteSpace(model.OpenId)) cardData.openid = model.OpenId; if (!string.IsNullOrWhiteSpace(model.Code)) cardData.code = model.Code; cardData.card_id = model.CardId; if (model.ExpireSeconds.HasValue) cardData.expire_seconds = 60; cardData.is_unique_code = model.IsUniqueCode; cardData.outer_id = model.OuterId; var content = WeiXinHttpHelper.PostString(url, new { action_name = "QR_CARD", action_info = new { card = cardData } }); var ticket = JObject.Parse(content).Value<string>("ticket"); return new CreateCardQrCodeResult { QrCodeUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + ticket, Ticket = ticket }; }