Пример #1
0
        bool CheckShopIsExpired(ActionExecutingContext filterContext)
        {
            var flag = true;

            if (ShopApplication.IsExpiredShop(CurrentSellerManager.ShopId))
            {
                string controllerName = filterContext.RouteData.Values["controller"].ToString().ToLower();
                string actionName     = filterContext.RouteData.Values["action"].ToString().ToLower();
                // string areaName = filterContext.RouteData.DataTokens["area"].ToString().ToLower();
                object area     = null;
                string areaName = "";
                if (filterContext.RouteData.Values.TryGetValue("area", out area))
                {
                    areaName = area.ToString().ToLower();
                }



                if ((controllerName == "shop" || controllerName == "accountsettings") && areaName == "selleradmin")
                {
                    return(true);//店铺和申请调用控制器返回验证通过
                }
                var result = new ViewResult()
                {
                    ViewName = "IsExpired"
                };
                // result.TempData.Add("Message", "你的店铺已过期;");
                // result.TempData.Add("Title", "你的店铺已过期!");
                TempData["Message"]  = "你的店铺已过期;";
                TempData["Title"]    = "你的店铺已过期!";
                filterContext.Result = result;
                flag = false;
            }
            if (ShopApplication.IsFreezeShop(CurrentSellerManager.ShopId))
            {
                var result = new ViewResult()
                {
                    ViewName = "IsFreeze"
                };
                // result.TempData.Add("Message", "抱歉,你的店铺已冻结,请与平台管理员联系…");
                // result.TempData.Add("Title", "你的店铺已冻结!");
                TempData["Message"] = "抱歉,你的店铺已冻结,请与平台管理员联系…";
                TempData["Title"]   = "你的店铺已冻结!";


                filterContext.Result = result;
                flag = false;
            }
            return(flag);
        }
Пример #2
0
        /// <summary>
        /// 门店列表
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetStoreList(string fromLatLng, string keyWords = "", long?tagsId = null, long?shopId = null, int pageNo = 1, int pageSize = 10)
        {
            //TODO:FG 异常查询 MysqlExecuted:226,耗时:1567.4137毫秒
            CheckOpenStore();
            ShopBranchQuery query = new ShopBranchQuery();

            query.PageNo                  = pageNo;
            query.PageSize                = pageSize;
            query.Status                  = ShopBranchStatus.Normal;
            query.ShopBranchName          = keyWords.Trim();
            query.ShopBranchTagId         = tagsId;
            query.CityId                  = -1;
            query.FromLatLng              = fromLatLng;
            query.OrderKey                = 2;
            query.OrderType               = true;
            query.ShopBranchProductStatus = ShopBranchSkuStatus.Normal;
            if (query.FromLatLng.Split(',').Length != 2)
            {
                throw new HimallException("无法获取您的当前位置,请确认是否开启定位服务!");
            }
            if (shopId.HasValue)
            {
                //var shop = ShopApplication.GetShopInfo(shopId.Value);
                var isFreeze = ShopApplication.IsFreezeShop(shopId.Value);
                if (isFreeze)
                {
                    return(Json(ErrorResult <dynamic>(msg: "此店铺已冻结")));
                }
                else
                {
                    var isExpired = ShopApplication.IsExpiredShop(shopId.Value);
                    if (isExpired)
                    {
                        return(Json(ErrorResult <dynamic>(msg: "此店铺已过期")));
                    }
                }
            }
            string address = "", province = "", city = "", district = "", street = "";
            string currentPosition = string.Empty;//当前详情地址,优先顺序:建筑、社区、街道
            Region cityInfo        = new Region();

            if (shopId.HasValue)//如果传入了商家ID,则只取商家下门店
            {
                query.ShopId = shopId.Value;
                if (query.ShopId <= 0)
                {
                    throw new HimallException("无法定位到商家!");
                }
            }
            else//否则取用户同城门店
            {
                var addressObj = ShopbranchHelper.GetAddressByLatLng(query.FromLatLng, ref address, ref province, ref city, ref district, ref street);
                if (string.IsNullOrWhiteSpace(city))
                {
                    city = province;
                }
                if (string.IsNullOrWhiteSpace(city))
                {
                    throw new HimallException("无法定位到城市!");
                }
                cityInfo = RegionApplication.GetRegionByName(city, Region.RegionLevel.City);
                if (cityInfo == null)
                {
                    throw new HimallException("无法定位到城市!");
                }
                if (cityInfo != null)
                {
                    query.CityId = cityInfo.Id;
                }
                //处理当前地址
                currentPosition = street;
            }
            var shopBranchs = ShopBranchApplication.SearchNearShopBranchs(query);
            //组装首页数据
            //补充门店活动数据
            var homepageBranchs = ProcessBranchHomePageData(shopBranchs.Models);

            AutoMapper.Mapper.CreateMap <HomePageShopBranch, HomeGetStoreListModel>();
            var  homeStores = AutoMapper.Mapper.Map <List <HomePageShopBranch>, List <HomeGetStoreListModel> >(homepageBranchs);
            long userId     = 0;

            if (CurrentUser != null)
            {//如果已登陆取购物车数据
                //memberCartInfo = CartApplication.GetShopBranchCart(CurrentUser.Id);
                userId = CurrentUser.Id;
            }
            //统一处理门店购物车数量
            var cartItemCount = ShopBranchApplication.GetShopBranchCartItemCount(userId, homeStores.Select(e => e.ShopBranch.Id).ToList());

            foreach (var item in homeStores)
            {
                //商品
                ShopBranchProductQuery proquery = new ShopBranchProductQuery();
                proquery.PageSize = 4;
                proquery.PageNo   = 1;
                proquery.OrderKey = 3;
                if (!string.IsNullOrWhiteSpace(keyWords))
                {
                    proquery.KeyWords = keyWords;
                }
                proquery.ShopBranchId            = item.ShopBranch.Id;
                proquery.ShopBranchProductStatus = ShopBranchSkuStatus.Normal;
                //proquery.FilterVirtualProduct = true;
                var pageModel = ShopBranchApplication.GetShopBranchProducts(proquery);
                var dtNow     = DateTime.Now;
                //var saleCountByMonth = OrderApplication.GetSaleCount(dtNow.AddDays(-30).Date, dtNow, shopBranchId: proquery.ShopBranchId.Value);
                item.SaleCount        = OrderApplication.GetSaleCount(shopBranchId: proquery.ShopBranchId.Value);
                item.SaleCountByMonth = ShopBranchApplication.GetShopBranchSaleCount(item.ShopBranch.Id, dtNow.AddDays(-30).Date, dtNow);
                item.ShowProducts     = pageModel.Models.Select(p =>
                {
                    var comcount = CommentApplication.GetProductHighCommentCount(productId: p.Id, shopBranchId: proquery.ShopBranchId.Value);
                    return(new HomeGetStoreListProductModel
                    {
                        Id = p.Id,
                        DefaultImage = HimallIO.GetRomoteProductSizeImage(p.ImagePath, 1, ImageSize.Size_150.GetHashCode()),
                        MinSalePrice = p.MinSalePrice,
                        ProductName = p.ProductName,
                        HasSKU = p.HasSKU,
                        MarketPrice = p.MarketPrice,
                        SaleCount = Himall.Core.Helper.TypeHelper.ObjectToInt(p.VirtualSaleCounts) + OrderApplication.GetSaleCount(dtNow.AddDays(-30).Date, dtNow, shopBranchId: proquery.ShopBranchId.Value, productId: p.Id),
                        HighCommentCount = comcount,
                    });
                }).ToList();
                item.ProductCount = pageModel.Total;
                if (cartItemCount != null)
                {
                    item.CartQuantity = cartItemCount.ContainsKey(item.ShopBranch.Id) ? cartItemCount[item.ShopBranch.Id] : 0;
                }
                //评分
                item.CommentScore = ShopBranchApplication.GetServiceMark(item.ShopBranch.Id).ComprehensiveMark;
            }
            return(JsonResult <dynamic>(new
            {
                Total = shopBranchs.Total,
                CityInfo = new { Id = cityInfo.Id, Name = cityInfo.Name },
                CurrentAddress = currentPosition,
                Stores = homeStores,
                ProductSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1
            }));
        }