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\"});")); } }
private ActionResult ProcessDeletePdsFromCartXuQiu() { #region 购物车 VWShoppingCartInfo shoppingCart = SessionUtil.GetXuQiuSession(); #endregion string callback = QueryString.SafeQ("callback");//jsonp回调函数 string prodetailids = QueryString.SafeQ("pdids", 8000); int num = QueryString.IntSafeQ("Num"); if (string.IsNullOrEmpty(prodetailids)) { return(Content(callback + "({\"Status\":\"请选择需要删除的商品\"});")); } else { List <int> pdidslist = new List <int>(); string[] pdisattr = prodetailids.Split(','); foreach (string str in pdisattr) { pdidslist.Add(StringUtils.GetDbInt(str)); } ShoppingXuQiuProcessor.RemoveCartXuQiuItems(shoppingCart, pdidslist); return(Content(callback + "({\"Status\":\"OK\"});")); } }
private ActionResult ProcessUpdateCartXuQiuNum() { #region 购物车 VWShoppingCartInfo shoppingCart = SessionUtil.GetXuQiuSession(); #endregion string callback = QueryString.SafeQ("callback");//jsonp回调函数 int productdetailid = QueryString.IntSafeQ("prodetailid"); int num = QueryString.IntSafeQ("Num"); if (productdetailid == 0) { return(Content(callback + "({\"Status\":\"请选择需要删除的商品\"});")); } else { ShoppingXuQiuProcessor.UpdateCarItemQty(shoppingCart, productdetailid, num); return(Content(callback + "({\"Status\":\"OK\"});")); } }
/// <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()); }
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; }