public JsonResult GetLimitedProducts(List <long> ids) { var result = LimitTimeApplication.GetPriceByProducrIds(ids).ToList(); var productIds = result.Select(p => p.ProductId); var skuInfos = ProductManagerApplication.GetSKUByProducts(productIds); //商品规格 var flashSaleIds = result.Select(p => p.Id); var flashSaleDetails = LimitTimeApplication.GetFlashSaleDetailByFlashSaleIds(ids).ToList(); //限时购明细 var products = result.Select(item => new { ProductName = item.ProductName, MinPrice = item.MinPrice, ProductId = item.ProductId, Count = (skuInfos == null || flashSaleDetails == null) ? 0 : (Math.Min(skuInfos.Where(a => a.ProductId == item.ProductId).Sum(b => b.Stock) , flashSaleDetails.Where(t => t.ProductId == item.ProductId).Sum(t => t.TotalCount)))//取活动=限时购活动库存和规格库存最少的一个 }); return(Json(products, true)); }
/// <summary> /// 门店首页获取诊疗项目列表 /// </summary> /// <param name="pageSize"></param> /// <param name="pageNo"></param> /// <param name="shopCategoryId">诊所一级分类</param> /// <param name="shopId">诊所ID</param> /// <param name="shopBranchId">门店ID</param> /// <returns></returns> public object GetProductList(int pageSize, int pageNo, string shopCategoryId, string shopId, string shopBranchId) { ShopBranchProductQuery query = new ShopBranchProductQuery(); query.PageSize = pageSize; query.PageNo = pageNo; //query.ShopCategoryId = TypeHelper.ObjectToInt(shopCategoryId, 0); query.ShopId = TypeHelper.ObjectToInt(shopId, 0); query.shopBranchId = TypeHelper.ObjectToInt(shopBranchId, 0); query.ShopBranchProductStatus = ShopBranchSkuStatus.Normal; if (query.ShopId <= 0) { return(Json(new { Success = false, Message = "无法定位到诊所!" })); } //if (query.ShopCategoryId <= 0) // return Json(new { Success = false, Message = "无法定位到诊所分类!" }); if (TypeHelper.ObjectToInt(shopCategoryId, 0) > 0) { query.ShopCategoryId = TypeHelper.ObjectToInt(shopCategoryId); } if (query.shopBranchId <= 0) { return(Json(new { Success = false, Message = "无法定位到门店!" })); } var pageModel = ShopBranchApplication.GetShopBranchProducts(query); if (pageModel.Models != null && pageModel.Models.Count > 0) { #region 处理诊疗项目 官方自营店会员折扣价,各活动价等。 var flashSalePriceList = LimitTimeApplication.GetPriceByProducrIds(pageModel.Models.Select(p => p.Id).ToList()); var fightGroupSalePriceList = FightGroupApplication.GetActiveByProductIds(pageModel.Models.Select(p => p.Id).ToArray()); if (CurrentUser != null) { var shopInfo = ShopApplication.GetShop(query.ShopId.Value); if (shopInfo != null && shopInfo.IsSelf)//当前诊所是否是官方自营店 { decimal discount = 1M; discount = CurrentUser.MemberDiscount; foreach (var item in pageModel.Models) { item.MinSalePrice = Math.Round(item.MinSalePrice * discount, 2); } } } foreach (var item in pageModel.Models) { var flashSale = flashSalePriceList.Any(p => p.ProductId == item.Id); var fightGroupSale = fightGroupSalePriceList.Any(p => p.ProductId == item.Id); if (flashSale && !fightGroupSale) { item.MinSalePrice = TypeHelper.ObjectToDecimal(flashSalePriceList.FirstOrDefault(p => p.ProductId == item.Id).MinPrice.ToString("f2")); } else if (!flashSale && fightGroupSale) { item.MinSalePrice = TypeHelper.ObjectToDecimal(fightGroupSalePriceList.FirstOrDefault(p => p.ProductId == item.Id).MiniGroupPrice.ToString("f2")); } } #endregion } var productlist = pageModel.Models.ToList().Select(item => { return(new { Id = item.Id, ProductName = item.ProductName, MeasureUnit = item.MeasureUnit, MinSalePrice = item.MinSalePrice.ToString("f2"), SaleCounts = item.SaleCounts, //销量统计没有考虑预约单支付完成。 RelativePath = Core.HimallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_350), //150-350 }); }); var result = new { Success = true, ProductList = productlist, total = pageModel.Total }; return(Json(result)); }
private List <CartProductModel> PackageCartProducts(Mall.Entities.ShoppingCartInfo cart, decimal prodPrice, decimal discount, IProductService productService, IShopService shopService, IShopBranchService shopBranchService, IVShopService vshopService, ITypeService typeservice, bool isBranch = false) { List <CartProductModel> products = new List <CartProductModel>(); var limitProducts = LimitTimeApplication.GetPriceByProducrIds(cart.Items.Select(e => e.ProductId).ToList());//限时购价格 var groupCart = cart.Items.Where(item => item.ShopBranchId == 0).Select(c => { var cItem = new Mall.Entities.ShoppingCartItem(); var skuInfo = productService.GetSku(c.SkuId); if (skuInfo != null) { cItem = c; } return(cItem); }).GroupBy(i => i.ProductId).ToList(); foreach (var item in cart.Items) { var product = ProductManagerApplication.GetProduct(item.ProductId); var shop = shopService.GetShop(product.ShopId); DTO.ShopBranch shopbranch = null; Entities.ShopBranchSkuInfo shopbranchsku = null; if (item.ShopBranchId > 0) { shopbranch = ShopBranchApplication.GetShopBranchById(item.ShopBranchId); shopbranchsku = shopBranchService.GetSkusByIds(item.ShopBranchId, new List <string> { item.SkuId }).FirstOrDefault(); } if (null != shop) { var vshop = vshopService.GetVShopByShopId(shop.Id); var sku = ProductManagerApplication.GetSKU(item.SkuId); if (sku == null) { continue; } //处理限时购、会员折扣价格 var prod = limitProducts.FirstOrDefault(e => e.ProductId == item.ProductId); prodPrice = sku.SalePrice; if (prod != null && !isBranch) { prodPrice = prod.MinPrice; } else { if (shop.IsSelf) {//官方自营店才计算会员折扣 prodPrice = sku.SalePrice * discount; } } #region 阶梯价--张宇枫 //阶梯价 if (product.IsOpenLadder) { var quantity = groupCart.Where(i => i.Key == item.ProductId).ToList().Sum(cartitem => cartitem.Sum(i => i.Quantity)); prodPrice = ProductManagerApplication.GetProductLadderPrice(item.ProductId, quantity); if (shop.IsSelf) { prodPrice = prodPrice * discount; } } #endregion Entities.TypeInfo typeInfo = typeservice.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; } if (sku != null) { #region 正在参加限时抢购商品在购物车失效 TDO:ZYF var isLimit = false; //门店商品,在参加限时购,也可以正常购买 var limit = LimitTimeApplication.GetLimitTimeMarketItemByProductId(item.ProductId); if (limit != null && !isBranch) { isLimit = limit.Status == Entities.FlashSaleInfo.FlashSaleStatus.Ongoing; } #endregion var _tmp = new CartProductModel { CartItemId = item.Id.ToString(), SkuId = item.SkuId, Id = product.Id.ToString(), ImgUrl = Core.MallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_150), Name = product.ProductName, Price = prodPrice.ToString("F2"), Count = item.Quantity.ToString(), ShopId = shop.Id.ToString(), Size = sku.Size, Color = sku.Color, Version = sku.Version, VShopId = vshop == null ? "0" : vshop.Id.ToString(), ShopName = shop.ShopName, ShopLogo = vshop == null ? "" : Core.MallIO.GetRomoteImagePath(vshop.StrLogo), Url = Core.MallIO.GetRomoteImagePath("/m-IOS/product/detail/") + item.ProductId, ProductStatus = isLimit ? 0 : (sku.Stock <= 0 ? ProductInfo.ProductSaleStatus.InStock.GetHashCode() : product.SaleStatus.GetHashCode()), Status = isLimit ? 1 : ProductManagerApplication.GetProductShowStatus(product, sku, shopbranch == null ? 1 : item.Quantity, shopbranch, shopbranchsku),// 0:正常;1:已失效;2:库存不足;3:已下架; ColorAlias = colorAlias, SizeAlias = sizeAlias, VersionAlias = versionAlias, AddTime = item.AddTime, ShopBranchId = item.ShopBranchId, ShopBranchName = null == shopbranch ? "" : shopbranch.ShopBranchName, ShopBranchLogo = null == shopbranch ? "" : Core.MallIO.GetRomoteImagePath(shopbranch.ShopImages) }; products.Add(_tmp); } } } return(products); }
public object GetCartProduct(string openId = "") { CheckUserLogin(); var cartHelper = ServiceProvider.Instance <ICartService> .Create; var cart = cartHelper.GetCart(CurrentUser.Id); var productService = ServiceProvider.Instance <IProductService> .Create; var shopService = ServiceProvider.Instance <IShopService> .Create; var vshopService = ServiceProvider.Instance <IVShopService> .Create; var siteSetting = ServiceProvider.Instance <ISiteSettingService> .Create.GetSiteSettings(); var typeservice = ServiceProvider.Instance <ITypeService> .Create; List <CartProductModel> products = new List <CartProductModel>(); //会员折扣 decimal discount = 1.0M;//默认折扣为1(没有折扣) if (CurrentUser != null) { discount = CurrentUser.MemberDiscount; } decimal prodPrice = 0.0M; //优惠价格 var limitProducts = LimitTimeApplication.GetPriceByProducrIds(cart.Items.Select(e => e.ProductId).ToList()); //限时购价格 foreach (var item in cart.Items) { var product = productService.GetProduct(item.ProductId); var shop = shopService.GetShop(product.ShopId); if (null != shop) { var vshop = vshopService.GetVShopByShopId(shop.Id); SKUInfo sku = productService.GetSku(item.SkuId); if (sku == null) { continue; } //处理限时购、会员折扣价格 var prod = limitProducts.FirstOrDefault(e => e.ProductId == item.ProductId); prodPrice = sku.SalePrice; if (prod != null) { prodPrice = prod.MinPrice; } else { if (shop.IsSelf) {//官方自营店才计算会员折扣 prodPrice = sku.SalePrice * discount; } } ProductTypeInfo typeInfo = typeservice.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 (sku != null) { var _tmp = new CartProductModel { CartItemId = item.Id.ToString(), SkuId = item.SkuId, Id = product.Id.ToString(), ImgUrl = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_150), Name = product.ProductName, Price = prodPrice.ToString("F2"), Count = item.Quantity.ToString(), ShopId = shop.Id.ToString(), Size = sku.Size, Color = sku.Color, Version = sku.Version, VShopId = vshop == null ? "0" : vshop.Id.ToString(), ShopName = shop.ShopName, ShopLogo = vshop == null ? "" : Core.HimallIO.GetRomoteImagePath(vshop.Logo), Url = Core.HimallIO.GetRomoteImagePath("/m-IOS/product/detail/") + item.ProductId, IsValid = (product.AuditStatus == ProductInfo.ProductAuditStatus.Audited && product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale) ? 1 : 0, ColorAlias = colorAlias, SizeAlias = sizeAlias, VersionAlias = versionAlias, AddTime = item.AddTime }; products.Add(_tmp); } } } products = products.OrderBy(item => item.ShopId).ThenByDescending(o => o.AddTime).ToList(); var cartShop = products.GroupBy(item => item.ShopId); var cartModel = new { Status = "OK", Data = cartShop }; return(Json(cartModel));//原api返回 }
public static List <ProductBrowsedHistoryModel> GetBrowsingProducts(int num, long userId = 0) { List <ProductBrowsedHistoryModel> productIdList = new List <ProductBrowsedHistoryModel>(); string productIds = Core.Helper.WebHelper.GetCookie(CookieKeysCollection.Mall_PRODUCT_BROWSING_HISTORY); if (!string.IsNullOrEmpty(productIds)) { var arr = productIds.Split(','); foreach (var a in arr) { var item = a.Split('#'); if (item.Length > 1) { productIdList.Add(new ProductBrowsedHistoryModel() { ProductId = long.Parse(item[0]), BrowseTime = DateTime.Parse(item[1]) }); } else { productIdList.Add(new ProductBrowsedHistoryModel() { ProductId = long.Parse(item[0]), BrowseTime = DateTime.Now }); } } } var ids = productIdList.Select(p => p.ProductId).ToList(); List <FlashSalePrice> flashSaleList = LimitTimeApplication.GetPriceByProducrIds(ids); List <ProductBrowsedHistoryModel> model = new List <ProductBrowsedHistoryModel>(); if (userId == 0) { var products = ProductManagerApplication.GetProductByIds(productIdList.Select(a => a.ProductId)) .Where(d => d.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale && d.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited).ToArray() .Select(a => new ProductBrowsedHistoryModel() { ImagePath = Core.MallIO.GetProductSizeImage(a.RelativePath, 1, (int)ImageSize.Size_100), ProductId = a.Id, ProductName = a.ProductName, ProductPrice = GetRealPrice(flashSaleList, a.Id, a.MinSalePrice), ShopId = a.ShopId }).ToList(); return(products.OrderByDescending(a => a.BrowseTime).ToList()); } else { foreach (var m in productIdList) { AddBrowsingProduct(m.ProductId, userId); } var browsing = ProductManagerApplication.GetBrowsingProducts(userId); var products = ProductManagerApplication.GetOnSaleProducts(browsing.Select(p => p.ProductId).ToList()); browsing = browsing.Where(p => products.Select(o => o.Id).Contains(p.ProductId)).ToList(); model = browsing.OrderByDescending(a => a.BrowseTime).Take(num) .Select(a => { var product = products.FirstOrDefault(p => p.Id == a.ProductId); return(new ProductBrowsedHistoryModel() { ImagePath = Core.MallIO.GetProductSizeImage(product.RelativePath, 1, (int)ImageSize.Size_100), ProductId = a.ProductId, ProductName = product.ProductName, ProductPrice = GetRealPrice(flashSaleList, a.ProductId, product.MinSalePrice), BrowseTime = a.BrowseTime, ShopId = product.ShopId }); }).ToList(); } return(model); }
public JsonResult GetCartProducts() { var cartHelper = new CartHelper(); var cart = cartHelper.GetCart(CurrentUser.Id); var productService = _iProductService; var shopService = _iShopService; var vshopService = _iVShopService; //会员折扣 decimal discount = 1.0M;//默认折扣为1(没有折扣) if (CurrentUser != null) { discount = CurrentUser.MemberDiscount; } List <long> pids = new List <long>(); decimal prodPrice = 0.0M; //优惠价格 var limitProducts = LimitTimeApplication.GetPriceByProducrIds(cart.Items.Select(e => e.ProductId).ToList()); //限时购价格 var products = cart.Items.Select(item => { var product = productService.GetProduct(item.ProductId); var shop = shopService.GetShop(product.ShopId); SKUInfo sku = null; string colorAlias = ""; string sizeAlias = ""; string versionAlias = ""; string skuDetails = ""; if (null != shop) { var vshop = vshopService.GetVShopByShopId(shop.Id); sku = productService.GetSku(item.SkuId); if (sku == null) { return(null); } //处理限时购、会员折扣价格 var prod = limitProducts.FirstOrDefault(e => e.ProductId == item.ProductId); prodPrice = sku.SalePrice; if (prod != null) { prodPrice = prod.MinPrice; } else { if (shop.IsSelf) {//官方自营店才计算会员折扣 prodPrice = sku.SalePrice * discount; } } var typeInfo = TypeApplication.GetType(product.TypeId); colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; skuDetails = ""; if (!string.IsNullOrWhiteSpace(sku.Size)) { skuDetails += sizeAlias + ":" + sku.Size + " "; } if (!string.IsNullOrWhiteSpace(sku.Color)) { skuDetails += colorAlias + ":" + sku.Color + " "; } if (!string.IsNullOrWhiteSpace(sku.Version)) { skuDetails += versionAlias + ":" + sku.Version + " "; } return(new { cartItemId = item.Id, skuId = item.SkuId, id = product.Id, imgUrl = Himall.Core.HimallIO.GetProductSizeImage(product.RelativePath, 1, (int)ImageSize.Size_150), name = product.ProductName, price = prodPrice, count = item.Quantity, shopId = shop.Id, vshopId = vshop == null ? 0 : vshop.Id, shopName = shop.ShopName, shopLogo = vshop == null ? "" : vshop.Logo, status = (product.AuditStatus == ProductInfo.ProductAuditStatus.Audited && product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale) ? 1 : 0, Size = sku.Size, Color = sku.Color, Version = sku.Version, ColorAlias = colorAlias, SizeAlias = sizeAlias, VersionAlias = versionAlias, skuDetails = skuDetails, AddTime = item.AddTime }); } else { return(null); } }).Where(d => d != null).OrderBy(s => s.vshopId).ThenByDescending(o => o.AddTime); var cartModel = new { products = products, amount = products.Sum(item => item.price * item.count), totalCount = products.Sum(item => item.count) }; return(Json(cartModel)); }
public JsonResult GetCartProducts() { ShoppingCartInfo cart = new CartHelper().GetCart(base.CurrentUser.Id); IProductService productService = this._iProductService; IShopService shopService = this._iShopService; IVShopService vshopService = this._iVShopService; decimal discount = 1.0M; if (base.CurrentUser != null) { discount = base.CurrentUser.MemberDiscount; } List <long> list = new List <long>(); decimal prodPrice = 0.0M; List <FlashSalePrice> limitProducts = LimitTimeApplication.GetPriceByProducrIds((from e in cart.Items select e.ProductId).ToList <long>()); var source = from s in cart.Items.Where <ShoppingCartItem>(delegate(ShoppingCartItem d) { long?nullable; return(!d.ShopBranchId.HasValue || (((nullable = d.ShopBranchId).GetValueOrDefault() == 0L) && nullable.HasValue)); }).Select(delegate(ShoppingCartItem item) { Func <FlashSalePrice, bool> predicate = null; ProductInfo product = productService.GetProduct(item.ProductId); ShopInfo shop = shopService.GetShop(product.ShopId, false); SKUInfo sku = null; string str = ""; string str2 = ""; string str3 = ""; string str4 = ""; if (null != shop) { string str5; VShopInfo vShopByShopId = vshopService.GetVShopByShopId(shop.Id); sku = productService.GetSku(item.SkuId); if (sku == null) { return(null); } if (predicate == null) { predicate = e => e.ProductId == item.ProductId; } FlashSalePrice price = limitProducts.FirstOrDefault <FlashSalePrice>(predicate); prodPrice = sku.SalePrice; if (price != null) { prodPrice = price.MinPrice; } else if (shop.IsSelf) { prodPrice = sku.SalePrice * discount; } ProductType type = TypeApplication.GetType(product.TypeId); str = ((type == null) || string.IsNullOrEmpty(type.ColorAlias)) ? SpecificationType.Color.ToDescription() : type.ColorAlias; str2 = ((type == null) || string.IsNullOrEmpty(type.SizeAlias)) ? SpecificationType.Size.ToDescription() : type.SizeAlias; str3 = ((type == null) || string.IsNullOrEmpty(type.VersionAlias)) ? SpecificationType.Version.ToDescription() : type.VersionAlias; str4 = ""; if (!string.IsNullOrWhiteSpace(sku.Size)) { str5 = str4; str4 = str5 + str2 + ":" + sku.Size + " "; } if (!string.IsNullOrWhiteSpace(sku.Color)) { str5 = str4; str4 = str5 + str + ":" + sku.Color + " "; } if (!string.IsNullOrWhiteSpace(sku.Version)) { str5 = str4; str4 = str5 + str3 + ":" + sku.Version + " "; } return(new { cartItemId = item.Id, skuId = item.SkuId, id = product.Id, imgUrl = HimallIO.GetProductSizeImage(product.RelativePath, 1, 150), name = product.ProductName, price = prodPrice, count = item.Quantity, shopId = shop.Id, vshopId = (vShopByShopId == null) ? 0L : vShopByShopId.Id, shopName = shop.ShopName, shopLogo = (vShopByShopId == null) ? "" : vShopByShopId.Logo, status = ((product.AuditStatus == ProductInfo.ProductAuditStatus.Audited) && (product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale)) ? 1 : 0, Size = sku.Size, Color = sku.Color, Version = sku.Version, ColorAlias = str, SizeAlias = str2, VersionAlias = str3, skuDetails = str4, AddTime = item.AddTime }); } return(null); }) where s != null orderby s.vshopId, s.AddTime descending select s; BranchCartHelper helper2 = new BranchCartHelper(); long memberId = 0L; if (base.CurrentUser != null) { memberId = base.CurrentUser.Id; } ShoppingCartInfo cartNoCache = helper2.GetCartNoCache(memberId, 0L); List <long> list2 = (from x in (from x in cartNoCache.Items where x.ShopBranchId.HasValue select x.ShopBranchId.Value).ToList <long>() group x by x into x select x.First <long>()).ToList <long>(); Dictionary <long, int> buyedCounts = null; if (memberId > 0L) { cart = helper2.GetCart(memberId, 0L); buyedCounts = new Dictionary <long, int>(); buyedCounts = OrderApplication.GetProductBuyCount(memberId, from x in cart.Items select x.ProductId); } List <object> list3 = new List <object>(); using (List <long> .Enumerator enumerator = list2.GetEnumerator()) { while (enumerator.MoveNext()) { Func <ShoppingCartItem, bool> func = null; long shopBranchId = enumerator.Current; prodPrice = 0.0M; List <ShopBranchSkusInfo> shopBranchSkuList = this._iShopBranchService.GetSkusByIds(shopBranchId, from x in cartNoCache.Items select x.SkuId); if (func == null) { func = delegate(ShoppingCartItem x) { long?nullable1 = x.ShopBranchId; long num = shopBranchId; return((nullable1.GetValueOrDefault() == num) && nullable1.HasValue); }; } var enumerable2 = from s in cartNoCache.Items.Where <ShoppingCartItem>(func).Select(delegate(ShoppingCartItem item) { Func <ShopBranchSkusInfo, bool> predicate = null; if (shopBranchId == 0x63L) { } ShopBranchInfo shopBranchById = this._iShopBranchService.GetShopBranchById(shopBranchId); ProductInfo product = this._iProductService.GetProduct(item.ProductId); ShopInfo shop = this._iShopService.GetShop(product.ShopId, false); SKUInfo sku = null; if ((shop != null) && (shopBranchById != null)) { VShopInfo vShopByShopId = this._iVShopService.GetVShopByShopId(shop.Id); sku = this._iProductService.GetSku(item.SkuId); if (sku == null) { return(null); } prodPrice = sku.SalePrice; if (shop.IsSelf) { prodPrice = sku.SalePrice * discount; } if (predicate == null) { predicate = x => x.SkuId == item.SkuId; } ShopBranchSkusInfo info6 = shopBranchSkuList.FirstOrDefault <ShopBranchSkusInfo>(predicate); long maxBuyCount = (info6 == null) ? ((long)0) : ((long)info6.Stock); if ((maxBuyCount > product.MaxBuyCount) && (product.MaxBuyCount > 0)) { maxBuyCount = product.MaxBuyCount; } if (((product.MaxBuyCount > 0) && (buyedCounts != null)) && buyedCounts.ContainsKey(item.ProductId)) { int num3 = buyedCounts[item.ProductId]; maxBuyCount -= num3; } return(new { cartItemId = item.Id, skuId = item.SkuId, id = product.Id, imgUrl = HimallIO.GetProductSizeImage(product.RelativePath, 1, 150), name = product.ProductName, price = prodPrice, count = item.Quantity, status = (info6 == null) ? 1 : ((info6.Status == ShopBranchSkuStatus.Normal) ? ((item.Quantity > maxBuyCount) ? 2 : 0) : 1), AddTime = item.AddTime, shopBranchId = shopBranchById.Id, shopBranchName = shopBranchById.ShopBranchName }); } return(null); }) where s != null orderby s.AddTime descending select s; list3.Add(enumerable2); } } var data = new { products = source, amount = Enumerable.Sum(source, item => item.price * (Decimal)item.count), totalCount = Enumerable.Sum(source, item => item.count), shopBranchCart = list3 }; return(base.Json(data)); }