Exemple #1
0
        /// <summary>
        /// 卡券消耗code
        /// </summary>
        /// <param name="code">需核销的Code码。 </param>
        /// <param name="cardId">卡券ID。创建卡券时use_custom_code填写true时必填。非自定义Code不必填写。</param>
        /// <returns></returns>
        public ActionResult CardConsume(string code, string cardId)
        {
            if (!VerifyParam("code"))
            {
                return(ErrMsg());
            }

            var weChatConfig = GetWechatConfig();

            var ret = CardApi.CardConsume(weChatConfig.WeixinAppId, weChatConfig.WeixinCorpSecret, code, cardId);

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