/// <summary> /// 删除全部产品 /// </summary> /// <returns></returns> private ActionResult ProcessDeleteAllFromCartXuQiu() { ShoppingXuQiuProcessor.ClearShoppingXuQiu(); string callback = QueryString.SafeQ("callback");//jsonp回调函数 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 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 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; }
/// <summary> /// 生成真实订单 /// </summary> /// <returns></returns> public string CreateOrderXuQiu() { ResultObj _result = new ResultObj(); int _resultstatus = (int)CommonStatus.Fail; long _preordercode = FormString.LongIntSafeQ("preordercode"); int _addressid = FormString.IntSafeQ("addressid"); int _paytype = FormString.IntSafeQ("paytype"); string _remark = FormString.SafeQ("remark", 80000); string acceptername = FormString.SafeQ("acceptername"); int province = FormString.IntSafeQ("province"); int city = FormString.IntSafeQ("city"); string address = FormString.SafeQ("address", 500); string mobilephone = FormString.SafeQ("mobilephone"); int jifen = FormString.IntSafeQ("jifen"); int memcouponid = FormString.IntSafeQ("memcouponid");//折扣券Id int expressid = FormString.IntSafeQ("expressid"); int ordertype = FormString.IntSafeQ("ordertype", -1); if (jifen % 100 != 0) { jifen = jifen / 100 * 100; } if (jifen > 0 && !AssetBLL.Instance.CheckIntegralEnough(memid, jifen)) { jifen = 0; } int billtype = FormString.IntSafeQ("billtype"); OrderBillBasicEntity _billentity = new OrderBillBasicEntity(); _billentity.BillType = billtype; if (billtype == (int)BillType.Normal) { string title = FormString.SafeQ("billtitle", 200); _billentity.CompanyName = title; } else if (billtype == (int)BillType.VAT) { _billentity.BillId = FormString.IntSafeQ("billvatid"); MemBillVATEntity _mementity = MemBillVATBLL.Instance.GetMemBillVAT(memid); _billentity.ReceiverName = FormString.SafeQ("billvatrename"); _billentity.ReceiverPhone = FormString.SafeQ("billvatrephone"); _billentity.ReceiverProvince = FormString.IntSafeQ("billvatreprovince"); _billentity.ReceiverCity = FormString.IntSafeQ("billvatrecity"); _billentity.ReceiverAddress = FormString.SafeQ("billvatreaddress", 300); _billentity.CompanyName = _mementity.CompanyName; _billentity.CompanyPhone = _mementity.CompanyPhone; _billentity.CompanyCode = _mementity.CompanyCode; _billentity.CompanyBank = _mementity.CompanyBank; _billentity.CompanyAddress = _mementity.CompanyAddress; _billentity.BankAccount = _mementity.BankAccount; _billentity.Status = _mementity.Status; } OrderAddressEntity _address = new OrderAddressEntity(); _address.CityId = city; _address.AccepterName = acceptername; _address.ProvinceId = province; _address.Address = address; _address.MobilePhone = mobilephone; Dictionary <int, VWOrderEntity> _vworderdic = OrderDetailPreTempBLL.Instance.GetVWOrdersByTempCode(_preordercode); List <int> listpdids = new List <int>(); string productdetails = ""; if (_vworderdic.Keys.Count > 0) { IList <VWOrderRemarkEntity> remarklist = new List <VWOrderRemarkEntity>(); if (!string.IsNullOrEmpty(_remark)) { remarklist = JsonJC.JsonToObject <List <VWOrderRemarkEntity> >(_remark.Replace(""", "\"")); } Dictionary <int, string> remarkdic = new Dictionary <int, string>(); foreach (VWOrderRemarkEntity reenti in remarklist) { remarkdic.Add(StringUtils.GetDbInt(reenti.CGMemId), reenti.Remark); } foreach (int okey in _vworderdic.Keys) { if (okey > 0) { foreach (VWOrderDetailEntity oden in _vworderdic[okey].Details) { listpdids.Add(oden.ProductDetailId); productdetails += "|" + oden.ProductDetailId.ToString() + "_" + oden.Num.ToString(); } productdetails = productdetails.TrimStart('|'); OrderCommonBLL.Instance.GetTransFeeForOrder(_vworderdic[okey]); _vworderdic[okey].CGMemId = okey; _vworderdic[okey].PreOrderCode = _preordercode; _vworderdic[okey].OrderType = (int)OrderType.OnLine; _vworderdic[okey].NeedDeliver = 1; //需要发货 _vworderdic[okey].PayPrice = 0; //支付价格0 _vworderdic[okey].PayType = _paytype; _vworderdic[okey].ExpressCom = 0; //普通配送 _vworderdic[okey].MemId = memid; _vworderdic[okey].MemLevel = member.MemGrade; _vworderdic[okey].IsStore = member.IsStore; _vworderdic[okey].OrderStyle = (int)OrderStyleEnum.XuQiu; if (remarkdic.ContainsKey(okey)) { _vworderdic[okey].Remark = remarkdic[okey]; } } else { foreach (VWOrderDetailEntity oden in _vworderdic[okey].Details) { listpdids.Add(oden.ProductDetailId); } } } if (ProductStyleBLL.Instance.ProductsEnough(productdetails)) { string ordercode = OrderBLL.Instance.CreateOrderList(_vworderdic, _address, _billentity); if (!string.IsNullOrEmpty(ordercode)) { if (productdetails != "") { if (ProductStyleBLL.Instance.ProductsToOrder(productdetails) > 0) { VWShoppingCartInfo ShoppingCartentity = ShoppingXuQiuProcessor.GetShoppingXuQiu(); ShoppingXuQiuProcessor.RemoveCartXuQiuItems(ShoppingCartentity, listpdids); _result.Status = (int)CommonStatus.Success; _result.Obj = ordercode; return(JsonJC.ObjectToJson(_result)); } else { _result.Status = (int)CommonStatus.ProductLess; _result.Obj = ""; return(JsonJC.ObjectToJson(_result)); } } else { _result.Status = (int)CommonStatus.Success; _result.Obj = ordercode; return(JsonJC.ObjectToJson(_result)); } } } else { _result.Status = (int)CommonStatus.ProductLess; _result.Obj = ""; return(JsonJC.ObjectToJson(_result)); } } _result.Status = (int)CommonStatus.Fail; _result.Obj = ""; return(JsonJC.ObjectToJson(_result)); }