Example #1
0
 public static VWShoppingCartInfo GetXuQiuSession()
 {
     #region 重新获取购物车SESSSION
     System.Web.HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies[Core.SysCookieName.ComBineXuQiu];
     string result = "0";
     if (cookie != null)
     {
         result = cookie.Value;
     }
     if (result == "1")
     {
         RemoveXuQiuSession();
         ShoppingXuQiuProcessor.WriteShoppingXuQiuCookieByLogin();
         CookieBLL.ComBineCartXuQiu(0);
     }
     #endregion
     VWShoppingCartInfo shoppingCart = ShoppingXuQiuProcessor.GetShoppingXuQiu();
     return(shoppingCart);
 }
Example #2
0
        public static void AddToXuQiu(VWShoppingCartInfo shoppingcart, ShoppCookie _entitycart)
        {
            bool boo_i  = true;
            int  sort_i = 0;

            if (shoppingcart != null && shoppingcart.CartItems.Count > 0)
            {
                foreach (ShoppCookie item in shoppingcart.CartItems)
                {
                    if (item.ProDId == _entitycart.ProDId)
                    {
                        item.C    = 1;
                        item.Num += _entitycart.Num;
                        boo_i     = false;
                        break;
                    }
                    item.S = sort_i++;
                }
            }
            if (boo_i)
            {
                if (shoppingcart == null)
                {
                    shoppingcart = new VWShoppingCartInfo();
                }
                if (shoppingcart.CartItems == null)
                {
                    shoppingcart.CartItems = new List <ShoppCookie>();
                }
                if (shoppingcart.CartItems.Count >= CommonKey.CartMaxNum)
                {
                    for (int i = 0; i <= shoppingcart.CartItems.Count - CommonKey.CartMaxNum; i++)
                    {
                        shoppingcart.CartItems.RemoveAt(0);
                    }
                }

                _entitycart.S = sort_i;
                shoppingcart.CartItems.Add(_entitycart);
            }
            ShoppingXuQiuProcessor.WriteShoppingXuQiuCookie(shoppingcart);
        }
Example #3
0
        public static void BuyImmediately(VWShoppingCartInfo shoppingcart, ShoppCookie _entitycart)
        {
            bool boo_i  = true;
            int  sort_i = 0;

            if (shoppingcart != null && shoppingcart.CartItems.Count > 0)
            {
                foreach (ShoppCookie item in shoppingcart.CartItems)
                {
                    item.C = 0;
                    if (item.ProDId == _entitycart.ProDId)
                    {
                        item.C   = 1;
                        item.Num = _entitycart.Num;
                        boo_i    = false;
                        break;
                    }
                    item.S = sort_i++;
                }
            }
            if (boo_i)
            {
                if (shoppingcart == null)
                {
                    shoppingcart = new VWShoppingCartInfo();
                }
                if (shoppingcart.CartItems == null)
                {
                    shoppingcart.CartItems = new List <ShoppCookie>();
                }
                _entitycart.C = 1;
                _entitycart.S = sort_i++;
                shoppingcart.CartItems.Add(_entitycart);
            }
            ShoppingXuQiuProcessor.WriteShoppingXuQiuCookie(shoppingcart);
        }
Example #4
0
        /// <summary>
        /// 添加购物车单品
        /// </summary>
        /// <param name="shoppingcart">购物车对象</param>
        /// <param name="wareCode">产品编号</param>
        /// <param name="Qty">数量</param>
        /// <param name="webSiteId">站点编号</param>
        public static VWShoppingCartInfo BuyContinue(VWShoppingCartInfo shoppingcart, IList <ShoppCookie> _entitycart)
        {
            int boo_i = 0;

            if (shoppingcart != null && shoppingcart.CartItems.Count > 0)
            {
                foreach (ShoppCookie item in shoppingcart.CartItems)
                {
                    item.C = 0;
                    foreach (ShoppCookie additem in _entitycart)
                    {
                        if (item.ProDId == additem.ProDId)
                        {
                            item.C   = 1;
                            item.Num = additem.Num;
                            item.S   = boo_i;
                            boo_i   += 1;
                            _entitycart.Remove(additem);
                            break;
                        }
                    }
                }
                if (shoppingcart.CartItems.Count + _entitycart.Count > CommonKey.CartMaxNum)
                {
                    for (int i = 0; i < shoppingcart.CartItems.Count + _entitycart.Count - CommonKey.CartMaxNum; i++)
                    {
                        shoppingcart.CartItems.RemoveAt(0);
                    }
                }
                if (_entitycart.Count > 0)
                {
                    foreach (ShoppCookie _additem in _entitycart)
                    {
                        _additem.C = 1;
                        _additem.S = boo_i;
                        boo_i     += 1;
                        shoppingcart.CartItems.Add(_additem);
                    }
                }
            }
            else
            {
                if (shoppingcart == null)
                {
                    shoppingcart = new VWShoppingCartInfo();
                }
                if (shoppingcart.CartItems == null)
                {
                    shoppingcart.CartItems = new List <ShoppCookie>();
                }
                foreach (ShoppCookie _additem in _entitycart)
                {
                    _additem.C = 1;
                    _additem.S = boo_i;
                    boo_i     += 1;
                }
                shoppingcart.CartItems = _entitycart;
            }
            ShoppingXuQiuProcessor.WriteShoppingXuQiuCookie(shoppingcart);
            return(shoppingcart);
        }