示例#1
0
        private ActionResult ProcessAddToXuQiu()
        {
            #region 需求清单
            VWShoppingCartInfo shoppingCart = SessionUtil.GetXuQiuSession();
            #endregion

            string callback    = QueryString.SafeQ("callback");//jsonp回调函数
            int    prodetailid = QueryString.IntSafeQ("prodetailid");
            int    num         = QueryString.IntSafeQ("Num");
            if (prodetailid == 0)
            {
                return(Content(callback + "({\"Status\":\"请选择商品\"});"));
            }
            if (ProductDetailBLL.Instance.GetProductDetail(prodetailid).StockNum < num)
            {
                return(Content(callback + "({\"Status\":\"库存数量不足\"})"));
            }
            else
            {
                ShoppCookie _entity = new ShoppCookie();
                _entity.C      = 1;
                _entity.Num    = num;
                _entity.ProDId = prodetailid;
                ShoppingXuQiuProcessor.AddToXuQiu(shoppingCart, _entity);
                return(Content(callback + "({\"Status\":\"OK\"});"));
            }
        }
示例#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);
        }
示例#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);
        }
示例#4
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());
        }
示例#5
0
        public void XuQiuCartMethod()
        {
            Dictionary <int, IList <MemShoppCarEntity> > shopdic = new Dictionary <int, IList <MemShoppCarEntity> >();

            int                itemproductnum   = 0; //产品数量
            decimal            productamountall = 0; //产品总金额
            string             pids             = QueryString.SafeQ("pids", 500);
            string             nums             = QueryString.SafeQ("nums", 500);
            VWShoppingCartInfo shoppingCart     = SessionUtil.GetXuQiuSession();

            //待项目完善后此段判断可删除
            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)
                    {
                        ShoppingXuQiuProcessor.RemoveXuQiuItem(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;
                        if (!shopdic.Keys.Contains(vwpentity.CGMemId))
                        {
                            shopdic[vwpentity.CGMemId] = new List <MemShoppCarEntity>();
                        }
                        shopdic[vwpentity.CGMemId].Add(shopcarentity);
                        itemproductnum    = itemproductnum + entity.Num;
                        productamountall += shopcarentity.TotalPrice;
                    }
                }
            }
            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            = ShoppingXuQiuProcessor.BuyContinue(shoppingCart, list);
                shoppingCart.CartItemsL = new List <MemShoppCarEntity>();

                foreach (ShoppCookie entity in shoppingCart.CartItems)
                {
                    if (entity.ProDId <= 0)
                    {
                        ShoppingXuQiuProcessor.RemoveXuQiuItem(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;
                        if (!shopdic.Keys.Contains(vwpentity.CGMemId))
                        {
                            shopdic[vwpentity.CGMemId] = new List <MemShoppCarEntity>();
                        }
                        shopdic[vwpentity.CGMemId].Add(shopcarentity);
                        itemproductnum    = itemproductnum + entity.Num;
                        productamountall += shopcarentity.TotalPrice;
                    }
                }
            }
            ViewBag.ShoppingCartXuQiu = shopdic;
            ViewBag.ItemNum           = itemproductnum;
            ViewBag.AmountAll         = productamountall;
        }
示例#6
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());
        }