public JsonResult EditLimitItem(string Title, string ProductName, long ProductId, decimal Price, string CategoryName, DateTime StartTime, DateTime EndTime, int Stock, int MaxSaleCount, long Id) { Result result = new Result(); try { LimitTimeMarketInfo limitTimeMarketItem = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItem(Id); limitTimeMarketItem.Title = Title; limitTimeMarketItem.ProductId = ProductId; limitTimeMarketItem.ProductName = ProductName; limitTimeMarketItem.CategoryName = CategoryName; limitTimeMarketItem.StartTime = StartTime; limitTimeMarketItem.EndTime = EndTime; limitTimeMarketItem.Price = Price; limitTimeMarketItem.Stock = Stock; limitTimeMarketItem.MaxSaleCount = MaxSaleCount; ServiceHelper.Create <ILimitTimeBuyService>().UpdateLimitTimeItem(limitTimeMarketItem); result.success = true; result.msg = "修改限时购成功"; } catch (HimallException himallException) { result.msg = himallException.Message; } catch (Exception exception) { Log.Error("修改限时购出错", exception); result.msg = "修改限时购出错!"; } return(Json(result)); }
private void CheckLimit(LimitTimeMarketInfo model) { if (context.LimitTimeMarketInfo.Any((LimitTimeMarketInfo m) => m.Id != model.Id && m.ShopId == model.ShopId && m.ProductId == model.ProductId && (m.EndTime > DateTime.Now) && ((int)m.AuditStatus == 2 || (int)m.AuditStatus == 1))) { throw new HimallException(string.Format("操作失败,限时购活动:{0} 已经存在.", model.ProductName)); } }
public void AuditItem(long Id, LimitTimeMarketInfo.LimitTimeMarketAuditStatus status, string message) { LimitTimeMarketInfo now = context.LimitTimeMarketInfo.FindById <LimitTimeMarketInfo>(Id); now.AuditStatus = status; now.CancelReson = message ?? ""; now.AuditTime = DateTime.Now; context.SaveChanges(); }
public void UpdateLimitTimeItem(LimitTimeMarketInfo model) { CheckLimit(model); LimitTimeMarketInfo title = context.LimitTimeMarketInfo.FindById <LimitTimeMarketInfo>(model.Id); title.Title = model.Title; title.ProductId = model.ProductId; title.ProductName = model.ProductName; title.CategoryName = model.CategoryName; title.StartTime = model.StartTime; title.EndTime = model.EndTime; title.Price = model.Price; title.Stock = model.Stock; title.MaxSaleCount = model.MaxSaleCount; context.SaveChanges(); }
public JsonResult AddLimitItem(string Title, string ProductName, long ProductId, decimal Price, string CategoryName, DateTime StartTime, DateTime EndTime, int MaxSaleCount, int Stock = 0) { Result result = new Result(); try { var average = _iOrderService.GetRecentMonthAveragePrice(CurrentSellerManager.ShopId, ProductId); var pro = _iProductService.GetProduct(ProductId); LimitTimeMarketInfo info = new LimitTimeMarketInfo { AuditStatus = LimitTimeMarketInfo.LimitTimeMarketAuditStatus.WaitForAuditing, Title = Title, ProductId = ProductId, ProductName = ProductName, CancelReson = "", CategoryName = CategoryName, StartTime = StartTime, EndTime = EndTime, MaxSaleCount = MaxSaleCount, Price = Price, SaleCount = 0, ShopId = CurrentSellerManager.ShopId, ShopName = _iShopService.GetShop(CurrentSellerManager.ShopId).ShopName, Stock = Stock, AuditTime = StartTime, RecentMonthPrice = average, ImagePath = pro.ImagePath, ProductAd = pro.ShortDescription, MinPrice = pro.MinSalePrice }; _iLimitTimeBuyService.AddLimitTimeItem(info); result.success = true; result.msg = "添加限时购成功"; } catch (HimallException ex) { result.msg = ex.Message; } catch (Exception ex) { Log.Error("添加限时购出错", ex); result.msg = "添加限时购出错!"; } return(Json(result)); }
public JsonResult AddLimitItem(string Title, string ProductName, long ProductId, decimal Price, string CategoryName, DateTime StartTime, DateTime EndTime, int MaxSaleCount, int Stock = 0) { Result result = new Result(); try { decimal recentMonthAveragePrice = ServiceHelper.Create <IOrderService>().GetRecentMonthAveragePrice(base.CurrentSellerManager.ShopId, ProductId); ProductInfo product = ServiceHelper.Create <IProductService>().GetProduct(ProductId); LimitTimeMarketInfo limitTimeMarketInfo = new LimitTimeMarketInfo() { AuditStatus = LimitTimeMarketInfo.LimitTimeMarketAuditStatus.WaitForAuditing, Title = Title, ProductId = ProductId, ProductName = ProductName, CancelReson = "", CategoryName = CategoryName, StartTime = StartTime, EndTime = EndTime, MaxSaleCount = MaxSaleCount, Price = Price, SaleCount = 0, ShopId = base.CurrentSellerManager.ShopId, ShopName = ServiceHelper.Create <IShopService>().GetShop(base.CurrentSellerManager.ShopId, false).ShopName, Stock = Stock, AuditTime = StartTime, RecentMonthPrice = recentMonthAveragePrice, ImagePath = product.ImagePath, ProductAd = product.ShortDescription, MinPrice = product.MinSalePrice }; ServiceHelper.Create <ILimitTimeBuyService>().AddLimitTimeItem(limitTimeMarketInfo); result.success = true; result.msg = "添加限时购成功"; } catch (HimallException himallException) { result.msg = himallException.Message; } catch (Exception exception) { Log.Error("添加限时购出错", exception); result.msg = "添加限时购出错!"; } return(Json(result)); }
public int GetMarketSaleCountForUserId(long pId, long userId) { List <OrderItemInfo> list = ( from a in context.OrderItemInfo.Include("OrderInfo") where a.ProductId == pId && a.IsLimitBuy && a.OrderInfo.UserId == userId && (int)a.OrderInfo.OrderStatus != 4 select a).ToList(); if (list.Count == 0) { return(0); } LimitTimeMarketInfo limitTimeMarketInfo = ( from item in context.LimitTimeMarketInfo where item.ProductId == pId && (int)item.AuditStatus == 2 && (item.EndTime >= DateTime.Now) select item).FirstOrDefault(); long?nullable = ( from a in list where a.OrderInfo.OrderDate >= limitTimeMarketInfo.StartTime select a).Sum <OrderItemInfo>((OrderItemInfo a) => new long?(a.Quantity)); return((int)nullable.GetValueOrDefault()); }
private decimal GetSalePrice(long productId, SKUInfo sku, long?collid, int Count) { decimal salePrice = sku.SalePrice; if (collid.HasValue && collid.Value != 0 && Count > 1) { CollocationSkuInfo colloSku = ServiceHelper.Create <ICollocationService>().GetColloSku(collid.Value, sku.Id); if (colloSku != null) { salePrice = colloSku.Price; } } else if (Count == 1) { LimitTimeMarketInfo limitTimeMarketItemByProductId = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(productId); if (limitTimeMarketItemByProductId != null) { salePrice = limitTimeMarketItemByProductId.Price; } } return(salePrice); }
public ActionResult EditLimitItem(long id) { List <SelectListItem> selectListItems = new List <SelectListItem>(); string[] serviceCategories = ServiceHelper.Create <ILimitTimeBuyService>().GetServiceCategories(); for (int i = 0; i < serviceCategories.Length; i++) { string str = serviceCategories[i]; SelectListItem selectListItem = new SelectListItem() { Selected = false, Text = str, Value = str }; selectListItems.Add(selectListItem); } LimitTimeMarketInfo limitTimeMarketItem = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItem(id); selectListItems.FirstOrDefault((SelectListItem c) => c.Text.Equals(limitTimeMarketItem.CategoryName)).Selected = true; ViewBag.Cate = selectListItems; LimitTimeMarketModel limitTimeMarketModel = new LimitTimeMarketModel() { Title = limitTimeMarketItem.Title, CategoryName = limitTimeMarketItem.CategoryName, StartTime = limitTimeMarketItem.StartTime.ToString("yyyy-MM-dd HH:mm"), EndTime = limitTimeMarketItem.EndTime.ToString("yyyy-MM-dd HH:mm"), ProductId = limitTimeMarketItem.ProductId, MaxSaleCount = limitTimeMarketItem.MaxSaleCount, ProductName = limitTimeMarketItem.ProductName, ProductPrice = ServiceHelper.Create <IProductService>().GetProduct(limitTimeMarketItem.ProductId).MinSalePrice, AuditStatus = limitTimeMarketItem.AuditStatus.ToDescription(), CancelReson = limitTimeMarketItem.CancelReson, Price = limitTimeMarketItem.Price, Stock = limitTimeMarketItem.Stock }; return(View(limitTimeMarketModel)); }
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)); }
public void AddLimitTimeItem(LimitTimeMarketInfo model) { CheckLimit(model); context.LimitTimeMarketInfo.Add(model); context.SaveChanges(); }
public ActionResult Detail(string id) { long valueId; ProductInfo[] array; int i; double num; 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 num1 = 0; long.TryParse(id, out num1); if (num1 == 0) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } limitTimeMarketItem = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItem(num1); if (limitTimeMarketItem == null || limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing) { limitTimeMarketItem = (limitTimeMarketItem == null ? ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(num1) : limitTimeMarketItem); if (limitTimeMarketItem == null || limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } } 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); } 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 num2 = 0; long num3 = 0; long num4 = 0; foreach (SKUInfo sKUInfo in product.SKUInfo) { string[] strArrays = sKUInfo.Id.Split(new char[] { '\u005F' }); if (strArrays.Count() > 0) { long.TryParse(strArrays[1], out num2); if (num2 != 0) { if (!maxSaleCount.Color.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Color))) { long num5 = ( 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 = (num5 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num2, Value = sKUInfo.Color }; color.Add(productSKU); } } } if (strArrays.Count() > 1) { long.TryParse(strArrays[2], out num3); if (num3 != 0) { if (!maxSaleCount.Size.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Size))) { long num6 = ( 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 = (num6 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num3, Value = sKUInfo.Size }; size.Add(productSKU1); } } } if (strArrays.Count() <= 2) { continue; } long.TryParse(strArrays[3], out num4); if (num4 == 0) { continue; } if (maxSaleCount.Version.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Version))) { continue; } long num7 = ( 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 = (num7 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num4, Value = sKUInfo.Version }; version.Add(productSKU2); } decimal num8 = new decimal(0); decimal num9 = new decimal(0); num8 = ( from s in product.SKUInfo where s.Stock >= 0 select s).Min <SKUInfo>((SKUInfo s) => s.SalePrice); num9 = ( from s in product.SKUInfo where s.Stock >= 0 select s).Max <SKUInfo>((SKUInfo s) => s.SalePrice); if (!(num8 == new decimal(0)) || !(num9 == new decimal(0))) { str = (num9 <= num8 ? string.Format("{0}", num8.ToString("f2")) : string.Format("{0}-{1}", num8.ToString("f2"), num9.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(); if (base.CurrentUser == null) { BrowseHistrory.AddBrowsingProduct(product.Id, 0); } else { BrowseHistrory.AddBrowsingProduct(product.Id, base.CurrentUser.Id); } ServiceHelper.Create <IProductService>().LogProductVisti(productId); 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 viewBag = base.ViewBag; num = (timeSpan1.TotalSeconds < 0 ? 0 : timeSpan1.TotalSeconds); viewBag.Second = num; return(View(maxSaleCount)); }
private void GetOrderProductsInfo(IEnumerable <string> skuIds, IEnumerable <int> counts) { IProductService productService = ServiceHelper.Create <IProductService>(); IShopService shopService = ServiceHelper.Create <IShopService>(); int num3 = 0; int cityId = 0; ShippingAddressInfo defaultUserShippingAddressByUserId = ServiceHelper.Create <IShippingAddressService>().GetDefaultUserShippingAddressByUserId(base.CurrentUser.Id); if (defaultUserShippingAddressByUserId != null) { cityId = Instance <IRegionService> .Create.GetCityId(defaultUserShippingAddressByUserId.RegionIdPath); } List <CartItemModel> list = skuIds.Select <string, CartItemModel>((string item) => { SKUInfo sku = productService.GetSku(item); IEnumerable <int> nums = counts; int num = num3; int num1 = num; num3 = num + 1; int num2 = nums.ElementAt <int>(num1); LimitTimeMarketInfo limitTimeMarketItemByProductId = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(sku.ProductInfo.Id); if (limitTimeMarketItemByProductId != null && num2 > limitTimeMarketItemByProductId.MaxSaleCount) { throw new HimallException(string.Concat("超过最大限购数量:", limitTimeMarketItemByProductId.MaxSaleCount.ToString())); } return(new CartItemModel() { skuId = item, id = sku.ProductInfo.Id, imgUrl = sku.ProductInfo.GetImage(ProductInfo.ImageSize.Size_100, 1), name = sku.ProductInfo.ProductName, shopId = sku.ProductInfo.ShopId, price = (limitTimeMarketItemByProductId == null ? sku.SalePrice : limitTimeMarketItemByProductId.Price), count = num2, productCode = sku.ProductInfo.ProductCode }); }).ToList(); IEnumerable <IGrouping <long, CartItemModel> > groupings = from a in list group a by a.shopId; List <ShopCartItemModel> shopCartItemModels = new List <ShopCartItemModel>(); foreach (IGrouping <long, CartItemModel> nums1 in groupings) { IEnumerable <long> nums2 = from r in nums1 select r.id; IEnumerable <int> nums3 = from r in nums1 select r.count; ShopCartItemModel shopCartItemModel = new ShopCartItemModel() { shopId = nums1.Key }; shopCartItemModel.CartItemModels = ( from a in list where a.shopId == shopCartItemModel.shopId select a).ToList(); shopCartItemModel.ShopName = shopService.GetShop(shopCartItemModel.shopId, false).ShopName; if (cityId != 0) { shopCartItemModel.Freight = ServiceHelper.Create <IProductService>().GetFreight(nums2, nums3, cityId); } List <ShopBonusReceiveInfo> detailToUse = ServiceHelper.Create <IShopBonusService>().GetDetailToUse(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count)); List <CouponRecordInfo> userCoupon = ServiceHelper.Create <ICouponService>().GetUserCoupon(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count)); if (detailToUse.Count() > 0 && userCoupon.Count() > 0) { ShopBonusReceiveInfo shopBonusReceiveInfo = detailToUse.FirstOrDefault(); CouponRecordInfo couponRecordInfo = userCoupon.FirstOrDefault(); decimal?price = shopBonusReceiveInfo.Price; decimal price1 = couponRecordInfo.ChemCloud_Coupon.Price; if ((price.GetValueOrDefault() <= price1 ? true : !price.HasValue)) { shopCartItemModel.Coupon = new CouponModel() { CouponName = couponRecordInfo.ChemCloud_Coupon.CouponName, CouponId = couponRecordInfo.Id, CouponPrice = couponRecordInfo.ChemCloud_Coupon.Price, Type = 0 }; } else { shopCartItemModel.Coupon = new CouponModel() { CouponName = shopBonusReceiveInfo.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.Name, CouponId = shopBonusReceiveInfo.Id, CouponPrice = shopBonusReceiveInfo.Price.Value, Type = 1 }; } } else if (detailToUse.Count() <= 0 && userCoupon.Count() <= 0) { shopCartItemModel.Coupon = null; } else if (detailToUse.Count() <= 0 && userCoupon.Count() > 0) { CouponRecordInfo couponRecordInfo1 = userCoupon.FirstOrDefault(); shopCartItemModel.Coupon = new CouponModel() { CouponName = couponRecordInfo1.ChemCloud_Coupon.CouponName, CouponId = couponRecordInfo1.Id, CouponPrice = couponRecordInfo1.ChemCloud_Coupon.Price, Type = 0 }; } else if (detailToUse.Count() > 0 && userCoupon.Count() <= 0) { ShopBonusReceiveInfo shopBonusReceiveInfo1 = detailToUse.FirstOrDefault(); shopCartItemModel.Coupon = new CouponModel() { CouponName = shopBonusReceiveInfo1.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.Name, CouponId = shopBonusReceiveInfo1.Id, CouponPrice = shopBonusReceiveInfo1.Price.Value, Type = 1 }; } decimal num4 = shopCartItemModel.CartItemModels.Sum <CartItemModel>((CartItemModel d) => d.price * d.count); decimal num5 = num4 - (shopCartItemModel.Coupon == null ? new decimal(0) : shopCartItemModel.Coupon.CouponPrice); decimal freeFreight = shopService.GetShop(shopCartItemModel.shopId, false).FreeFreight; shopCartItemModel.isFreeFreight = false; if (freeFreight > new decimal(0)) { shopCartItemModel.shopFreeFreight = freeFreight; if (num5 >= freeFreight) { shopCartItemModel.Freight = new decimal(0); shopCartItemModel.isFreeFreight = true; } } shopCartItemModels.Add(shopCartItemModel); } decimal num6 = ( from a in shopCartItemModels where a.Coupon != null select a).Sum <ShopCartItemModel>((ShopCartItemModel b) => b.Coupon.CouponPrice); ViewBag.products = shopCartItemModels; base.ViewBag.totalAmount = list.Sum <CartItemModel>((CartItemModel item) => item.price * item.count); base.ViewBag.Freight = shopCartItemModels.Sum <ShopCartItemModel>((ShopCartItemModel a) => a.Freight); dynamic viewBag = base.ViewBag; dynamic obj = ViewBag.totalAmount; viewBag.orderAmount = obj + ViewBag.Freight - num6; IMemberIntegralService memberIntegralService = ServiceHelper.Create <IMemberIntegralService>(); MemberIntegral memberIntegral = memberIntegralService.GetMemberIntegral(base.CurrentUser.Id); int num7 = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals); ViewBag.userIntegrals = num7; ViewBag.integralPerMoney = 0; ViewBag.memberIntegralInfo = memberIntegral; MemberIntegralExchangeRules integralChangeRule = memberIntegralService.GetIntegralChangeRule(); decimal viewBag1 = new decimal(0); decimal viewBag2 = new decimal(0); if (integralChangeRule == null || integralChangeRule.IntegralPerMoney <= 0) { viewBag1 = new decimal(0); viewBag2 = new decimal(0); } else { if (ViewBag.totalAmount - num6 - Math.Round((decimal)num7 / integralChangeRule.IntegralPerMoney, 2) <= 0) { viewBag1 = Math.Round(ViewBag.totalAmount - num6, 2); viewBag2 = Math.Round((ViewBag.totalAmount - num6) * integralChangeRule.IntegralPerMoney); } else { viewBag1 = Math.Round((decimal)num7 / integralChangeRule.IntegralPerMoney, 2); viewBag2 = num7; } if (viewBag1 <= new decimal(0)) { viewBag1 = new decimal(0); viewBag2 = new decimal(0); } } ViewBag.integralPerMoney = viewBag1; ViewBag.userIntegrals = viewBag2; }
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)); }