Exemple #1
0
        /// <summary>
        /// 删除购物车印品
        /// </summary>
        /// <param name="bookid"></param>
        /// <returns></returns>
        public ActionResult AjaxDeleteCartProduct(int bookid)
        {
            if (UserSession.CurrentUser == null)
            {
                return(Content("{\"success\":false,\"message\":\"请先登录\"}"));
            }
            BaseResponse br = DBCartBLL.DeleteUserCartProduct(UserSession.CurrentUser.ID, bookid);

            return(Content("{\"success\":" + br.IsSuccess.ToString().ToLower() + ",\"message\":\"" + br.Message + "\",\"bookid\":" + bookid + "}"));
        }
Exemple #2
0
        public ActionResult Index(string msg)
        {
            if (string.IsNullOrEmpty(msg))
            {
                ViewBag.Msg = msg;
            }
            IList <Inpinke_Cart> list = DBCartBLL.GetUserCart(UserSession.CurrentUser.ID);

            return(View(list));
        }
Exemple #3
0
        public ActionResult Index(FormCollection col)
        {
            IList <Inpinke_Cart> list = DBCartBLL.GetUserCart(UserSession.CurrentUser.ID);

            try
            {
                string bookids = col["bookids"];
                if (string.IsNullOrEmpty(bookids))
                {
                    ViewBag.Msg = "商品信息异常,请重新确认";
                    return(View(list));
                }
                //bookids = bookids.TrimEnd(',');
                string[] bookidInfo = bookids.Split(',');
                foreach (string bookid in bookidInfo)
                {
                    Inpinke_Book bModel = DBBookBLL.GetBookByID(int.Parse(bookid));
                    if (bModel != null)
                    {
                        Inpinke_Cart model = new Inpinke_Cart()
                        {
                            BookID    = int.Parse(bookid),
                            Num       = int.Parse(col["num_" + bookid]),
                            CouponID  = int.Parse(col["coupon_select_" + bookid]),
                            Envelope  = int.Parse(col["envelope_" + bookid]),
                            ProductID = bModel.ProductID,
                            UserID    = UserSession.CurrentUser.ID
                        };
                        BaseResponse br = DBCartBLL.AddBook2Cart(model);
                        if (!br.IsSuccess)
                        {
                            ViewBag.Msg = "商品信息异常,请重新确认";
                            return(View(list));
                        }
                    }
                }
                return(RedirectToAction("OrderInfo"));
            }
            catch (Exception ex)
            {
                ViewBag.Msg = "商品信息确认失败,请稍后再试";
                Logger.Error(string.Format("购物车-Index Error:{0}", ex.ToString()));
                return(View(list));
            }
        }
Exemple #4
0
        /// <summary>
        /// 异步保存购物车商品信息
        /// </summary>
        /// <param name="cartInfo"></param>
        /// <returns></returns>
        public ActionResult AjaxUpdateCartInfo(CartModels cartInfo)
        {
            Inpinke_Cart cart = DBCartBLL.GetCartProductByID(cartInfo.ID);

            if (cart == null)
            {
                return(Content("{\"success\":false,\"message\":\"未找到对应的商品\"}"));
            }
            cart.Envelope = cartInfo.Envelope;
            cart.CouponID = cartInfo.CouponID;
            cart.Num      = cartInfo.Num;
            BaseResponse br = DBCartBLL.UpdateUserCart(cart);

            if (!br.IsSuccess)
            {
                return(Content("{\"success\":false,\"message\":\"" + br.Message + "\"}"));
            }
            return(Content("{\"success\":true}"));
        }
Exemple #5
0
        /// <summary>
        /// 添加书本到购物车
        /// </summary>
        /// <param name="bookid"></param>
        /// <returns></returns>
        public ActionResult AddBook2Cart(int bookid)
        {
            Inpinke_Book book = DBBookBLL.GetBookByID(bookid);

            if (book == null)
            {
                ViewBag.Msg = "Sorry!没有找到您要购买的印品";
                return(RedirectToAction("Index", new { msg = ViewBag.Msg }));
            }

            Inpinke_Cart myCart = new Inpinke_Cart()
            {
                UserID    = book.UserID,
                BookID    = book.ID,
                Num       = 1,
                ProductID = book.ProductID
            };
            IList <Inpinke_Product> plusList = DBProductBLL.GetPlusProduct(book.ProductID, ProductType.Envelope);

            if (plusList != null && plusList.Count() > 0)
            {
                myCart.Envelope = plusList.FirstOrDefault().ID;
            }
            IList <Inpinke_Product> plusList1 = DBProductBLL.GetPlusProduct(book.ProductID, ProductType.PlusStuff);

            if (plusList1 != null && plusList1.Count() > 0)
            {
                myCart.Envelope = plusList1.FirstOrDefault().ID;
            }

            BaseResponse br = DBCartBLL.AddBook2Cart(myCart);

            if (!br.IsSuccess)
            {
                ViewBag.Msg = br.Message;
            }
            return(RedirectToAction("Index", new { msg = ViewBag.Msg }));
        }
Exemple #6
0
        public ActionResult OrderInfo(OrderInfoModel orderInfo)
        {
            IList <Inpinke_User_Address> addressList = DBAddressBLL.GetUserAddress(UserSession.CurrentUser.ID);

            if (addressList != null && addressList.Count() > 0)
            {
                ViewBag.UserAddress = addressList;
            }
            Inpinke_User_Address address = new Inpinke_User_Address();

            if (orderInfo.AddressID > 0)
            {
                address = addressList.Where(e => e.ID == orderInfo.AddressID).FirstOrDefault();
                if (address == null)
                {
                    ViewBag.Msg = "不存在该收货人信息,请重新填写";
                    return(View());
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    ViewBag.Msg = "输入信息有误,麻烦再检查一下";
                    return(View());
                }
                address = new Inpinke_User_Address()
                {
                    Address  = orderInfo.Address,
                    AreaID   = orderInfo.AreaID,
                    ProvID   = orderInfo.ProvID,
                    CityID   = orderInfo.CityID,
                    Mobile   = orderInfo.Mobile,
                    UserID   = UserSession.CurrentUser.ID,
                    UserName = orderInfo.Consignee
                };
                BaseResponse br = DBAddressBLL.AddUserAddress(address);
                if (!br.IsSuccess)
                {
                    ViewBag.Msg = br.Message;
                    return(View());
                }
            }
            IList <Inpinke_Cart> cartList = DBCartBLL.GetUserCart(UserSession.CurrentUser.ID);
            decimal       orderPrice      = DBCartBLL.GetCartTotalPrices(UserSession.CurrentUser.ID);
            Inpinke_Order order           = new Inpinke_Order()
            {
                OrderCode = DBOrderBLL.GetOrderCode(cartList[0].Inpinke_Product.ProductType),
                AddressID = address.ID,

                RecUserName = address.UserName,
                RecMobile   = address.Mobile,
                RecProvID   = address.ProvID,
                RecCityID   = address.CityID,
                RecAreaID   = address.AreaID,
                RecAddress  = address.Address,
                RecAreaName = address.AreaName,
                RecCityName = address.CityName,
                RecProvName = address.ProvName,

                UserID     = UserSession.CurrentUser.ID,
                OrgPrice   = orderPrice,
                TotalPrice = orderPrice,
                UserRemark = orderInfo.Remark
            };

            BaseResponse br1 = DBOrderBLL.AddOrder(order);

            if (!br1.IsSuccess)
            {
                ViewBag.Msg = br1.Message;
                return(View());
            }
            return(RedirectToAction("Pay", new { orderid = order.ID }));
        }