Beispiel #1
0
        /// <summary>
        /// 获取用户已领取卡券
        /// </summary>
        /// <param name="openId">需要查询的用户openid</param>
        /// <param name="cardId">卡券ID。不填写时默认查询当前appid下的卡券。</param>
        /// <returns></returns>
        public ActionResult GetCardListByOpenId(string openId, string cardId)
        {
            if (!VerifyParam("openId"))
            {
                return(ErrMsg());
            }

            var weChatConfig = GetWechatConfig();

            var ret = CardApi.GetCardList(weChatConfig.WeixinAppId, weChatConfig.WeixinCorpSecret, openId, cardId);

            if (ret.errcode == Weixin.ReturnCode.请求成功)
            {
                return(Json(new
                {
                    message = "",
                    success = true,
                    card_list = ret.card_list
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new
                {
                    message = ret.errmsg,
                    success = false
                }, JsonRequestBehavior.AllowGet));
            }
        }