Exemplo n.º 1
0
        public ActionResult VshopHomeSiteApp()
        {
            Models.VshopHomeSiteViewModel model = new Models.VshopHomeSiteViewModel();
            //未开通微店就进不去首页设置
            var vshop = _iVShopService.GetVShopByShopId(CurrentSellerManager.ShopId);

            model.VShop      = vshop;
            model.ShopId     = CurrentSellerManager.ShopId;
            model.SlideImage = _iSlideAdsService.GetSlidAds(CurrentSellerManager.ShopId, Entities.SlideAdInfo.SlideAdType.VShopHome).ToList();
            model.Banner     = _iNavigationService.GetSellerNavigations(CurrentSellerManager.ShopId, PlatformType.WeiXin).ToList();
            return(View(model));
        }
Exemplo n.º 2
0
        public static List <Mall.DTO.SlideAdModel> GetGuidePages()
        {
            var models = _iSlideAdsService.GetSlidAds(0, SlideAdInfo.SlideAdType.AppGuide).OrderBy(a => a.DisplaySequence).ToList();
            var m      = models.Select(a => new Mall.DTO.SlideAdModel()
            {
                Id              = a.Id,
                ShopId          = a.ShopId,
                DisplaySequence = a.DisplaySequence,
                ImageUrl        = a.ImageUrl,
                TypeId          = a.TypeId
            }).ToList();

            return(m);
        }
Exemplo n.º 3
0
        public ActionResult SlideImageSettings()
        {
            var slideImageSettings = _iSlideAdsService.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.WeixinHome).ToArray();
            var slideImageService  = _iSlideAdsService;
            var models             = slideImageSettings.Select(item =>
            {
                var slideImage = slideImageService.GetSlidAd(0, item.Id);
                return(new SlideAdModel()
                {
                    ID = item.Id,
                    imgUrl = item.ImageUrl,
                    DisplaySequence = item.DisplaySequence,
                    Url = item.Url,
                    Description = item.Description
                });
            });

            return(View(models));
        }
Exemplo n.º 4
0
        public JsonResult GetSlideImages()
        {
            //轮播图
            var slideImageSettings = _iSlideAdsService.GetSlidAds(0, SlideAdInfo.SlideAdType.IOSShopHome).ToArray();
            var slideImageService  = _iSlideAdsService;
            var slideModel         = slideImageSettings.Select(item =>
            {
                var slideImage = slideImageService.GetSlidAd(0, item.Id);
                return(new
                {
                    id = item.Id,
                    imgUrl = Core.HimallIO.GetImagePath(item.ImageUrl),
                    displaySequence = item.DisplaySequence,
                    url = item.Url,
                    description = item.Description
                });
            });

            return(Json(new { rows = slideModel, total = 100 }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取轮播图
        /// </summary>
        /// <returns></returns>
        public List <Entities.SlideAdInfo> GetSlideAds()
        {
            ISlideAdsService _ISlideAdsService = ServiceApplication.Create <ISlideAdsService>();
            var sql    = _ISlideAdsService.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.AppGifts);
            var result = sql.ToList();

            foreach (var item in result)
            {
                item.ImageUrl = HimallIO.GetRomoteImagePath(item.ImageUrl);
            }
            return(result);
        }
Exemplo n.º 6
0
        public JsonResult GetSlideImages(int id)
        {
            //轮播图
            var slideImageSettings = _iSlideAdsService.GetSlidAds(0, (Entities.SlideAdInfo.SlideAdType)id).ToArray();
            var slideImageService  = _iSlideAdsService;
            var slideModel         = slideImageSettings.Select(item =>
            {
                //var slideImage = slideImageService.GetSlidAd(0, item.Id);

                return(new
                {
                    id = item.Id,
                    imgUrl = Core.MallIO.GetImagePath(item.ImageUrl),
                    displaySequence = item.DisplaySequence,
                    url = item.Url + "," + GetLinkName(item.Url),
                    description = item.Description
                });
            });

            return(Json(new { rows = slideModel, total = 100 }));
        }
        public JsonResult GetSlideJson()
        {
            var data = _iSlideAdsService.GetSlidAds(0, SlideAdInfo.SlideAdType.PlatformLimitTime);
            IEnumerable <HandSlideModel> slide = data.ToArray().Select(item => new HandSlideModel()
            {
                Id    = item.Id,
                Pic   = Core.HimallIO.GetImagePath(item.ImageUrl),
                URL   = item.Url,
                Index = item.DisplaySequence
            });

            DataGridModel <HandSlideModel> dataGrid = new DataGridModel <HandSlideModel>()
            {
                rows = slide, total = slide.Count()
            };

            return(Json(dataGrid));
        }
Exemplo n.º 8
0
        public JsonResult AppGetSlideImages()
        {
            //轮播图
            var slideImageSettings = _iSlideAdsService.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.AppGifts).ToArray();
            var slideImageService  = _iSlideAdsService;
            var slideModel         = slideImageSettings.Select(item =>
            {
                var slideImage = slideImageService.GetSlidAd(0, item.Id);
                return(new
                {
                    id = item.Id,
                    imgUrl = Core.MallIO.GetImagePath(item.ImageUrl),
                    displaySequence = item.DisplaySequence,
                    url = item.Url,
                    description = item.Description
                });
            });

            return(Json(new { rows = slideModel, total = slideModel.Count() }));
        }
Exemplo n.º 9
0
        public ActionResult Index()
        {
            //轮播图
            var slideImageSettings = _iSlideAdsService.GetSlidAds(0, SlideAdInfo.SlideAdType.DistributionHome).ToList();

            ViewBag.slideImage = slideImageSettings;

            CheckPromoter();
            //首页推荐商品
            var models = DistributionApplication.GetDistributionProducts(CurrentUser.Id);

            foreach (var product in models)
            {
                product.Image = HimallIO.GetRomoteProductSizeImage(product.Image, 1, (int)Himall.CommonModel.ImageSize.Size_100);
            }
            #region 二维码
            var    curhttp = System.Web.HttpContext.Current;
            string url     = curhttp.Request.Url.Scheme + "://" + curhttp.Request.Url.Authority;;
            url = url + Url.Action("Index", "DistributionMarket");

            ViewBag.ShopQCodeUrl = url;

            var    map      = Core.Helper.QRCodeHelper.Create(url);
            string fileName = "/temp/" + curUserId + DateTime.Now.ToString("yyMMddHHmmssffffff") + ".jpg";
            map.Save(Server.MapPath(fileName));
            map.Dispose();

            ViewBag.ShopQCode      = fileName;
            ViewBag.WeiXinDisIndex = false;
            if (!string.IsNullOrWhiteSpace(this._siteSetting.WeixinAppId) && !string.IsNullOrWhiteSpace(this._siteSetting.WeixinAppSecret) && (PlatformType == PlatformType.WeiXin))
            {
                ViewBag.WeiXinDisIndex = true;
            }
            #endregion
            return(View(models));
        }
Exemplo n.º 10
0
        public ActionResult SlideAds()
        {
            var slides = _iSlideAdsService.GetSlidAds(CurrentSellerManager.ShopId, Entities.SlideAdInfo.SlideAdType.ShopHome);

            return(View(slides));
        }
Exemplo n.º 11
0
        public ActionResult Home(string id)
        {
            long     shopId  = 0;
            ShopInfo shopObj = null;

            //shopId 不是数字
            if (!long.TryParse(id, out shopId))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            //店铺Id不存在
            shopObj = _iShopService.GetShop(shopId);
            if (null == shopObj)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            #region 初始化Model

            ShopHomeModel model = new ShopHomeModel
            {
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Floors       = new List <ShopHomeFloor>(),
                Navignations = new List <BannerInfo>(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Slides       = new List <SlideAdInfo>(),
                Logo         = ""
            };


            #endregion

            #region 店铺信息

            var mark = ShopServiceMark.GetShopComprehensiveMark(shopObj.Id);
            model.Shop.Name              = shopObj.ShopName;
            model.Shop.CompanyName       = shopObj.CompanyName;
            model.Shop.Id                = shopObj.Id;
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Phone             = shopObj.CompanyPhone;
            model.Shop.Address           = _iRegionService.GetFullName(shopObj.CompanyRegionId);
            model.Logo = shopObj.Logo;

            #endregion

            if (shopObj.IsSelf)
            {
                model.Shop.PackMark          = 5;
                model.Shop.ServiceMark       = 5;
                model.Shop.ComprehensiveMark = 5;
            }



            #region 导航和3个推荐商品

            //导航
            model.Navignations = _iNavigationService.GetSellerNavigations(shopObj.Id).ToList();

            //banner和3个推荐商品
            var list = _iSlideAdsService.GetImageAds(shopObj.Id).OrderBy(item => item.Id).ToList();
            model.ImageAds     = list.Where(p => !p.IsTransverseAD).ToList();
            model.TransverseAD = list.FirstOrDefault(p => p.IsTransverseAD);
            model.Slides       = _iSlideAdsService.GetSlidAds(shopObj.Id, SlideAdInfo.SlideAdType.ShopHome).ToList();

            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(shopObj.Id).ToList();
            foreach (var main in categories.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in categories.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }

            #endregion

            #region 楼层信息

            var shopHomeModules = _iShopHomeModuleService.GetAllShopHomeModuleInfos(shopObj.Id).Where(a => a.IsEnable).ToArray().OrderBy(p => p.DisplaySequence);
            foreach (var item in shopHomeModules)
            {
                List <ShopHomeFloorProduct> products = new List <ShopHomeFloorProduct>();
                foreach (var p in item.ShopHomeModuleProductInfo.Where(d => d.ProductInfo.AuditStatus == ProductInfo.ProductAuditStatus.Audited && d.ProductInfo.SaleStatus == ProductInfo.ProductSaleStatus.OnSale).ToList().OrderBy(p => p.DisplaySequence))
                {
                    products.Add(new ShopHomeFloorProduct
                    {
                        Id        = p.ProductId,
                        Name      = p.ProductInfo.ProductName,
                        Pic       = p.ProductInfo.ImagePath,
                        Price     = p.ProductInfo.MinSalePrice.ToString("f2"),
                        SaleCount = (int)_iProductService.GetProductVistInfo(p.ProductInfo.Id).SaleCounts
                    });
                }

                List <ShopHomeFloorTopImg> topimgs = new List <ShopHomeFloorTopImg>();
                foreach (var i in item.Himall_ShopHomeModulesTopImg.ToList().OrderBy(p => p.DisplaySequence))
                {
                    topimgs.Add(new ShopHomeFloorTopImg
                    {
                        Url     = i.Url,
                        ImgPath = i.ImgPath
                    });
                }
                ShopHomeFloor floor = new ShopHomeFloor
                {
                    FloorName = item.Name,
                    FloorUrl  = item.Url,
                    Products  = products,
                    TopImgs   = topimgs
                };

                model.Floors.Add(floor);
            }
            #endregion

            #region 热门销售

            var sale = _iProductService.GetHotSaleProduct(shopObj.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale.ToArray())
                {
                    model.HotSaleProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts
                    });
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shopObj.Id, 5);
            if (hot != null)
            {
                foreach (var item in hot.ToList())
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 累加浏览次数

            _iShopService.LogShopVisti(shopObj.Id);

            #endregion

            #region 微店二维码
            var    vshop    = _iVShopService.GetVShopByShopId(shopObj.Id);
            string vshopUrl = "";
            if (vshop != null)
            {
                vshopUrl = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshop.Id;
                CreateQR(model, vshop.Logo, vshopUrl);
            }
            else
            {
                vshopUrl = "http://" + HttpContext.Request.Url.Host + "/m-" + PlatformType.WeiXin.ToString();
                CreateQR(model, string.Empty, vshopUrl);
            }
            #endregion

            #region 店铺页脚
            model.Footer = _iShopHomeModuleService.GetFooter(shopObj.Id);
            #endregion

            ViewBag.IsExpired = _iShopService.IsExpiredShop(shopId);
            ViewBag.IsFreeze  = _iShopService.IsFreezeShop(shopId);

            //补充当前店铺红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = shopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = shopId;
            //统计店铺访问人数
            StatisticApplication.StatisticShopVisitUserCount(shopId);
            return(View(model));
        }
Exemplo n.º 12
0
        // GET: Web/Shop
        // [OutputCache(VaryByParam = "id", Duration = ConstValues.PAGE_CACHE_DURATION)]
        public ActionResult Home(string id)
        {
            long shopId = 0;

            Entities.ShopInfo shopObj = null;

            //shopId 不是数字
            if (!long.TryParse(id, out shopId))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            //店铺Id不存在
            shopObj = _iShopService.GetShop(shopId);
            if (null == shopObj)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
                //404 页面
            }

            #region 初始化Model

            ShopHomeModel model = new ShopHomeModel
            {
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Floors       = new List <ShopHomeFloor>(),
                Navignations = new List <Entities.BannerInfo>(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Slides       = new List <Entities.SlideAdInfo>(),
                Logo         = ""
            };


            #endregion

            #region 店铺信息

            var mark = ShopServiceMark.GetShopComprehensiveMark(shopObj.Id);
            model.Shop.Name              = shopObj.ShopName;
            model.Shop.CompanyName       = shopObj.CompanyName;
            model.Shop.Id                = shopObj.Id;
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Phone             = shopObj.CompanyPhone;
            model.Shop.Address           = _iRegionService.GetFullName(shopObj.CompanyRegionId);
            model.Logo = shopObj.Logo;

            #endregion

            if (shopObj.IsSelf)
            {
                model.Shop.PackMark          = 5;
                model.Shop.ServiceMark       = 5;
                model.Shop.ComprehensiveMark = 5;
            }



            #region 导航和3个推荐商品

            //导航
            model.Navignations = _iNavigationService.GetSellerNavigations(shopObj.Id).ToList();

            //banner和3个推荐商品
            var list = _iSlideAdsService.GetImageAds(shopObj.Id).OrderBy(item => item.Id).ToList();
            model.ImageAds     = list.Where(p => !p.IsTransverseAD).ToList();
            model.TransverseAD = list.FirstOrDefault(p => p.IsTransverseAD);
            model.Slides       = _iSlideAdsService.GetSlidAds(shopObj.Id, Entities.SlideAdInfo.SlideAdType.ShopHome).ToList();

            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(shopObj.Id).Where(a => a.IsShow).ToList();//这里不好写到底层去,有些地方产品设计上不需要过滤
            foreach (var main in categories.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in categories.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }

            #endregion

            #region 楼层信息
            bool isSaleCountOnOff     = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1;
            var  shopHomeModules      = _iShopHomeModuleService.GetAllShopHomeModuleInfos(shopObj.Id).Where(a => a.IsEnable).OrderBy(p => p.DisplaySequence);
            ShopHomeFloorProduct info = null;
            var modules        = shopHomeModules.Select(p => p.Id).ToList();
            var imgs           = _iShopHomeModuleService.GetImages(modules);
            var moduleProducts = _iShopHomeModuleService.GetProducts(modules);
            var onSaleProducts = ProductManagerApplication.GetOnSaleProducts(moduleProducts.Select(p => p.ProductId).ToList());

            foreach (var item in shopHomeModules)
            {
                List <ShopHomeFloorProduct> products = new List <ShopHomeFloorProduct>();
                var moduleProduct = moduleProducts.Where(p => p.HomeModuleId == item.Id);
                foreach (var p in moduleProduct.OrderBy(p => p.DisplaySequence))
                {
                    var product = onSaleProducts.FirstOrDefault(x => x.Id == p.ProductId);
                    if (product == null)
                    {
                        continue;
                    }
                    info = new ShopHomeFloorProduct
                    {
                        Id    = product.Id,
                        Name  = product.ProductName,
                        Pic   = product.ImagePath,
                        Price = product.MinSalePrice.ToString("f2"),
                        //TODO:FG 循环查询销量 待优化
                        SaleCount = (int)_iProductService.GetProductVistInfo(product.Id).SaleCounts
                    };

                    if (isSaleCountOnOff)
                    {
                        info.SaleCount = info.SaleCount + (int)product.VirtualSaleCounts;
                    }
                    products.Add(info);
                }
                var topimgs = imgs
                              .Where(p => p.HomeModuleId == item.Id)
                              .OrderBy(p => p.DisplaySequence)
                              .Select(i => new ShopHomeFloorTopImg
                {
                    Url     = i.Url,
                    ImgPath = i.ImgPath
                }).ToList();

                model.Floors.Add(new ShopHomeFloor
                {
                    FloorName = item.Name,
                    FloorUrl  = item.Url,
                    Products  = products,
                    TopImgs   = topimgs
                });
            }
            #endregion

            #region 热门销售
            //热门销售不受平台销量开关影响
            var sale = _iProductService.GetHotSaleProduct(shopObj.Id, 5);
            if (sale != null)
            {
                HotProductInfo hotInfo = null;
                foreach (var item in sale.ToArray())
                {
                    hotInfo = new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts
                    };
                    hotInfo.SaleCount = hotInfo.SaleCount + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts);
                    model.HotSaleProducts.Add(hotInfo);
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shopObj.Id, 5);
            if (hot != null)
            {
                HotProductInfo hot_Info = null;
                foreach (var item in hot.ToList())
                {
                    hot_Info = new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    };
                    model.HotAttentionProducts.Add(hot_Info);
                }
            }
            #endregion


            #region 微店二维码
            var    vshop    = _iVShopService.GetVShopByShopId(shopObj.Id);
            string vshopUrl = "";
            if (vshop != null)
            {
                vshopUrl = CurrentUrlHelper.CurrentUrlNoPort() + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshop.Id;
                CreateQR(model, vshop.StrLogo, vshopUrl);
            }
            else
            {
                vshopUrl = CurrentUrlHelper.CurrentUrlNoPort() + "/m-" + PlatformType.WeiXin.ToString();
                CreateQR(model, string.Empty, vshopUrl);
            }
            #endregion

            #region 店铺页脚
            model.Footer = _iShopHomeModuleService.GetFooter(shopObj.Id);
            #endregion

            ViewBag.IsExpired = _iShopService.IsExpiredShop(shopId);
            ViewBag.IsFreeze  = _iShopService.IsFreezeShop(shopId);

            //补充当前店铺红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = shopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = shopId;
            //统计店铺访问人数
            StatisticApplication.StatisticShopVisitUserCount(shopId);
            ViewBag.Keyword          = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords         = SiteSettings.HotKeyWords;
            ViewBag.IsOpenTopImageAd = shopObj.IsOpenTopImageAd;
            return(View(model));
        }
Exemplo n.º 13
0
        // GET: Web/LimitTimeBuy
        public ActionResult Home(
            string keywords = "", /* 搜索关键字 */
            string catename = "", /* 分类名*/
            int orderKey    = 5,  /* 排序项(1:默认,2:销量,3:价格,4 : 结束时间,5:状态) */
            int orderType   = 1,  /* 排序方式(1:升序,2:降序) */
            int isStart     = 0,  /*是否开始( 1 : 开始 , 2 : 未开始 )*/
            int pageNo      = 1,  /*页码*/
            int pageSize    = 60  /*每页显示数据量*/
            )
        {
            #region 初始化查询Model
            FlashSaleQuery model = new FlashSaleQuery()
            {
                ItemName           = keywords,
                OrderKey           = orderKey,
                OrderType          = orderType,
                CategoryName       = catename,
                IsStart            = isStart,
                IsPreheat          = true,
                PageNo             = pageNo,
                PageSize           = pageSize,
                AuditStatus        = FlashSaleInfo.FlashSaleStatus.Ongoing,
                CheckProductStatus = true
            };

            #endregion

            #region ViewBag

            List <SelectListItem> CateSelItem = new List <SelectListItem>();
            var cateArray = _iLimitTimeBuyService.GetServiceCategories();
            foreach (var cate in cateArray)
            {
                CateSelItem.Add(new SelectListItem {
                    Selected = false, Text = cate, Value = cate
                });
            }
            if (!string.IsNullOrWhiteSpace(catename))
            {
                var _tmp = CateSelItem.FirstOrDefault(c => c.Text.Equals(catename));
                if (_tmp != null)
                {
                    _tmp.Selected = true;
                }
            }

            ViewBag.Cate      = CateSelItem;
            ViewBag.keywords  = keywords;
            ViewBag.orderKey  = orderKey;
            ViewBag.orderType = orderType;
            ViewBag.catename  = catename;
            ViewBag.Logined   = (null != CurrentUser) ? 1 : 0;
            ViewBag.isStart   = isStart;
            ViewBag.Slide     = _iSlideAdsService.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.PlatformLimitTime);

            #endregion


            #region 查询商品

            //var itemsModel = _iLimitTimeBuyService.GetItemList(model);
            var itemsModel = _iLimitTimeBuyService.GetAll(model);
            int total      = itemsModel.Total;
            var items      = itemsModel.Models.ToArray();


            if (itemsModel.Total == 0)
            {
                ViewBag.keywords = keywords;
                return(View());
            }

            ViewBag.Products = ProductManagerApplication.GetProducts(items.Select(p => p.ProductId));
            #endregion


            #region 分页控制
            PagingInfo info = new PagingInfo
            {
                CurrentPage  = model.PageNo,
                ItemsPerPage = pageSize,
                TotalItems   = total
            };
            ViewBag.pageInfo = info;
            #endregion

            return(View(items ?? new FlashSaleInfo[] { }));
        }
Exemplo n.º 14
0
        public ActionResult Index()
        {
            if (!IsInstalled())
            {
                return(RedirectToAction("Agreement", "Installer"));
            }
            var ser_user = _iMemberService;

            #region 初始化首页数据
            var homePageModel = new HomePageModel();

            if (CurrentSiteSetting.AdvertisementState)
            {
                homePageModel.AdvertisementUrl       = CurrentSiteSetting.AdvertisementUrl;
                homePageModel.AdvertisementImagePath = CurrentSiteSetting.AdvertisementImagePath;
            }

            //获取信任登录插件需要在首页head中填充的验证内容
            ViewBag.OAuthValidateContents = GetOAuthValidateContents();
            homePageModel.SiteName        = CurrentSiteSetting.SiteName;
            homePageModel.Title           = string.IsNullOrWhiteSpace(CurrentSiteSetting.Site_SEOTitle) ? "商城首页" : CurrentSiteSetting.Site_SEOTitle;
            var view = ViewEngines.Engines.FindView(ControllerContext, "Index", null);
            List <HomeFloorModel> floorModels = new List <HomeFloorModel>();
            homePageModel.handImage = _iSlideAdsService.GetHandSlidAds().ToList();
            var silder = _iSlideAdsService.GetSlidAds(0, SlideAdInfo.SlideAdType.PlatformHome).ToList();
            homePageModel.slideImage = silder;
            var imageAds = _iSlideAdsService.GetImageAds(0).ToList();
            //人气单品
            homePageModel.imageAds = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.Single).ToList();
            //banner右侧广告
            homePageModel.imageAdsTop = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.BannerAds).ToList();

            homePageModel.CenterAds = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.Customize).ToList();
            homePageModel.ShopAds   = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.BrandsAds).ToList();

            if (homePageModel.imageAds.Count == 0)
            {
                homePageModel.imageAds = imageAds.Take(8).ToList();
            }
            if (homePageModel.imageAdsTop.Count == 0)
            {
                homePageModel.imageAdsTop = imageAds.Take(2).ToList();
            }
            if (homePageModel.CenterAds.Count == 0)
            {
                homePageModel.CenterAds = imageAds.Take(3).ToList();
            }
            if (homePageModel.ShopAds.Count == 0)
            {
                homePageModel.ShopAds = imageAds.Take(2).ToList();
            }

            /*没地方用,先去掉
             * var articleService = ServiceHelper.Create<IArticleService>();
             * ViewBag.ArticleTabs = new List<IQueryable<ArticleInfo>>()
             * {   articleService.GetTopNArticle<ArticleInfo>(8, 4),
             *      articleService.GetTopNArticle<ArticleInfo>(8, 5),
             *      articleService.GetTopNArticle<ArticleInfo>(8, 6),
             *      articleService.GetTopNArticle<ArticleInfo>(8, 7)
             * };
             */

            //楼层数据
            var floors = _iFloorService.GetHomeFloors().ToList();
            foreach (var f in floors)
            {
                var model          = new HomeFloorModel();
                var texts          = f.FloorTopicInfo.Where(a => a.TopicType == Position.Top).ToList();
                var products       = f.FloorTopicInfo.Where(a => a.TopicType != Position.Top).ToList();
                var productModules = f.FloorProductInfo.ToList();
                var brands         = f.FloorBrandInfo.Take(10).ToList();
                model.Name           = f.FloorName;
                model.SubName        = f.SubName;
                model.StyleLevel     = f.StyleLevel;
                model.DefaultTabName = f.DefaultTabName;

                //文本设置
                foreach (var s in texts)
                {
                    model.TextLinks.Add(new HomeFloorModel.WebFloorTextLink()
                    {
                        Id   = s.Id,
                        Name = s.TopicName,
                        Url  = s.Url
                    });
                }

                //广告设置
                foreach (var s in products)
                {
                    model.Products.Add(new HomeFloorModel.WebFloorProductLinks
                    {
                        Id       = s.Id,
                        ImageUrl = s.TopicImage,
                        Url      = s.Url,
                        Type     = s.TopicType
                    });
                }

                //推荐品牌
                foreach (var s in brands)
                {
                    model.Brands.Add(new WebFloorBrand
                    {
                        Id   = s.BrandInfo.Id,
                        Img  = s.BrandInfo.Logo,
                        Url  = "",
                        Name = s.BrandInfo.Name
                    });
                }

                //推荐商品
                foreach (var s in productModules)
                {
                    model.ProductModules.Add(new HomeFloorModel.ProductModule
                    {
                        Id          = s.Id,
                        ProductId   = s.ProductId,
                        MarketPrice = s.ProductInfo.MarketPrice,
                        price       = s.ProductInfo.MinSalePrice,
                        productImg  = Himall.Core.HimallIO.GetProductSizeImage(s.ProductInfo.ImagePath, 1, (int)ImageSize.Size_350),
                        productName = s.ProductInfo.ProductName,
                        Tab         = s.Tab
                    });
                }

                if (model.StyleLevel == 1 || model.StyleLevel == 4 || model.StyleLevel == 5 || model.StyleLevel == 6 || model.StyleLevel == 7)
                {
                    model.Tabs = f.Himall_FloorTabls.OrderBy(p => p.Id).Select(p => new Himall.Web.Areas.Web.Models.HomeFloorModel.Tab()
                    {
                        Name   = p.Name,
                        Detail = p.Himall_FloorTablDetails.ToList()
                                 .Where(d => d.Himall_Products.AuditStatus == ProductInfo.ProductAuditStatus.Audited &&
                                        d.Himall_Products.SaleStatus == ProductInfo.ProductSaleStatus.OnSale)
                                 .Select(d => new Himall.Web.Areas.Web.Models.HomeFloorModel.ProductDetail()
                        {
                            ProductId = d.Himall_Products.Id,
                            ImagePath = Himall.Core.HimallIO.GetProductSizeImage(d.Himall_Products.ImagePath, 1, (int)ImageSize.Size_350),
                            Price     = d.Himall_Products.MinSalePrice,
                            Name      = d.Himall_Products.ProductName
                        }).ToList()
                    }).ToList();

                    model.Scrolls = model.Products.Where(p => p.Type == Position.ScrollOne || p.Type == Position.ScrollTwo ||
                                                         p.Type == Position.ScrollThree || p.Type == Position.ScrollFour).ToList();

                    model.RightTops = model.Products.Where(p => p.Type == Position.ROne || p.Type == Position.RTwo ||
                                                           p.Type == Position.RThree || p.Type == Position.RFour).ToList();

                    model.RightBottons = model.Products.Where(p => p.Type == Position.RFive || p.Type == Position.RSix ||
                                                              p.Type == Position.RSeven || p.Type == Position.REight).ToList();
                }
                floorModels.Add(model);
            }
            homePageModel.floorModels = floorModels;

            //全部品牌
            HomeBrands homeBrands = new HomeBrands();
            var        listBrands = Application.BrandApplication.GetBrands(null);
            foreach (var item in listBrands)
            {
                homeBrands.listBrands.Add(new WebFloorBrand
                {
                    Id   = item.Id,
                    Img  = item.Logo,
                    Url  = "",
                    Name = item.Name
                });
            }
            homePageModel.brands = homeBrands;

            //限时购
            var setting = _iSiteSettingService.GetSiteSettings();
            if (setting.Limittime)
            {
                homePageModel.FlashSaleModel = _iLimitTimeBuyService.GetRecentFlashSale();
            }
            else
            {
                homePageModel.FlashSaleModel = new List <FlashSaleModel>();
            }

            return(View(homePageModel));

            #endregion
        }