Ejemplo n.º 1
0
        /// <summary>
        /// 关闭或开启同步
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveXcxState()
        {
            _returnData = new Return_Msg();
            int id    = Context.GetRequestInt("id", 0);
            int state = Context.GetRequestInt("state", 0);

            if (id <= 0)
            {
                _returnData.Msg = "参数错误";
                return(Json(_returnData));
            }

            PlatApplyApp model = PlatApplyAppBLL.SingleModel.GetModel(id);

            if (model == null)
            {
                _returnData.Msg = "数据过期,请刷新重试";
                return(Json(_returnData));
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModel(model.StoreId);

            if (store == null)
            {
                _returnData.Msg = "店铺数据过期,请刷新重试";
                return(Json(_returnData));
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(store.Aid);

            if (xcxrelation == null)
            {
                _returnData.Msg = "店铺数据过期,请刷新重试";
                return(Json(_returnData));
            }
            xcxrelation.State = state;
            _returnData.isok  = XcxAppAccountRelationBLL.SingleModel.Update(xcxrelation, "state");
            _returnData.Msg   = _returnData.isok ? "保存成功" : "保存失败";

            return(Json(_returnData));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 申请独立小程序
        /// </summary>
        /// <returns></returns>
        public ActionResult ApplyStoreApp()
        {
            returnObj = new Return_Msg_APP();
            int userid = Context.GetRequestInt("userid", 0);

            if (userid <= 0)
            {
                returnObj.Msg = "userid不能为0";
            }
            PlatMyCard mycard = PlatMyCardBLL.SingleModel.GetModelByUserId(userid);

            if (mycard == null)
            {
                returnObj.Msg = "名片已过期";
                return(Json(returnObj));
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModelBycardid(mycard.AId, mycard.Id);

            if (store == null)
            {
                returnObj.Msg = "店铺已过期";
                return(Json(returnObj));
            }

            PlatApplyApp model = new PlatApplyApp();

            model.AddTime      = DateTime.Now;
            model.BindAId      = mycard.AId;
            model.CustomerName = mycard.Name;
            model.MycardId     = mycard.Id;
            model.OpenState    = 0;
            model.StoreId      = store.Id;
            model.UpdateTime   = DateTime.Now;
            model.Id           = Convert.ToInt32(PlatApplyAppBLL.SingleModel.Add(model));
            returnObj.isok     = model.Id > 0;
            returnObj.Msg      = returnObj.isok ? "提交成功,正在审核中" : "提交失败";

            return(Json(returnObj));
        }
Ejemplo n.º 3
0
        public ActionResult OpenStore()
        {
            _returnData = new Return_Msg();

            int         aid              = Context.GetRequestInt("aid", 0);
            int         id               = Context.GetRequestInt("id", 0);
            int         type             = Context.GetRequestInt("type", 0);
            int         useLength        = Context.GetRequestInt("uselength", 0);
            XcxTemplate xcxtemplateModel = XcxTemplateBLL.SingleModel.GetModelByType((int)TmpType.小未平台子模版);

            if (xcxtemplateModel == null)
            {
                _returnData.Msg = "改模板还未上线";
                return(Json(_returnData));
            }
            if (id <= 0)
            {
                _returnData.Msg = "参数错误";
                return(Json(_returnData));
            }

            PlatApplyApp platApplyAppModel = PlatApplyAppBLL.SingleModel.GetModel(id);

            if (platApplyAppModel == null)
            {
                _returnData.Msg = "数据过期,请刷新重试";
                return(Json(_returnData));
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                _returnData.Msg = "还未开通小未平台模板";
                return(Json(_returnData));
            }

            try
            {
                if (type == 0)
                {
                    string msg = "";
                    _returnData.isok = PlatApplyAppBLL.SingleModel.OpenStore(platApplyAppModel, xcxrelation.AccountId.ToString(), useLength, xcxtemplateModel.Id, ref msg);
                    _returnData.Msg  = _returnData.isok ? "开通成功" : (msg.Length <= 0 ? "开通失败" : msg);
                }
                else if (type == 1)
                {
                    string msg = "";
                    _returnData.isok = PlatApplyAppBLL.SingleModel.AddTimeLength(platApplyAppModel, xcxrelation.AccountId.ToString(), useLength, xcxtemplateModel.Id, ref msg);
                    _returnData.Msg  = _returnData.isok ? "续期成功" : (msg.Length <= 0 ? "续期失败" : msg);
                }
                else
                {
                    _returnData.Msg = "无效类型";
                }
            }
            catch (Exception ex)
            {
                log4net.LogHelper.WriteError(this.GetType(), ex);
                _returnData.Msg = "系统繁忙";
            }


            return(Json(_returnData));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取平台指定店铺详情
        /// </summary>
        /// <returns></returns>
        public ActionResult GetStoreDetail()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId   = Context.GetRequest("appId", string.Empty);
            int    userId  = Context.GetRequestInt("userId", 0);
            int    storeId = Context.GetRequestInt("storeId", 0);
            int    type    = Context.GetRequestInt("type", 0);

            if (string.IsNullOrEmpty(appId))
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj));
            }
            List <string>         listPlatMyCardIds = new List <string>();
            int                   myCardId          = Context.GetRequestInt("myCardId", 0);
            int                   isStoreID         = Context.GetRequestInt("isStoreID", 0);//如果是1 表示myCardId为店铺Id 这里是轮播图处理兼容旧数据
            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.Msg = "小程序未授权";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            PlatStore platStore = new PlatStore();

            if (type == 1 && isStoreID == 0)
            {
                //表示从我的店铺名片进来
                if (myCardId <= 0)
                {
                    platStore = null;
                }
                else
                {
                    platStore = PlatStoreBLL.SingleModel.GetPlatStore(myCardId, type);
                }
            }
            else if (type == 2)
            {
                //表示独立小程序进来的
                platStore = PlatStoreBLL.SingleModel.GetPlatStore(r.Id, type);
                r         = _xcxAppAccountRelationBLL.GetModel(platStore.BindPlatAid);//查找所属平台
                if (r != null)
                {
                    listPlatMyCardIds = PlatMyCardBLL.SingleModel.GetCardIds(r.Id, r.AppId).Split(',').ToList();
                    if (!listPlatMyCardIds.Contains(platStore.MyCardId.ToString()))
                    {
                        returnObj.Msg = "店铺不存在(平台换绑了小程序,请重新入驻)";
                        return(Json(returnObj, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            else
            {
                //平台轮播图 置顶商家 进入店铺会带上isStoreID

                if (isStoreID > 0)
                {
                    type      = 0;
                    platStore = PlatStoreBLL.SingleModel.GetPlatStore(myCardId, type);
                }
                else
                {
                    platStore = PlatStoreBLL.SingleModel.GetPlatStore(storeId, type);
                }
            }

            if (platStore == null)
            {
                returnObj.Msg = "店铺不存在";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            if (platStore.State == -1)
            {
                returnObj.Msg = "店铺无效(未支付)";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }



            if (type != 2)
            {
                //这里的appID是平台的
                listPlatMyCardIds = PlatMyCardBLL.SingleModel.GetCardIds(r.Id, appId).Split(',').ToList();
                if (!listPlatMyCardIds.Contains(platStore.MyCardId.ToString()))
                {
                    returnObj.Msg = "店铺不存在(平台换绑了小程序,请重新入驻绑定)";
                    return(Json(returnObj, JsonRequestBehavior.AllowGet));
                }
            }



            //店铺关联的权限表数据
            XcxAppAccountRelation storexcxrelation = _xcxAppAccountRelationBLL.GetModel(platStore.Aid);

            if (storexcxrelation != null)
            {
                platStore.AppId = storexcxrelation.AppId;
            }

            //TODO 后续流量大了再放入redis然后定时去更新
            platStore.StorePV++;
            //访客人数
            platStore.StoreUV       = PlatUserFavoriteMsgBLL.SingleModel.GetVisitorCount(platStore.MyCardId, platStore.BindPlatAid, (int)PointsDataType.店铺, "", "");
            platStore.FavoriteCount = PlatUserFavoriteMsgBLL.SingleModel.GetStoreFavoriteCount(r.Id, platStore.Id);

            PlatUserFavoriteMsg platUserFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, platStore.Id, userId, (int)PointsActionType.收藏, (int)PointsDataType.店铺);

            platStore.Favorited = (platUserFavoriteMsg != null && platUserFavoriteMsg.State != -1 ? 1 : 0);

            platStore.CategoryName = PlatStoreCategoryBLL.SingleModel.GetModel(platStore.Category).Name;

            int tjCount = 0;

            List <PlatChildGoods> listTjGoods = listTjGoods = PlatChildGoodsBLL.SingleModel.GetListByRedis(platStore.Aid, ref tjCount, string.Empty, 0, 0, 1, 1, 4, "TopState desc,VirtualSalesCount+SalesCount desc,sort desc");

            //if (type == 0)
            //{

            //    listTjGoods = _platChildGoodsBLL.GetListByRedis(platStore.Aid, ref tjCount, string.Empty, 0, 0, 1, 1, 4, "TopState desc,VirtualSalesCount+SalesCount desc,sort desc");
            //}
            //else
            //{
            //    listTjGoods = _platChildGoodsBLL.GetListByRedis(r.Id, ref tjCount, string.Empty, 0, 0, 1, 1, 4, "TopState desc,VirtualSalesCount+SalesCount desc,sort desc");
            //}
            if (listTjGoods != null && listTjGoods.Count > 0)
            {
                listTjGoods.ForEach(x =>
                {
                    platStore.TjGoods.Add(new TjGoods()
                    {
                        Aid       = x.AId,
                        Id        = x.Id,
                        Name      = x.Name,
                        Img       = x.Img,
                        PriceStr  = (x.PriceFen * 0.01).ToString("0.00"),
                        SaleCount = (x.SalesCount + x.VirtualSalesCount),
                        TopState  = x.TopState
                    });
                });
            }

            PlatApplyApp platApplyApp = PlatApplyAppBLL.SingleModel.GetPlatApplyAppByStoreId(platStore.Id);

            if (platApplyApp != null)
            {
                platStore.AppState = platApplyApp.OpenState;
            }

            if (!PlatStoreBLL.SingleModel.Update(platStore, "StorePV"))
            {
                returnObj.Msg = "更新店铺浏览量异常";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            //PlatMsgviewFavoriteShare msgview = _platMsgviewFavoriteShareBLL.GetModelByMsgId(platStore.BindPlatAid, platStore.Id,(int)PointsDataType.店铺);
            //if(msgview!=null)
            //{
            //    platStore.StorePV = msgview.ViewCount;
            //}

            PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModel(platStore.MyCardId);

            if (platMyCard != null)
            {
                platStore.storeOwner = new StoreOwner()
                {
                    UserId = platMyCard.UserId,
                    Name   = platMyCard.Name,
                    Avatar = platMyCard.ImgUrl,
                    State  = platMyCard.State,
                };
            }

            if (!string.IsNullOrEmpty(platStore.StoreService))
            {
                platStore.StoreServiceModelList = Newtonsoft.Json.JsonConvert.DeserializeObject <List <StoreServiceModel> >(platStore.StoreService);
            }
            else
            {
                List <StoreServiceModel> list = new List <StoreServiceModel>();
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "WIFI"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "停车位"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "支付宝支付"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "微信支付"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "刷卡支付"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "空调雅座"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "付费停车"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "接送服务"
                });
                platStore.StoreServiceModelList = list;
            }

            if (!string.IsNullOrEmpty(platStore.SwitchConfig))
            {
                platStore.SwitchModel = Newtonsoft.Json.JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig);
            }
            else
            {
                platStore.SwitchModel = new PlatStoreSwitchModel();
            }

            platStore.StorePV += platStore.StoreVirtualPV;
            returnObj.dataObj  = new
            {
                platStore = platStore
            };
            returnObj.isok = true;
            returnObj.Msg  = "获取成功";
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }