Пример #1
0
        private ActionResult ProcessDelFromCart()
        {
            #region 购物车
            VWShoppingCartInfo shoppingCart = SessionUtil.GetCartSession();
            #endregion

            string callback    = QueryString.SafeQ("callback");//jsonp回调函数
            int    prodetailid = QueryString.IntSafeQ("prodetailid");
            int    num         = QueryString.IntSafeQ("Num");

            if (prodetailid == 0)
            {
                return(Content(callback + "({\"Status\":\"请选择需要删除的商品\"});"));
            }
            else
            {
                ShoppingCartProcessor.RemoveCartItem(shoppingCart, prodetailid);
                return(Content(callback + "({\"Status\":\"OK\"});"));
            }
        }
Пример #2
0
        /// <summary>
        /// 网站首页
        /// </summary>
        /// <returns></returns>
        public ActionResult ShopCart()
        {
            string pids  = QueryString.SafeQ("pids", 500);
            string nums  = QueryString.SafeQ("nums", 500);
            int    jishi = QueryString.IntSafeQ("js");

            if (jishi == 0)
            {
                jishi = (int)JiShiSongEnum.Normal;
            }
            VWShoppingCartInfo shoppingCart = new VWShoppingCartInfo();

            if (jishi == (int)JiShiSongEnum.JiShi)
            {
                shoppingCart = SessionUtil.GetXuQiuSession();
            }
            else
            {
                shoppingCart = SessionUtil.GetCartSession();
            }


            IList <MemShoppCarEntity> clist = new List <MemShoppCarEntity>();

            if (shoppingCart != null && shoppingCart.CartItems != null && shoppingCart.CartItems.Count > 0)
            {
                IList <ShoppCookie> shopcoolist = shoppingCart.CartItems.OrderByDescending(c => c.C).ThenByDescending(c => c.S).ToList();
                //shoppingCart.CartItemsL = new List<ShoppCarEntity>();
                foreach (ShoppCookie entity in shopcoolist)
                {
                    if (entity.ProDId <= 0)
                    {
                        if (jishi == (int)JiShiSongEnum.JiShi)
                        {
                            ShoppingXuQiuProcessor.RemoveXuQiuItem(shoppingCart, entity.ProDId);
                        }
                        else
                        {
                            ShoppingCartProcessor.RemoveCartItem(shoppingCart, entity.ProDId);
                        }
                    }
                    else
                    {
                        VWProductEntity   vwpentity     = ProductBLL.Instance.GetProVWByDetailId(entity.ProDId);
                        MemShoppCarEntity shopcarentity = new MemShoppCarEntity();
                        shopcarentity.PicUrl          = vwpentity.PicUrl;
                        shopcarentity.PicSuffix       = vwpentity.PicSuffix;
                        shopcarentity.Price           = Calculate.GetPrice(member.Status, member.IsStore, member.StoreType, member.MemGrade, vwpentity.TradePrice, vwpentity.Price, vwpentity.IsBP, vwpentity.DealerPrice);
                        shopcarentity.ProductName     = vwpentity.AdTitle;
                        shopcarentity.Spec1           = vwpentity.Spec1;
                        shopcarentity.Spec2           = vwpentity.Spec2;
                        shopcarentity.Spec3           = vwpentity.Spec3;
                        shopcarentity.TotalPrice      = shopcarentity.Price * entity.Num;
                        shopcarentity.Num             = entity.Num;
                        shopcarentity.ProductType     = vwpentity.ProductType;
                        shopcarentity.ProductId       = vwpentity.ProductId;
                        shopcarentity.StockNum        = vwpentity.StockNum;
                        shopcarentity.Check           = entity.C == 1;
                        shopcarentity.ProductDetailId = entity.ProDId;
                        clist.Add(shopcarentity);
                    }
                }
                shoppingCart.CartItemsL = clist;
            }
            if (!string.IsNullOrEmpty(pids))
            {
                string[]            pidattr = pids.Split('_');
                string[]            numattr = nums.Split('_');
                IList <ShoppCookie> list    = new List <ShoppCookie>();
                for (int i = 0; i < pidattr.Length; i++)
                {
                    VWProductEntity _productentity = ProductBLL.Instance.GetProVWByDetailId(StringUtils.GetDbInt(pidattr[i]));
                    if (_productentity.ProductDetailId > 0)
                    {
                        ShoppCookie cookentity = new ShoppCookie();
                        cookentity.C      = 1;
                        cookentity.Num    = StringUtils.GetDbInt(numattr[i]);
                        cookentity.ProDId = _productentity.ProductDetailId;
                        list.Add(cookentity);
                    }
                }
                if (jishi == (int)JiShiSongEnum.JiShi)
                {
                    shoppingCart = ShoppingXuQiuProcessor.BuyContinue(shoppingCart, list);
                }
                else
                {
                    shoppingCart = ShoppingCartProcessor.BuyContinue(shoppingCart, list);
                }

                clist = new List <MemShoppCarEntity>();
                IList <ShoppCookie> shopcoolist = shoppingCart.CartItems.OrderByDescending(c => c.C).ThenByDescending(c => c.S).ToList();

                foreach (ShoppCookie entity in shopcoolist)
                {
                    if (entity.ProDId <= 0)
                    {
                        if (jishi == (int)JiShiSongEnum.JiShi)
                        {
                            ShoppingXuQiuProcessor.RemoveXuQiuItem(shoppingCart, entity.ProDId);
                        }
                        else
                        {
                            ShoppingCartProcessor.RemoveCartItem(shoppingCart, entity.ProDId);
                        }
                    }
                    else
                    {
                        VWProductEntity   vwpentity     = ProductBLL.Instance.GetProVWByDetailId(entity.ProDId);
                        MemShoppCarEntity shopcarentity = new MemShoppCarEntity();
                        shopcarentity.PicUrl          = vwpentity.PicUrl;
                        shopcarentity.PicSuffix       = vwpentity.PicSuffix;
                        shopcarentity.Price           = Calculate.GetPrice(member.Status, member.IsStore, member.StoreType, member.MemGrade, vwpentity.TradePrice, vwpentity.Price, vwpentity.IsBP, vwpentity.DealerPrice);
                        shopcarentity.ProductName     = vwpentity.AdTitle;
                        shopcarentity.Spec1           = vwpentity.Spec1;
                        shopcarentity.Spec2           = vwpentity.Spec2;
                        shopcarentity.Spec3           = vwpentity.Spec3;
                        shopcarentity.TotalPrice      = shopcarentity.Price * entity.Num;
                        shopcarentity.Num             = entity.Num;
                        shopcarentity.ProductType     = vwpentity.ProductType;
                        shopcarentity.ProductId       = vwpentity.ProductId;
                        shopcarentity.StockNum        = vwpentity.StockNum;
                        shopcarentity.Check           = entity.C == 1;
                        shopcarentity.ProductDetailId = entity.ProDId;
                        clist.Add(shopcarentity);
                    }
                }
                shoppingCart.CartItemsL = clist;
            }
            ViewBag.ShoppingCart = shoppingCart;
            ViewBag.MemId        = memid;
            ViewBag.JiShiSong    = jishi;

            ViewBag.PageMenu = "3";
            return(View());
        }
Пример #3
0
        public ActionResult Cart()
        {
            string             pids         = QueryString.SafeQ("pids", 500);
            string             nums         = QueryString.SafeQ("nums", 500);
            VWShoppingCartInfo shoppingCart = SessionUtil.GetCartSession();

            //待项目完善后此段判断可删除
            if (shoppingCart != null && shoppingCart.CartItems != null && shoppingCart.CartItems.Count > 0)
            {
                shoppingCart.CartItemsL = new List <MemShoppCarEntity>();

                foreach (ShoppCookie entity in shoppingCart.CartItems)
                {
                    if (entity.ProDId <= 0)
                    {
                        ShoppingCartProcessor.RemoveCartItem(shoppingCart, entity.ProDId);
                    }
                    else
                    {
                        VWProductEntity   vwpentity     = ProductBLL.Instance.GetProVWByDetailId(entity.ProDId);
                        MemShoppCarEntity shopcarentity = new MemShoppCarEntity();
                        shopcarentity.PicUrl          = vwpentity.PicUrl;
                        shopcarentity.PicSuffix       = vwpentity.PicSuffix;
                        shopcarentity.Price           = Calculate.GetPrice(member.Status, member.IsStore, member.StoreType, member.MemGrade, vwpentity.TradePrice, vwpentity.Price, vwpentity.IsBP, vwpentity.DealerPrice);
                        shopcarentity.ProductName     = vwpentity.AdTitle;
                        shopcarentity.Spec1           = vwpentity.Spec1;
                        shopcarentity.Spec2           = vwpentity.Spec2;
                        shopcarentity.Spec3           = vwpentity.Spec3;
                        shopcarentity.TotalPrice      = shopcarentity.Price * entity.Num;
                        shopcarentity.Num             = entity.Num;
                        shopcarentity.ProductType     = vwpentity.ProductType;
                        shopcarentity.ProductId       = vwpentity.ProductId;
                        shopcarentity.Check           = entity.C == 1;
                        shopcarentity.ProductDetailId = entity.ProDId;
                        shopcarentity.CGMemId         = vwpentity.CGMemId;
                        shopcarentity.CGMemNickName   = vwpentity.CGMemNickName;
                        shopcarentity.IsAhmTake       = vwpentity.IsAhmTake;
                        shoppingCart.CartItemsL.Add(shopcarentity);
                    }
                }
            }
            if (!string.IsNullOrEmpty(pids))
            {
                string[]                  pidattr = pids.Split('_');
                string[]                  numattr = nums.Split('_');
                IList <ShoppCookie>       list    = new List <ShoppCookie>();
                IList <MemShoppCarEntity> listL   = new List <MemShoppCarEntity>();
                for (int i = 0; i < pidattr.Length; i++)
                {
                    VWProductEntity _productentity = ProductBLL.Instance.GetProVWByDetailId(StringUtils.GetDbInt(pidattr[i]));
                    if (_productentity.ProductDetailId > 0)
                    {
                        ShoppCookie cookentity = new ShoppCookie();
                        cookentity.C      = 1;
                        cookentity.Num    = StringUtils.GetDbInt(numattr[i]);
                        cookentity.ProDId = _productentity.ProductDetailId;
                        list.Add(cookentity);
                    }
                }
                shoppingCart            = ShoppingCartProcessor.BuyContinue(shoppingCart, list);
                shoppingCart.CartItemsL = new List <MemShoppCarEntity>();

                foreach (ShoppCookie entity in shoppingCart.CartItems)
                {
                    if (entity.ProDId <= 0)
                    {
                        ShoppingCartProcessor.RemoveCartItem(shoppingCart, entity.ProDId);
                    }
                    else
                    {
                        VWProductEntity   vwpentity     = ProductBLL.Instance.GetProVWByDetailId(entity.ProDId);
                        MemShoppCarEntity shopcarentity = new MemShoppCarEntity();
                        shopcarentity.PicUrl          = vwpentity.PicUrl;
                        shopcarentity.PicSuffix       = vwpentity.PicSuffix;
                        shopcarentity.Price           = Calculate.GetPrice(member.Status, member.IsStore, member.StoreType, member.MemGrade, vwpentity.TradePrice, vwpentity.Price, vwpentity.IsBP, vwpentity.DealerPrice);
                        shopcarentity.ProductName     = vwpentity.AdTitle;
                        shopcarentity.Spec1           = vwpentity.Spec1;
                        shopcarentity.Spec2           = vwpentity.Spec2;
                        shopcarentity.Spec3           = vwpentity.Spec3;
                        shopcarentity.TotalPrice      = shopcarentity.Price * entity.Num;
                        shopcarentity.Num             = entity.Num;
                        shopcarentity.ProductType     = vwpentity.ProductType;
                        shopcarentity.ProductId       = vwpentity.ProductId;
                        shopcarentity.Check           = entity.C == 1;
                        shopcarentity.ProductDetailId = entity.ProDId;
                        shopcarentity.CGMemId         = vwpentity.CGMemId;
                        shopcarentity.CGMemNickName   = vwpentity.CGMemNickName;
                        shopcarentity.IsAhmTake       = vwpentity.IsAhmTake;
                        shoppingCart.CartItemsL.Add(shopcarentity);
                    }
                }
            }


            //int memid = 0; int issupplier = 0;
            //MemberLoginEntity member = CookieBLL.GetLoginCookie();
            //if (member != null && member.MemId > 0)
            //{
            //    memid = member.MemId ;
            //    issupplier = member.IsStore;
            //}
            ViewBag.ShoppingCart = shoppingCart;
            ViewBag.MemId        = memid;
            return(View());
        }