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)); }
public ActionResult Home(string id) { int i; long num = 0; ShopInfo shop = null; if (!long.TryParse(id, out num)) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } shop = ServiceHelper.Create <IShopService>().GetShop(num, false); if (shop == null) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } ShopHomeModel shopHomeModel = 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 = "" }; ShopHomeModel shopName = shopHomeModel; IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(num); StatisticOrderCommentsInfo statisticOrderCommentsInfo = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 1 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo1 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 9 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo2 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 5 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo3 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 2 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo4 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 10 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo5 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 6 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo6 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 3 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo7 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 4 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo8 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 11 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo9 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 12 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo10 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 7 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo11 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 8 select c).FirstOrDefault(); int num1 = 5; if (statisticOrderCommentsInfo == null || statisticOrderCommentsInfo3 == null) { ViewBag.ProductAndDescription = num1; ViewBag.ProductAndDescriptionPeer = num1; ViewBag.ProductAndDescriptionMin = num1; ViewBag.ProductAndDescriptionMax = num1; } else { ViewBag.ProductAndDescription = statisticOrderCommentsInfo.CommentValue; ViewBag.ProductAndDescriptionPeer = statisticOrderCommentsInfo3.CommentValue; ViewBag.ProductAndDescriptionMin = statisticOrderCommentsInfo7.CommentValue; ViewBag.ProductAndDescriptionMax = statisticOrderCommentsInfo6.CommentValue; } if (statisticOrderCommentsInfo1 == null || statisticOrderCommentsInfo4 == null) { ViewBag.SellerServiceAttitude = num1; ViewBag.SellerServiceAttitudePeer = num1; ViewBag.SellerServiceAttitudeMax = num1; ViewBag.SellerServiceAttitudeMin = num1; } else { ViewBag.SellerServiceAttitude = statisticOrderCommentsInfo1.CommentValue; ViewBag.SellerServiceAttitudePeer = statisticOrderCommentsInfo4.CommentValue; ViewBag.SellerServiceAttitudeMax = statisticOrderCommentsInfo8.CommentValue; ViewBag.SellerServiceAttitudeMin = statisticOrderCommentsInfo9.CommentValue; } if (statisticOrderCommentsInfo5 == null || statisticOrderCommentsInfo2 == null) { ViewBag.SellerDeliverySpeed = num1; ViewBag.SellerDeliverySpeedPeer = num1; ViewBag.SellerDeliverySpeedMax = num1; ViewBag.sellerDeliverySpeedMin = num1; } else { ViewBag.SellerDeliverySpeed = statisticOrderCommentsInfo2.CommentValue; ViewBag.SellerDeliverySpeedPeer = statisticOrderCommentsInfo5.CommentValue; ViewBag.SellerDeliverySpeedMax = statisticOrderCommentsInfo10.CommentValue; ViewBag.sellerDeliverySpeedMin = statisticOrderCommentsInfo11.CommentValue; } ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id); shopName.Shop.Name = shop.ShopName; shopName.Shop.CompanyName = shop.CompanyName; shopName.Shop.Id = shop.Id; shopName.Shop.PackMark = shopComprehensiveMark.PackMark; shopName.Shop.ServiceMark = shopComprehensiveMark.ServiceMark; shopName.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark; shopName.Shop.Phone = shop.CompanyPhone; shopName.Shop.Address = ServiceHelper.Create <IRegionService>().GetRegionFullName(shop.CompanyRegionId, " "); shopName.Logo = shop.Logo; shopName.Navignations = ServiceHelper.Create <INavigationService>().GetSellerNavigations(shop.Id, PlatformType.PC).ToList(); shopName.ImageAds = ( from item in ServiceHelper.Create <ISlideAdsService>().GetImageAds(shop.Id) orderby item.Id select item).ToList(); shopName.Slides = ServiceHelper.Create <ISlideAdsService>().GetSlidAds(shop.Id, SlideAdInfo.SlideAdType.ShopHome).ToList(); List <ShopCategoryInfo> list = ServiceHelper.Create <IShopCategoryService>().GetShopCategory(shop.Id).ToList(); foreach (ShopCategoryInfo shopCategoryInfo in from s in list where s.ParentCategoryId == 0 select s) { CategoryJsonModel categoryJsonModel = new CategoryJsonModel() { Name = shopCategoryInfo.Name, Id = shopCategoryInfo.Id.ToString(), SubCategory = new List <SecondLevelCategory>() }; CategoryJsonModel categoryJsonModel1 = categoryJsonModel; foreach (ShopCategoryInfo shopCategoryInfo1 in from s in list where s.ParentCategoryId == shopCategoryInfo.Id select s) { SecondLevelCategory secondLevelCategory = new SecondLevelCategory() { Name = shopCategoryInfo1.Name, Id = shopCategoryInfo1.Id.ToString() }; categoryJsonModel1.SubCategory.Add(secondLevelCategory); } shopName.ShopCategory.Add(categoryJsonModel1); } ShopHomeModuleInfo[] array = ServiceHelper.Create <IShopHomeModuleService>().GetAllShopHomeModuleInfos(shop.Id).ToArray(); ShopHomeModuleInfo[] shopHomeModuleInfoArray = array; for (i = 0; i < shopHomeModuleInfoArray.Length; i++) { ShopHomeModuleInfo shopHomeModuleInfo = shopHomeModuleInfoArray[i]; List <ShopHomeFloorProduct> shopHomeFloorProducts = new List <ShopHomeFloorProduct>(); foreach (ShopHomeModuleProductInfo shopHomeModuleProductInfo in shopHomeModuleInfo.ShopHomeModuleProductInfo.ToList()) { ShopHomeFloorProduct shopHomeFloorProduct = new ShopHomeFloorProduct() { Id = shopHomeModuleProductInfo.ProductId, Name = shopHomeModuleProductInfo.ProductInfo.ProductName, Pic = shopHomeModuleProductInfo.ProductInfo.ImagePath, Price = shopHomeModuleProductInfo.ProductInfo.MinSalePrice.ToString("f2"), SaleCount = (int)ServiceHelper.Create <IProductService>().GetProductVistInfo(shopHomeModuleProductInfo.ProductInfo.Id, null).SaleCounts }; shopHomeFloorProducts.Add(shopHomeFloorProduct); } ShopHomeFloor shopHomeFloor = new ShopHomeFloor() { FloorName = shopHomeModuleInfo.Name, Products = shopHomeFloorProducts }; shopName.Floors.Add(shopHomeFloor); } IQueryable <ProductInfo> hotSaleProduct = ServiceHelper.Create <IProductService>().GetHotSaleProduct(shop.Id, 5); if (hotSaleProduct != null) { ProductInfo[] productInfoArray = hotSaleProduct.ToArray(); for (i = 0; i < productInfoArray.Length; i++) { ProductInfo productInfo = productInfoArray[i]; List <HotProductInfo> hotSaleProducts = shopName.HotSaleProducts; HotProductInfo hotProductInfo = new HotProductInfo() { ImgPath = productInfo.ImagePath, Name = productInfo.ProductName, Price = productInfo.MinSalePrice, Id = productInfo.Id, SaleCount = (int)productInfo.SaleCounts }; hotSaleProducts.Add(hotProductInfo); } } IQueryable <ProductInfo> hotConcernedProduct = ServiceHelper.Create <IProductService>().GetHotConcernedProduct(shop.Id, 5); if (hotConcernedProduct != null) { foreach (ProductInfo list1 in hotConcernedProduct.ToList()) { List <HotProductInfo> hotAttentionProducts = shopName.HotAttentionProducts; HotProductInfo hotProductInfo1 = new HotProductInfo() { ImgPath = list1.ImagePath, Name = list1.ProductName, Price = list1.MinSalePrice, Id = list1.Id, SaleCount = list1.ConcernedCount }; hotAttentionProducts.Add(hotProductInfo1); } } ServiceHelper.Create <IShopService>().LogShopVisti(shop.Id); ViewBag.IsExpired = ServiceHelper.Create <IShopService>().IsExpiredShop(num); return(View(shopName)); }