示例#1
0
 /// <summary>
 /// 获取快速支付码
 /// </summary>
 /// <param name="xcxrelation"></param>
 /// <param name="platStore"></param>
 public void GetQuicklyPayQrCode(XcxAppAccountRelation xcxrelation, ref PlatStore platStore)
 {
     if (string.IsNullOrEmpty(platStore.SwitchModel.StorePayQrcode))
     {
         string token = "";
         if (XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token))
         {
             qrcodeclass qrcodeModel = CommondHelper.GetMiniAppQrcode(token, "pages/home/shop-detail/pay", "", 500);
             if (!string.IsNullOrEmpty(qrcodeModel.url))
             {
                 platStore.SwitchModel.StorePayQrcode = qrcodeModel.url;
                 platStore.SwitchConfig = JsonConvert.SerializeObject(platStore.SwitchModel);
                 base.Update(platStore, "SwitchConfig");
             }
             else
             {
                 log4net.LogHelper.WriteInfo(this.GetType(), $"生成快速支付码失败:msg:{qrcodeModel.msg},aid:{xcxrelation.Id}");
             }
         }
         else
         {
             log4net.LogHelper.WriteInfo(this.GetType(), $"获取生成快速支付码的token失败:msg:{token},aid:{xcxrelation.Id}");
         }
     }
 }
示例#2
0
        /// <summary>
        /// 商品一物一码
        /// </summary>
        /// <param name="goodsId">商品ID</param>
        /// <param name="pageUrl">小程序商品详情页路径</param>
        /// <param name="type">0:子模板小程序,1:平台版小程序</param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public string GetGoodsCodeUrl(int goodsId, string pageUrl, int type, ref string msg)
        {
            PlatChildGoods goods = base.GetModel(goodsId);

            if (goods == null)
            {
                msg = "商品二维码:找不到商品数据";
                return("");
            }

            string url = RedisUtil.Get <string>(string.Format(_redis_PlatChildGoodsCodeUrlKey, type, goodsId));

            if (!string.IsNullOrEmpty(url))
            {
                return(url);
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(goods.AId);

            if (xcxrelation == null || string.IsNullOrEmpty(xcxrelation.AppId))
            {
                msg = "商品二维码:店铺没绑定小程序";
                return("");
            }

            string token = "";

            if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token))
            {
                msg = token;
                return("");
            }

            //小程序二维码
            string      scen   = $"goodsId={goodsId}";
            qrcodeclass result = CommondHelper.GetMiniAppQrcode(token, pageUrl, scen);

            if (result != null && result.isok > 0)
            {
                url = result.url;
                if (string.IsNullOrEmpty(url))
                {
                    return("");
                }
                url = url.Replace("http:", "https:");
                RedisUtil.Set <string>(string.Format(_redis_PlatChildGoodsCodeUrlKey, type, goodsId), url, TimeSpan.FromDays(1));
                return(url);
            }

            msg = "商品二维码:获取失败";
            return("");
        }
示例#3
0
        /// <summary>
        /// 获取平台店铺二维码
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="pageurl"></param>
        /// <param name="scene"></param>
        /// <returns></returns>
        public string GetStoreCode(int storeid, string pageurl, ref string msg)
        {
            PlatStore store = base.GetModel(storeid);

            if (store == null)
            {
                msg = "店铺二维码:找不到店铺数据";
                return("");
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(store.BindPlatAid);

            if (xcxrelation == null)
            {
                msg = "平台店铺二维码:模板过期";
                return("");
            }

            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                msg = "无效模板";
                return("");
            }

            string token = "";

            if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token))
            {
                msg = token;
                return("");
            }

            //店铺没有开通小程序
            //平台小程序二维码
            string      scen        = $"{storeid}";
            qrcodeclass qrcodemodel = CommondHelper.GetMiniAppQrcode(token, pageurl, scen);

            if (qrcodemodel == null || string.IsNullOrEmpty(qrcodemodel.url))
            {
                msg = qrcodemodel != null ? qrcodemodel.msg : "生成名片码失败";
                return("");
            }

            return(qrcodemodel.url);
        }
示例#4
0
        /// <summary>
        /// 获取名片码
        /// </summary>
        /// <returns></returns>
        public ActionResult GetMyCardCodeUrl()
        {
            returnObj = new Return_Msg_APP();
            int    userId  = Context.GetRequestInt("userid", 0);
            int    aid     = Context.GetRequestInt("aid", 0);
            string pageUrl = Context.GetRequest("pageurl", "");

            if (userId <= 0)
            {
                returnObj.Msg = "userid不能为空";
                return(Json(returnObj));
            }
            if (aid <= 0)
            {
                returnObj.Msg = "aid不能为空";
                return(Json(returnObj));
            }
            if (string.IsNullOrEmpty(pageUrl))
            {
                returnObj.Msg = "名片路径不能为空";
                return(Json(returnObj));
            }

            PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModelByUserId(userId);

            if (myCard == null)
            {
                returnObj.Msg = "名片过期";
                return(Json(returnObj));
            }
            //判断是否已有名片码
            if (!string.IsNullOrEmpty(myCard.QrCodeImgUrl))
            {
                returnObj.dataObj = myCard.QrCodeImgUrl;
                returnObj.isok    = true;
                return(Json(returnObj));
            }

            XcxAppAccountRelation xcxrelation = _xcxAppAccountRelationBLL.GetModel(aid);

            if (xcxrelation == null)
            {
                returnObj.Msg = "模板过期";
                return(Json(returnObj));
            }

            //XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);
            //if (xcxTemplate == null)
            //{
            //    returnObj.Msg = "无效模板";
            //    return Json(returnObj);
            //}

            string token = "";

            if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token))
            {
                returnObj.Msg = token;
                return(Json(returnObj));
            }

            string      scen        = $"{userId}";
            qrcodeclass qrCodeModel = CommondHelper.GetMiniAppQrcode(token, pageUrl, scen);

            if (qrCodeModel == null || string.IsNullOrEmpty(qrCodeModel.url))
            {
                returnObj.Msg = qrCodeModel == null?"生成名片码失败": qrCodeModel.msg + "失败";
                return(Json(returnObj));
            }

            myCard.QrCodeImgUrl = qrCodeModel.url;
            myCard.UpdateTime   = DateTime.Now;
            PlatMyCardBLL.SingleModel.Update(myCard, "QrCodeImgUrl,UpdateTime");
            returnObj.dataObj = myCard.QrCodeImgUrl;
            returnObj.isok    = true;
            return(Json(returnObj));
        }
示例#5
0
        /// <summary>
        /// 子模版获取小程序二维码
        /// </summary>
        /// <param name="storeid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public string GetStoreCode(int storeid, ref string msg)
        {
            PlatStore store = base.GetModel(storeid);

            if (store == null)
            {
                msg = "店铺二维码:找不到店铺数据";
                return("");
            }

            string url = RedisUtil.Get <string>(string.Format(_redis_PlatStoreCodeUrlKey, storeid));

            if (!string.IsNullOrEmpty(url))
            {
                return(url);
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(store.Aid);

            if (xcxrelation == null || string.IsNullOrEmpty(xcxrelation.AppId))
            {
                msg = "店铺二维码:店铺没绑定小程序";
                return("");
            }
            //OpenAuthorizerConfig XUserList = openAuthorizerConfigBLL.GetModelByAppids(xcxrelation.AppId);
            //if (XUserList == null)
            //{
            //    msg = "店铺二维码:店铺小程序还未授权";
            //    return "";
            //}

            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                msg = "店铺二维码:无效模板";
                return("");
            }

            string token = "";

            if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token))
            {
                msg = token;
                return("");
            }

            //小程序二维码

            qrcodeclass result = CommondHelper.GetMiniAppQrcode(token, xcxTemplate.Address);

            if (result != null && result.isok > 0)
            {
                url = result.url;
                if (string.IsNullOrEmpty(url))
                {
                    return("");
                }
                url = url.Replace("http:", "https:");
                RedisUtil.Set <string>(string.Format(_redis_PlatStoreCodeUrlKey, storeid), url, TimeSpan.FromSeconds(5));
                return(url);
            }

            msg = "店铺二维码:获取失败";
            return("");
        }