Пример #1
0
        /// <summary>
        /// Mini购物车获取商品数量
        /// </summary>
        /// <returns></returns>
        public JsonResult GetMiniShoppingCartCount()
        {
            LoginUser userInfo          = UserMgr.ReadUserInfo();
            int       userSysNo         = userInfo == null ? 0 : userInfo.UserSysNo;
            int       totalProductCount = 0;
            //ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartByCustomer(userSysNo);

            if (shoppingCart == null)
            {
                shoppingCart = new ShoppingCart();
            }

            if (shoppingCart != null && shoppingCart.ShoppingItemGroupList != null)
            {
                foreach (var itemGroup in shoppingCart.ShoppingItemGroupList)
                {
                    foreach (var item in itemGroup.ShoppingItemList)
                    {
                        totalProductCount += itemGroup.Quantity * item.UnitQuantity;
                    }
                }
            }
            //ShoppingStorageManager.SaveShoppingCart(shoppingCart);
            //将迷你购物车加入Cookie
            OrderPipelineProcessResult shoppingResult = ShoppingFacade.BuildShoppingCart(shoppingCart);

            ShoppingStorageManager.SaveShoppingCartMini(ShoppingFacade.BuildMiniShoppingCartFromPipeline(shoppingResult));
            return(new JsonResult()
            {
                Data = totalProductCount
            });
        }
Пример #2
0
        /// <summary>
        /// 获取Mini购物车
        /// </summary>
        /// <returns></returns>
        public PartialViewResult GetMiniShoppingCart()
        {
            //ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();

            //ShoppingCartMiniResult shoppingResult = ShoppingStorageManager.GetShoppingCartMiniFromCookie();
            //ShoppingStorageManager.SaveShoppingCart(shoppingCart);
            ////将迷你购物车加入Cookie
            //ShoppingStorageManager.SaveShoppingCartMini(ShoppingStorageManager.GetShoppingCartMiniFromCookie());
            LoginUser    userInfo     = UserMgr.ReadUserInfo();
            int          userSysNo    = userInfo == null ? 0 : userInfo.UserSysNo;
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartByCustomer(userSysNo);

            if (shoppingCart == null)
            {
                shoppingCart = new ShoppingCart();
            }
            ShoppingCartMiniResult shoppingResult = ShoppingFacade.BuildMiniShoppingCartFromPipeline(ShoppingFacade.BuildShoppingCart(shoppingCart));

            //ShoppingStorageManager.SaveShoppingCart(shoppingCart);
            //将迷你购物车加入Cookie
            ShoppingStorageManager.SaveShoppingCartMini(shoppingResult);

            return(PartialView("_ShoppingCartMini", shoppingResult));
        }