Beispiel #1
0
        public ActionResult Pay(string cpcode, string cpname, string cpdesc, float price, int num, int paytype /*1-支付宝,2-微信*/)
        {
            orders o = new orders();

            o.orderno      = generate_orderno(1, 1);
            o.product_code = cpcode;
            o.product_name = cpname;
            o.product_desc = cpdesc;
            o.price        = price;
            o.num          = num;
            switch (paytype)
            {
            case 1:
                o.paytype = "支付宝";
                break;

            case 2:
                o.paytype = "微信支付";
                break;

            case 3:
                o.paytype = "银联支付";
                break;
            }

            o.sumittime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            o.Insert();
            float f         = price * 100.0F * num;
            int   total_fee = (int)f;

            LogService.LOG_LEVENL = 3;
            LogService.Debug(this.GetType().ToString(), "total_fee=" + f);

            switch (paytype)
            {
            case 1:
                Response.Redirect(Url.Action("Index", "aliPay") + "?productCode=" + cpcode + "&productName=" + cpname + "&productDesc=" + cpdesc + "&orderno=" + o.orderno + "&total_fee=" + total_fee);
                break;

            case 2:
                Response.Redirect(Url.Action("Index", "Weixin") + "?productCode=" + cpcode + "&productName=" + cpname + "&productDesc=" + cpdesc + "&orderno=" + o.orderno + "&total_fee=" + total_fee);
                break;

            case 3:
                Response.Redirect(Url.Action("Index", "Bank") + "?productCode=" + cpcode + "&productName=" + cpname + "&productDesc=" + cpdesc + "&orderno=" + o.orderno + "&total_fee=" + total_fee);
                break;
            }
            return(Content(""));
        }
Beispiel #2
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 ? "" : "订单创建失败";
        }
Beispiel #3
0
 public void Post([FromBody] orders value)
 {
     this.db.ExecuteScalar(value.Insert());
 }