Example #1
0
        public Himall.Entities.ShoppingCartInfo GetCartNoCache(long memberId, long shopBranchId)
        {
            Himall.Entities.ShoppingCartInfo shoppingCartInfo;
            if (memberId > 0)//已经登录,系统从服务器读取购物车信息,否则从Cookie获取购物车信息
            {
                shoppingCartInfo = CartApplication.GetShopBranchCartNoCache(memberId, shopBranchId);
            }
            else
            {
                shoppingCartInfo = new Himall.Entities.ShoppingCartInfo();

                string cartInfo = WebHelper.GetCookie(CookieKeysCollection.HIMALL_CART_BRANCH);
                if (!string.IsNullOrWhiteSpace(cartInfo))
                {
                    string[] cartItems     = cartInfo.Split(',');
                    var      cartInfoItems = new List <Himall.Entities.ShoppingCartItem>();
                    foreach (string cartItem in cartItems)
                    {
                        var cartItemParts = cartItem.Split(':');
                        if (shopBranchId == 0 || cartItemParts[2] == shopBranchId.ToString())
                        {
                            cartInfoItems.Add(new Himall.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);
        }