zoukankan      html  css  js  c++  java
  • 购物车代码

    public ActionResult Ordershopcart()
            {
                //获取会员信息
                Member member 
    = CookieUtil.GetLoginCookie();
                //获取购物车对象
                Mola.Model.ShoppingCartInfo shoppingCart 
    = Common.GetShoppingCartInfo(member, Common.GetComBinFlag(), null);
                
    if (shoppingCart == null || shoppingCart.CartItems == null)
                {
                    
    return Redirect("/");
                }
                
    if (!string.IsNullOrEmpty(shoppingCart.ModOrderCode))
                {
                    
    return Redirect("/Cart/ModOrdershopcart.aspx");
                }
                //保存购物车对象
                Common.SaveShoppingCartInfo(shoppingCart, shoppingCart.SerializationCart, 
    false0false);
                ViewBag.ShoppingCart 
    = shoppingCart;
                ViewBag.DiscountCode 
    = Common.GetShoppingDiscountData() == null ? "" : Common.GetShoppingDiscountData();
                
    return View();

            }
            /// <summary>
            
    /// 更新购物车数量
            
    /// </summary>
            
    /// <returns></returns>
            public ActionResult UpdateCarItemQty()
            {
                
    //获取序列化购物车
                SerializationCartInfo sCart = Common.GetSerializationCart();
                
    if (sCart == null)
                {
                    
    return Redirect("/Cart/shopping_index.aspx");
                }
                
    string wareCode = QueryString.safeq("WareCode");
                
    decimal qty = QueryString.intsafeq("Qty");
                
    bool isCombin = Common.GetComBinFlag();
                
    int webSite = QueryString.intsafeq("WebSiteId");
                
    int kitOrder = QueryString.intsafeq("KitOrder");

                
    //转化成购物车对象
                Member member = Mola.Core.CookieUtil.GetLoginCookie();
                //更新购物车信息
                
    string strMsg = new CartClient().UpdateCartItemQty(wareCode, kitOrder, qty, webSite, isCombin, member, ref sCart);
                
    if (string.IsNullOrEmpty(strMsg))
                {
                    
    return Content(StringUtils.ToJson(sCart));
                }
                
    else
                {
                    
    string jsonCart = StringUtils.ToJson(sCart);
                    
    if (strMsg != "Y")
                    {
                        
    return Content("{MSG:'" + NoticeHelper.GetNotice(strMsg) + "',ShoppingCart:" + jsonCart + "}");
                    }
                    
    else
                    {
                        Common.SetComBinFlag(
    0);
                        Common.SaveShoppingCartInfo(sCart, 
    false1true);
                        ShoppingCartInfo cartInfo 
    = Common.GetShoppingCartInfo(member, isCombin, sCart);
                        
    // cartInfo.CartItems[0].KitDetail[0].KitOrder
                        return Content(StringUtils.ToJson(cartInfo));
                    }
                }
            }
            /// <summary>
            
    /// 
            
    /// </summary>
            
    /// <returns></returns>
            public ActionResult RemoveCartItem()
            {
                
    #region 购物车
                SerializationCartInfo sCart 
    = Common.GetSerializationCart();

                Mola.Model.Member member 
    = Mola.Core.CookieUtil.GetLoginCookie();

                
    #endregion

                
    string wareCode = QueryString.safeq("WareCode");
                
    bool isCombin = Common.GetComBinFlag();
                
    int webSiteId = QueryString.intsafeq("WebSiteId");
                
    int kitOrder = QueryString.intsafeq("KitOrder");

                ShoppingCartInfo cartInfo 
    = new ShoppingCartInfo();

                
    //转化成购物车对象
                string strMsg = new CartClient().RemoveCartItem(wareCode, kitOrder, webSiteId, isCombin, member, ref sCart);
                
    if (strMsg == "Y")
                {
                    Common.SetComBinFlag(
    0);
                    Common.RemoveShppingcartItem(wareCode, kitOrder);
                    Common.SaveShoppingCartInfo(sCart, 
    false1true);
                    cartInfo 
    = Common.GetShoppingCartInfo(member, isCombin, sCart);
                }

                
    return Content(StringUtils.ToJson(cartInfo));
            }
    /// <summary>
            
    /// 修改购物车
            
    /// </summary>
            
    /// <returns></returns>
            public ActionResult ModOrdershopcart()
            {
                
    //获取购物车
                Mola.Model.ShoppingCartInfo shoppingCart = Common.GetShoppingCartInfo(CookieUtil.GetLoginCookie(), Common.GetComBinFlag(), null);

                
    #region 数据检查
                
    if (shoppingCart == null || shoppingCart.CartItems == null || shoppingCart.CartItems.Count <= 0)
                {
                    
    return Redirect("/Cart/shopping_index.aspx");
                }
                
    if (string.IsNullOrEmpty(shoppingCart.ModOrderCode))
                {
                    
    return Redirect("/Cart/Ordershopcart.aspx");
                }
                
    #endregion

                ViewBag.ShoppingCart 
    = shoppingCart;
                ViewBag.DiscountCode 
    = Common.GetShoppingDiscountData() == null ? "" : Common.GetShoppingDiscountData();
                
    return View();
            }

            
    #region 取消修改订单

            
    public ActionResult OrderCancelMod()
            {
                Model.Member member 
    = CookieUtil.GetLoginCookie();
                ShoppingCartInfo shoppingCart 
    = Common.GetShoppingCartInfo(member);

                
    if (member == null)
                {
                    Common.ClearShoppingCart(member);
                    
    return Redirect("/cart/Ordershopcart.aspx");
                }

                
    if (shoppingCart != null)
                {
                    
    string ordercode = shoppingCart.ModOrderCode;
                    Common.ClearShoppingCart(member);
                    
    return Redirect("/Order/OrderDetail.aspx?ordercode=" + ordercode);
                }
                
    else
                {
                    Common.ClearShoppingCart(member);
                    
    return Redirect("/Member/default.aspx");
                }

            }
            
    #endregion

            
    #region 新加 验证打折
            
    public bool ActiveCode()
            {
                
    bool result = true;
                
    string disCode = FormString.safeq("Active_Code"); ;
                
    string orgDisCode = disCode;
                
    if (disCode == "")
                {
                    
    return false;
                }

                Model.Member member 
    = CookieUtil.GetLoginCookie();
                ShoppingCartInfo shoppingCart 
    = Common.GetShoppingCartInfo(member);

                
    //验证折扣
                result = new CartClient().ExistsDiscount(ref disCode, shoppingCart.TotalAmount);
                
    if (!result)
                {
                    
    return result;
                }

                
    //添加折扣            
                shoppingCart.DiscountList = new CartClient().AddDiscount(disCode);
                Common.SaveShoppingCartInfo(shoppingCart, shoppingCart.SerializationCart, 
    false0true);
                
    if (orgDisCode.Length == 16)
                {
                    Common.SaveShoppingDiscountData(orgDisCode);
                }
                
    else
                {
                    Common.SaveShoppingDiscountData(disCode);
                }
                


                
    return result;
            }
  • 相关阅读:
    【[USACO08FEB]酒店Hotel】
    【[USACO15JAN]草鉴定Grass Cownoisseur】
    【[USACO09DEC]牛收费路径Cow Toll Paths】
    【[HAOI2009]逆序对数列】
    【Hankson 的趣味题】
    【开车旅行】
    【[ZJOI2006]物流运输】
    【[HNOI2005]狡猾的商人】
    【愤怒的小鸟】
    【[HNOI2015]菜肴制作】
  • 原文地址:https://www.cnblogs.com/shizhi57/p/2110198.html
Copyright © 2011-2022 走看看