Beispiel #1
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));
        }
Beispiel #2
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));
        }