Esempio n. 1
0
        /// <summary>
        /// 添加购物车
        /// </summary>
        /// <param name="FlowerId"></param>
        /// <param name="Num"></param>
        /// <returns></returns>
        public ActionResult AddToCart(string FlowerId, int Num)
        {
            Business.Sys_FlowerShopCart bus  = new Business.Sys_FlowerShopCart();
            Model.FlowerShopCart        Cart = bus.GetFlowerShopCart(FlowerId.ToString(), userid);
            if (Cart != null)
            {
                Cart.Num       += Num;
                Cart.UpdateTime = DateTime.Now;

                bus.UpdateFlowerShopCart(Cart);//原来有这个商品,更新下数量
            }
            else
            {
                Model.FlowerShopCart model = new Model.FlowerShopCart();
                model.Num        = Num;
                model.UsersId    = userid;
                model.FlowerId   = FlowerId;
                model.Status     = 1;
                model.CreateTime = DateTime.Now;
                model.UpdateTime = DateTime.Now;
                bus.InsertFlowerShopCart(model);
            }
            int num = bus.GetFlowerList().Where(m => m.UsersId == userid).ToList().Sum(m => m.Num);

            return(Json(new { code = 1, cnum = num }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public ActionResult GetTotal()
        {
            Business.Sys_FlowerShopCart bus  = new Business.Sys_FlowerShopCart();
            List <Model.FlowerShopCart> list = bus.GetFlowerList().Where(m => m.UsersId == userid).ToList();
            int num = list.Sum(p => p.Num);

            return(Json(new { code = 1, cnum = num }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
 /// <summary>
 /// 从购物车移除
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult RemoveFromCart(string id)
 {
     Business.Sys_FlowerShopCart bus  = new Business.Sys_FlowerShopCart();
     Model.FlowerShopCart        Cart = bus.GetFlowerShopCartById(id);
     if (Cart != null)
     {
         bus.DeleteFlowerShopCart(Cart.Id.ToString());//
     }
     return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet));
 }
Esempio n. 4
0
        /// <summary>
        /// 购物车
        /// </summary>
        /// <returns></returns>
        public ActionResult GetCartList()
        {
            Business.Sys_FlowerShopCart Sys_OrdersManaage = new Business.Sys_FlowerShopCart();
            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(userid))
            {
                sb.Append(" and UsersId='" + userid + "'");
            }
            List <Model.FlowerCartVM> list = Sys_OrdersManaage.FlowerShopCartList(sb.ToString());

            Model.CartLine model = new Model.CartLine();
            model.Products = list;
            return(View(model));
        }
Esempio n. 5
0
        public ActionResult IncreaseOrDecreaseOne(string id, int quantity)
        {
            Business.Sys_FlowerShopCart bus  = new Business.Sys_FlowerShopCart();
            Model.FlowerShopCart        Cart = bus.GetFlowerShopCartById(id);
            if (Cart != null)
            {
                Cart.Num        = quantity;
                Cart.UpdateTime = DateTime.Now;

                bus.UpdateFlowerShopCart(Cart);//原来有这个商品,更新下数量
            }
            return(Json(new
            {
                msg = true
            }));
        }
Esempio n. 6
0
        public ActionResult PayOrders(string goodnum, string FlowerNums)
        {
            string ids = Request["ids"].TrimEnd(',');

            ViewData["ids"] = ids;
            //ViewData["PayTotal"] = Orders.SellingPrice;
            ViewData["msg"] = " 提示:请在30分钟内完成在线支付,逾期将视为订单无效";
            Business.Sys_FlowerShopCart Sys_OrdersManaage = new Business.Sys_FlowerShopCart();
            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(userid))
            {
                sb.Append(" and UsersId='" + userid + "'");
            }
            sb.Append(" and  b.FlowerId in(" + ids + ")");
            List <Model.FlowerCartVM> list = Sys_OrdersManaage.FlowerShopCartList(sb.ToString());

            Model.CartLine model = new Model.CartLine();
            model.Products = list;
            return(View(model));
            //return Redirect("/WxPay/Index?OrdersId=" + Orders.OrderId + "&PayTotal=" + Flower.FlowerSalesPrice * int.Parse(OrdersNum));
        }