Exemplo n.º 1
0
        public HttpResponseMessage XuDingOrderWX([FromBody] T_Order order)
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                order.ETime = order.BTime.AddMinutes(order.Duration);
                if (order.ETime < DateTime.Now)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定结束时间必须大于当前时间!";
                }
                else if (order.BTime.Minute != 0 && order.BTime.Minute != 30)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定开始时间必须以半小时为间隔,如:12:00,12:30!";
                }
                else if (order.ETime.Minute != 0 && order.ETime.Minute != 30)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定结束时间必须以半小时为间隔,如:14:00,14:30!";
                }
                else if (order.Duration < 30 || order.Duration % 30 != 0)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定时长至少半小时,时长必须半小时为整";
                }
                else
                {
                    bool checkOrderTime = false;
                    using (IT_Order repository = new T_OrderRepository())
                    {
                        checkOrderTime = repository.CheckOrderTime(order);
                    }
                    if (checkOrderTime)
                    {
                        resultMsg.code = 1;
                        resultMsg.msg  = "预定时间段被占用,请重新选择预定时间";
                    }
                    else
                    {
                        T_Order porder = null;
                        using (IT_Order repository = new T_OrderRepository())
                        {
                            porder = repository.FindFirstOrDefault(o => o.OrderNo == order.ParentNo && o.PayStatus == 1);
                        }
                        if (porder != null)
                        {
                            order.ShopID  = porder.ShopID;
                            order.Mobile  = porder.Mobile;
                            order.CardNo  = porder.CardNo;
                            order.ReMarks = 0;
                            order.Flag    = 1;

                            T_Shop shop = null;
                            using (IT_Shop repository = new T_ShopRepository())
                            {
                                shop = repository.FindFirstOrDefault(o => o.ID == order.ShopID);
                            }
                            if (shop != null)
                            {
                                WK.Tea.Lock.ApiRequest.CreateCardRequest postEntity = new WK.Tea.Lock.ApiRequest.CreateCardRequest
                                {
                                    communityNo = "1316882760",
                                    roomNo      = shop.RoomNo,
                                    floorNo     = shop.FloorNo,
                                    buildNo     = shop.BuildNo,
                                    startTime   = order.BTime.AddMinutes(-15).ToString("yyMMddHHmm"),
                                    endTime     = order.ETime.AddMinutes(10).ToString("yyMMddHHmm"),
                                    mobile      = string.IsNullOrWhiteSpace(order.Mobile) ? WK.Tea.Lock.ApiRequest.LockApiHelper.Mobile : order.Mobile
                                };
                                //WK.Tea.Lock.ApiRequest.CreateCardResponse result =
                                //    WK.Tea.Lock.ApiRequest.LockApiHelper.WebApi.Post<WK.Tea.Lock.ApiRequest.CreateCardRequest, WK.Tea.Lock.ApiRequest.CreateCardResponse>("https://api.uclbrt.com/?c=Qrcode&a=getLink", postEntity);
                                using (IT_Order repository = new T_OrderRepository())
                                {
                                    TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                                    order.OrderNo = "XDWX" + Convert.ToInt64(ts.TotalMilliseconds).ToString();
                                    //order.CardNo = result.cardNo;
                                    order.ReMarks   = 1;
                                    order.PayStatus = 0;
                                    order.Flag      = 0;
                                    order.FeeCode   = 50;
                                    var t = order.Duration - 30;
                                    if (t > 0)
                                    {
                                        order.FeeCode += t / 30 * 50;
                                    }
                                    order.OpenID = User.Identity.Name;
                                    order.CTime  = DateTime.Now;
                                    order        = repository.Insert(order);

                                    resultMsg.code = 200;
                                    resultMsg.data = order;
                                }
                            }
                            else
                            {
                                resultMsg.code = 1;
                                resultMsg.msg  = "门店不存在";
                            }
                        }
                        else
                        {
                            resultMsg.code = 1;
                            resultMsg.msg  = "主订单不存在";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }
Exemplo n.º 2
0
        public HttpResponseMessage EditOrderAdmin([FromBody] T_Order order)
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                order.Duration = (int)(order.ETime - order.BTime).TotalMinutes;
                if (order.BTime.Minute != 0 && order.BTime.Minute != 30)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定开始时间必须以半小时为间隔,如:12:00,12:30!";
                }
                else if (order.ETime.Minute != 0 && order.ETime.Minute != 30)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定结束时间必须以半小时为间隔,如:14:00,14:30!";
                }
                else if (order.Duration % 30 != 0)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "时长必须半小时为整";
                }
                else
                {
                    bool checkOrderTime = false;
                    using (IT_Order repository = new T_OrderRepository())
                    {
                        checkOrderTime = repository.CheckOrderTime(order);
                    }
                    if (order.OrderNo.Substring(0, 1) != "R" && checkOrderTime)
                    {
                        resultMsg.code = 1;
                        resultMsg.msg  = "预定时间段被占用,请重新选择预定时间";
                    }
                    else
                    {
                        T_Shop shop = null;
                        using (IT_Shop repository = new T_ShopRepository())
                        {
                            shop = repository.FindFirstOrDefault(o => o.ID == order.ShopID);
                        }
                        if (shop != null)
                        {
                            WK.Tea.Lock.ApiRequest.CreateCardRequest postEntity = new WK.Tea.Lock.ApiRequest.CreateCardRequest
                            {
                                communityNo = "1316882760",
                                roomNo      = shop.RoomNo,
                                floorNo     = shop.FloorNo,
                                buildNo     = shop.BuildNo,
                                startTime   = order.BTime.AddMinutes(-15).ToString("yyMMddHHmm"),
                                endTime     = order.ETime.AddMinutes(10).ToString("yyMMddHHmm"),
                                mobile      = string.IsNullOrWhiteSpace(order.Mobile) ? WK.Tea.Lock.ApiRequest.LockApiHelper.Mobile : order.Mobile
                            };
                            WK.Tea.Lock.ApiRequest.CreateCardResponse result =
                                WK.Tea.Lock.ApiRequest.LockApiHelper.WebApi.Post <WK.Tea.Lock.ApiRequest.CreateCardRequest, WK.Tea.Lock.ApiRequest.CreateCardResponse>("https://api.uclbrt.com/?c=Qrcode&a=getLink", postEntity);
                            using (IT_Order repository = new T_OrderRepository())
                            {
                                order.CardNo = result.cardNo;
                                order.OP     = null;
                                repository.Update(order);
                            }
                        }
                        else
                        {
                            resultMsg.code = 1;
                            resultMsg.msg  = "门店不存在";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }
Exemplo n.º 3
0
        public HttpResponseMessage AddOrderWX([FromBody] T_Order order)
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                order.ETime = order.BTime.AddMinutes(order.Duration);
                if (order.BTime.Minute != 0 && order.BTime.Minute != 30)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定开始时间必须以半小时为间隔,如:12:00,12:30!";
                }
                else if (order.ETime.Minute != 0 && order.ETime.Minute != 30)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定结束时间必须以半小时为间隔,如:14:00,14:30!";
                }
                else if (order.Duration < 120 || order.Duration % 30 != 0)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定时长至少2小时,时长必须半小时为整";
                }
                else
                {
                    bool checkOrderTime = false;
                    using (IT_Order repository = new T_OrderRepository())
                    {
                        checkOrderTime = repository.CheckOrderTime(order);
                    }
                    if (checkOrderTime)
                    {
                        resultMsg.code = 1;
                        resultMsg.msg  = "预定时间段被占用,请重新选择预定时间";
                    }
                    else
                    {
                        T_Shop shop = null;
                        using (IT_Shop repository = new T_ShopRepository())
                        {
                            shop = repository.FindFirstOrDefault(o => o.ID == order.ShopID);
                        }
                        if (shop != null)
                        {
                            using (IT_Order repository = new T_OrderRepository())
                            {
                                TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                                order.OrderNo   = "DCWX" + Convert.ToInt64(ts.TotalMilliseconds).ToString();
                                order.ReMarks   = 1;
                                order.PayStatus = 0;
                                order.Flag      = 0;
                                order.FeeCode   = 288;
                                var t = order.Duration - 120;
                                if (t > 0)
                                {
                                    order.FeeCode += t / 30 * 50;
                                }
                                order.OpenID   = User.Identity.Name;
                                order.CTime    = DateTime.Now;
                                order          = repository.Insert(order);
                                resultMsg.data = order;
                            }
                        }
                        else
                        {
                            resultMsg.code = 1;
                            resultMsg.msg  = "门店不存在";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }
Exemplo n.º 4
0
        public HttpResponseMessage AddOrderAdmin([FromBody] T_Order order)
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                order.Duration = (int)(order.ETime - order.BTime).TotalMinutes;
                if (order.BTime.Minute != 0 && order.BTime.Minute != 30)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定开始时间必须以半小时为间隔,如:12:00,12:30!";
                }
                else if (order.ETime.Minute != 0 && order.ETime.Minute != 30)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定结束时间必须以半小时为间隔,如:14:00,14:30!";
                }
                else if (order.Duration < 120 || order.Duration % 30 != 0)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定时长至少2小时,时长必须半小时为整";
                }
                else
                {
                    bool checkOrderTime = false;
                    using (IT_Order repository = new T_OrderRepository())
                    {
                        checkOrderTime = repository.CheckOrderTime(order);
                    }
                    if (checkOrderTime)
                    {
                        resultMsg.code = 1;
                        resultMsg.msg  = "预定时间段被占用,请重新选择预定时间";
                    }
                    else
                    {
                        T_Shop shop = null;
                        using (IT_Shop repository = new T_ShopRepository())
                        {
                            shop = repository.FindFirstOrDefault(o => o.ID == order.ShopID);
                        }
                        if (shop != null)
                        {
                            WK.Tea.Lock.ApiRequest.CreateCardRequest postEntity = new WK.Tea.Lock.ApiRequest.CreateCardRequest
                            {
                                communityNo = "1316882760",
                                roomNo      = shop.RoomNo,
                                floorNo     = shop.FloorNo,
                                buildNo     = shop.BuildNo,
                                startTime   = order.BTime.AddMinutes(-15).ToString("yyMMddHHmm"),
                                endTime     = order.ETime.AddMinutes(10).ToString("yyMMddHHmm"),
                                mobile      = string.IsNullOrWhiteSpace(order.Mobile) ? WK.Tea.Lock.ApiRequest.LockApiHelper.Mobile : order.Mobile
                            };
                            WK.Tea.Lock.ApiRequest.CreateCardResponse result =
                                WK.Tea.Lock.ApiRequest.LockApiHelper.WebApi.Post <WK.Tea.Lock.ApiRequest.CreateCardRequest, WK.Tea.Lock.ApiRequest.CreateCardResponse>("https://api.uclbrt.com/?c=Qrcode&a=getLink", postEntity);
                            using (IT_Order repository = new T_OrderRepository())
                            {
                                order.CardNo = result.cardNo;
                                order.Flag   = 0;
                                order.OP     = User.Identity.Name;
                                order.CTime  = DateTime.Now;
                                repository.Insert(order);
                                string url = "http://dc.orangenet.com.cn/Door/Qrcode?orderId=" + order.ID;
                                WeixinTempMsg.SendManagerOrderMsg(url, shop.ShopAddress, order.BTime, order.ETime, order.FeeCode.Value);
                                //WeixinTempMsg.SendCleanMsg(shop.ShopAddress, order.OrderNo, order.BTime, order.ETime);
                            }
                        }
                        else
                        {
                            resultMsg.code = 1;
                            resultMsg.msg  = "门店不存在";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }
Exemplo n.º 5
0
        public HttpResponseMessage RenewOrderWX([FromBody] T_Order order)
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                order.Duration = (int)(order.ETime - order.BTime).TotalMinutes;
                if (order.BTime.Minute != 0 && order.BTime.Minute != 30)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定开始时间必须以半小时为间隔,如:12:00,12:30!";
                }
                else if (order.ETime.Minute != 0 && order.ETime.Minute != 30)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定结束时间必须以半小时为间隔,如:14:00,14:30!";
                }
                else if (order.Duration < 30 || order.Duration % 30 != 0)
                {
                    resultMsg.code = 1;
                    resultMsg.msg  = "预定时长至少半小时,时长必须半小时为整";
                }
                else
                {
                    bool checkOrderTime = false;
                    using (IT_Order repository = new T_OrderRepository())
                    {
                        checkOrderTime = repository.CheckOrderTime(order);
                    }
                    if (checkOrderTime)
                    {
                        resultMsg.code = 1;
                        resultMsg.msg  = "预定时间段被占用,请重新选择预定时间";
                    }
                    else
                    {
                        T_Order porder = null;
                        using (IT_Order repository = new T_OrderRepository())
                        {
                            porder = repository.FindFirstOrDefault(o => o.OrderNo == order.ParentNo);
                        }
                        if (porder != null)
                        {
                            order.ShopID  = porder.ShopID;
                            order.Mobile  = porder.Mobile;
                            order.ReMarks = 0;
                            order.Flag    = 1;

                            T_Shop shop = null;
                            using (IT_Shop repository = new T_ShopRepository())
                            {
                                shop = repository.FindFirstOrDefault(o => o.ID == order.ShopID);
                            }
                            if (shop != null)
                            {
                                string cardNo = string.Empty;
                                var    code   = new Random().Next(1000, 9999).ToString();
                                if (shop.LockType != 1)
                                {
                                    WK.Tea.Lock.ApiRequest.CreateCardRequest postEntity = new WK.Tea.Lock.ApiRequest.CreateCardRequest
                                    {
                                        communityNo = "1316882760",
                                        roomNo      = shop.RoomNo,
                                        floorNo     = shop.FloorNo,
                                        buildNo     = shop.BuildNo,
                                        startTime   = order.BTime.AddMinutes(-15).ToString("yyMMddHHmm"),
                                        endTime     = order.ETime.AddMinutes(10).ToString("yyMMddHHmm"),
                                        mobile      = string.IsNullOrWhiteSpace(order.Mobile) ? WK.Tea.Lock.ApiRequest.LockApiHelper.Mobile : order.Mobile
                                    };
                                    WK.Tea.Lock.ApiRequest.CreateCardResponse result =
                                        WK.Tea.Lock.ApiRequest.LockApiHelper.WebApi.Post <WK.Tea.Lock.ApiRequest.CreateCardRequest, WK.Tea.Lock.ApiRequest.CreateCardResponse>("https://api.uclbrt.com/?c=Qrcode&a=getLink", postEntity);

                                    cardNo = result.cardNo;
                                }
                                else
                                {
                                    var startTime = order.BTime.AddMinutes(-15).ToString("yyMMddHHmm");
                                    var endTime   = order.ETime.AddMinutes(10).ToString("yyMMddHHmm");

                                    WebApiHelper.CreateInstance().AddLockKey(code, shop.LockID, startTime, endTime);
                                }
                                using (IT_Order repository = new T_OrderRepository())
                                {
                                    order.CardNo = cardNo;
                                    order.LockPW = code;
                                    order.Flag   = 0;
                                    order.OP     = User.Identity.Name;
                                    repository.Insert(order);
                                    string url = "http://dc.orangenet.com.cn/Door/Qrcode?orderId=" + order.ID;
                                    WeixinTempMsg.SendManagerOrderMsg(url, shop.ShopAddress, order.BTime, order.ETime, order.FeeCode.Value, order.OrderNo, 1);
                                    WeixinTempMsg.SendCleanMsg(shop.ShopAddress, order.OrderNo, order.BTime, order.ETime, shop.CleanerOpenID, 1);
                                    WeixinTempMsg.SendSMS(shop.ShopAddress, order.Mobile, shop.ShopPhoneNum, order.BTime, order.ETime, url);
                                }
                            }
                            else
                            {
                                resultMsg.code = 1;
                                resultMsg.msg  = "门店不存在";
                            }
                        }
                        else
                        {
                            resultMsg.code = 1;
                            resultMsg.msg  = "主订单不存在";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }