public object GetShippingAddressList(long shopBranchId) { if (shopBranchId == 0L) { throw new HimallException("获取门店ID失败"); } this.CheckUserLogin(); IQueryable <ShippingAddressInfo> shippingAddressByUserId = Instance <IShippingAddressService> .Create.GetUserShippingAddressByUserId(this.CurrentUser.Id); List <ShippingAddressInfo> list = new List <ShippingAddressInfo>(); ShopBranchInfo shopBranchById = Instance <IShopBranchService> .Create.GetShopBranchById(shopBranchId); if (shopBranchById == null || !shopBranchById.IsStoreDelive) { throw new HimallException("门店ID错误,或不支持配送"); } foreach (ShippingAddressInfo shippingAddressInfo1 in (IEnumerable <ShippingAddressInfo>)shippingAddressByUserId) { int?serveRadius = shopBranchById.ServeRadius; if (serveRadius.HasValue) { string fromLatLng = string.Format("{0},{1}", (object)shippingAddressInfo1.Latitude, (object)shippingAddressInfo1.Longitude); if (fromLatLng.Length > 1) { double distancesFromApi = Instance <IShopBranchService> .Create.GetLatLngDistancesFromAPI(fromLatLng, string.Format("{0},{1}", (object)shopBranchById.Latitude, (object)shopBranchById.Longitude)); double num = distancesFromApi; serveRadius = shopBranchById.ServeRadius; if ((num >= (double)serveRadius.GetValueOrDefault() ? 0 : (serveRadius.HasValue ? 1 : 0)) != 0 && distancesFromApi != 0.0) { shippingAddressInfo1.CanDelive = true; } } } ShippingAddressInfo shippingAddressInfo2 = new ShippingAddressInfo() { Id = shippingAddressInfo1.Id, ShipTo = shippingAddressInfo1.ShipTo, Phone = shippingAddressInfo1.Phone, RegionFullName = shippingAddressInfo1.RegionFullName, Address = shippingAddressInfo1.Address, RegionId = shippingAddressInfo1.RegionId, RegionIdPath = shippingAddressInfo1.RegionIdPath, IsDefault = shippingAddressInfo1.IsDefault, Latitude = shippingAddressInfo1.Latitude, Longitude = shippingAddressInfo1.Longitude, CanDelive = shippingAddressInfo1.CanDelive }; list.Add(shippingAddressInfo2); } return((object)this.Json(new { Success = "true", ShippingAddress = list })); }
public object GetShippingAddress(long id, long shopBranchId) { if (shopBranchId == 0L) { throw new HimallException("获取门店ID失败"); } this.CheckUserLogin(); ShippingAddressInfo shippingAddressInfo = Queryable.FirstOrDefault <ShippingAddressInfo>(Instance <IShippingAddressService> .Create.GetUserShippingAddressByUserId(this.CurrentUser.Id), (Expression <Func <ShippingAddressInfo, bool> >)(e => e.Id == id)); ShopBranchInfo shopBranchById = Instance <IShopBranchService> .Create.GetShopBranchById(shopBranchId); if (shippingAddressInfo == null || shopBranchById == null || !shopBranchById.IsStoreDelive) { return((object)this.Json(new { Success = "true", ShippingAddress = new ShippingAddressInfo() })); } int?serveRadius = shopBranchById.ServeRadius; if (serveRadius.HasValue) { string fromLatLng = string.Format("{0},{1}", (object)shippingAddressInfo.Latitude, (object)shippingAddressInfo.Longitude); if (fromLatLng.Length > 1) { double distancesFromApi = Instance <IShopBranchService> .Create.GetLatLngDistancesFromAPI(fromLatLng, string.Format("{0},{1}", (object)shopBranchById.Latitude, (object)shopBranchById.Longitude)); double num = distancesFromApi; serveRadius = shopBranchById.ServeRadius; if ((num >= (double)serveRadius.GetValueOrDefault() ? 0 : (serveRadius.HasValue ? 1 : 0)) != 0 && distancesFromApi != 0.0) { shippingAddressInfo.CanDelive = true; } } } return((object)this.Json(new { Success = "true", ShippingAddress = new ShippingAddressInfo() { Id = shippingAddressInfo.Id, ShipTo = shippingAddressInfo.ShipTo, Phone = shippingAddressInfo.Phone, RegionFullName = shippingAddressInfo.RegionFullName, Address = shippingAddressInfo.Address, RegionId = shippingAddressInfo.RegionId, RegionIdPath = shippingAddressInfo.RegionIdPath, Latitude = shippingAddressInfo.Latitude, Longitude = shippingAddressInfo.Longitude, CanDelive = shippingAddressInfo.CanDelive } })); }
/// <summary> /// 更新门店信息、管理员密码 /// </summary> /// <param name="shopBranch"></param> public static void UpdateShopBranch(ShopBranch shopBranch) { if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName)) { throw new HimallException("门店名称不能重复!"); } Mapper.CreateMap <ShopBranch, ShopBranchInfo>(); ShopBranchInfo info = Mapper.Map <ShopBranch, ShopBranchInfo>(shopBranch); info.AddressPath = RegionApplication.GetRegionPath(info.AddressId); info.AddressPath = info.AddressPath + ","; _shopBranchService.UpdateShopBranch(info); if (!(string.IsNullOrWhiteSpace(shopBranch.PasswordOne) || string.IsNullOrWhiteSpace(shopBranch.PasswordTwo))) { string salt = GetSalt(); string passwrodEncode = GetPasswrodEncode(shopBranch.PasswordOne, salt); _shopBranchService.UpdateShopBranchManagerPwd(shopBranch.Id, shopBranch.UserName, passwrodEncode, salt); } }
public void UpdateShopBranch(ShopBranchInfo shopBranch) { var branchEntity = Context.ShopBranchInfo.FirstOrDefault(e => e.Id == shopBranch.Id); if (branchEntity == null) { throw new Himall.Core.HimallException("数据异常,更新失败!"); } branchEntity.ShopBranchName = shopBranch.ShopBranchName; branchEntity.AddressDetail = shopBranch.AddressDetail; branchEntity.AddressId = shopBranch.AddressId; branchEntity.ContactPhone = shopBranch.ContactPhone; branchEntity.ContactUser = shopBranch.ContactUser; branchEntity.AddressPath = shopBranch.AddressPath; branchEntity.ShopImages = shopBranch.ShopImages; branchEntity.Longitude = shopBranch.Longitude; branchEntity.Latitude = shopBranch.Latitude; branchEntity.ServeRadius = shopBranch.ServeRadius; Context.SaveChanges(); }
/// <summary> /// 订单自动分配到门店 /// </summary> /// <param name="query"></param> /// <param name="skuIds">订单内商品SkuId</param> /// <param name="counts">订单内商品购买数量</param> /// <returns></returns> public ShopBranchInfo GetAutoMatchShopBranch(ShopBranchQuery query, string[] skuIds, int[] counts) { ShopBranchInfo resultObj = null; var skuInfos = Context.SKUInfo.Where(p => skuIds.Contains(p.Id)).ToList(); query.ProductIds = skuInfos.Select(p => p.ProductId).ToArray(); query.Status = CommonModel.ShopBranchStatus.Normal; var data = GetShopBranchsAll(query); //获取商家下的有该产品SKU的状态正常门店 var shopBranchSkus = GetSkus(query.ShopId, data.Models.Select(p => p.Id)); //获取当前商家下门店的SKU data.Models.ForEach(p => p.Enabled = skuInfos.All(skuInfo => shopBranchSkus.Any(sbSku => sbSku.ShopBranchId == p.Id && sbSku.Stock >= counts[skuInfos.IndexOf(skuInfo)] && sbSku.SkuId == skuInfo.Id)) ); var result = data.Models.Where(p => p.Enabled).ToList(); //只取商家下都有该商品SKU库存的门店数据 bool fromLatLng = false; //用户收货地址是否定位了经纬度 if (!string.IsNullOrWhiteSpace(query.FromLatLng)) { fromLatLng = query.FromLatLng.Split(',').Length == 2; } if (result.Count > 0) { if (fromLatLng)//优先用服务半径匹配,取距离最近的、又有库存的门店。前提要收货地址定位了经纬度 { resultObj = result.Where(p => p.Latitude > 0 && p.Longitude > 0 && p.ServeRadius >= p.Distance).OrderBy(p => p.Distance).Take(1).FirstOrDefault <ShopBranchInfo>(); } if (resultObj == null)//如果服务半径无法满足,则根据配送范围去匹配 { var deliveryScope = GetShopDeliveryScopeAll(new ShopDeliveryScopeQuery() { }); if (query.StreetId > 0) //优先筛选出与买家收货地址同街道的所有门店 { List <long> shopBrachIds = deliveryScope.Models.Where(p => p.FullRegionPath.Contains(CommonConst.ADDRESS_PATH_SPLIT + query.StreetId + CommonConst.ADDRESS_PATH_SPLIT)).Select(p => p.ShopBranchId).Distinct().ToList(); if (shopBrachIds.Count > 0) { if (shopBrachIds.Count > 1)//如果匹配多个则取距离最近一个 { if (fromLatLng) { resultObj = result.Where(p => p.Latitude > 0 && p.Longitude > 0 && shopBrachIds.Contains(p.Id)).OrderBy(p => p.Distance).Take(1).FirstOrDefault <ShopBranchInfo>(); } } else { resultObj = result.Where(p => shopBrachIds.Contains(p.Id)).FirstOrDefault <ShopBranchInfo>(); } } } if (resultObj == null)//如果街道无法满足,则根据区县匹配 { if (query.DistrictId > 0) { List <long> shopBrachIds = deliveryScope.Models.Where(p => p.FullRegionPath.Contains(CommonConst.ADDRESS_PATH_SPLIT + query.DistrictId + CommonConst.ADDRESS_PATH_SPLIT)).Select(p => p.ShopBranchId).Distinct().ToList(); if (shopBrachIds.Count > 0) { if (shopBrachIds.Count > 1)//如果匹配多个则取距离最近一个 { if (fromLatLng) { resultObj = result.Where(p => p.Latitude > 0 && p.Longitude > 0 && shopBrachIds.Contains(p.Id)).OrderBy(p => p.Distance).Take(1).FirstOrDefault <ShopBranchInfo>(); } } else { resultObj = result.Where(p => shopBrachIds.Contains(p.Id)).FirstOrDefault <ShopBranchInfo>(); } } } } } } return(resultObj); }
public object PostEditShippingAddress(ShippingAddressEditModel value) { long?shopbranchid; int num; if (value.shopbranchid.HasValue) { shopbranchid = value.shopbranchid; num = shopbranchid.Value != 0L ? 1 : 0; } else { num = 0; } if (num == 0) { throw new HimallException("获取门店ID失败"); } shopbranchid = value.shopbranchid; long id = shopbranchid.Value; this.CheckUserLogin(); ShippingAddressInfo shipinfo = new ShippingAddressInfo(); shipinfo.UserId = this.CurrentUser.Id; shipinfo.Id = value.id; shipinfo.RegionId = value.regionId; shipinfo.Address = value.address; shipinfo.Phone = value.phone; shipinfo.ShipTo = value.shipTo; shipinfo.Longitude = new float?(value.longitude); shipinfo.Latitude = new float?(value.latitude); ShopBranchInfo shopBranchById = Instance <IShopBranchService> .Create.GetShopBranchById(id); if (shopBranchById == null || !shopBranchById.IsStoreDelive) { return((object)this.Json(new { Success = "false", Msg = "门店不提供配送服务" })); } if (shopBranchById.ServeRadius.HasValue) { string fromLatLng = string.Format("{0},{1}", (object)shipinfo.Latitude, (object)shipinfo.Longitude); if (fromLatLng.Length <= 1) { return((object)this.Json(new { Success = "false", Msg = "收货地址经纬度获取失败" })); } double distancesFromApi = Instance <IShopBranchService> .Create.GetLatLngDistancesFromAPI(fromLatLng, string.Format("{0},{1}", (object)shopBranchById.Latitude, (object)shopBranchById.Longitude)); int?serveRadius = shopBranchById.ServeRadius; if ((distancesFromApi <= (double)serveRadius.GetValueOrDefault() ? 0 : (serveRadius.HasValue ? 1 : 0)) != 0) { return((object)this.Json(new { Success = "false", Msg = "距离超过门店配送距离的不可配送" })); } } try { Instance <IShippingAddressService> .Create.UpdateShippingAddress(shipinfo); } catch (Exception ex) { return((object)this.Json(new { Success = "false", Msg = ex.Message })); } return((object)this.Json(new { Success = "true" })); }
public object GetBranchCartProducts(long shopBranchId) { long memberId = 0L; decimal discount = 1.0M; if (base.CurrentUser != null) { memberId = base.CurrentUser.Id; discount = base.CurrentUser.MemberDiscount; } ShoppingCartInfo cart = this.GetCart(memberId, shopBranchId); ShopBranchInfo shopBranchById = this._iShopBranchService.GetShopBranchById(shopBranchId); IProductService productService = this._iProductService; IShopService shopService = this._iShopService; IVShopService vshopService = this._iVShopService; List <long> list = new List <long>(); decimal prodPrice = 0.0M; var enumerable = from s in cart.Items.Select(delegate(ShoppingCartItem item) { ProductInfo product = productService.GetProduct(item.ProductId); ShopBranchSkusInfo info2 = this._iShopBranchService.GetSkusByIds(shopBranchId, new List <string> { item.SkuId }).FirstOrDefault <ShopBranchSkusInfo>(); ShopInfo shop = shopService.GetShop(product.ShopId, false); SKUInfo sku = null; string str = ""; if (null != shop) { VShopInfo vShopByShopId = vshopService.GetVShopByShopId(shop.Id); sku = productService.GetSku(item.SkuId); if (sku == null) { return(null); } prodPrice = sku.SalePrice; if (shop.IsSelf) { prodPrice = sku.SalePrice * discount; } ProductType type = TypeApplication.GetType(product.TypeId); str = ""; if (!string.IsNullOrWhiteSpace(sku.Size)) { str = str + sku.Size + " "; } if (!string.IsNullOrWhiteSpace(sku.Color)) { str = str + sku.Color + " "; } if (!string.IsNullOrWhiteSpace(sku.Version)) { str = str + sku.Version + " "; } return(new { bId = shopBranchId, cartItemId = item.Id, skuId = item.SkuId, id = product.Id, name = product.ProductName, price = prodPrice, count = item.Quantity, stock = (info2 == null) ? 0 : info2.Stock, status = (info2 == null) ? 1 : ((info2.Status == ShopBranchSkuStatus.Normal) ? ((item.Quantity > info2.Stock) ? 2 : 0) : 1), skuDetails = str, AddTime = item.AddTime }); } return(null); }) where s != null orderby s.status, s.AddTime descending select s; var content = new { Success = true, products = enumerable, amount = enumerable.Where(x => x.status == 0).Sum(x => x.price * x.count), totalCount = enumerable.Where(x => x.status == 0).Sum(x => x.count), DeliveFee = shopBranchById.DeliveFee, DeliveTotalFee = shopBranchById.DeliveTotalFee, FreeMailFee = shopBranchById.FreeMailFee, shopBranchStatus = shopBranchById.Status }; return(base.Json(content)); }
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)); }
public JsonResult GetBranchCartProducts(long shopBranchId) { BranchCartHelper helper = new BranchCartHelper(); long memberId = 0L; decimal discount = 1.0M; if (base.CurrentUser != null) { memberId = base.CurrentUser.Id; discount = base.CurrentUser.MemberDiscount; } ShoppingCartInfo cart = helper.GetCart(memberId, shopBranchId); ShopBranchInfo shopBranchById = this._iShopBranchService.GetShopBranchById(shopBranchId); Dictionary <long, int> buyedCounts = null; if (memberId > 0L) { buyedCounts = new Dictionary <long, int>(); buyedCounts = OrderApplication.GetProductBuyCount(memberId, from x in cart.Items select x.ProductId); } decimal prodPrice = 0.0M; List <ShopBranchSkusInfo> shopBranchSkuList = this._iShopBranchService.GetSkusByIds(shopBranchId, from x in cart.Items select x.SkuId); var enumerable = from s in cart.Items.Select(delegate(ShoppingCartItem item) { ProductInfo product = this._iProductService.GetProduct(item.ProductId); ShopBranchSkusInfo info2 = shopBranchSkuList.FirstOrDefault <ShopBranchSkusInfo>(x => x.SkuId == item.SkuId); long maxBuyCount = (info2 == null) ? ((long)0) : ((long)info2.Stock); if ((maxBuyCount > product.MaxBuyCount) && (product.MaxBuyCount != 0)) { maxBuyCount = product.MaxBuyCount; } if (((product.MaxBuyCount > 0) && (buyedCounts != null)) && buyedCounts.ContainsKey(item.ProductId)) { int num2 = buyedCounts[item.ProductId]; maxBuyCount -= num2; } ShopInfo shop = this._iShopService.GetShop(product.ShopId, false); SKUInfo sku = null; string str = ""; if (null != shop) { 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; } ProductType type = TypeApplication.GetType(product.TypeId); str = ""; if (!string.IsNullOrWhiteSpace(sku.Size)) { str = str + sku.Size + " "; } if (!string.IsNullOrWhiteSpace(sku.Color)) { str = str + sku.Color + " "; } if (!string.IsNullOrWhiteSpace(sku.Version)) { str = str + sku.Version + " "; } return(new { bId = shopBranchId, cartItemId = item.Id, skuId = item.SkuId, id = product.Id, name = product.ProductName, price = prodPrice, count = item.Quantity, stock = (info2 == null) ? 0L : maxBuyCount, status = (info2 == null) ? 1 : ((info2.Status == ShopBranchSkuStatus.Normal) ? ((item.Quantity > maxBuyCount) ? 2 : 0) : 1), skuDetails = str, AddTime = item.AddTime }); } return(null); }) where s != null orderby s.status, s.AddTime descending select s; var data = new { products = enumerable, amount = Enumerable.Sum(Enumerable.Where(enumerable, x => x.status == 0), item => item.price * (Decimal)item.count), totalCount = Enumerable.Sum(Enumerable.Where(enumerable, x => x.status == 0), item => item.count), DeliveFee = shopBranchById.DeliveFee, DeliveTotalFee = shopBranchById.DeliveTotalFee, FreeMailFee = shopBranchById.FreeMailFee, shopBranchStatus = shopBranchById.Status }; return(base.Json(data)); }