コード例 #1
0
ファイル: VShopController.cs プロジェクト: giagiigi/ChemCloud
        public ActionResult Introduce(long id)
        {
            Image     image;
            VShopInfo vShop = ServiceHelper.Create <IVShopService>().GetVShop(id);
            string    empty = string.Empty;

            if (vShop != null)
            {
                object[] host = new object[] { "http://", base.HttpContext.Request.Url.Host, "/m-", ChemCloud.Core.PlatformType.WeiXin.ToString(), "/vshop/detail/", id };
                string   str  = string.Concat(host);
                string   str1 = Server.MapPath(vShop.Logo);
                image = (string.IsNullOrWhiteSpace(vShop.Logo) || !System.IO.File.Exists(str1) ? QRCodeHelper.Create(str) : QRCodeHelper.Create(str, str1));
                DateTime now  = DateTime.Now;
                string   str2 = string.Concat(now.ToString("yyMMddHHmmssffffff"), ".jpg");
                empty = string.Concat("/temp/", str2);
                image.Save(string.Concat(Server.MapPath("~/temp/"), str2));
            }
            ViewBag.QRCode = empty;
            if (base.CurrentUser != null)
            {
                ViewBag.IsFavorite = ServiceHelper.Create <IShopService>().IsFavoriteShop(base.CurrentUser.Id, vShop.ShopId);
            }
            else
            {
                ViewBag.IsFavorite = false;
            }
            ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(vShop.ShopId);
            dynamic viewBag           = base.ViewBag;
            decimal comprehensiveMark = shopComprehensiveMark.ComprehensiveMark;

            viewBag.shopMark = comprehensiveMark.ToString();
            IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(vShop.ShopId);
            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 num = 5;

            if (statisticOrderCommentsInfo == null || statisticOrderCommentsInfo3 == null)
            {
                ViewBag.ProductAndDescription     = num;
                ViewBag.ProductAndDescriptionPeer = num;
                ViewBag.ProductAndDescriptionMin  = num;
                ViewBag.ProductAndDescriptionMax  = num;
            }
            else
            {
                ViewBag.ProductAndDescription     = statisticOrderCommentsInfo.CommentValue;
                ViewBag.ProductAndDescriptionPeer = statisticOrderCommentsInfo3.CommentValue;
                ViewBag.ProductAndDescriptionMin  = statisticOrderCommentsInfo7.CommentValue;
                ViewBag.ProductAndDescriptionMax  = statisticOrderCommentsInfo6.CommentValue;
            }
            if (statisticOrderCommentsInfo1 == null || statisticOrderCommentsInfo4 == null)
            {
                ViewBag.SellerServiceAttitude     = num;
                ViewBag.SellerServiceAttitudePeer = num;
                ViewBag.SellerServiceAttitudeMax  = num;
                ViewBag.SellerServiceAttitudeMin  = num;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = statisticOrderCommentsInfo1.CommentValue;
                ViewBag.SellerServiceAttitudePeer = statisticOrderCommentsInfo4.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = statisticOrderCommentsInfo8.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = statisticOrderCommentsInfo9.CommentValue;
            }
            if (statisticOrderCommentsInfo5 == null || statisticOrderCommentsInfo2 == null)
            {
                ViewBag.SellerDeliverySpeed     = num;
                ViewBag.SellerDeliverySpeedPeer = num;
                ViewBag.SellerDeliverySpeedMax  = num;
                ViewBag.sellerDeliverySpeedMin  = num;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = statisticOrderCommentsInfo2.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = statisticOrderCommentsInfo5.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = statisticOrderCommentsInfo10.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = statisticOrderCommentsInfo11.CommentValue;
            }
            return(View(vShop));
        }
コード例 #2
0
        public ActionResult SearchAd(string sid, long cid = 0, string keywords = "", int pageNo = 1, decimal startPrice = 0, decimal endPrice = decimal.MaxValue)
        {
            int      pageSize = 40;
            long     shopId   = 0;
            ShopInfo shopObj  = null;

            endPrice   = endPrice <= 0 || endPrice < startPrice ? decimal.MaxValue : endPrice;
            startPrice = startPrice < 0 ? 0 : startPrice;

            //shopId 不是数字
            if (!long.TryParse(sid, 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 导航和3个推荐商品

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

            //banner和3个推荐商品
            model.ImageAds = _iSlideAdsService.GetImageAds(shopObj.Id).OrderBy(item => item.Id).ToList();

            model.Slides = _iSlideAdsService.GetSlidAds(shopObj.Id, SlideAdInfo.SlideAdType.ShopHome).ToList();

            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(shopObj.Id).ToArray();
            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 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

            SearchProductQuery query = new SearchProductQuery()
            {
                ShopId         = long.Parse(sid),
                ShopCategoryId = cid,
                Keyword        = keywords,
                StartPrice     = startPrice,
                EndPrice       = endPrice,
                PageNumber     = pageNo,
                PageSize       = pageSize
            };

            SearchProductResult result = _iSearchProductService.SearchProduct(query);

            model.Products = result.Data;

            //#endregion

            #region 热门销售

            var sale = _iProductService.GetHotSaleProduct(shopObj.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale)
                {
                    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).ToList();
            if (hot != null)
            {
                foreach (var item in hot)
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(shopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                ViewBag.ProductAndDescription     = productAndDescription.CommentValue;
                ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                ViewBag.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                ViewBag.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                ViewBag.ProductAndDescription     = defaultValue;
                ViewBag.ProductAndDescriptionPeer = defaultValue;
                ViewBag.ProductAndDescriptionMin  = defaultValue;
                ViewBag.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                ViewBag.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = defaultValue;
                ViewBag.SellerServiceAttitudePeer = defaultValue;
                ViewBag.SellerServiceAttitudeMax  = defaultValue;
                ViewBag.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                ViewBag.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = sellerDeliverySpeedMax.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = sellerDeliverySpeedMin.CommentValue;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = defaultValue;
                ViewBag.SellerDeliverySpeedPeer = defaultValue;
                ViewBag.SellerDeliverySpeedMax  = defaultValue;
                ViewBag.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 分页控制
            PagingInfo info = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = result.Total
            };
            ViewBag.pageInfo = info;
            #endregion
            var categoryName = string.Empty;
            if (keywords == string.Empty)
            {
                if (cid != 0)
                {
                    var category = _iShopCategoryService.GetCategory(cid) ?? new ShopCategoryInfo()
                    {
                    };
                    categoryName = category.Name;
                }
            }
            ViewBag.CategoryName   = categoryName;
            ViewBag.Keyword        = keywords;
            ViewBag.cid            = cid;
            ViewBag.BrowsedHistory = BrowseHistrory.GetBrowsingProducts(13, CurrentUser == null ? 0 : CurrentUser.Id);

            //补充当前店铺红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = shopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = shopId;
            //统计店铺访问人数
            StatisticApplication.StatisticShopVisitUserCount(shopId);
            return(View(model));
        }
コード例 #3
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));
        }
コード例 #4
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));
        }
コード例 #5
0
        public ActionResult Detail(string id = "")
        {
            decimal num;
            decimal num1;
            string  str = "";
            ProductDetailModelForWeb productDetailModelForWeb = new ProductDetailModelForWeb()
            {
                Product = new ProductInfo(),
                Shop    = new ShopInfoModel(),
                Color   = new CollectionSKU(),
                Size    = new CollectionSKU(),
                Version = new CollectionSKU()
            };
            ProductDetailModelForWeb showMobileDescription = productDetailModelForWeb;
            ProductInfo product = null;
            ShopInfo    shop    = null;
            long        num2    = 0;

            long.TryParse(id, out num2);
            if (num2 == 0)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            product = ServiceHelper.Create <IProductService>().GetProduct(num2);
            showMobileDescription.ProductDescription = product.ProductDescriptionInfo.ShowMobileDescription;
            if (product == null)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            LimitTimeMarketInfo limitTimeMarketItemByProductId = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(product.Id);

            if (limitTimeMarketItemByProductId != null)
            {
                return(RedirectToAction("Detail", "LimitTimeBuy", new { id = limitTimeMarketItemByProductId.Id }));
            }
            shop = ServiceHelper.Create <IShopService>().GetShop(product.ShopId, false);
            ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);

            showMobileDescription.Shop.PackMark          = shopComprehensiveMark.PackMark;
            showMobileDescription.Shop.ServiceMark       = shopComprehensiveMark.ServiceMark;
            showMobileDescription.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark;
            IQueryable <ProductCommentInfo> commentsByProductId = ServiceHelper.Create <ICommentService>().GetCommentsByProductId(num2);

            showMobileDescription.Shop.Name        = shop.ShopName;
            showMobileDescription.Shop.ProductMark = (commentsByProductId == null || commentsByProductId.Count() == 0 ? new decimal(0) : commentsByProductId.Average <ProductCommentInfo>((ProductCommentInfo p) => (decimal)p.ReviewMark));
            showMobileDescription.Shop.Id          = product.ShopId;
            showMobileDescription.Shop.FreeFreight = shop.FreeFreight;
            ViewBag.ProductNum = ServiceHelper.Create <IProductService>().GetShopOnsaleProducts(product.ShopId);
            if (base.CurrentUser != null)
            {
                ViewBag.IsFavorite = ServiceHelper.Create <IProductService>().IsFavorite(product.Id, base.CurrentUser.Id);
            }
            else
            {
                ViewBag.IsFavorite = false;
            }
            if (product.SKUInfo != null && product.SKUInfo.Count() > 0)
            {
                long num3 = 0;
                long num4 = 0;
                long num5 = 0;
                foreach (SKUInfo sKUInfo in product.SKUInfo)
                {
                    string[] strArrays = sKUInfo.Id.Split(new char[] { '\u005F' });
                    if (strArrays.Count() > 0)
                    {
                        long.TryParse(strArrays[1], out num3);
                        if (num3 != 0)
                        {
                            if (!showMobileDescription.Color.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Color)))
                            {
                                long num6 = (
                                    from s in product.SKUInfo
                                    where s.Color.Equals(sKUInfo.Color)
                                    select s).Sum <SKUInfo>((SKUInfo s) => s.Stock);
                                CollectionSKU color      = showMobileDescription.Color;
                                ProductSKU    productSKU = new ProductSKU()
                                {
                                    Name          = "选择颜色",
                                    EnabledClass  = (num6 != 0 ? "enabled" : "disabled"),
                                    SelectedClass = "",
                                    SKUId         = num3,
                                    Value         = sKUInfo.Color
                                };
                                color.Add(productSKU);
                            }
                        }
                    }
                    if (strArrays.Count() > 1)
                    {
                        long.TryParse(strArrays[2], out num4);
                        if (num4 != 0)
                        {
                            if (!showMobileDescription.Size.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Size)))
                            {
                                long num7 = (
                                    from s in product.SKUInfo
                                    where s.Size.Equals(sKUInfo.Size)
                                    select s).Sum <SKUInfo>((SKUInfo s1) => s1.Stock);
                                CollectionSKU size        = showMobileDescription.Size;
                                ProductSKU    productSKU1 = new ProductSKU()
                                {
                                    Name          = "选择尺码",
                                    EnabledClass  = (num7 != 0 ? "enabled" : "disabled"),
                                    SelectedClass = "",
                                    SKUId         = num4,
                                    Value         = sKUInfo.Size
                                };
                                size.Add(productSKU1);
                            }
                        }
                    }
                    if (strArrays.Count() <= 2)
                    {
                        continue;
                    }
                    long.TryParse(strArrays[3], out num5);
                    if (num5 == 0)
                    {
                        continue;
                    }
                    if (showMobileDescription.Version.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Version)))
                    {
                        continue;
                    }
                    long num8 = (
                        from s in product.SKUInfo
                        where s.Version.Equals(sKUInfo.Version)
                        select s).Sum <SKUInfo>((SKUInfo s) => s.Stock);
                    CollectionSKU version     = showMobileDescription.Version;
                    ProductSKU    productSKU2 = new ProductSKU()
                    {
                        Name          = "选择版本",
                        EnabledClass  = (num8 != 0 ? "enabled" : "disabled"),
                        SelectedClass = "",
                        SKUId         = num5,
                        Value         = sKUInfo.Version
                    };
                    version.Add(productSKU2);
                }
                decimal num9  = new decimal(0);
                decimal num10 = new decimal(0);
                num9 = (
                    from s in product.SKUInfo
                    where s.Stock >= 0
                    select s).Min <SKUInfo>((SKUInfo s) => s.SalePrice);
                num10 = (
                    from s in product.SKUInfo
                    where s.Stock >= 0
                    select s).Max <SKUInfo>((SKUInfo s) => s.SalePrice);
                if (!(num9 == new decimal(0)) || !(num10 == new decimal(0)))
                {
                    str = (num10 <= num9 ? string.Format("{0}", num9.ToString("f2")) : string.Format("{0}-{1}", num9.ToString("f2"), num10.ToString("f2")));
                }
                else
                {
                    str = product.MinSalePrice.ToString("f2");
                }
            }
            base.ViewBag.Price = (string.IsNullOrWhiteSpace(str) ? product.MinSalePrice.ToString("f2") : str);
            IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(product.ShopId);
            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 num11 = 5;

            if (statisticOrderCommentsInfo == null || statisticOrderCommentsInfo3 == null)
            {
                ViewBag.ProductAndDescription     = num11;
                ViewBag.ProductAndDescriptionPeer = num11;
                ViewBag.ProductAndDescriptionMin  = num11;
                ViewBag.ProductAndDescriptionMax  = num11;
            }
            else
            {
                ViewBag.ProductAndDescription     = statisticOrderCommentsInfo.CommentValue;
                ViewBag.ProductAndDescriptionPeer = statisticOrderCommentsInfo3.CommentValue;
                ViewBag.ProductAndDescriptionMin  = statisticOrderCommentsInfo7.CommentValue;
                ViewBag.ProductAndDescriptionMax  = statisticOrderCommentsInfo6.CommentValue;
            }
            if (statisticOrderCommentsInfo1 == null || statisticOrderCommentsInfo4 == null)
            {
                ViewBag.SellerServiceAttitude     = num11;
                ViewBag.SellerServiceAttitudePeer = num11;
                ViewBag.SellerServiceAttitudeMax  = num11;
                ViewBag.SellerServiceAttitudeMin  = num11;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = statisticOrderCommentsInfo1.CommentValue;
                ViewBag.SellerServiceAttitudePeer = statisticOrderCommentsInfo4.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = statisticOrderCommentsInfo8.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = statisticOrderCommentsInfo9.CommentValue;
            }
            if (statisticOrderCommentsInfo5 == null || statisticOrderCommentsInfo2 == null)
            {
                ViewBag.SellerDeliverySpeed     = num11;
                ViewBag.SellerDeliverySpeedPeer = num11;
                ViewBag.SellerDeliverySpeedMax  = num11;
                ViewBag.sellerDeliverySpeedMin  = num11;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = statisticOrderCommentsInfo2.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = statisticOrderCommentsInfo5.CommentValue;
                dynamic viewBag = base.ViewBag;
                num = (statisticOrderCommentsInfo10 != null ? statisticOrderCommentsInfo10.CommentValue : new decimal(0));
                viewBag.SellerDeliverySpeedMax = num;
                dynamic obj = base.ViewBag;
                num1 = (statisticOrderCommentsInfo11 != null ? statisticOrderCommentsInfo11.CommentValue : new decimal(0));
                obj.sellerDeliverySpeedMin = num1;
            }
            showMobileDescription.Product = product;
            ICommentService commentService = ServiceHelper.Create <ICommentService>();
            CommentQuery    commentQuery   = new CommentQuery()
            {
                ProductID = product.Id,
                PageNo    = 1,
                PageSize  = 10000
            };
            PageModel <ProductCommentInfo> comments = commentService.GetComments(commentQuery);

            ViewBag.CommentCount = comments.Total;
            IQueryable <ProductConsultationInfo> consultations = ServiceHelper.Create <IConsultationService>().GetConsultations(num2);
            double num12 = product.ChemCloud_ProductComments.Count();
            double num13 = product.ChemCloud_ProductComments.Count((ProductCommentInfo item) => item.ReviewMark >= 4);

            ViewBag.NicePercent   = num13 / num12 * 100;
            ViewBag.Consultations = consultations.Count();
            if (ServiceHelper.Create <IVShopService>().GetVShopByShopId(shop.Id) != null)
            {
                ViewBag.VShopId = ServiceHelper.Create <IVShopService>().GetVShopByShopId(shop.Id).Id;
            }
            else
            {
                ViewBag.VShopId = -1;
            }
            IEnumerable <CouponInfo> couponList = GetCouponList(shop.Id);

            if (couponList != null)
            {
                int num14 = couponList.Count();
                ViewBag.CouponCount = num14;
            }
            ShopBonusInfo byShopId = ServiceHelper.Create <IShopBonusService>().GetByShopId(shop.Id);

            if (byShopId != null)
            {
                ViewBag.BonusCount             = byShopId.Count;
                ViewBag.BonusGrantPrice        = byShopId.GrantPrice;
                ViewBag.BonusRandomAmountStart = byShopId.RandomAmountStart;
                ViewBag.BonusRandomAmountEnd   = byShopId.RandomAmountEnd;
            }
            ViewBag.CashDepositsObligation = Instance <ICashDepositsService> .Create.GetCashDepositsObligation(product.Id);

            showMobileDescription.CashDepositsServer = Instance <ICashDepositsService> .Create.GetCashDepositsObligation(product.Id);

            return(View(showMobileDescription));
        }
コード例 #6
0
        public object GetVShopIntroduce(long id)
        {
            var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShop(id);

            var    env             = EngineContext.Current.Resolve <IWebHostEnvironment>();
            string qrCodeImagePath = string.Empty;

            if (vshop != null)
            {
                Image  qrcode;
                string vshopUrl = CurrentUrlHelper.CurrentUrlNoPort() + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + id;
                if (!string.IsNullOrWhiteSpace(vshop.StrLogo) && MallIO.ExistFile(vshop.StrLogo))
                {
                    qrcode = Core.Helper.QRCodeHelper.Create(vshopUrl, MallIO.GetImagePath(vshop.StrLogo));
                }
                else
                {
                    qrcode = Core.Helper.QRCodeHelper.Create(vshopUrl);
                }
                string fileName = DateTime.Now.ToString("yyMMddHHmmssffffff") + ".jpg";
                qrCodeImagePath = CurrentUrlHelper.CurrentUrlNoPort() + "/temp/" + fileName;
                qrcode.Save(env.ContentRootPath + "/temp/" + fileName);
            }
            var  qrCode   = qrCodeImagePath;
            bool favorite = false;

            if (CurrentUser != null)
            {
                favorite = ServiceProvider.Instance <IShopService> .Create.IsFavoriteShop(CurrentUser.Id, vshop.ShopId);
            }

            var mark     = ShopServiceMark.GetShopComprehensiveMark(vshop.ShopId);
            var shopMark = mark.ComprehensiveMark.ToString();

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(vshop.ShopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            decimal defaultValue           = 5;
            var     _productAndDescription = defaultValue;
            var     _sellerServiceAttitude = defaultValue;
            var     _sellerDeliverySpeed   = defaultValue;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                _productAndDescription = productAndDescription.CommentValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                _sellerServiceAttitude = sellerServiceAttitude.CommentValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                _sellerDeliverySpeed = sellerDeliverySpeed.CommentValue;
            }
            #endregion
            var vshopModel = new
            {
                QRCode                = qrCode,
                Name                  = vshop.Name,
                IsFavorite            = favorite,
                ProductAndDescription = _productAndDescription,
                SellerDeliverySpeed   = _sellerDeliverySpeed,
                SellerServiceAttitude = _sellerServiceAttitude,
                Description           = vshop.Description,
                ShopId                = vshop.ShopId,
                Id = vshop.Id,
                //Logo = "http://" + Url.Request.RequestUri.Host+vshop.Logo
                Logo = Core.MallIO.GetRomoteImagePath(vshop.StrLogo)
            };
            dynamic result = new ExpandoObject();
            result.VShop = vshopModel;
            return(Json(new { result }));
        }
コード例 #7
0
        public ActionResult Detail(string id)
        {
            LimitTimeBuyDetailModel detailModel = new LimitTimeBuyDetailModel();
            string price = "";

            #region 定义Model和变量

            LimitTimeProductDetailModel model = new LimitTimeProductDetailModel
            {
                MainId = long.Parse(id),
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new Entities.ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };

            FlashSaleModel    market = null;
            Entities.ShopInfo shop   = null;

            long gid = 0, mid = 0;

            #endregion

            #region 商品Id不合法
            if (long.TryParse(id, out mid))
            {
            }
            if (mid == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
            }
            #endregion

            #region 初始化商品和店铺
            //参数是限时购活动ID
            try
            {
                market = _iLimitTimeBuyService.Get(mid);
            }
            catch
            {
                market = null;
            }
            if (market != null)
            {
                switch (market.Status)
                {
                case FlashSaleInfo.FlashSaleStatus.Ended:
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));

                case FlashSaleInfo.FlashSaleStatus.Cancelled:
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }

                model.FlashSale = market;
            }
            if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是商品ID
                market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market;

                if (market == null)
                {
                    //跳转到404页面
                    return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
                if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }
                market = _iLimitTimeBuyService.Get(market.Id);
            }
            model.FlashSale = market;

            if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now))
            {
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            shop = _iShopService.GetShop(market.ShopId);

            #endregion

            #region  存在的商品
            if (null == market || market.Id == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            #endregion

            #region 商品描述
            var product = _iProductService.GetProduct(market.ProductId);
            gid = market.ProductId;

            model.Product = product;
            var description = ProductManagerApplication.GetProductDescription(product.Id);
            model.ProductDescription = description.ShowMobileDescription;
            if (description.DescriptionPrefixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptionPrefixId, product.ShopId);
                model.DescriptionPrefix = desc == null ? "" : desc.Content;
            }

            if (description.DescriptiondSuffixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(description.DescriptiondSuffixId, product.ShopId);
                model.DescriptiondSuffix = desc == null ? "" : desc.Content;
            }

            var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            model.Shop.Name               = shop.ShopName;
            model.Shop.ProductMark        = CommentApplication.GetProductAverageMark(gid);
            model.Shop.Id                 = product.ShopId;
            model.Shop.FreeFreight        = shop.FreeFreight;
            detailModel.ProductNum        = _iProductService.GetShopOnsaleProducts(product.ShopId);
            detailModel.FavoriteShopCount = _iShopService.GetShopFavoritesCount(product.ShopId);
            if (CurrentUser == null)
            {
                detailModel.IsFavorite     = false;
                detailModel.IsFavoriteShop = false;
            }
            else
            {
                detailModel.IsFavorite = _iProductService.IsFavorite(product.Id, CurrentUser.Id);
                var favoriteShopIds = _iShopService.GetFavoriteShopInfos(CurrentUser.Id).Select(item => item.ShopId).ToArray();//获取已关注店铺
                detailModel.IsFavoriteShop = favoriteShopIds.Contains(product.ShopId);
            }
            #endregion

            #region 店铺分类

            var categories = _iShopCategoryService.GetShopCategory(product.ShopId);
            List <Entities.ShopCategoryInfo> allcate = categories.ToList();
            foreach (var main in allcate.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in allcate.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 sale = _iProductService.GetHotSaleProduct(shop.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 + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts)
                    });
                }
            }

            #endregion

            #region 热门关注

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

            #region 商品规格

            Entities.TypeInfo typeInfo     = _iTypeService.GetType(product.TypeId);
            string            colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
            string            sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
            string            versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
            if (product != null)
            {
                colorAlias   = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias;
                sizeAlias    = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias;
                versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias;
            }
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;
            var skus = ProductManagerApplication.GetSKUs(product.Id);
            if (skus.Count > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in skus)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color))
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = skus.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = Core.MallIO.GetImagePath(sku.ShowPic)
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size))
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version))
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
                //var min = skus.Where(s => s.Stock >= 0).Min(s => s.SalePrice);
                //var max = skus.Where(s => s.Stock >= 0).Max(s => s.SalePrice);
                //if (min == 0 && max == 0)
                //{
                //    price = product.MinSalePrice.ToString("f2");
                //}
                //else if (max > min)
                //{
                //    price = string.Format("{0}-{1}", min.ToString("f2"), max.ToString("f2"));
                //}
                //else
                //{
                //    price = string.Format("{0}", min.ToString("f2"));
                //}
                price = ProductWebApplication.GetProductPriceStr2(product, skus);//最小价或区间价文本
            }
            detailModel.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price;
            #endregion

            #region 商品属性
            List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>();
            var prodAttrs = ProductManagerApplication.GetProductAttributes(product.Id);
            foreach (var attr in prodAttrs)
            {
                if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId))
                {
                    var attribute = _iTypeService.GetAttribute(attr.AttributeId);
                    var values    = _iTypeService.GetAttributeValues(attr.AttributeId);
                    TypeAttributesModel attrModel = new TypeAttributesModel()
                    {
                        AttrId     = attr.AttributeId,
                        AttrValues = new List <TypeAttrValue>(),
                        Name       = attribute.Name
                    };
                    foreach (var attrV in values)
                    {
                        if (prodAttrs.Any(p => p.ValueId == attrV.Id))
                        {
                            attrModel.AttrValues.Add(new TypeAttrValue
                            {
                                Id   = attrV.Id.ToString(),
                                Name = attrV.Value
                            });
                        }
                    }
                    ProductAttrs.Add(attrModel);
                }
                else
                {
                    var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId);
                    var values   = _iTypeService.GetAttributeValues(attr.AttributeId);
                    if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString()))
                    {
                        attrTemp.AttrValues.Add(new TypeAttrValue
                        {
                            Id   = attr.ValueId.ToString(),
                            Name = values.FirstOrDefault(a => a.Id == attr.ValueId).Value
                        });
                    }
                }
            }
            detailModel.ProductAttrs = ProductAttrs;
            #endregion

            #region 获取评论、咨询数量

            var comments = CommentApplication.GetCommentsByProduct(product.Id);
            detailModel.CommentCount = comments.Count;

            var consultations = ServiceApplication.Create <IConsultationService>().GetConsultations(gid);

            var total     = comments.Count;
            var niceTotal = comments.Count(item => item.ReviewMark >= 4);
            detailModel.NicePercent   = (int)((niceTotal / (double)total) * 100);
            detailModel.Consultations = consultations.Count();

            if (_iVShopService.GetVShopByShopId(shop.Id) == null)
            {
                detailModel.VShopId = -1;
            }
            else
            {
                detailModel.VShopId = _iVShopService.GetVShopByShopId(shop.Id).Id;
            }
            #endregion

            #region 累加浏览次数、 加入历史记录
            //if (CurrentUser != null)
            //{
            //    BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id);
            //}
            //else
            //{
            //    BrowseHistrory.AddBrowsingProduct(product.Id);
            //}
            //_iProductService.LogProductVisti(gid);
            #endregion

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(product.ShopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null && !shop.IsSelf)
            {
                detailModel.ProductAndDescription     = productAndDescription.CommentValue;
                detailModel.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                detailModel.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                detailModel.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                detailModel.ProductAndDescription     = defaultValue;
                detailModel.ProductAndDescriptionPeer = defaultValue;
                detailModel.ProductAndDescriptionMin  = defaultValue;
                detailModel.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf)
            {
                detailModel.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                detailModel.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                detailModel.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                detailModel.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                detailModel.SellerServiceAttitude     = defaultValue;
                detailModel.SellerServiceAttitudePeer = defaultValue;
                detailModel.SellerServiceAttitudeMax  = defaultValue;
                detailModel.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf)
            {
                detailModel.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                detailModel.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                detailModel.SellerDeliverySpeedMax  = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0;
                detailModel.sellerDeliverySpeedMin  = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0;
            }
            else
            {
                detailModel.SellerDeliverySpeed     = defaultValue;
                detailModel.SellerDeliverySpeedPeer = defaultValue;
                detailModel.SellerDeliverySpeedMax  = defaultValue;
                detailModel.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 是否收藏此商品
            if (CurrentUser != null && CurrentUser.Id > 0)
            {
                model.IsFavorite = _iProductService.IsFavorite(product.Id, CurrentUser.Id);
            }
            else
            {
                model.IsFavorite = false;
            }
            #endregion

            long vShopId;
            var  vshopinfo = _iVShopService.GetVShopByShopId(shop.Id);
            if (vshopinfo == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = vshopinfo.Id;
            }
            detailModel.VShopId = vShopId;
            model.Shop.VShopId  = vShopId;

            model.VShopLog = _iVShopService.GetVShopLog(model.Shop.VShopId);
            if (string.IsNullOrWhiteSpace(model.VShopLog))
            {
                //throw new Mall.Core.MallException("店铺未开通微店功能");
                model.VShopLog = SiteSettings.WXLogo;
            }
            detailModel.Logined = (null != CurrentUser) ? 1 : 0;
            model.EnabledBuy    = product.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale;
            int saleCounts = 0;
            saleCounts = market.SaleCount;
            if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                detailModel.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }
            else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                detailModel.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
                saleCounts         = Mall.Core.Helper.TypeHelper.ObjectToInt(product.SaleCounts) + Mall.Core.Helper.TypeHelper.ObjectToInt(product.VirtualSaleCounts);
            }
            ViewBag.DetailModel = detailModel;

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(market.ShopId);
            ViewBag.CustomerServices = customerServices;

            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            model.IsSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1;                                          //是否显示销量
            model.SaleCount        = saleCounts;                                                                                              //销量
            model.FreightTemplate  = FreightTemplateApplication.GetFreightTemplate(product.FreightTemplateId);
            model.Freight          = FreightTemplateApplication.GetFreightStr(market.ProductId, model.FreightTemplate, CurrentUser, product); //运费或免运费
            model.StockAll         = market.Quantity;

            return(View(model));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        public ActionResult Search(string sid, long cid = 0L, string keywords = "", int pageNo = 1, [DecimalConstant(0, 0, 0, 0, 0)] decimal startPrice = default(decimal), decimal endPrice = 0)
        {
            long     num;
            int      num1 = 40;
            long     num2 = 0;
            ShopInfo shop = null;

            endPrice   = (endPrice <= new decimal(0) || endPrice < startPrice ? new decimal(-1, -1, -1, false, 0) : endPrice);
            startPrice = (startPrice < new decimal(0) ? new decimal(0) : startPrice);
            if (!long.TryParse(sid, out num2))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            shop = ServiceHelper.Create <IShopService>().GetShop(num2, 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 list = shopHomeModel;

            list.Navignations = ServiceHelper.Create <INavigationService>().GetSellerNavigations(shop.Id, PlatformType.PC).ToList();
            list.ImageAds     = (
                from item in ServiceHelper.Create <ISlideAdsService>().GetImageAds(shop.Id)
                orderby item.Id
                select item).ToList();
            list.Slides = ServiceHelper.Create <ISlideAdsService>().GetSlidAds(shop.Id, SlideAdInfo.SlideAdType.ShopHome).ToList();
            ShopCategoryInfo[] array = ServiceHelper.Create <IShopCategoryService>().GetShopCategory(shop.Id).ToArray();
            foreach (ShopCategoryInfo shopCategoryInfo in
                     from s in array
                     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 array
                         where s.ParentCategoryId == shopCategoryInfo.Id
                         select s)
                {
                    SecondLevelCategory secondLevelCategory = new SecondLevelCategory()
                    {
                        Name = shopCategoryInfo1.Name,
                        Id   = shopCategoryInfo1.Id.ToString()
                    };
                    categoryJsonModel1.SubCategory.Add(secondLevelCategory);
                }
                list.ShopCategory.Add(categoryJsonModel1);
            }
            ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);

            list.Shop.Name              = shop.ShopName;
            list.Shop.CompanyName       = shop.CompanyName;
            list.Shop.Id                = shop.Id;
            list.Shop.PackMark          = shopComprehensiveMark.PackMark;
            list.Shop.ServiceMark       = shopComprehensiveMark.ServiceMark;
            list.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark;
            list.Shop.Phone             = shop.CompanyPhone;
            list.Shop.Address           = ServiceHelper.Create <IRegionService>().GetRegionFullName(shop.CompanyRegionId, " ");
            list.Logo = shop.Logo;
            ProductSearch productSearch = new ProductSearch()
            {
                startPrice     = startPrice,
                EndPrice       = endPrice,
                shopId         = num2,
                BrandId        = 0,
                ShopCategoryId = new long?(cid),
                Ex_Keyword     = "",
                Keyword        = keywords,
                OrderKey       = 0,
                OrderType      = true,
                AttrIds        = new List <string>(),
                PageSize       = num1,
                PageNumber     = pageNo
            };
            PageModel <ProductInfo> pageModel = ServiceHelper.Create <IProductService>().SearchProduct(productSearch);
            int total = pageModel.Total;

            ProductInfo[] productInfoArray  = pageModel.Models.ToArray();
            ProductInfo[] productInfoArray1 = productInfoArray;
            for (int i = 0; i < productInfoArray1.Length; i++)
            {
                ProductInfo saleCounts = productInfoArray1[i];
                saleCounts.SaleCounts = ServiceHelper.Create <IProductService>().GetProductVistInfo(saleCounts.Id, null).SaleCounts;
            }
            list.Products = ((IEnumerable <ProductInfo>)(productInfoArray ?? new ProductInfo[0])).ToList();
            IQueryable <ProductInfo> hotSaleProduct = ServiceHelper.Create <IProductService>().GetHotSaleProduct(shop.Id, 5);

            if (hotSaleProduct != null)
            {
                foreach (ProductInfo productInfo in hotSaleProduct)
                {
                    List <HotProductInfo> hotSaleProducts = list.HotSaleProducts;
                    HotProductInfo        hotProductInfo  = new HotProductInfo()
                    {
                        ImgPath   = productInfo.ImagePath,
                        Name      = productInfo.ProductName,
                        Price     = productInfo.MinSalePrice,
                        Id        = productInfo.Id,
                        SaleCount = (int)productInfo.SaleCounts
                    };
                    hotSaleProducts.Add(hotProductInfo);
                }
            }
            List <ProductInfo> productInfos = ServiceHelper.Create <IProductService>().GetHotConcernedProduct(shop.Id, 5).ToList();

            if (productInfos != null)
            {
                foreach (ProductInfo productInfo1 in productInfos)
                {
                    List <HotProductInfo> hotAttentionProducts = list.HotAttentionProducts;
                    HotProductInfo        hotProductInfo1      = new HotProductInfo()
                    {
                        ImgPath   = productInfo1.ImagePath,
                        Name      = productInfo1.ProductName,
                        Price     = productInfo1.MinSalePrice,
                        Id        = productInfo1.Id,
                        SaleCount = productInfo1.ConcernedCount
                    };
                    hotAttentionProducts.Add(hotProductInfo1);
                }
            }
            IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(num2);
            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 num3 = 5;

            if (statisticOrderCommentsInfo == null || statisticOrderCommentsInfo3 == null)
            {
                ViewBag.ProductAndDescription     = num3;
                ViewBag.ProductAndDescriptionPeer = num3;
                ViewBag.ProductAndDescriptionMin  = num3;
                ViewBag.ProductAndDescriptionMax  = num3;
            }
            else
            {
                ViewBag.ProductAndDescription     = statisticOrderCommentsInfo.CommentValue;
                ViewBag.ProductAndDescriptionPeer = statisticOrderCommentsInfo3.CommentValue;
                ViewBag.ProductAndDescriptionMin  = statisticOrderCommentsInfo7.CommentValue;
                ViewBag.ProductAndDescriptionMax  = statisticOrderCommentsInfo6.CommentValue;
            }
            if (statisticOrderCommentsInfo1 == null || statisticOrderCommentsInfo4 == null)
            {
                ViewBag.SellerServiceAttitude     = num3;
                ViewBag.SellerServiceAttitudePeer = num3;
                ViewBag.SellerServiceAttitudeMax  = num3;
                ViewBag.SellerServiceAttitudeMin  = num3;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = statisticOrderCommentsInfo1.CommentValue;
                ViewBag.SellerServiceAttitudePeer = statisticOrderCommentsInfo4.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = statisticOrderCommentsInfo8.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = statisticOrderCommentsInfo9.CommentValue;
            }
            if (statisticOrderCommentsInfo5 == null || statisticOrderCommentsInfo2 == null)
            {
                ViewBag.SellerDeliverySpeed     = num3;
                ViewBag.SellerDeliverySpeedPeer = num3;
                ViewBag.SellerDeliverySpeedMax  = num3;
                ViewBag.sellerDeliverySpeedMin  = num3;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = statisticOrderCommentsInfo2.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = statisticOrderCommentsInfo5.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = statisticOrderCommentsInfo10.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = statisticOrderCommentsInfo11.CommentValue;
            }
            PagingInfo pagingInfo = new PagingInfo()
            {
                CurrentPage  = pageNo,
                ItemsPerPage = num1,
                TotalItems   = total
            };

            ViewBag.pageInfo = pagingInfo;
            string empty = string.Empty;

            if (keywords == string.Empty && cid != 0)
            {
                empty = (ServiceHelper.Create <IShopCategoryService>().GetCategory(cid) ?? new ShopCategoryInfo()).Name;
            }
            ViewBag.CategoryName = empty;
            ViewBag.Keyword      = keywords;
            ViewBag.cid          = cid;
            dynamic viewBag = base.ViewBag;

            num = (base.CurrentUser == null ? 0 : base.CurrentUser.Id);
            viewBag.BrowsedHistory = BrowseHistrory.GetBrowsingProducts(13, num);
            return(View(list));
        }
コード例 #10
0
        public ActionResult ProductDetail(string id = "")
        {
            CheckPromoter();

            var    shopService = ServiceHelper.Create <IVShopService>();
            string price       = "";

            ProductDetailModel detailModel           = new ProductDetailModel();
            DistributionProductDetailShowModel model = new DistributionProductDetailShowModel()
            {
                Product = new Model.ProductInfo(),
                Shop    = new ShopInfoModel(),
                Color   = new CollectionSKU(),
                Size    = new CollectionSKU(),
                Version = new CollectionSKU()
            };

            ProductInfo          product   = null;
            ProductBrokerageInfo probroker = null;
            ShopInfo             shop      = null;
            long gid = 0;

            #region 商品Id不合法
            if (long.TryParse(id, out gid))
            {
            }
            if (gid == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            #endregion



            #region 初始化商品和店铺
            probroker = _iDistributionService.GetDistributionProductInfo(gid);
            product   = _iProductService.GetProduct(gid);

            if (probroker == null)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }

            if (product == null)
            {
                //跳转到404页面
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            model.ProductDescription = product.ProductDescriptionInfo.ShowMobileDescription;

            model.DistributionAgentNum       = probroker.AgentNum.Value;
            model.DistributionSaleNum        = probroker.SaleNum.Value;
            model.DistributionCommission     = 0;
            model.ShopDistributionProductNum = _iDistributionService.GetShopDistributionProductCount(product.ShopId);
            decimal rate = probroker.rate;
            if (rate > 0)
            {
                model.DistributionCommission = (product.MinSalePrice * rate / 100);
                int _tmp = (int)(model.DistributionCommission * 100);
                //保留两位小数,但不四舍五入
                model.DistributionCommission = (decimal)(((decimal)_tmp) / (decimal)100);
            }

            //是否已代理
            List <long> proids = new List <long>();
            proids.Add(gid);
            List <long> canAgentIds = _iDistributionService.GetCanAgentProductId(proids, curUserId).ToList();
            model.DistributionIsAgent = true;
            if (canAgentIds.Count > 0)
            {
                model.DistributionIsAgent = false;
            }

            shop = ServiceHelper.Create <IShopService>().GetShop(product.ShopId);
            var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            var comm = ServiceHelper.Create <ICommentService>().GetCommentsByProductId(gid);
            model.Shop.Name        = shop.ShopName;
            model.Shop.ProductMark = (comm == null || comm.Count() == 0) ? 0 : comm.Average(p => (decimal)p.ReviewMark);
            model.Shop.Id          = product.ShopId;
            model.Shop.FreeFreight = shop.FreeFreight;
            detailModel.ProductNum = ServiceHelper.Create <IProductService>().GetShopOnsaleProducts(product.ShopId);
            bool isFavorite;
            if (CurrentUser == null)
            {
                isFavorite = false;
            }
            else
            {
                isFavorite = ServiceHelper.Create <IProductService>().IsFavorite(product.Id, CurrentUser.Id);
            }
            detailModel.IsFavorite = isFavorite;
            #endregion

            #region 商品规格

            ProductTypeInfo typeInfo     = _iTypeService.GetType(product.TypeId);
            string          colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
            string          sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
            string          versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;

            if (product.SKUInfo != null && product.SKUInfo.Count() > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in product.SKUInfo)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0)
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = product.SKUInfo.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = sku.ShowPic
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1)
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = product.SKUInfo.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2)
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = product.SKUInfo.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
                decimal min = 0, max = 0;
                min = product.SKUInfo.Where(s => s.Stock >= 0).Min(s => s.SalePrice);
                max = product.SKUInfo.Where(s => s.Stock >= 0).Max(s => s.SalePrice);
                if (min == 0 && max == 0)
                {
                    price = product.MinSalePrice.ToString("f2");
                }
                else if (max > min)
                {
                    price = string.Format("{0}-{1}", min.ToString("f2"), max.ToString("f2"));
                }
                else
                {
                    price = string.Format("{0}", min.ToString("f2"));
                }
            }
            ViewBag.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price;
            #endregion

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(product.ShopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                detailModel.ProductAndDescription     = productAndDescription.CommentValue;
                detailModel.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                detailModel.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                detailModel.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                detailModel.ProductAndDescription     = defaultValue;
                detailModel.ProductAndDescriptionPeer = defaultValue;
                detailModel.ProductAndDescriptionMin  = defaultValue;
                detailModel.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                detailModel.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                detailModel.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                detailModel.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                detailModel.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                detailModel.SellerServiceAttitude     = defaultValue;
                detailModel.SellerServiceAttitudePeer = defaultValue;
                detailModel.SellerServiceAttitudeMax  = defaultValue;
                detailModel.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                detailModel.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                detailModel.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                detailModel.SellerDeliverySpeedMax  = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0;
                detailModel.sellerDeliverySpeedMin  = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0;
            }
            else
            {
                detailModel.SellerDeliverySpeed     = defaultValue;
                detailModel.SellerDeliverySpeedPeer = defaultValue;
                detailModel.SellerDeliverySpeedMax  = defaultValue;
                detailModel.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion


            model.Product = product;

            //var comments = ServiceHelper.Create<ICommentService>().GetComments(new CommentQuery
            //{
            //    ProductID = product.Id,
            //    PageNo = 1,
            //    PageSize = 10000
            //});
            //detailModel.CommentCount = comments.Total;

            var com      = product.Himall_ProductComments.Where(item => !item.IsHidden.HasValue || item.IsHidden.Value == false);
            var comCount = com.Count();
            detailModel.CommentCount = comCount;

            var consultations = ServiceHelper.Create <IConsultationService>().GetConsultations(gid);

            //double total = product.Himall_ProductComments.Count();
            //double niceTotal = product.Himall_ProductComments.Count(item => item.ReviewMark >= 4);
            double total     = (double)comCount;
            double niceTotal = com.Count(item => item.ReviewMark >= 4);
            detailModel.NicePercent   = (int)((niceTotal / total) * 100);
            detailModel.Consultations = consultations.Count();
            long vShopId;
            if (shopService.GetVShopByShopId(shop.Id) == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = shopService.GetVShopByShopId(shop.Id).Id;
            }
            detailModel.VShopId = vShopId;
            model.Shop.VShopId  = vShopId;
            var bonus = ServiceHelper.Create <IShopBonusService>().GetByShopId(shop.Id);
            if (bonus != null)
            {
                detailModel.BonusCount             = bonus.Count;
                detailModel.BonusGrantPrice        = bonus.GrantPrice;
                detailModel.BonusRandomAmountStart = bonus.RandomAmountStart;
                detailModel.BonusRandomAmountEnd   = bonus.RandomAmountEnd;
            }
            detailModel.CashDepositsObligation = ServiceHelper.Create <ICashDepositsService>().GetCashDepositsObligation(product.Id);
            var cashDepositModel = ServiceHelper.Create <ICashDepositsService>().GetCashDepositsObligation(product.Id);
            model.CashDepositsServer = cashDepositModel;
            model.VShopLog           = shopService.GetVShopLog(model.Shop.VShopId);
            model.FavoriteShopCount  = _iShopService.GetShopFavoritesCount(product.ShopId);

            ViewBag.DetailModel = detailModel;


            //分销信息

            return(View(model));
        }
コード例 #11
0
        public ActionResult Detail(string id)
        {
            long valueId;

            ProductInfo[]            array;
            int                      i;
            double                   num;
            decimal                  num1;
            decimal                  num2;
            string                   str = "";
            ProductDetailModelForWeb productDetailModelForWeb = new ProductDetailModelForWeb()
            {
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };
            ProductDetailModelForWeb maxSaleCount        = productDetailModelForWeb;
            LimitTimeMarketInfo      limitTimeMarketItem = null;
            ShopInfo shop      = null;
            long     productId = 0;
            long     num3      = 0;

            long.TryParse(id, out num3);
            if (num3 == 0)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
            }
            limitTimeMarketItem = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItem(num3);
            if (limitTimeMarketItem == null || limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing)
            {
                limitTimeMarketItem = (limitTimeMarketItem == null ? ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(num3) : limitTimeMarketItem);
                if (limitTimeMarketItem == null || limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing)
                {
                    return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
            }
            if (limitTimeMarketItem != null && (limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing || limitTimeMarketItem.EndTime < DateTime.Now))
            {
                return(RedirectToAction("Detail", "Product", new { id = limitTimeMarketItem.ProductId }));
            }
            maxSaleCount.MaxSaleCount = limitTimeMarketItem.MaxSaleCount;
            maxSaleCount.Title        = limitTimeMarketItem.Title;
            shop = ServiceHelper.Create <IShopService>().GetShop(limitTimeMarketItem.ShopId, false);
            if (limitTimeMarketItem == null || limitTimeMarketItem.Id == 0)
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            ProductInfo product = ServiceHelper.Create <IProductService>().GetProduct(limitTimeMarketItem.ProductId);

            productId                       = limitTimeMarketItem.ProductId;
            product.MarketPrice             = limitTimeMarketItem.Price;
            product.SaleCounts              = limitTimeMarketItem.SaleCount;
            maxSaleCount.Product            = product;
            maxSaleCount.ProductDescription = product.ProductDescriptionInfo.Description;
            if (product.ProductDescriptionInfo.DescriptionPrefixId != 0)
            {
                ProductDescriptionTemplateInfo template = ServiceHelper.Create <IProductDescriptionTemplateService>().GetTemplate(product.ProductDescriptionInfo.DescriptionPrefixId, product.ShopId);
                maxSaleCount.DescriptionPrefix = (template == null ? "" : template.Content);
            }
            if (product.ProductDescriptionInfo.DescriptiondSuffixId != 0)
            {
                ProductDescriptionTemplateInfo productDescriptionTemplateInfo = ServiceHelper.Create <IProductDescriptionTemplateService>().GetTemplate(product.ProductDescriptionInfo.DescriptiondSuffixId, product.ShopId);
                maxSaleCount.DescriptiondSuffix = (productDescriptionTemplateInfo == null ? "" : productDescriptionTemplateInfo.Content);
            }
            ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);

            maxSaleCount.Shop.PackMark          = shopComprehensiveMark.PackMark;
            maxSaleCount.Shop.ServiceMark       = shopComprehensiveMark.ServiceMark;
            maxSaleCount.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark;
            IQueryable <ProductCommentInfo> commentsByProductId = ServiceHelper.Create <ICommentService>().GetCommentsByProductId(productId);

            maxSaleCount.Shop.Name        = shop.ShopName;
            maxSaleCount.Shop.ProductMark = (commentsByProductId == null || commentsByProductId.Count() == 0 ? new decimal(0) : commentsByProductId.Average <ProductCommentInfo>((ProductCommentInfo p) => (decimal)p.ReviewMark));
            maxSaleCount.Shop.Id          = product.ShopId;
            maxSaleCount.Shop.FreeFreight = shop.FreeFreight;
            ViewBag.ProductNum            = ServiceHelper.Create <IProductService>().GetShopOnsaleProducts(product.ShopId);
            if (base.CurrentUser != null)
            {
                ViewBag.IsFavorite = ServiceHelper.Create <IProductService>().IsFavorite(product.Id, base.CurrentUser.Id);
            }
            else
            {
                ViewBag.IsFavorite = false;
            }
            IQueryable <ShopCategoryInfo> shopCategory = ServiceHelper.Create <IShopCategoryService>().GetShopCategory(product.ShopId);
            List <ShopCategoryInfo>       list         = shopCategory.ToList();

            foreach (ShopCategoryInfo shopCategoryInfo in
                     from s in list
                     where s.ParentCategoryId == 0
                     select s)
            {
                CategoryJsonModel categoryJsonModel = new CategoryJsonModel()
                {
                    Name = shopCategoryInfo.Name
                };
                valueId = shopCategoryInfo.Id;
                categoryJsonModel.Id          = valueId.ToString();
                categoryJsonModel.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);
                }
                maxSaleCount.ShopCategory.Add(categoryJsonModel1);
            }
            IQueryable <ProductInfo> hotSaleProduct = ServiceHelper.Create <IProductService>().GetHotSaleProduct(shop.Id, 5);

            if (hotSaleProduct != null)
            {
                array = hotSaleProduct.ToArray();
                for (i = 0; i < array.Length; i++)
                {
                    ProductInfo           productInfo     = array[i];
                    List <HotProductInfo> hotSaleProducts = maxSaleCount.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)
            {
                array = hotConcernedProduct.ToArray();
                for (i = 0; i < array.Length; i++)
                {
                    ProductInfo           productInfo1         = array[i];
                    List <HotProductInfo> hotAttentionProducts = maxSaleCount.HotAttentionProducts;
                    HotProductInfo        hotProductInfo1      = new HotProductInfo()
                    {
                        ImgPath   = productInfo1.ImagePath,
                        Name      = productInfo1.ProductName,
                        Price     = productInfo1.MinSalePrice,
                        Id        = productInfo1.Id,
                        SaleCount = productInfo1.ConcernedCount
                    };
                    hotAttentionProducts.Add(hotProductInfo1);
                }
            }
            if (product.SKUInfo != null && product.SKUInfo.Count() > 0)
            {
                long num4 = 0;
                long num5 = 0;
                long num6 = 0;
                foreach (SKUInfo sKUInfo in product.SKUInfo)
                {
                    string[] strArrays = sKUInfo.Id.Split(new char[] { '\u005F' });
                    if (strArrays.Count() > 0)
                    {
                        long.TryParse(strArrays[1], out num4);
                        if (num4 != 0)
                        {
                            if (!maxSaleCount.Color.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Color)))
                            {
                                long num7 = (
                                    from s in product.SKUInfo
                                    where s.Color.Equals(sKUInfo.Color)
                                    select s).Sum <SKUInfo>((SKUInfo s) => s.Stock);
                                CollectionSKU color      = maxSaleCount.Color;
                                ProductSKU    productSKU = new ProductSKU()
                                {
                                    Name          = "选择颜色",
                                    EnabledClass  = (num7 != 0 ? "enabled" : "disabled"),
                                    SelectedClass = "",
                                    SKUId         = num4,
                                    Value         = sKUInfo.Color
                                };
                                color.Add(productSKU);
                            }
                        }
                    }
                    if (strArrays.Count() > 1)
                    {
                        long.TryParse(strArrays[2], out num5);
                        if (num5 != 0)
                        {
                            if (!maxSaleCount.Size.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Size)))
                            {
                                long num8 = (
                                    from s in product.SKUInfo
                                    where s.Size.Equals(sKUInfo.Size)
                                    select s).Sum <SKUInfo>((SKUInfo s1) => s1.Stock);
                                CollectionSKU size        = maxSaleCount.Size;
                                ProductSKU    productSKU1 = new ProductSKU()
                                {
                                    Name          = "选择尺码",
                                    EnabledClass  = (num8 != 0 ? "enabled" : "disabled"),
                                    SelectedClass = "",
                                    SKUId         = num5,
                                    Value         = sKUInfo.Size
                                };
                                size.Add(productSKU1);
                            }
                        }
                    }
                    if (strArrays.Count() <= 2)
                    {
                        continue;
                    }
                    long.TryParse(strArrays[3], out num6);
                    if (num6 == 0)
                    {
                        continue;
                    }
                    if (maxSaleCount.Version.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Version)))
                    {
                        continue;
                    }
                    long num9 = (
                        from s in product.SKUInfo
                        where s.Version.Equals(sKUInfo.Version)
                        select s).Sum <SKUInfo>((SKUInfo s) => s.Stock);
                    CollectionSKU version     = maxSaleCount.Version;
                    ProductSKU    productSKU2 = new ProductSKU()
                    {
                        Name          = "选择版本",
                        EnabledClass  = (num9 != 0 ? "enabled" : "disabled"),
                        SelectedClass = "",
                        SKUId         = num6,
                        Value         = sKUInfo.Version
                    };
                    version.Add(productSKU2);
                }
                decimal num10 = new decimal(0);
                decimal num11 = new decimal(0);
                num10 = (
                    from s in product.SKUInfo
                    where s.Stock >= 0
                    select s).Min <SKUInfo>((SKUInfo s) => s.SalePrice);
                num11 = (
                    from s in product.SKUInfo
                    where s.Stock >= 0
                    select s).Max <SKUInfo>((SKUInfo s) => s.SalePrice);
                if (!(num10 == new decimal(0)) || !(num11 == new decimal(0)))
                {
                    str = (num11 <= num10 ? string.Format("{0}", num10.ToString("f2")) : string.Format("{0}-{1}", num10.ToString("f2"), num11.ToString("f2")));
                }
                else
                {
                    str = product.MinSalePrice.ToString("f2");
                }
            }
            base.ViewBag.Price = (string.IsNullOrWhiteSpace(str) ? product.MinSalePrice.ToString("f2") : str);
            List <TypeAttributesModel>  typeAttributesModels  = new List <TypeAttributesModel>();
            List <ProductAttributeInfo> productAttributeInfos = ServiceHelper.Create <IProductService>().GetProductAttribute(product.Id).ToList();

            foreach (ProductAttributeInfo productAttributeInfo in productAttributeInfos)
            {
                if (typeAttributesModels.Any((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId))
                {
                    TypeAttributesModel typeAttributesModel = typeAttributesModels.FirstOrDefault((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId);
                    if (typeAttributesModel.AttrValues.Any((TypeAttrValue p) => p.Id == productAttributeInfo.ValueId.ToString()))
                    {
                        continue;
                    }
                    List <TypeAttrValue> attrValues    = typeAttributesModel.AttrValues;
                    TypeAttrValue        typeAttrValue = new TypeAttrValue();
                    valueId            = productAttributeInfo.ValueId;
                    typeAttrValue.Id   = valueId.ToString();
                    typeAttrValue.Name = productAttributeInfo.AttributesInfo.AttributeValueInfo.FirstOrDefault((AttributeValueInfo a) => a.Id == productAttributeInfo.ValueId).Value;
                    attrValues.Add(typeAttrValue);
                }
                else
                {
                    TypeAttributesModel typeAttributesModel1 = new TypeAttributesModel()
                    {
                        AttrId     = productAttributeInfo.AttributeId,
                        AttrValues = new List <TypeAttrValue>(),
                        Name       = productAttributeInfo.AttributesInfo.Name
                    };
                    TypeAttributesModel typeAttributesModel2 = typeAttributesModel1;
                    foreach (AttributeValueInfo attributeValueInfo in productAttributeInfo.AttributesInfo.AttributeValueInfo)
                    {
                        if (!productAttributeInfos.Any((ProductAttributeInfo p) => p.ValueId == attributeValueInfo.Id))
                        {
                            continue;
                        }
                        List <TypeAttrValue> typeAttrValues = typeAttributesModel2.AttrValues;
                        TypeAttrValue        value          = new TypeAttrValue();
                        valueId    = attributeValueInfo.Id;
                        value.Id   = valueId.ToString();
                        value.Name = attributeValueInfo.Value;
                        typeAttrValues.Add(value);
                    }
                    typeAttributesModels.Add(typeAttributesModel2);
                }
            }
            ViewBag.ProductAttrs = typeAttributesModels;
            ICommentService commentService = ServiceHelper.Create <ICommentService>();
            CommentQuery    commentQuery   = new CommentQuery()
            {
                ProductID = product.Id,
                PageNo    = 1,
                PageSize  = 10000
            };
            PageModel <ProductCommentInfo> comments = commentService.GetComments(commentQuery);

            ViewBag.CommentCount = comments.Total;
            IQueryable <ProductConsultationInfo> consultations = ServiceHelper.Create <IConsultationService>().GetConsultations(productId);

            ViewBag.Consultations = consultations.Count();
            double num12 = product.Himall_ProductComments.Count();
            double num13 = product.Himall_ProductComments.Count((ProductCommentInfo item) => item.ReviewMark >= 4);

            ViewBag.NicePercent   = num13 / num12 * 100;
            ViewBag.Consultations = consultations.Count();
            if (ServiceHelper.Create <IVShopService>().GetVShopByShopId(shop.Id) != null)
            {
                ViewBag.VShopId = ServiceHelper.Create <IVShopService>().GetVShopByShopId(shop.Id).Id;
            }
            else
            {
                ViewBag.VShopId = -1;
            }
            IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(product.ShopId);
            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 num14 = 5;

            if (statisticOrderCommentsInfo == null || statisticOrderCommentsInfo3 == null)
            {
                ViewBag.ProductAndDescription     = num14;
                ViewBag.ProductAndDescriptionPeer = num14;
                ViewBag.ProductAndDescriptionMin  = num14;
                ViewBag.ProductAndDescriptionMax  = num14;
            }
            else
            {
                ViewBag.ProductAndDescription     = statisticOrderCommentsInfo.CommentValue;
                ViewBag.ProductAndDescriptionPeer = statisticOrderCommentsInfo3.CommentValue;
                ViewBag.ProductAndDescriptionMin  = statisticOrderCommentsInfo7.CommentValue;
                ViewBag.ProductAndDescriptionMax  = statisticOrderCommentsInfo6.CommentValue;
            }
            if (statisticOrderCommentsInfo1 == null || statisticOrderCommentsInfo4 == null)
            {
                ViewBag.SellerServiceAttitude     = num14;
                ViewBag.SellerServiceAttitudePeer = num14;
                ViewBag.SellerServiceAttitudeMax  = num14;
                ViewBag.SellerServiceAttitudeMin  = num14;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = statisticOrderCommentsInfo1.CommentValue;
                ViewBag.SellerServiceAttitudePeer = statisticOrderCommentsInfo4.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = statisticOrderCommentsInfo8.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = statisticOrderCommentsInfo9.CommentValue;
            }
            if (statisticOrderCommentsInfo5 == null || statisticOrderCommentsInfo2 == null)
            {
                ViewBag.SellerDeliverySpeed     = num14;
                ViewBag.SellerDeliverySpeedPeer = num14;
                ViewBag.SellerDeliverySpeedMax  = num14;
                ViewBag.sellerDeliverySpeedMin  = num14;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = statisticOrderCommentsInfo2.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = statisticOrderCommentsInfo5.CommentValue;
                dynamic viewBag = base.ViewBag;
                num1 = (statisticOrderCommentsInfo10 != null ? statisticOrderCommentsInfo10.CommentValue : new decimal(0));
                viewBag.SellerDeliverySpeedMax = num1;
                dynamic obj = base.ViewBag;
                num2 = (statisticOrderCommentsInfo11 != null ? statisticOrderCommentsInfo11.CommentValue : new decimal(0));
                obj.sellerDeliverySpeedMin = num2;
            }
            base.ViewBag.Logined    = (base.CurrentUser != null ? 1 : 0);
            base.ViewBag.EnabledBuy = (product.AuditStatus != ProductInfo.ProductAuditStatus.Audited || !(limitTimeMarketItem.StartTime <= DateTime.Now) || !(limitTimeMarketItem.EndTime > DateTime.Now) ? false : product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale);
            DateTime endTime  = limitTimeMarketItem.EndTime;
            TimeSpan timeSpan = new TimeSpan(endTime.Ticks);

            endTime = DateTime.Now;
            TimeSpan timeSpan1 = timeSpan.Subtract(new TimeSpan(endTime.Ticks));
            dynamic  viewBag1  = base.ViewBag;

            num             = (timeSpan1.TotalSeconds < 0 ? 0 : timeSpan1.TotalSeconds);
            viewBag1.Second = num;
            return(View(maxSaleCount));
        }
コード例 #12
0
        public object GetVShopIntroduce(long id)
        {
            var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShop(id);

            string qrCodeImagePath = string.Empty;

            if (vshop != null)
            {
                Image  qrcode;
                string vshopUrl = "http://" + Url.Request.RequestUri.Host + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + id;
                //string vshopUrl = Core.HimallIO.GetRomoteImagePath("/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/") + id;
                //string logoFullPath = HttpContext.Current.Server.MapPath(vshop.Logo);
                string logoFullPath = Core.HimallIO.GetRomoteImagePath(vshop.Logo);
                if (string.IsNullOrWhiteSpace(vshop.Logo) || !Core.HimallIO.ExistFile(logoFullPath))
                {
                    qrcode = Core.Helper.QRCodeHelper.Create(vshopUrl);
                }
                else
                {
                    qrcode = Core.Helper.QRCodeHelper.Create(vshopUrl, logoFullPath);
                }

                string fileName = DateTime.Now.ToString("yyMMddHHmmssffffff") + ".jpg";
                qrCodeImagePath = "http://" + Url.Request.RequestUri.Host + "/temp/" + fileName;
                qrcode.Save(HttpContext.Current.Server.MapPath("~/temp/") + fileName);
            }
            var  qrCode   = qrCodeImagePath;
            bool favorite = false;

            if (CurrentUser != null)
            {
                favorite = ServiceProvider.Instance <IShopService> .Create.IsFavoriteShop(CurrentUser.Id, vshop.ShopId);
            }

            var mark     = ShopServiceMark.GetShopComprehensiveMark(vshop.ShopId);
            var shopMark = mark.ComprehensiveMark.ToString();

            #region 获取诊所的评价统计
            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(vshop.ShopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            decimal defaultValue           = 5;
            var     _productAndDescription = defaultValue;
            var     _sellerServiceAttitude = defaultValue;
            var     _sellerDeliverySpeed   = defaultValue;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                _productAndDescription = productAndDescription.CommentValue;
            }
            //诊所服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                _sellerServiceAttitude = sellerServiceAttitude.CommentValue;
            }
            //诊所发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                _sellerDeliverySpeed = sellerDeliverySpeed.CommentValue;
            }
            #endregion
            var vshopModel = new
            {
                QRCode                = qrCode,
                Name                  = vshop.Name,
                IsFavorite            = favorite,
                ProductAndDescription = _productAndDescription,
                SellerDeliverySpeed   = _sellerDeliverySpeed,
                SellerServiceAttitude = _sellerServiceAttitude,
                Description           = vshop.Description,
                ShopId                = vshop.ShopId,
                Id = vshop.Id,
                //Logo = "http://" + Url.Request.RequestUri.Host+vshop.Logo
                Logo = Core.HimallIO.GetRomoteImagePath(vshop.Logo)
            };
            return(Json(new { Success = "True", VShop = vshopModel }));
        }
コード例 #13
0
        public object GetLimitBuyProduct(long id)
        {
            ProductDetailModelForMobie model = new ProductDetailModelForMobie()
            {
                Product = new ProductInfoModel(),
                Shop    = new ShopInfoModel(),
                Color   = new CollectionSKU(),
                Size    = new CollectionSKU(),
                Version = new CollectionSKU()
            };
            ProductInfo    product = null;
            ShopInfo       shop    = null;
            FlashSaleModel market  = null;

            market = ServiceProvider.Instance <ILimitTimeBuyService> .Create.Get(id);

            if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是诊疗项目ID
                market = market == null ? ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetFlaseSaleByProductId(id) : market;

                if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    //跳转到404页面
                    return(Json(new { Success = "false", ErrorMsg = "你所请求的限时购或者诊疗项目不存在!" }));
                }
            }

            if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now))
            {
                return(Json(new { Success = "true", IsValidLimitBuy = "false" }));
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            product = ServiceProvider.Instance <IProductService> .Create.GetProduct(market.ProductId);

            bool hasSku = false;

            #region 诊疗项目SKU
            ProductTypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(product.TypeId);

            string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
            string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
            string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;

            if (product.SKUInfo != null && product.SKUInfo.Count() > 0)
            {
                hasSku = true;
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in product.SKUInfo)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0)
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = product.SKUInfo.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色" ,
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = sku.ShowPic
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1)
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = product.SKUInfo.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码" ,
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2)
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = product.SKUInfo.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本" ,
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            #region 诊所
            shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId);

            var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            var comm = ServiceProvider.Instance <ICommentService> .Create.GetCommentsByProductId(product.Id);

            model.Shop.Name        = shop.ShopName;
            model.Shop.ProductMark = (comm == null || comm.Count() == 0) ? 0 : comm.Average(p => ( decimal )p.ReviewMark);
            model.Shop.Id          = product.ShopId;
            model.Shop.FreeFreight = shop.FreeFreight;
            model.Shop.ProductNum  = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(product.ShopId);

            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(product.ShopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                model.Shop.ProductAndDescription = productAndDescription.CommentValue;
            }
            else
            {
                model.Shop.ProductAndDescription = defaultValue;
            }
            //诊所服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                model.Shop.SellerServiceAttitude = sellerServiceAttitude.CommentValue;
            }
            else
            {
                model.Shop.SellerServiceAttitude = defaultValue;
            }
            //诊所发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                model.Shop.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue;
            }
            else
            {
                model.Shop.SellerDeliverySpeed = defaultValue;
            }
            if (ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id) == null)
            {
                model.Shop.VShopId = -1;
            }
            else
            {
                model.Shop.VShopId = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id).Id;
            }

            //优惠券
            var result = GetCouponList(shop.Id);  //取设置的优惠券
            if (result != null)
            {
                var couponCount = result.Count();
                model.Shop.CouponCount = couponCount;
            }
            #endregion

            #region 诊疗项目
            var consultations = ServiceProvider.Instance <IConsultationService> .Create.GetConsultations(product.Id);

            double total      = product.Himall_ProductComments.Count();
            double niceTotal  = product.Himall_ProductComments.Count(item => item.ReviewMark >= 4);
            bool   isFavorite = false;
            if (CurrentUser == null)
            {
                isFavorite = false;
            }
            else
            {
                isFavorite = ServiceProvider.Instance <IProductService> .Create.IsFavorite(product.Id, CurrentUser.Id);
            }
            var limitBuy = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(product.Id);

            var productImage = new List <string>();
            for (int i = 1; i < 6; i++)
            {
                if (File.Exists(HttpContext.Current.Server.MapPath(product.RelativePath + string.Format("/{0}.png", i))))
                {
                    productImage.Add(Core.HimallIO.GetRomoteImagePath(product.RelativePath + string.Format("/{0}.png", i)));
                }
            }
            model.Product = new ProductInfoModel()
            {
                ProductId          = product.Id,
                CommentCount       = product.Himall_ProductComments.Count(),
                Consultations      = consultations.Count(),
                ImagePath          = productImage,
                IsFavorite         = isFavorite,
                MarketPrice        = market.MinPrice,
                MinSalePrice       = product.MinSalePrice,
                NicePercent        = model.Shop.ProductMark == 0 ? 100 : ( int )((niceTotal / total) * 100),
                ProductName        = product.ProductName,
                ProductSaleStatus  = product.SaleStatus,
                AuditStatus        = product.AuditStatus,
                ShortDescription   = product.ShortDescription,
                ProductDescription = product.ProductDescriptionInfo.ShowMobileDescription,
                IsOnLimitBuy       = limitBuy != null
            };
            #endregion

            LogProduct(market.ProductId);
            //统计诊疗项目浏览量、诊所浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            TimeSpan end    = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
            TimeSpan start  = new TimeSpan(DateTime.Now.Ticks);
            TimeSpan ts     = end.Subtract(start);
            var      second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;

            return(Json(new
            {
                Success = "true",
                IsOnLimitBuy = "true",
                HasSku = hasSku,
                MaxSaleCount = market.LimitCountOfThePeople,
                Title = market.Title,
                Second = second,
                Product = model.Product,
                Shop = model.Shop,
                Color = model.Color,
                Size = model.Size,
                Version = model.Version,
                ColorAlias = colorAlias,
                SizeAlias = sizeAlias,
                VersionAlias = versionAlias
            }));
        }
コード例 #14
0
        public object GetProductDetail(long id)
        {
            ProductDetailModelForMobie model = new ProductDetailModelForMobie()
            {
                Product = new ProductInfoModel(),
                Shop    = new ShopInfoModel(),
                Color   = new CollectionSKU(),
                Size    = new CollectionSKU(),
                Version = new CollectionSKU()
            };

            ProductInfo product = null;
            ShopInfo    shop    = null;

            product = ServiceProvider.Instance <IProductService> .Create.GetProduct(id);

            var cashDepositModel = ServiceProvider.Instance <ICashDepositsService> .Create.GetCashDepositsObligation(product.Id);//提供服务(消费者保障、七天无理由、及时发货)

            model.CashDepositsServer = cashDepositModel;
            #region 根据运费模板获取发货地址
            var freightTemplateService   = ServiceHelper.Create <IFreightTemplateService>();
            FreightTemplateInfo template = freightTemplateService.GetFreightTemplate(product.FreightTemplateId);
            string productAddress        = string.Empty;
            if (template != null && template.SourceAddress.HasValue)
            {
                var fullName = ServiceHelper.Create <IRegionService>().GetFullName(template.SourceAddress.Value);
                if (fullName != null)
                {
                    var ass = fullName.Split(' ');
                    if (ass.Length >= 2)
                    {
                        productAddress = ass[0] + " " + ass[1];
                    }
                    else
                    {
                        productAddress = ass[0];
                    }
                }
            }

            model.ProductAddress  = productAddress;
            model.FreightTemplate = template;
            #endregion
            #region 店铺Logo
            long vShopId;
            shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId);

            var vshopinfo = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id);

            if (vshopinfo == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = vshopinfo.Id;
            }
            model.Shop.VShopId = vShopId;
            model.VShopLog     = ServiceProvider.Instance <IVShopService> .Create.GetVShopLog(model.Shop.VShopId);

            #endregion

            model.Shop.FavoriteShopCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(product.ShopId);//关注人数

            var com = product.Himall_ProductComments.Where(item => !item.IsHidden.HasValue || item.IsHidden.Value == false);

            var limitBuy = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(id);

            #region 商品SKU

            ProductTypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(product.TypeId);

            string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
            string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
            string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;

            if (limitBuy != null)
            {
                var limitSku = ServiceProvider.Instance <ILimitTimeBuyService> .Create.Get(limitBuy.Id);

                var limitSkuItem = limitSku.Details.OrderBy(d => d.Price).FirstOrDefault();
                if (limitSkuItem != null)
                {
                    product.MinSalePrice = limitSkuItem.Price;
                }
            }
            if (product.SKUInfo != null && product.SKUInfo.Count() > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in product.SKUInfo)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0)
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = product.SKUInfo.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = Himall.Core.HimallIO.GetRomoteImagePath(sku.ShowPic)
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1)
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = product.SKUInfo.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2)
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = product.SKUInfo.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            #region 店铺
            shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId);

            var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            var comm = ServiceProvider.Instance <ICommentService> .Create.GetCommentsByProductId(id);

            model.Shop.Name        = shop.ShopName;
            model.Shop.ProductMark = (comm == null || comm.Count() == 0) ? 0 : comm.Average(p => (decimal)p.ReviewMark);
            model.Shop.Id          = product.ShopId;
            model.Shop.FreeFreight = shop.FreeFreight;
            model.Shop.ProductNum  = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(product.ShopId);

            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(product.ShopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                model.Shop.ProductAndDescription = productAndDescription.CommentValue;
            }
            else
            {
                model.Shop.ProductAndDescription = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                model.Shop.SellerServiceAttitude = sellerServiceAttitude.CommentValue;
            }
            else
            {
                model.Shop.SellerServiceAttitude = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                model.Shop.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue;
            }
            else
            {
                model.Shop.SellerDeliverySpeed = defaultValue;
            }
            if (ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id) == null)
            {
                model.Shop.VShopId = -1;
            }
            else
            {
                model.Shop.VShopId = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id).Id;
            }

            //优惠券
            var couponCount = GetCouponList(shop.Id);//取设置的优惠券
            if (couponCount > 0)
            {
                model.Shop.CouponCount = couponCount;
            }

            // 客服
            var customerServices = CustomerServiceApplication.GetMobileCustomerService(shop.Id);
            var meiqia           = CustomerServiceApplication.GetPreSaleByShopId(shop.Id).FirstOrDefault(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia);
            if (meiqia != null)
            {
                customerServices.Insert(0, meiqia);
            }
            #endregion

            #region 商品
            var consultations = ServiceProvider.Instance <IConsultationService> .Create.GetConsultations(id);

            double  total          = product.Himall_ProductComments.Count();
            double  niceTotal      = product.Himall_ProductComments.Count(item => item.ReviewMark >= 4);
            bool    isFavorite     = false;
            bool    IsFavoriteShop = false;
            decimal discount       = 1M;
            if (CurrentUser == null)
            {
                isFavorite     = false;
                IsFavoriteShop = false;
            }
            else
            {
                isFavorite = ServiceProvider.Instance <IProductService> .Create.IsFavorite(product.Id, CurrentUser.Id);

                var favoriteShopIds = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Select(item => item.ShopId).ToArray();//获取已关注店铺

                IsFavoriteShop = favoriteShopIds.Contains(product.ShopId);
                discount       = CurrentUser.MemberDiscount;
            }

            var productImage = new List <string>();
            for (int i = 1; i < 6; i++)
            {
                if (Core.HimallIO.ExistFile(product.RelativePath + string.Format("/{0}.png", i)))
                {
                    var path = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, i, (int)Himall.CommonModel.ImageSize.Size_350);
                    productImage.Add(path);
                }
            }
            //File.Exists(HttpContext.Current.Server.MapPath(product.ImagePath + string.Format("/{0}.png", 1)));
            decimal minSalePrice    = shop.IsSelf ? product.MinSalePrice * discount : product.MinSalePrice;
            var     isValidLimitBuy = "false";
            if (limitBuy != null)
            {
                isValidLimitBuy = "true";
                minSalePrice    = limitBuy.MinPrice; //限时购不打折
            }
            bool isFightGroupActive = false;
            var  activeInfo         = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveByProId(product.Id);

            if (activeInfo != null && activeInfo.ActiveStatus > FightGroupActiveStatus.Ending)
            {
                isFightGroupActive = true;
            }

            model.Product = new ProductInfoModel()
            {
                ProductId          = product.Id,
                CommentCount       = com.Count(),//product.Himall_ProductComments.Count(),
                Consultations      = consultations.Count(),
                ImagePath          = productImage,
                IsFavorite         = isFavorite,
                MarketPrice        = product.MarketPrice,
                MinSalePrice       = minSalePrice,
                NicePercent        = model.Shop.ProductMark == 0 ? 100 : (int)((niceTotal / total) * 100),
                ProductName        = product.ProductName,
                ProductSaleStatus  = product.SaleStatus,
                AuditStatus        = product.AuditStatus,
                ShortDescription   = product.ShortDescription,
                ProductDescription = GetProductDescription(product.ProductDescriptionInfo),
                IsOnLimitBuy       = limitBuy != null
            };
            #endregion

            #region 佣金
            var     probroker      = DistributionApplication.GetDistributionProductInfo(id);
            var     IsDistribution = false;
            decimal Brokerage      = 0;
            if (probroker != null)
            {
                IsDistribution = true;
                Brokerage      = probroker.Commission;
            }
            #endregion

            #region  代金红包

            var bonus = ServiceProvider.Instance <IShopBonusService> .Create.GetByShopId(shop.Id);

            int     BonusCount             = 0;
            decimal BonusGrantPrice        = 0;
            decimal BonusRandomAmountStart = 0;
            decimal BonusRandomAmountEnd   = 0;

            if (bonus != null)
            {
                BonusCount             = bonus.Count;
                BonusGrantPrice        = bonus.GrantPrice;
                BonusRandomAmountStart = bonus.RandomAmountStart;
                BonusRandomAmountEnd   = bonus.RandomAmountEnd;
            }

            var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, shop.Id);

            #endregion

            LogProduct(id);
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);
            var IsPromoter = false;
            if (CurrentUser != null && CurrentUser.Id > 0)
            {
                var prom = DistributionApplication.GetPromoterByUserId(CurrentUser.Id);
                if (prom != null && prom.Status == PromoterInfo.PromoterStatus.Audited)
                {
                    IsPromoter = true;
                }
            }
            return(Json(new
            {
                Success = "true",
                IsOnLimitBuy = isValidLimitBuy,
                IsFightGroupActive = isFightGroupActive,
                ActiveId = isFightGroupActive ? activeInfo.Id : 0,
                ActiveStatus = activeInfo != null ? activeInfo.ActiveStatus.GetHashCode() : 0,
                MaxSaleCount = limitBuy == null ? 0 : limitBuy.LimitCountOfThePeople,
                Title = limitBuy == null ? string.Empty : limitBuy.Title,
                Second = limitBuy == null ? 0 : (limitBuy.EndDate - DateTime.Now).TotalSeconds,
                Product = model.Product,
                CashDepositsServer = model.CashDepositsServer,                                //提供服务(消费者保障、七天无理由、及时发货)
                ProductAddress = model.ProductAddress,                                        //发货地址
                Free = model.FreightTemplate.IsFree == FreightTemplateType.Free ? "免运费" : "", //是否免运费
                VShopLog = Himall.Core.HimallIO.GetRomoteImagePath(model.VShopLog),
                Shop = model.Shop,
                IsFavoriteShop = IsFavoriteShop,
                Color = model.Color,
                Size = model.Size,
                Version = model.Version,
                BonusCount = BonusCount,
                BonusGrantPrice = BonusGrantPrice,
                BonusRandomAmountStart = BonusRandomAmountStart,
                BonusRandomAmountEnd = BonusRandomAmountEnd,
                fullDiscount = fullDiscount,
                ColorAlias = colorAlias,
                SizeAlias = sizeAlias,
                VersionAlias = versionAlias,
                IsDistribution = IsDistribution,
                Brokerage = Brokerage.ToString("f2"),
                IsPromoter = IsPromoter,
                userId = CurrentUser == null ? 0 : CurrentUser.Id,
                IsOpenStore = SiteSettingApplication.GetSiteSettings() != null && SiteSettingApplication.GetSiteSettings().IsOpenStore,
                CustomerServices = customerServices
            }));
        }
コード例 #15
0
        ///// <summary>
        ///// 获取限时抢购商品详情
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        public object GetLimitBuyProduct(string openId, long countDownId)
        {
            CheckUserLogin();
            ProductDetailModelForMobie model = new ProductDetailModelForMobie()
            {
                Product = new ProductInfoModel(),
                Shop    = new ShopInfoModel(),
                Color   = new CollectionSKU(),
                Size    = new CollectionSKU(),
                Version = new CollectionSKU()
            };
            ProductInfo    product = null;
            ShopInfo       shop    = null;
            FlashSaleModel market  = null;

            market = ServiceProvider.Instance <ILimitTimeBuyService> .Create.Get(countDownId);


            if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是商品ID
                market = market == null ? ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetFlaseSaleByProductId(countDownId) : market;

                if (market == null || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    //跳转到404页面
                    return(Json(new { Success = "false", ErrorMsg = "你所请求的限时购或者商品不存在!" }));
                }
            }

            if (market != null && (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing || DateTime.Parse(market.EndDate) < DateTime.Now))
            {
                return(Json(new { Success = "true", IsValidLimitBuy = "false" }));
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            product = ServiceProvider.Instance <IProductService> .Create.GetProduct(market.ProductId);

            bool hasSku = false;

            #region 商品SKU
            ProductTypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(product.TypeId);

            string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
            string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
            string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;


            List <object> SkuItemList = new List <object>();
            List <object> Skus        = new List <object>();
            if (product.SKUInfo != null && product.SKUInfo.Count() > 0)
            {
                hasSku = true;
                #region 颜色
                long          colorId = 0, sizeId = 0, versionId = 0;
                List <object> colorAttributeValue = new List <object>();
                List <string> listcolor           = new List <string>();
                foreach (var sku in product.SKUInfo)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0)
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }                                            //相同颜色规格累加对应值
                        if (colorId != 0)
                        {
                            if (!listcolor.Contains(sku.Color))
                            {
                                var c          = product.SKUInfo.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                var colorvalue = new
                                {
                                    ValueId           = colorId,
                                    UseAttributeImage = "False",
                                    Value             = sku.Color,
                                    ImageUrl          = Himall.Core.HimallIO.GetRomoteImagePath(sku.ShowPic)
                                };
                                listcolor.Add(sku.Color);
                                colorAttributeValue.Add(colorvalue);
                            }
                        }
                    }
                }
                var color = new
                {
                    AttributeName  = colorAlias,
                    AttributeId    = product.TypeId,
                    AttributeValue = colorAttributeValue
                };
                if (colorId > 0)
                {
                    SkuItemList.Add(color);
                }
                #endregion

                #region 容量
                List <object> sizeAttributeValue = new List <object>();
                List <string> listsize           = new List <string>();
                foreach (var sku in product.SKUInfo)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 1)
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!listsize.Contains(sku.Size))
                            {
                                var ss        = product.SKUInfo.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                var sizeValue = new
                                {
                                    ValueId           = sizeId,
                                    UseAttributeImage = false,
                                    Value             = sku.Size,
                                    ImageUrl          = Himall.Core.HimallIO.GetRomoteImagePath(sku.ShowPic)
                                };
                                listsize.Add(sku.Size);
                                sizeAttributeValue.Add(sizeValue);
                            }
                        }
                    }
                }
                var size = new
                {
                    AttributeName  = sizeAlias,
                    AttributeId    = product.TypeId,
                    AttributeValue = sizeAttributeValue
                };
                if (sizeId > 0)
                {
                    SkuItemList.Add(size);
                }
                #endregion

                #region 规格
                List <object> versionAttributeValue = new List <object>();
                List <string> listversion           = new List <string>();
                foreach (var sku in product.SKUInfo)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 2)
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!listversion.Contains(sku.Version))
                            {
                                var v            = product.SKUInfo.Where(s => s.Version.Equals(sku.Version));
                                var versionValue = new
                                {
                                    ValueId           = versionId,
                                    UseAttributeImage = false,
                                    Value             = sku.Version,
                                    ImageUrl          = Himall.Core.HimallIO.GetRomoteImagePath(sku.ShowPic)
                                };
                                listversion.Add(sku.Version);
                                versionAttributeValue.Add(versionValue);
                            }
                        }
                    }
                }
                var version = new
                {
                    AttributeName  = versionAlias,
                    AttributeId    = product.TypeId,
                    AttributeValue = versionAttributeValue
                };
                if (versionId > 0)
                {
                    SkuItemList.Add(version);
                }
                #endregion

                #region Sku值
                foreach (var sku in product.SKUInfo)
                {
                    FlashSaleDetailInfo detailInfo = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetDetail(sku.Id);

                    var prosku = new
                    {
                        SkuItems        = "",
                        MemberPrices    = "",
                        SkuId           = sku.Id,
                        ProductId       = product.Id,
                        SKU             = sku.Sku,
                        Weight          = 0,
                        Stock           = sku.Stock,
                        WarningStock    = sku.SafeStock,
                        CostPrice       = sku.CostPrice,
                        SalePrice       = sku.SalePrice,//限时抢购价格
                        StoreStock      = 0,
                        StoreSalePrice  = 0,
                        OldSalePrice    = 0,
                        ImageUrl        = "",
                        ThumbnailUrl40  = "",
                        ThumbnailUrl410 = "",
                        MaxStock        = 15,
                        FreezeStock     = 0,
                        ActivityStock   = sku.Stock,       //限时抢购库存
                        ActivityPrice   = detailInfo.Price //限时抢购价格
                    };
                    Skus.Add(prosku);
                }
                #endregion
            }
            #endregion

            #region 店铺
            shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId);

            var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);
            model.Shop.PackMark          = mark.PackMark;
            model.Shop.ServiceMark       = mark.ServiceMark;
            model.Shop.ComprehensiveMark = mark.ComprehensiveMark;
            var comm = ServiceProvider.Instance <ICommentService> .Create.GetCommentsByProductId(product.Id);

            model.Shop.Name        = shop.ShopName;
            model.Shop.ProductMark = (comm == null || comm.Count() == 0) ? 0 : comm.Average(p => (decimal)p.ReviewMark);
            model.Shop.Id          = product.ShopId;
            model.Shop.FreeFreight = shop.FreeFreight;
            model.Shop.ProductNum  = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(product.ShopId);

            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(product.ShopId);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                model.Shop.ProductAndDescription = productAndDescription.CommentValue;
            }
            else
            {
                model.Shop.ProductAndDescription = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                model.Shop.SellerServiceAttitude = sellerServiceAttitude.CommentValue;
            }
            else
            {
                model.Shop.SellerServiceAttitude = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                model.Shop.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue;
            }
            else
            {
                model.Shop.SellerDeliverySpeed = defaultValue;
            }
            if (ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id) == null)
            {
                model.Shop.VShopId = -1;
            }
            else
            {
                model.Shop.VShopId = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id).Id;
            }


            List <object> coupons = new List <object>();
            //优惠券
            var result = GetCouponList(shop.Id);//取设置的优惠券
            if (result != null)
            {
                var couponCount = result.Count();
                model.Shop.CouponCount = couponCount;
                if (result.ToList().Count > 0)
                {
                    foreach (var item in result.ToList())
                    {
                        var couponInfo = new
                        {
                            CouponId           = item.Id,
                            CouponName         = item.CouponName,
                            Price              = item.Price,
                            SendCount          = item.Num,
                            UserLimitCount     = item.PerMax,
                            OrderUseLimit      = item.OrderAmount,
                            StartTime          = item.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                            ClosingTime        = item.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                            CanUseProducts     = "",
                            ObtainWay          = item.ReceiveType,
                            NeedPoint          = item.NeedIntegral,
                            UseWithGroup       = false,
                            UseWithPanicBuying = false,
                            UseWithFireGroup   = false,
                            LimitText          = item.CouponName,
                            CanUseProduct      = "店铺通用",
                            StartTimeText      = item.StartTime.ToString("yyyy.MM.dd"),
                            ClosingTimeText    = item.EndTime.ToString("yyyy.MM.dd")
                        };
                        coupons.Add(couponInfo);
                    }
                }
            }


            #endregion

            #region 商品
            var consultations = ServiceProvider.Instance <IConsultationService> .Create.GetConsultations(product.Id);

            double total      = product.Himall_ProductComments.Count();
            double niceTotal  = product.Himall_ProductComments.Count(item => item.ReviewMark >= 4);
            bool   isFavorite = false;
            if (CurrentUser == null)
            {
                isFavorite = false;
            }
            else
            {
                isFavorite = ServiceProvider.Instance <IProductService> .Create.IsFavorite(product.Id, CurrentUser.Id);
            }
            var limitBuy = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(product.Id);

            var productImage = new List <string>();
            for (int i = 1; i < 6; i++)
            {
                if (File.Exists(HttpContext.Current.Server.MapPath(product.RelativePath + string.Format("/{0}.png", i))))
                {
                    productImage.Add(Core.HimallIO.GetRomoteImagePath(product.RelativePath + string.Format("/{0}.png", i)));
                }
            }
            model.Product = new ProductInfoModel()
            {
                ProductId          = product.Id,
                CommentCount       = product.Himall_ProductComments.Count(),
                Consultations      = consultations.Count(),
                ImagePath          = productImage,
                IsFavorite         = isFavorite,
                MarketPrice        = product.MarketPrice,
                MinSalePrice       = product.MinSalePrice,
                NicePercent        = model.Shop.ProductMark == 0 ? 100 : (int)((niceTotal / total) * 100),
                ProductName        = product.ProductName,
                ProductSaleStatus  = product.SaleStatus,
                AuditStatus        = product.AuditStatus,
                ShortDescription   = product.ShortDescription,
                ProductDescription = product.ProductDescriptionInfo.ShowMobileDescription,
                IsOnLimitBuy       = limitBuy != null
            };
            #endregion

            //LogProduct(market.ProductId);
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            TimeSpan end    = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
            TimeSpan start  = new TimeSpan(DateTime.Now.Ticks);
            TimeSpan ts     = end.Subtract(start);
            var      second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;

            List <object> ProductImgs = new List <object>();
            for (int i = 1; i < 5; i++)
            {
                ProductImgs.Add(Core.HimallIO.GetRomoteProductSizeImage(product.ImagePath, i, (int)ImageSize.Size_350));
            }

            var countDownStatus = 0;

            if (market.Status == FlashSaleInfo.FlashSaleStatus.Ended)
            {
                countDownStatus = 4;//"PullOff";  //已下架
            }
            else if (market.Status == FlashSaleInfo.FlashSaleStatus.Cancelled || market.Status == FlashSaleInfo.FlashSaleStatus.AuditFailed || market.Status == FlashSaleInfo.FlashSaleStatus.WaitForAuditing)
            {
                countDownStatus = 4;//"NoJoin";  //未参与
            }
            else if (DateTime.Parse(market.BeginDate) > DateTime.Now)
            {
                countDownStatus = 6; // "AboutToBegin";  //即将开始   6
            }
            else if (DateTime.Parse(market.EndDate) < DateTime.Now)
            {
                countDownStatus = 4;// "ActivityEnd";   //已结束  4
            }
            else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ended)
            {
                countDownStatus = 6;// "SoldOut";  //已抢完
            }
            else
            {
                countDownStatus = 2;//"Normal";  //正常  2
            }

            //Normal:正常
            //PullOff:已下架
            //NoJoin:未参与
            //AboutToBegin:即将开始
            //ActivityEnd:已结束
            //SoldOut:已抢完

            var json = new
            {
                Status = "OK",
                Data   = new
                {
                    CountDownId      = market.Id,//.CountDownId,
                    MaxCount         = market.LimitCountOfThePeople,
                    CountDownStatus  = countDownStatus,
                    StartDate        = DateTime.Parse(market.BeginDate).ToString("yyyy/MM/dd HH:mm:ss"),
                    EndDate          = DateTime.Parse(market.EndDate).ToString("yyyy/MM/dd HH:mm:ss"),
                    NowTime          = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo),
                    ProductId        = product.Id,
                    ProductName      = product.ProductName,
                    MetaDescription  = model.Product.ProductDescription,
                    ShortDescription = product.ShortDescription,
                    ShowSaleCounts   = product.SaleCounts.ToString(),
                    Weight           = product.Weight.ToString(),
                    MinSalePrice     = market.MinPrice.ToString("0.##"), //product.SKUInfo.Min(c => c.SalePrice).ToString("0.##"),//限时抢购价格
                    MaxSalePrice     = product.MarketPrice,
                    Stock            = market.Quantity,                  //限时抢购库存
                    MarketPrice      = product.MarketPrice,              //product.SKUInfo.Min(c => c.SalePrice).ToString("0.##"),
                    IsfreeShipping   = product.Himall_Shops.FreeFreight, //product.Product.IsfreeShipping.ToString(),
                    ThumbnailUrl60   = Core.HimallIO.GetRomoteProductSizeImage(product.ImagePath, 1, (int)ImageSize.Size_350),
                    ProductImgs      = ProductImgs,
                    SkuItemList      = SkuItemList,
                    Skus             = Skus,
                    Freight          = 0,
                    Coupons          = coupons,
                }
            };
            return(json);
        }
コード例 #16
0
        public ActionResult Detail(string id)
        {
            ProductDescriptionTemplateInfo template;
            long                        num15;
            TimeSpan                    span;
            TimeSpan                    span2;
            TimeSpan                    span3;
            ParameterExpression         expression;
            LimitTimeBuyDetailModel     model  = new LimitTimeBuyDetailModel();
            string                      str    = "";
            LimitTimeProductDetailModel model2 = new LimitTimeProductDetailModel
            {
                MainId = long.Parse(id),
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };
            FlashSaleModel model3    = null;
            ShopInfo       shop      = null;
            long           productId = 0L;
            long           result    = 0L;

            if (long.TryParse(id, out result))
            {
            }
            if (result == 0L)
            {
                return(base.RedirectToAction("Error404", "Error", new { area = "Mobile" }));
            }
            model3 = this._iLimitTimeBuyService.Get(result);
            switch (model3.Status)
            {
            case FlashSaleInfo.FlashSaleStatus.Ended:
                return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId }));

            case FlashSaleInfo.FlashSaleStatus.Cancelled:
                return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId }));
            }
            model2.FlashSale = model3;
            if ((model3 == null) || (model3.Status != FlashSaleInfo.FlashSaleStatus.Ongoing))
            {
                model3 = (model3 == null) ? this._iLimitTimeBuyService.GetFlaseSaleByProductId(result) : model3;
                if (model3 == null)
                {
                    return(base.RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
                if (model3.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId }));
                }
            }
            if ((model3 != null) && ((model3.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) || (DateTime.Parse(model3.EndDate) < DateTime.Now)))
            {
                return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId }));
            }
            model2.MaxSaleCount = model3.LimitCountOfThePeople;
            model2.Title        = model3.Title;
            shop = this._iShopService.GetShop(model3.ShopId, false);
            if ((model3 == null) || (model3.Id == 0L))
            {
                return(base.RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            ProductInfo product = this._iProductService.GetProduct(model3.ProductId);

            productId                 = model3.ProductId;
            model2.Product            = product;
            model2.ProductDescription = product.ProductDescriptionInfo.ShowMobileDescription;
            if (product.ProductDescriptionInfo.DescriptionPrefixId != 0L)
            {
                template = this._iProductDescriptionTemplateService.GetTemplate(product.ProductDescriptionInfo.DescriptionPrefixId, product.ShopId);
                model2.DescriptionPrefix = (template == null) ? "" : template.Content;
            }
            if (product.ProductDescriptionInfo.DescriptiondSuffixId != 0L)
            {
                template = this._iProductDescriptionTemplateService.GetTemplate(product.ProductDescriptionInfo.DescriptiondSuffixId, product.ShopId);
                model2.DescriptiondSuffix = (template == null) ? "" : template.Content;
            }
            ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id);

            model2.Shop.PackMark          = shopComprehensiveMark.PackMark;
            model2.Shop.ServiceMark       = shopComprehensiveMark.ServiceMark;
            model2.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark;
            IQueryable <ProductCommentInfo> commentsByProductId = this._iCommentService.GetCommentsByProductId(productId);

            model2.Shop.Name = shop.ShopName;
            Decimal num1;

            if (commentsByProductId != null && Queryable.Count <ProductCommentInfo>(commentsByProductId) != 0)
            {
                num1 = Queryable.Average <ProductCommentInfo>(commentsByProductId, (Expression <Func <ProductCommentInfo, Decimal> >)(p => (Decimal)p.ReviewMark));
            }
            else
            {
                num1 = new Decimal(0);
            }
            model2.Shop.ProductMark = num1;
            model2.Shop.Id          = product.ShopId;
            model2.Shop.FreeFreight = shop.FreeFreight;
            model.ProductNum        = this._iProductService.GetShopOnsaleProducts(product.ShopId);
            model.FavoriteShopCount = this._iShopService.GetShopFavoritesCount(product.ShopId);
            if (base.CurrentUser == null)
            {
                model.IsFavorite     = false;
                model.IsFavoriteShop = false;
            }
            else
            {
                model.IsFavorite     = this._iProductService.IsFavorite(product.Id, base.CurrentUser.Id);
                model.IsFavoriteShop = (from item in this._iShopService.GetFavoriteShopInfos(base.CurrentUser.Id) select item.ShopId).ToArray <long>().Contains <long>(product.ShopId);
            }
            List <ShopCategoryInfo> source = this._iShopCategoryService.GetShopCategory(product.ShopId).ToList <ShopCategoryInfo>();

            using (IEnumerator <ShopCategoryInfo> enumerator = (from s in source
                                                                where s.ParentCategoryId == 0L
                                                                select s).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Func <ShopCategoryInfo, bool> predicate = null;
                    ShopCategoryInfo  main   = enumerator.Current;
                    CategoryJsonModel model5 = new CategoryJsonModel
                    {
                        Name        = main.Name,
                        Id          = main.Id.ToString(),
                        SubCategory = new List <SecondLevelCategory>()
                    };
                    if (predicate == null)
                    {
                        predicate = s => s.ParentCategoryId == main.Id;
                    }
                    foreach (ShopCategoryInfo info4 in source.Where <ShopCategoryInfo>(predicate))
                    {
                        SecondLevelCategory category = new SecondLevelCategory
                        {
                            Name = info4.Name,
                            Id   = info4.Id.ToString()
                        };
                        model5.SubCategory.Add(category);
                    }
                    model2.ShopCategory.Add(model5);
                }
            }
            IQueryable <ProductInfo> hotSaleProduct = this._iProductService.GetHotSaleProduct(shop.Id, 5);

            if (hotSaleProduct != null)
            {
                foreach (ProductInfo info5 in hotSaleProduct.ToArray <ProductInfo>())
                {
                    HotProductInfo info6 = new HotProductInfo
                    {
                        ImgPath   = info5.ImagePath,
                        Name      = info5.ProductName,
                        Price     = info5.MinSalePrice,
                        Id        = info5.Id,
                        SaleCount = (int)info5.SaleCounts
                    };
                    model2.HotSaleProducts.Add(info6);
                }
            }
            IQueryable <ProductInfo> hotConcernedProduct = this._iProductService.GetHotConcernedProduct(shop.Id, 5);

            if (hotConcernedProduct != null)
            {
                foreach (ProductInfo info5 in hotConcernedProduct.ToArray <ProductInfo>())
                {
                    HotProductInfo info7 = new HotProductInfo
                    {
                        ImgPath   = info5.ImagePath,
                        Name      = info5.ProductName,
                        Price     = info5.MinSalePrice,
                        Id        = info5.Id,
                        SaleCount = info5.ConcernedCount
                    };
                    model2.HotAttentionProducts.Add(info7);
                }
            }
            ProductTypeInfo type = this._iTypeService.GetType(product.TypeId);
            string          str2 = ((type == null) || string.IsNullOrEmpty(type.ColorAlias)) ? SpecificationType.Color.ToDescription() : type.ColorAlias;
            string          str3 = ((type == null) || string.IsNullOrEmpty(type.SizeAlias)) ? SpecificationType.Size.ToDescription() : type.SizeAlias;
            string          str4 = ((type == null) || string.IsNullOrEmpty(type.VersionAlias)) ? SpecificationType.Version.ToDescription() : type.VersionAlias;

            model2.ColorAlias   = str2;
            model2.SizeAlias    = str3;
            model2.VersionAlias = str4;
            if ((product.SKUInfo != null) && (product.SKUInfo.Count <SKUInfo>() > 0))
            {
                long num3 = 0L;
                long num4 = 0L;
                long num5 = 0L;
                using (IEnumerator <SKUInfo> enumerator3 = product.SKUInfo.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        Func <ProductSKU, bool> func2 = null;
                        Func <SKUInfo, bool>    func3 = null;
                        Func <ProductSKU, bool> func4 = null;
                        Func <SKUInfo, bool>    func5 = null;
                        Func <ProductSKU, bool> func6 = null;
                        Func <SKUInfo, bool>    func7 = null;
                        SKUInfo  sku      = enumerator3.Current;
                        string[] strArray = sku.Id.Split(new char[] { '_' });
                        if (strArray.Count <string>() > 0)
                        {
                            if (long.TryParse(strArray[1], out num3))
                            {
                            }
                            if (num3 != 0L)
                            {
                                if (func2 == null)
                                {
                                    func2 = v => v.Value.Equals(sku.Color);
                                }
                                if (!model2.Color.Any <ProductSKU>(func2))
                                {
                                    if (func3 == null)
                                    {
                                        func3 = s => s.Color.Equals(sku.Color);
                                    }
                                    long       num6 = product.SKUInfo.Where <SKUInfo>(func3).Sum <SKUInfo>((Func <SKUInfo, long>)(s => s.Stock));
                                    ProductSKU tsku = new ProductSKU
                                    {
                                        Name          = "选择" + str2,
                                        EnabledClass  = (num6 != 0L) ? "enabled" : "disabled",
                                        SelectedClass = "",
                                        SkuId         = num3,
                                        Value         = sku.Color,
                                        Img           = sku.ShowPic
                                    };
                                    model2.Color.Add(tsku);
                                }
                            }
                        }
                        if (strArray.Count <string>() > 1)
                        {
                            if (long.TryParse(strArray[2], out num4))
                            {
                            }
                            if (num4 != 0L)
                            {
                                if (func4 == null)
                                {
                                    func4 = v => v.Value.Equals(sku.Size);
                                }
                                if (!model2.Size.Any <ProductSKU>(func4))
                                {
                                    if (func5 == null)
                                    {
                                        func5 = s => s.Size.Equals(sku.Size);
                                    }
                                    long       num7  = product.SKUInfo.Where <SKUInfo>(func5).Sum <SKUInfo>((Func <SKUInfo, long>)(s1 => s1.Stock));
                                    ProductSKU tsku2 = new ProductSKU
                                    {
                                        Name          = "选择" + str3,
                                        EnabledClass  = (num7 != 0L) ? "enabled" : "disabled",
                                        SelectedClass = "",
                                        SkuId         = num4,
                                        Value         = sku.Size
                                    };
                                    model2.Size.Add(tsku2);
                                }
                            }
                        }
                        if (strArray.Count <string>() > 2)
                        {
                            if (long.TryParse(strArray[3], out num5))
                            {
                            }
                            if (num5 != 0L)
                            {
                                if (func6 == null)
                                {
                                    func6 = v => v.Value.Equals(sku.Version);
                                }
                                if (!model2.Version.Any <ProductSKU>(func6))
                                {
                                    if (func7 == null)
                                    {
                                        func7 = s => s.Version.Equals(sku.Version);
                                    }
                                    long       num8  = product.SKUInfo.Where <SKUInfo>(func7).Sum <SKUInfo>((Func <SKUInfo, long>)(s => s.Stock));
                                    ProductSKU tsku3 = new ProductSKU
                                    {
                                        Name          = "选择" + str4,
                                        EnabledClass  = (num8 != 0L) ? "enabled" : "disabled",
                                        SelectedClass = "",
                                        SkuId         = num5,
                                        Value         = sku.Version
                                    };
                                    model2.Version.Add(tsku3);
                                }
                            }
                        }
                    }
                }
                decimal num9  = 0M;
                decimal num10 = 0M;
                num9 = (from s in product.SKUInfo
                        where s.Stock >= 0L
                        select s).Min <SKUInfo>((Func <SKUInfo, decimal>)(s => s.SalePrice));
                num10 = (from s in product.SKUInfo
                         where s.Stock >= 0L
                         select s).Max <SKUInfo>((Func <SKUInfo, decimal>)(s => s.SalePrice));
                if ((num9 == 0M) && (num10 == 0M))
                {
                    str = product.MinSalePrice.ToString("f2");
                }
                else if (num10 > num9)
                {
                    str = string.Format("{0}-{1}", num9.ToString("f2"), num10.ToString("f2"));
                }
                else
                {
                    str = string.Format("{0}", num9.ToString("f2"));
                }
            }
            model.Price = string.IsNullOrWhiteSpace(str) ? product.MinSalePrice.ToString("f2") : str;
            List <TypeAttributesModel>  list2 = new List <TypeAttributesModel>();
            List <ProductAttributeInfo> list3 = this._iProductService.GetProductAttribute(product.Id).ToList <ProductAttributeInfo>();

            using (List <ProductAttributeInfo> .Enumerator enumerator4 = list3.GetEnumerator())
            {
                while (enumerator4.MoveNext())
                {
                    Func <TypeAttributesModel, bool> func9  = null;
                    Func <TypeAttributesModel, bool> func10 = null;
                    Func <TypeAttrValue, bool>       func11 = null;
                    Func <AttributeValueInfo, bool>  func12 = null;
                    ProductAttributeInfo             attr   = enumerator4.Current;
                    if (func9 == null)
                    {
                        func9 = p => p.AttrId == attr.AttributeId;
                    }
                    if (!list2.Any <TypeAttributesModel>(func9))
                    {
                        TypeAttributesModel model7 = new TypeAttributesModel
                        {
                            AttrId     = attr.AttributeId,
                            AttrValues = new List <TypeAttrValue>(),
                            Name       = attr.AttributesInfo.Name
                        };
                        using (IEnumerator <AttributeValueInfo> enumerator5 = attr.AttributesInfo.AttributeValueInfo.GetEnumerator())
                        {
                            while (enumerator5.MoveNext())
                            {
                                Func <ProductAttributeInfo, bool> func8 = null;
                                AttributeValueInfo attrV = enumerator5.Current;
                                if (func8 == null)
                                {
                                    func8 = p => p.ValueId == attrV.Id;
                                }
                                if (list3.Any <ProductAttributeInfo>(func8))
                                {
                                    TypeAttrValue value2 = new TypeAttrValue
                                    {
                                        Id   = attrV.Id.ToString(),
                                        Name = attrV.Value
                                    };
                                    model7.AttrValues.Add(value2);
                                }
                            }
                        }
                        list2.Add(model7);
                    }
                    else
                    {
                        if (func10 == null)
                        {
                            func10 = p => p.AttrId == attr.AttributeId;
                        }
                        TypeAttributesModel model9 = list2.FirstOrDefault <TypeAttributesModel>(func10);
                        if (func11 == null)
                        {
                            func11 = p => p.Id == attr.ValueId.ToString();
                        }
                        if (!model9.AttrValues.Any <TypeAttrValue>(func11))
                        {
                            TypeAttrValue value3 = new TypeAttrValue
                            {
                                Id = attr.ValueId.ToString()
                            };
                            if (func12 == null)
                            {
                                func12 = a => a.Id == attr.ValueId;
                            }
                            value3.Name = attr.AttributesInfo.AttributeValueInfo.FirstOrDefault <AttributeValueInfo>(func12).Value;
                            model9.AttrValues.Add(value3);
                        }
                    }
                }
            }
            model.ProductAttrs = list2;
            IEnumerable <ProductCommentInfo> enumerable = Enumerable.Where <ProductCommentInfo>((IEnumerable <ProductCommentInfo>)product.Himall_ProductComments, (Func <ProductCommentInfo, bool>)(item => !item.IsHidden.HasValue || !item.IsHidden.Value));
            int num11 = enumerable.Count <ProductCommentInfo>();

            model.CommentCount = num11;
            IQueryable <ProductConsultationInfo> consultations = this._iConsultationService.GetConsultations(productId);

            model.Consultations = consultations.Count <ProductConsultationInfo>();
            double num12 = num11;
            double num13 = enumerable.Count <ProductCommentInfo>(item => item.ReviewMark >= 4);

            model.NicePercent   = (int)((num13 / num12) * 100.0);
            model.Consultations = consultations.Count <ProductConsultationInfo>();
            if (this._iVShopService.GetVShopByShopId(shop.Id) == null)
            {
                model.VShopId = -1L;
            }
            else
            {
                model.VShopId = this._iVShopService.GetVShopByShopId(shop.Id).Id;
            }
            IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = this._iShopService.GetShopStatisticOrderComments(product.ShopId);
            StatisticOrderCommentsInfo info9 = (from c in shopStatisticOrderComments
                                                where ((int)c.CommentKey) == 1
                                                select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info10 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 9
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info11 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 5
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info12 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 2
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info13 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 10
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info14 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 6
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info15 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 3
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info16 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 4
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info17 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 11
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info18 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 12
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info19 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 7
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            StatisticOrderCommentsInfo info20 = (from c in shopStatisticOrderComments
                                                 where ((int)c.CommentKey) == 8
                                                 select c).FirstOrDefault <StatisticOrderCommentsInfo>();
            decimal num14 = 5M;

            if (!(((info9 == null) || (info12 == null)) || shop.IsSelf))
            {
                model.ProductAndDescription     = info9.CommentValue;
                model.ProductAndDescriptionPeer = info12.CommentValue;
                model.ProductAndDescriptionMin  = info16.CommentValue;
                model.ProductAndDescriptionMax  = info15.CommentValue;
            }
            else
            {
                model.ProductAndDescription     = num14;
                model.ProductAndDescriptionPeer = num14;
                model.ProductAndDescriptionMin  = num14;
                model.ProductAndDescriptionMax  = num14;
            }
            if (!(((info10 == null) || (info13 == null)) || shop.IsSelf))
            {
                model.SellerServiceAttitude     = info10.CommentValue;
                model.SellerServiceAttitudePeer = info13.CommentValue;
                model.SellerServiceAttitudeMax  = info17.CommentValue;
                model.SellerServiceAttitudeMin  = info18.CommentValue;
            }
            else
            {
                model.SellerServiceAttitude     = num14;
                model.SellerServiceAttitudePeer = num14;
                model.SellerServiceAttitudeMax  = num14;
                model.SellerServiceAttitudeMin  = num14;
            }
            if (!(((info14 == null) || (info11 == null)) || shop.IsSelf))
            {
                model.SellerDeliverySpeed     = info11.CommentValue;
                model.SellerDeliverySpeedPeer = info14.CommentValue;
                model.SellerDeliverySpeedMax  = (info19 != null) ? info19.CommentValue : 0M;
                model.sellerDeliverySpeedMin  = (info20 != null) ? info20.CommentValue : 0M;
            }
            else
            {
                model.SellerDeliverySpeed     = num14;
                model.SellerDeliverySpeedPeer = num14;
                model.SellerDeliverySpeedMax  = num14;
                model.sellerDeliverySpeedMin  = num14;
            }
            if ((base.CurrentUser != null) && (base.CurrentUser.Id > 0L))
            {
                model2.IsFavorite = this._iProductService.IsFavorite(product.Id, base.CurrentUser.Id);
            }
            else
            {
                model2.IsFavorite = false;
            }
            VShopInfo vShopByShopId = this._iVShopService.GetVShopByShopId(shop.Id);

            if (vShopByShopId == null)
            {
                num15 = -1L;
            }
            else
            {
                num15 = vShopByShopId.Id;
            }
            model.VShopId       = num15;
            model2.Shop.VShopId = num15;
            model2.VShopLog     = this._iVShopService.GetVShopLog(model2.Shop.VShopId);
            if (string.IsNullOrWhiteSpace(model2.VShopLog))
            {
                model2.VShopLog = base.CurrentSiteSetting.WXLogo;
            }
            model.Logined     = (base.CurrentUser != null) ? 1 : 0;
            model2.EnabledBuy = (((product.AuditStatus == ProductInfo.ProductAuditStatus.Audited) && (DateTime.Parse(model3.BeginDate) <= DateTime.Now)) && (DateTime.Parse(model3.EndDate) > DateTime.Now)) && (product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale);
            if (((model3.Status == FlashSaleInfo.FlashSaleStatus.Ongoing) && (DateTime.Parse(model3.BeginDate) < DateTime.Now)) && (DateTime.Parse(model3.EndDate) > DateTime.Now))
            {
                span         = new TimeSpan(DateTime.Parse(model3.EndDate).Ticks);
                span2        = new TimeSpan(DateTime.Now.Ticks);
                span3        = span.Subtract(span2);
                model.Second = (span3.TotalSeconds < 0.0) ? 0.0 : span3.TotalSeconds;
            }
            else if ((model3.Status == FlashSaleInfo.FlashSaleStatus.Ongoing) && (DateTime.Parse(model3.BeginDate) > DateTime.Now))
            {
                span         = new TimeSpan(DateTime.Parse(model3.BeginDate).Ticks);
                span2        = new TimeSpan(DateTime.Now.Ticks);
                span3        = span.Subtract(span2);
                model.Second = (span3.TotalSeconds < 0.0) ? 0.0 : span3.TotalSeconds;
            }
            ((dynamic)base.ViewBag).DetailModel = model;
            List <Himall.DTO.CustomerService> mobileCustomerService = CustomerServiceApplication.GetMobileCustomerService(model3.ShopId);

            Himall.DTO.CustomerService service = Enumerable.FirstOrDefault <Himall.DTO.CustomerService>((IEnumerable <Himall.DTO.CustomerService>)CustomerServiceApplication.GetPreSaleByShopId(model3.ShopId), (Func <Himall.DTO.CustomerService, bool>)(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia));
            if (service != null)
            {
                mobileCustomerService.Insert(0, service);
            }
            ((dynamic)base.ViewBag).CustomerServices = mobileCustomerService;
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);
            return(base.View(model2));
        }