Beispiel #1
0
 public bool AddOrder(OrderModel models)
 {
     try { ODal.AddOrder(models); return(true); }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #2
0
        public ActionResult AddOrder(OrderModel model)
        {
            if (ModelState.IsValid)
            {
                OrderDal dal = new OrderDal();
                int      id  = dal.AddOrder(model);
                ModelState.Clear();
            }

            return(RedirectToAction("Index"));
        }
Beispiel #3
0
 //添加订单
 // POST: api/Order
 public OrderModel Post([FromBody] OrderModel m)
 {
     return(dal.AddOrder(m.PId, m.OrderNo));
 }
Beispiel #4
0
        public bool AddOrderByUserId(string card, string bastdate, string paytype, string remark, string ordercode)
        {
            UserBll userbll = new UserBll();
            // int csum = Convert.ToInt32(sum);
            int userid = 0;

            userid = userbll.GetUserIdByToken();
            bool orderres = false;

            if (userid > 0)
            {
                T_Order       order    = new T_Order();
                CartBll       cartbll  = new CartBll();
                OrderDal      orderdal = new OrderDal();
                List <T_Cart> cartlist = new List <T_Cart>();
                cartlist = cartbll.GetCartListByUserId(userid);
                AddressBll addressbll = new AddressBll();
                T_Address  address    = new T_Address();
                // UserBll userbll = new UserBll();
                T_User user = new T_User();
                user                = userbll.GerUserByUserId(userid);
                address             = addressbll.GetAddressByUserId();
                order.OrderCode     = ordercode;
                order.CreateDate    = DateTime.Now;
                order.Adress        = address.Adress + address.Area + "_" + address.Name;
                order.Mobile        = address.Mobile;
                order.OrderStatus   = "待付款";
                order.PayType       = paytype;
                order.bastdate      = bastdate;
                order.card_birthday = card;
                order.Remark        = remark;
                order.UserId        = userid;
                string  makabi    = "";
                decimal?sumprice  = 0;
                int     makaprice = 0;
                bool    res       = false;

                if (cartlist != null)
                {
                    foreach (T_Cart cart in cartlist)
                    {
                        T_OrderDetail orderdetail = new T_OrderDetail();
                        orderdetail.CreateDate    = DateTime.Now;
                        orderdetail.OrderCode     = order.OrderCode;
                        orderdetail.ProductId     = cart.ProductId;
                        orderdetail.ProductName   = cart.ProductName;
                        orderdetail.ProductNumber = cart.ProductNumber;
                        orderdetail.ProductPrice  = cart.ProductPrice;
                        orderdetail.Specification = cart.Specification;
                        res = orderdal.AddOrderDetail(orderdetail);
                        if (res)
                        {
                            cartbll.DelCartById(cart.Id);
                        }
                        sumprice = sumprice + cart.ProductPrice;
                    }
                }
                if (user != null)
                {
                    makabi = user.MaKaCurrency.ToString();

                    makaprice = (int)user.MaKaCurrency / 10;
                    if (makaprice >= sumprice)
                    {
                        sumprice = 0;
                    }
                    else
                    {
                        sumprice = (int)sumprice - makaprice;
                    }
                    order.makabi = user.MaKaCurrency;
                }
                if (sumprice <= 230)
                {
                    sumprice   = sumprice + 18;
                    order.fare = 18;
                }
                else
                {
                    order.fare = 0;
                }

                order.OrderPrice = sumprice;
                orderres         = orderdal.AddOrder(order);
                if (orderres)
                {
                    userbll.UpdateUser(userid, (int)user.MaKaCurrency);
                }
                return(orderres);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 新增单个订单
 /// </summary>
 /// <param name="ord">订单对象</param>
 /// <returns></returns>
 public static bool AddOrder(OrderTable ord)
 {
     return(OrderDal.AddOrder(ord));
 }