public Mall.Entities.ShoppingCartInfo GetCart(long memberId, long shopBranchId) { Mall.Entities.ShoppingCartInfo shoppingCartInfo; if (memberId > 0)//已经登录,系统从服务器读取购物车信息,否则从Cookie获取购物车信息 { shoppingCartInfo = _iBranchCartService.GetCart(memberId, shopBranchId); } else { shoppingCartInfo = new Mall.Entities.ShoppingCartInfo(); string cartInfo = WebHelper.GetCookie(CookieKeysCollection.Mall_CART_BRANCH); if (!string.IsNullOrWhiteSpace(cartInfo)) { string[] cartItems = cartInfo.Split(','); var cartInfoItems = new List <Mall.Entities.ShoppingCartItem>(); int i = 0; foreach (string cartItem in cartItems) { var cartItemParts = cartItem.Split(':'); if (shopBranchId == 0 || cartItemParts[2] == shopBranchId.ToString()) { cartInfoItems[i++] = new Mall.Entities.ShoppingCartItem() { ProductId = long.Parse(cartItemParts[0].Split('_')[0]), SkuId = cartItemParts[0], Quantity = int.Parse(cartItemParts[1]), ShopBranchId = long.Parse(cartItemParts[2]) } } ; } shoppingCartInfo.Items = cartInfoItems; } } return(shoppingCartInfo); }
/// <summary> /// 取会员门店购物车项 /// </summary> /// <param name="memeberId"></param> /// <param name="shopbranchId">门店编号,0取所有</param> /// <returns></returns> public static ShoppingCartInfo GetShopBranchCart(long memberId, long shopbranchId = 0) { return(_iBranchCartService.GetCart(memberId, shopbranchId)); }