示例#1
0
        public string AddOrder(int userid, int productid, int pronum)
        {
            string       result       = "1";
            Order        order        = new Order();
            OrderBll     orderbll     = new OrderBll();
            OrderList    orderlist    = new OrderList();
            OrderListBll orderlistbll = new OrderListBll();


            ProductBll pbll = new ProductBll();
            UsersBll   ubll = new UsersBll();

            try
            {
                //检查 当前用户是否有末完成的订单  有不能
                //if (orderbll.GetAll("*", " [status]=1 and userid=" + userid, null, "id").Entity.Count <= 0)
                //{


                var p = pbll.GetByPrimaryKey(productid).Entity;
                var u = ubll.GetByPrimaryKey(userid).Entity;
                order.UserId         = userid;
                order.ReciverName    = u.UserName;
                order.PayMentTypeId  = 1;//货到付款
                order.RevicerAddress = u.Address;
                order.RevicerTel     = u.Mobile;
                order.Status         = 1;//
                order.RealPrice      = pronum * p.OemPrice;
                order.TotalPrice     = pronum * p.OemPrice;
                order.Count          = 1;
                order.OrderTime      = DateTime.Now;
                order.OrderNo        = OrderHelper.GetProNo();
                //添加订单
                int orderaddid = orderbll.AddAndReturn(order);

                //添加订单详情
                orderlist.Count       = order.Count;
                orderlist.Productid   = productid;
                orderlist.Orderid     = orderaddid;
                orderlist.OemPrice    = p.OemPrice;
                orderlist.MarketPrice = p.MarketPrice;
                orderlistbll.Add(orderlist);
                //}
                //else
                //{
                //    result = "-2";
                //}
            }
            catch
            {
                result = "-1";
            }



            return(result);
        }
示例#2
0
        public string AddOrder(int userid, string data, int price, string pno, string payMentType, int bananaCount)
        {
            string   result   = "0";
            Order    order    = new Order();
            OrderBll orderbll = new OrderBll();

            UsersBll ubll = new UsersBll();
            var      u    = ubll.GetByPrimaryKey(userid).Entity;

            try
            {
                order.UserId         = userid;
                order.ReciverName    = u.UserName;
                order.PayMentTypeId  = (byte?)(payMentType == "货到付款" ? 1 : 2);//货到付款
                order.RevicerAddress = u.Address;
                order.RevicerTel     = u.Mobile;
                order.Status         = 0;//等待确认
                order.RealPrice      = price;
                order.TotalPrice     = price;
                order.Count          = 1;
                order.OrderTime      = DateTime.Now;
                order.OrderNo        = OrderHelper.GetProNo();
                order.Pno            = pno == "" ? null : pno;
                order.BananaCount    = bananaCount;
                //添加订单
                int orderaddid = orderbll.AddAndReturn(order);
                sendYzm("18758177964", "26871", new string[] { u.UserName + u.Mobile, DateTime.Now.ToString() });
                string[] dataArr = data.Split(',');
                if (dataArr.Length > 0)
                {
                    for (int d = 0; d < dataArr.Length; d++)
                    {
                        if (!string.IsNullOrEmpty(dataArr[d]))
                        {
                            if (dataArr[d].IndexOf("|") > -1)
                            {
                                string[] arr = dataArr[d].Split('|');
                                AddOrderList(u, Convert.ToInt32(arr[0]), Convert.ToInt32(arr[1]), orderaddid);
                                result = orderaddid.ToString();
                            }
                        }
                    }
                }
            }
            catch
            {
                result = "-1";
            }



            return(result);
        }