Esempio n. 1
0
        public string editorderinfo(string orderid, string d1, string d2, string deliverydate, string orderstate)
        {
            int d1id  = TypeParse.DbObjToInt(d1, 0);
            int d2id  = TypeParse.DbObjToInt(d2, 0);
            int state = TypeParse.DbObjToInt(orderstate, 0);

            orderinfo data = new orderinfo();

            data.deliverydate = TypeParse.DbObjToDateTime(deliverydate, DateTime.Now);
            data.deliveryIid  = d1id;
            data.deliveryIIid = d2id;
            data.orderstate   = state;
            data.orderid      = orderid;

            bool result = order.editorder(data);

            if (result)
            {
                return("t");
            }
            else
            {
                return("f");
            }
        }
Esempio n. 2
0
        public static List <orderinfo> getphlist(string condition)
        {
            List <orderinfo> list = new List <orderinfo>();
            string           sql  = "select sum(usercart.buynum) as n,product.productcode,product.productimg,product.productname from usercart,userorder,product where usercart.ordernumber=userorder.ordernumber and usercart.productid=product.productid " + condition + " group by usercart.productid,product.productcode,product.productname,product.productimg";

            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql).Tables[0];
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        orderinfo item = new orderinfo();
                        item.tjbuynum    = TypeParse.DbObjToInt(dr["n"].ToString(), 0);
                        item.productname = TypeParse.DbObjToString(dr["productname"].ToString(), "");
                        item.productcode = TypeParse.DbObjToString(dr["productcode"].ToString(), "");
                        item.productimg  = TypeParse.DbObjToString(dr["productimg"].ToString(), "");
                        list.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(list);
        }
Esempio n. 3
0
        public string addcart(string productid, string userid, string buynum)
        {
            int         pid  = TypeParse.DbObjToInt(productid, 0);
            int         bnum = TypeParse.DbObjToInt(buynum, 1);
            productinfo item = product.getproductinfo(pid);

            bool cz = order.CheckCart(userid, pid);

            if (cz)
            {
                string jstr = "{'productid':'" + productid + "','userid':'" + userid + "','buynum':'" + buynum + "'}";
                return(jstr);
            }
            else
            {
                orderinfo data = new orderinfo();
                data.productid = pid;
                data.vipprice  = item.vipprice;
                data.userid    = userid;
                data.buynum    = bnum;
                data.adddate   = DateTime.Now;
                bool result = order.AddCart(data);
                if (result)
                {
                    return("t");
                }
                else
                {
                    return("f");
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        ///编辑订单
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool editorder(orderinfo data)
        {
            SqlParameter[] parms = new SqlParameter[5];
            parms[0]       = new SqlParameter("@id", SqlDbType.VarChar, 20);
            parms[0].Value = data.orderid;
            parms[1]       = new SqlParameter("@deliverydate", SqlDbType.DateTime);
            parms[1].Value = data.deliverydate;
            parms[2]       = new SqlParameter("@orderstate", SqlDbType.Int);
            parms[2].Value = data.orderstate;
            parms[3]       = new SqlParameter("@deliveryIid", SqlDbType.Int);
            parms[3].Value = data.deliveryIid;
            parms[4]       = new SqlParameter("@deliveryIIid", SqlDbType.Int);
            parms[4].Value = data.deliveryIIid;

            string sql    = "update [userorder] set deliverydate=@deliverydate,orderstate=@orderstate,deliveryIid=@deliveryIid,deliveryIIid=@deliveryIIid where orderid=@id";
            int    result = 0;

            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(result > 0);
        }
Esempio n. 5
0
        public static bool AddCart(orderinfo item)
        {
            SqlParameter[] parms = new SqlParameter[7];
            parms[0]           = new SqlParameter("@id", SqlDbType.VarChar, 20);
            parms[0].Direction = ParameterDirection.Output;
            parms[1]           = new SqlParameter("@productid", SqlDbType.NVarChar, 50);
            parms[1].Value     = item.productid;
            parms[2]           = new SqlParameter("@userid", SqlDbType.NVarChar, 50);
            parms[2].Value     = item.userid;
            parms[3]           = new SqlParameter("adddate", SqlDbType.DateTime);
            parms[3].Value     = item.adddate;
            parms[4]           = new SqlParameter("@vipprice", SqlDbType.Decimal);
            parms[4].Value     = item.vipprice;
            parms[5]           = new SqlParameter("@buynum", SqlDbType.Int);
            parms[5].Value     = item.buynum;
            parms[6]           = new SqlParameter("@cartstate", SqlDbType.Int);
            parms[6].Value     = item.cartstate;

            string sql = "exec dbo.www_getno 'usercart',10,@id output " +
                         "Insert into usercart(cartid,productid,userid,adddate,vipprice,buynum,cartstate) VALUES (@id,@productid,@userid,@adddate,@vipprice,@buynum,@cartstate)";
            int result = 0;

            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
                return(result > 0);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 得到订单列表
        /// </summary>
        /// <param name="pdata"></param>
        /// <returns></returns>
        public static List <orderinfo> getorderlist(pageinfo pdata)
        {
            List <orderinfo> list = new List <orderinfo>();

            try
            {
                DataTable dt = pagehelper.getpagedt(pdata);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        orderinfo item = new orderinfo();
                        item.orderid      = TypeParse.DbObjToString(dr["orderid"].ToString(), "0");
                        item.tel          = TypeParse.DbObjToString(dr["tel"].ToString(), "");
                        item.mobile       = TypeParse.DbObjToString(dr["mobile"].ToString(), "");
                        item.address      = TypeParse.DbObjToString(dr["address"].ToString(), "");
                        item.contact      = TypeParse.DbObjToString(dr["contact"].ToString(), "");
                        item.allmoney     = Decimal.Parse(TypeParse.DbObjToString(dr["allmoney"].ToString(), "0.00"));
                        item.paymoney     = Decimal.Parse(TypeParse.DbObjToString(dr["paymoney"].ToString(), "0.00"));
                        item.orderstate   = TypeParse.DbObjToInt(dr["orderstate"].ToString(), 0);
                        item.orderdate    = TypeParse.DbObjToDateTime(dr["orderdate"].ToString(), DateTime.Now);
                        item.deliverydate = TypeParse.DbObjToDateTime(dr["deliverydate"].ToString(), DateTime.Now);
                        item.ordernumber  = TypeParse.DbObjToString(dr["ordernumber"].ToString(), "");
                        item.deliveryI    = TypeParse.DbObjToString(dr["deliveryI"].ToString(), "");
                        item.deliveryII   = TypeParse.DbObjToString(dr["deliveryII"].ToString(), "");
                        switch (item.orderstate)
                        {
                        case 0:
                            item.orderstatestr = "进行中";
                            break;

                        case 10:
                            item.orderstatestr = "已完成";
                            break;

                        case 44:
                            item.orderstatestr = "待处理";
                            break;

                        default:
                            item.orderstatestr = "进行中";
                            break;
                        }
                        list.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(list);
        }
Esempio n. 7
0
        private new void DataBinding()
        {
            DataTable dt = new orderinfo().getOrderByUserName(Session["userName"].ToString());

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["orderPrice"] = Math.Round(new decimal(Convert.ToDouble(dt.Rows[i]["orderPrice"].ToString())), 2).ToString();
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
Esempio n. 8
0
        /// <summary>
        /// 生成订单
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool addorder(orderinfo data)
        {
            SqlParameter[] parms = new SqlParameter[14];
            parms[0]           = new SqlParameter("@id", SqlDbType.VarChar, 20);
            parms[0].Direction = ParameterDirection.Output;
            parms[1]           = new SqlParameter("@ordernumber", SqlDbType.NVarChar, 50);
            parms[1].Value     = data.ordernumber;
            parms[2]           = new SqlParameter("@orderdate", SqlDbType.DateTime);
            parms[2].Value     = data.orderdate;
            parms[3]           = new SqlParameter("@deliverydate", SqlDbType.DateTime);
            parms[3].Value     = data.deliverydate;
            parms[4]           = new SqlParameter("@allmoney", SqlDbType.Decimal);
            parms[4].Value     = data.allmoney;
            parms[5]           = new SqlParameter("@paymoney", SqlDbType.Decimal);
            parms[5].Value     = data.paymoney;
            parms[6]           = new SqlParameter("@orderstate", SqlDbType.Int);
            parms[6].Value     = data.orderstate;
            parms[7]           = new SqlParameter("@userid", SqlDbType.NVarChar, 50);
            parms[7].Value     = data.userid;
            parms[8]           = new SqlParameter("@address", SqlDbType.VarChar, 50);
            parms[8].Value     = data.address;
            parms[9]           = new SqlParameter("@contact", SqlDbType.VarChar, 10);
            parms[9].Value     = data.contact;
            parms[10]          = new SqlParameter("@mobile", SqlDbType.VarChar, 30);
            parms[10].Value    = data.mobile;
            parms[11]          = new SqlParameter("@tel", SqlDbType.VarChar, 30);
            parms[11].Value    = data.tel;
            parms[12]          = new SqlParameter("@deliveryIid", SqlDbType.Int);
            parms[12].Value    = data.deliveryIid;
            parms[13]          = new SqlParameter("@deliveryIIid", SqlDbType.Int);
            parms[13].Value    = data.deliveryIIid;


            string sql = "exec dbo.www_getno 'userorder',10,@id output " +
                         "insert into [userorder] (orderid,ordernumber,orderdate,deliverydate,allmoney,paymoney,orderstate,userid,address,contact,mobile,tel,deliveryIid,deliveryIIid) values(@id,@ordernumber,@orderdate,@deliverydate,@allmoney,@paymoney,@orderstate,@userid,@address,@contact,@mobile,@tel,@deliveryIid,@deliveryIIid)";
            int result = 0;

            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(result > 0);
        }
Esempio n. 9
0
        orders createorder(orderinfo param)
        {
            orders order = new orders();

            order.ordersInfo    = Newtonsoft.Json.JsonConvert.SerializeObject(param);
            order.startlocation = param.startingPoint;
            order.endlocation   = param.endingPoint;
            order.state         = 0;
            order.userprice     = (float)param.price;
            order.driverprice   = (float)param.driverprice;
            order.orderType     = param.riderType;
            order.routeid       = int.Parse(param.routeid);
            order.StartTime     = param.startDate;
            return(order);
        }
Esempio n. 10
0
 public override void RegisterServieceRequest(ServiceRegister Register)
 {
     Register.Register("riderType1", (Request parameter, ref Request result) =>
     {
         var request       = (Request)parameter;
         orderinfo param   = (orderinfo)request.Content;
         param.driverprice = param.price - Math.Round(param.price * double.Parse(CostService.Config["Profit"]), 2);
         param.id          = request.Head["KeyID"];
         riderTypeOne.Add(param.id, param);
         result.Content = createorder(param);
     });
     Register.Register("riderType2", (Request parameter, ref Request result) =>
     {
         var request       = (Request)parameter;
         orderinfo param   = (orderinfo)request.Content;
         param.driverprice = param.price - Math.Round(param.price * double.Parse(CostService.Config["Profit"]), 2);
         param.id          = request.Head["KeyID"];
         riderTypeTwo.Add(param.id, param);
         result.Content = createorder(param);
     });
     Register.Register("riderType3", (Request parameter, ref Request result) =>
     {
         var request       = (Request)parameter;
         orderinfo param   = (orderinfo)request.Content;
         param.driverprice = param.price - Math.Round(param.price * double.Parse(CostService.Config["Profit"]), 2);
         param.id          = request.Head["KeyID"];
         riderTypeThere.Add(param.id, param);
         result.Content = createorder(param);
     });
     Register.Register("riderType4", (Request parameter, ref Request result) =>
     {
         var request       = (Request)parameter;
         orderinfo param   = (orderinfo)request.Content;
         param.driverprice = param.price - Math.Round(param.price * double.Parse(CostService.Config["Profit"]), 2);
         param.id          = request.Head["KeyID"];
         riderTypeThere.Add(param.id, param);
         result.Content = createorder(param);
     });
 }
Esempio n. 11
0
        public static List <orderinfo> getcartlistbyordernumber(string ordernumber)
        {
            SqlParameter[] parms = new SqlParameter[1];
            parms[0]       = new SqlParameter("@ordernumber", SqlDbType.NVarChar, 50);
            parms[0].Value = ordernumber;


            List <orderinfo> list = new List <orderinfo>();
            string           sql  = "select a.cartid,a.buynum,a.ordernumber,a.vipprice,a.userid, b.productname,b.productimg,b.productcode  from usercart a,product b where a.ordernumber=@ordernumber and a.productid=b.productid";

            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql, parms).Tables[0];
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        orderinfo item = new orderinfo();
                        item.cartid      = TypeParse.DbObjToString(dr["cartid"].ToString(), "0");
                        item.buynum      = TypeParse.DbObjToInt(dr["buynum"].ToString(), 0);
                        item.ordernumber = TypeParse.DbObjToString(dr["ordernumber"].ToString(), "");
                        item.vipprice    = Decimal.Parse(TypeParse.DbObjToString(dr["vipprice"].ToString(), "0.00"));
                        item.userid      = TypeParse.DbObjToString(dr["userid"].ToString(), "0");
                        item.productname = TypeParse.DbObjToString(dr["productname"].ToString(), "");
                        item.productcode = TypeParse.DbObjToString(dr["productcode"].ToString(), "");
                        item.productimg  = TypeParse.DbObjToString(dr["productimg"].ToString(), "");
                        list.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(list);
        }
Esempio n. 12
0
        //根据购物车状态得到购物车产品
        public static List <orderinfo> getcartlist(int state, string userid)
        {
            SqlParameter[] parms = new SqlParameter[2];
            parms[0]       = new SqlParameter("@state", SqlDbType.Int);
            parms[0].Value = state;
            parms[1]       = new SqlParameter("@userid", SqlDbType.NVarChar, 50);
            parms[1].Value = userid;

            string           sql;
            List <orderinfo> list = new List <orderinfo>();

            sql = "select a.cartid,a.vipprice,a.userid,a.productid,a.cartstate,a.adddate,a.buynum,b.productimg,b.productname  from usercart a,product b where a.userid=@userid and a.productid=b.productid and a.cartstate=@state";
            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql, parms).Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    orderinfo item = new orderinfo();
                    item.cartid      = TypeParse.DbObjToString(dr["cartid"].ToString(), "0");
                    item.productid   = TypeParse.DbObjToInt(dr["productid"].ToString(), 0);
                    item.productname = TypeParse.DbObjToString(dr["productname"].ToString(), "");
                    item.cartstate   = TypeParse.DbObjToInt(dr["cartstate"].ToString(), 0);
                    item.vipprice    = Decimal.Parse(TypeParse.DbObjToString(dr["vipprice"].ToString(), "0.00"));
                    item.productimg  = TypeParse.DbObjToString(dr["productimg"].ToString(), "");
                    item.buynum      = TypeParse.DbObjToInt(dr["buynum"].ToString(), 1);
                    list.Add(item);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(list);
        }
Esempio n. 13
0
        public string bandeditorder(string orderid)
        {
            orderinfo odata = order.getorderinfo(orderid);
            string    str;

            //大区下拉菜单
            List <categoryinfo> d1list = category.getdeliveryI();
            StringBuilder       d1sb   = new StringBuilder();

            d1sb.Append("<select id=\"d1select\" class=\"orderselect\"  onchange=\"changed1()\">");
            foreach (categoryinfo pitem in d1list)
            {
                string template;

                if (odata.deliveryIid == pitem.deliveryIid)
                {
                    template = "<option value=\"{0}\" selected=\"selected\">{1}</option>";
                }
                else
                {
                    template = "<option value=\"{0}\">{1}</option>";
                }

                d1sb.AppendFormat(template, pitem.deliveryIid, pitem.deliveryI);
            }
            d1sb.Append("</select>");

            //小区下拉菜单
            StringBuilder       d2sb   = new StringBuilder();
            List <categoryinfo> d2list = category.getdeliveryIIbyID(odata.deliveryIid);

            d2sb.Append("<select id=\"d2select\" class=\"orderselect\">");
            foreach (categoryinfo pitem in d2list)
            {
                string template;

                if (odata.deliveryIIid == pitem.deliveryIIid)
                {
                    template = "<option value=\"{0}\" selected=\"selected\">{1}</option>";
                }
                else
                {
                    template = "<option value=\"{0}\">{1}</option>";
                }

                d2sb.AppendFormat(template, pitem.deliveryIIid, pitem.deliveryII);
            }
            d2sb.Append("</select>");

            //送货日期
            string deliverydatestr = "<input type=\"text\" id=\"deliverydate\" onclick=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" value=\"" + odata.deliverydate.ToString("yyyy-MM-dd") + "\" readonly=\"readonly\" style=\"width: 110px; height: 18px; border: solid 1px #cacaca;\" />";

            //订单状态
            string orderstatestr;

            if (odata.orderstate == 0)
            {
                orderstatestr = "<select id=\"orderstate\"><option value=\"0\">进行中</option><option value=\"10\">已完成</option><option value=\"44\">待处理</option></select>";
            }
            else if (odata.orderstate == 10)
            {
                orderstatestr = "<select id=\"orderstate\"><option value=\"0\">进行中</option><option value=\"10\" selected=\"selected\">已完成</option><option value=\"44\">待处理</option></select>";
            }
            else if (odata.orderstate == 44)
            {
                orderstatestr = "<select id=\"orderstate\"><option value=\"0\">进行中</option><option value=\"10\">已完成</option><option value=\"44\"  selected=\"selected\">待处理</option></select>";
            }
            else
            {
                orderstatestr = "<select id=\"orderstate\"><option value=\"0\">进行中</option><option value=\"10\">已完成</option><option value=\"44\">待处理</option></select>";
            }
            str = "<table width=\"100%\" cellpadding=\"0\" cellspace=\"0\" border=\"0\" class=\"editordertb\"><tr><td>收货人</td><td colspan=\"3\">" + odata.contact + "</td></tr><tr><td>详细地址</td><td  colspan=\"3\">" + odata.address + "</td></tr><tr><td>大区</td><td>" + d1sb.ToString() + "</td><td>小区</td><td><label id=\"d2selectlabel\">" + d2sb.ToString() + "</label></td></tr><tr><td>送货时间</td><td colspan=\"3\">" + deliverydatestr + "</td></tr><tr><td>订单状态</td><td colspan=\"3\">" + orderstatestr + "</td></tr><tr><td colspan=\"4\" align=\"right\"><input type=\"button\" onclick=\"editorderinfo('" + odata.orderid + "')\" value=\"修改订单\"/>&nbsp;&nbsp;<input type=\"button\" onclick=\"delorderinfo('" + odata.ordernumber + "')\"  value=\"删除订单\"/></td></tr></table>";

            return(str);
        }
Esempio n. 14
0
        public string addorder(string ddate)
        {
            string uid = "";
            int    addressid;

            if (HttpContext.Current.Request.Cookies["tfuid"] != null)
            {
                string userid = HttpContext.Current.Request.Cookies["tfuid"].Value.ToString();
                uid = userid;
            }
            //是否有默认收货地址
            List <addressinfo> alist = address.getaddressinfobyuid(uid);

            if (alist.Count < 1)
            {
                return("address_f");
            }
            else
            {
                addressid = alist[0].addressid;
            }

            List <orderinfo> cartlist = order.getcartlist(0, uid);
            int ccount = cartlist.Count;

            if (ccount > 0)
            {
                userinfo udata     = user.getuserinfo(uid);
                decimal  udiscount = udata.atdiscount;
                decimal  pmoney    = order.getallprice(uid);
                decimal  dmoney    = pmoney - pmoney * udiscount;
                decimal  paymoney  = pmoney * udiscount;

                orderinfo odata = new orderinfo();
                odata.userid       = uid;
                odata.address      = alist[0].address;
                odata.contact      = alist[0].contact;
                odata.tel          = alist[0].tel;
                odata.mobile       = alist[0].mobile;
                odata.deliveryIid  = alist[0].deliveryIid;
                odata.deliveryIIid = alist[0].deliveryIIid;
                odata.allmoney     = pmoney;
                odata.paymoney     = paymoney;
                odata.orderdate    = DateTime.Now;
                odata.ordernumber  = order.getordernumber(uid);
                odata.orderstate   = 0;
                DateTime dt;
                if (DateTime.Now.Hour >= 16)
                {
                    dt = DateTime.Now.AddDays(1);
                }
                else
                {
                    dt = DateTime.Now;
                }
                odata.deliverydate = TypeParse.DbObjToDateTime(ddate, dt);
                bool r1 = order.addorder(odata);
                if (r1)
                {
                    bool r2 = order.changecartstate(odata.ordernumber, uid);
                    if (r2)
                    {
                        return("t");
                    }
                    else
                    {
                        return("f");
                    }
                }
                else
                {
                    return("f");
                }
            }
            else
            {
                return("buynum_f");
            }
        }
Esempio n. 15
0
        public Result Post([FromBody] orderinfo value)
        {
            lock (this)
            {
                var str = HttpContext.Session.GetInt32("order");
                if (str != null && DateTime.Now.Minute == str)
                {
                    return(Result.Run(res => throw new Exception("不能频繁提交订单")));
                }
            }
            return(Result.Run(ress =>
            {
                var openid = HttpContext.Session.GetString("openid");
                HttpContext.Session.SetInt32("order", DateTime.Now.Minute);
                if (value.riderType != 4 && value.startDate.AddMinutes(2) <= DateTime.Now.AddHours(2))
                {
                    throw new Exception("乘坐时间必须在2小时后");
                }
                if (value.riderType == 4)
                {
                    value.startDate.AddMinutes(5);
                }
                orders result = Hup.CreateMsg.Run(value).Content;
                var user = this.Uc.read(openid);
                if (user.bill < value.price)
                {
                    ress.code = 2;
                    ress.data = value.price;
                    throw new Exception("账户余额不足。");
                }
                result.userid = user.id;
                var sql = result.Insert();
                var cmd = this.db.CreateCommand();
                this.db.Open();
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
                cmd.CommandText = "select LAST_INSERT_ID()";
                //var n = this.db.Execute(sql);
                var id = (ulong)cmd.ExecuteScalar();  //this.db.ExecuteScalar<long>("");
                if (value.riderType == 4)
                {
                    string locationInfo = "insert into locationInfo(orderid,longitude,latitude)values('" + id + "','" + value.longitude + "','" + value.latitude + "')";
                    int n = this.db.Execute(locationInfo, value);
                }
                value.startDate = value.startDate.AddMinutes(5);
                this.db.Close();
                string[] eumslist = new string[] { "", "顺风车", "专车", "速递", "快车" };
                Task.Run(async() =>
                {
                    await TaskManagerService.Factory().AutoRun(value.startDate, key =>
                    {
                        JObject obj = new JObject();
                        obj.Add("state", 3);
                        string upsql = uilt.uiltT.Update(obj, "orders", " where id='" + id + "' ");
                        db.Execute(upsql);
                        uilt.uiltT.SendWxMessage(token, "您的订单从" + value.startingPoint + "到" + value.endingPoint + "的行程,由于长时间没有司机接单已经超时,请重新创建行程。", openid);
                        return Task.CompletedTask;
                    }, "task" + id);
                });

                Task.Run(() =>
                {
                    if (value.riderType == 4)
                    {
                        foreach (var key in driverService.driverinfo)
                        {
                            var t = (((key.Value.pointy - value.longitude) * Math.PI * 12656 * Math.Cos(((key.Value.pointx + value.latitude) / 2) * Math.PI / 180) / 180) *
                                     ((key.Value.pointy - value.longitude) * Math.PI * 12656 * Math.Cos(((key.Value.pointx + value.latitude) / 2) * Math.PI / 180) / 180));
                            var t2 = (((key.Value.pointx - value.latitude) * Math.PI * 12656 / 180) * ((key.Value.pointx - value.latitude) * Math.PI * 12656 / 180));
                            if (Math.Sqrt(t + t2) < 3 && key.Value.status == 1)
                            {
                                uilt.uiltT.SendWxMessage(token, "有新的从" + value.startingPoint + "到" + value.endingPoint + "的" + eumslist[value.riderType] + "订单。", key.Key);
                            }
                        }
                        return;
                    }
                    string noticeSql = "select wxCount from userinfo join driverinfo on userinfo.id=driverinfo.userid where driverstate=1";
                    noticeSql += " and route like '%" + value.riderType + "%' ";
                    var list = this.db.Query <string>(noticeSql);
                    foreach (var key in list)
                    {
                        uilt.uiltT.SendWxMessage(token, "有新的从" + value.startingPoint + "到" + value.endingPoint + "的" + eumslist[value.riderType] + "订单。", key);
                    }
                }).Wait();
                ress.data = id;
            }));


            //return id.ToString();// n > 0 ? "" : "订单创建失败";
        }
Esempio n. 16
0
        /// <summary>
        /// 得到单个订单信息
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public static orderinfo getorderinfo(string orderid)
        {
            SqlParameter[] parms = new SqlParameter[1];
            parms[0]       = new SqlParameter("@orderid", SqlDbType.NVarChar, 50);
            parms[0].Value = orderid;

            orderinfo item = new orderinfo();
            string    sql  = "select a.orderid,a.ordernumber,a.allmoney,a.paymoney,a.deliveryIid,a.deliveryIIid,a.orderdate,a.deliverydate,a.orderstate,a.contact,a.tel,a.mobile,a.address,c.deliveryI,d.deliveryII from [userorder] a,deliveryI c,deliveryII d where  a.deliveryIid=c.deliveryIid and a.deliveryIIid=d.deliveryIIid and orderid=@orderid";

            try
            {
                SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.connectionstring, CommandType.Text, sql, parms);
                if (dr.Read())
                {
                    item.orderid      = TypeParse.DbObjToString(dr["orderid"].ToString(), "0");
                    item.tel          = TypeParse.DbObjToString(dr["tel"].ToString(), "");
                    item.ordernumber  = TypeParse.DbObjToString(dr["ordernumber"].ToString(), "");
                    item.mobile       = TypeParse.DbObjToString(dr["mobile"].ToString(), "");
                    item.address      = TypeParse.DbObjToString(dr["address"].ToString(), "");
                    item.contact      = TypeParse.DbObjToString(dr["contact"].ToString(), "");
                    item.allmoney     = Decimal.Parse(TypeParse.DbObjToString(dr["allmoney"].ToString(), "0.00"));
                    item.paymoney     = Decimal.Parse(TypeParse.DbObjToString(dr["paymoney"].ToString(), "0.00"));
                    item.orderstate   = TypeParse.DbObjToInt(dr["orderstate"].ToString(), 0);
                    item.orderdate    = TypeParse.DbObjToDateTime(dr["orderdate"].ToString(), DateTime.Now);
                    item.deliverydate = TypeParse.DbObjToDateTime(dr["deliverydate"].ToString(), DateTime.Now);
                    item.ordernumber  = TypeParse.DbObjToString(dr["ordernumber"].ToString(), "");
                    item.deliveryI    = TypeParse.DbObjToString(dr["deliveryI"].ToString(), "");
                    item.deliveryII   = TypeParse.DbObjToString(dr["deliveryII"].ToString(), "");
                    item.deliveryIid  = TypeParse.DbObjToInt(dr["deliveryIid"].ToString(), 0);
                    item.deliveryIIid = TypeParse.DbObjToInt(dr["deliveryIIid"].ToString(), 0);
                    switch (item.orderstate)
                    {
                    case 0:
                        item.orderstatestr = "进行中";
                        break;

                    case 10:
                        item.orderstatestr = "已完成";
                        break;

                    case 44:
                        item.orderstatestr = "待处理";
                        break;

                    default:
                        item.orderstatestr = "进行中";
                        break;
                    }
                    dr.Close();
                    dr.Dispose();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
            }
            return(item);
        }