/// <summary> /// 新增多个或单个订单 /// </summary> /// <param name="OrderList">订单集合/对象</param> /// <returns></returns> public JsonResult AddOrder(string OrderList) { UserInfo user = Session["user"] as UserInfo; //判断收货地址是否为空 if (user.ReceivingAddress == "") { return(Json(3, JsonRequestBehavior.AllowGet)); } JavaScriptSerializer js = new JavaScriptSerializer(); List <OrderTable> list = js.Deserialize <List <OrderTable> >(OrderList); //计算总金额 decimal price = 0; list.ToList().ForEach(p => price += p.OrderAmount ?? 0); if (user.UserWallet < price) { return(Json(2, JsonRequestBehavior.AllowGet)); } if (OrderBll.AddOrders(list, Convert.ToInt32(Session["userid"]), price)) { //修改购物车数量 Session["carcount"] = Convert.ToInt32(Session["carcount"]) - list.Count(); return(Json(1, JsonRequestBehavior.AllowGet)); } return(Json(0, JsonRequestBehavior.AllowGet)); }