Esempio n. 1
0
        // GET: Admin/Message
        public ActionResult Index(int orderId)
        {
            T_Order order = null;

            using (IT_Order repository = new T_OrderRepository())
            {
                order = repository.FindFirstOrDefault(o => o.ID == orderId);
            }

            if (order != null)
            {
                T_Shop shop = null;
                using (IT_Shop repository = new T_ShopRepository())
                {
                    shop = repository.FindFirstOrDefault(o => o.ID == order.ShopID);
                }
                if (shop != null)
                {
                    WeixinTempMsg.SendCleanMsg(shop.ShopAddress, order.OrderNo, order.BTime, order.ETime, shop.CleanerOpenID);
                }
                return(Json("发送成功", JsonRequestBehavior.AllowGet));
            }

            return(Json("发送失败", JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取房卡示例
        /// </summary>
        public ActionResult Qrcode(int orderId)
        {
            using (IT_Order repository = new T_OrderRepository())
            {
                T_Order order = repository.FindFirstOrDefault(o => o.ID == orderId);
                if (order == null)
                {
                    ViewBag.Message = "订单不存在";
                }
                else
                {
                    DateTime nowTime = DateTime.Now;
                    if (nowTime > order.BTime.AddMinutes(-15) && nowTime < order.ETime.AddMinutes(10))
                    {
                        string mobile = string.IsNullOrWhiteSpace(order.Mobile) ? LockApiHelper.Mobile : order.Mobile;
                        string data   = LockApiHelper.WebApi.GetCardDataParams("1316882760",
                                                                               mobile, "86", order.CardNo);
                        ViewBag.Url = "http://cz.uclbrt.com/apiLogin?data=" + data;
                        LogWriter.Default.WriteWarning(string.Format("uclbrt lock url: {0}", ViewBag.Url));
                        return(Redirect(ViewBag.Url));
                    }
                    else if (nowTime <= order.BTime.AddMinutes(-15))
                    {
                        ViewBag.Message = string.Format("您的预定的时间为:\n{0} - {1}\n门锁二维码可以提前15分钟获取!"
                                                        , order.BTime.ToString("MM/dd HH:mm"), order.ETime.ToString("MM/dd HH:mm"));
                    }
                    else
                    {
                        ViewBag.Message = string.Format("预定已过期!");
                    }
                }
            }

            return(View());
        }
Esempio n. 3
0
        public HttpResponseMessage GetOrderReport(string ReportWay, string SearchDate = null)
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                string tjWay = "";
                byte?  sort  = null;
                if (string.IsNullOrEmpty(ReportWay))
                {
                    resultMsg.code = (int)StatusCodeEnum.Error;
                    resultMsg.msg  = "请选择筛选条件";
                }
                var ways = ReportWay.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < ways.Length; i++)
                {
                    if (ways[i] == "1")
                    {
                        if (!string.IsNullOrWhiteSpace(tjWay))
                        {
                            tjWay += ",";
                        }
                        tjWay += "A.ShopID,B.ShopName";
                        sort   = 0;
                    }
                    else if (ways[i] == "2")
                    {
                        if (!string.IsNullOrWhiteSpace(tjWay))
                        {
                            tjWay += ",";
                        }
                        tjWay += "convert(varchar(10),A.BTime,120)";
                    }
                }
                string where = null;
                if (!string.IsNullOrWhiteSpace(SearchDate))
                {
                    Regex reg   = new Regex(@"[0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2}");
                    var   dates = reg.Matches(SearchDate);
                    if (dates.Count > 1)
                    {
                        where  = "A.BTime>='" + Convert.ToDateTime(dates[0].Value).ToString() + "'";
                        where += " AND A.BTime<'" + Convert.ToDateTime(dates[1].Value).AddDays(1).ToString() + "'";
                    }
                }
                using (IT_Order repository = new T_OrderRepository())
                {
                    var list = repository.GetOrderReportList(tjWay, where, sort, "test");
                    resultMsg.data  = list;
                    resultMsg.count = list.Count;
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }
Esempio n. 4
0
 // GET: Order
 public ActionResult Settlement(int id)
 {
     using (IT_Order repository = new T_OrderRepository())
     {
         var model = repository.GetVOrderByID(id);
         return(View(model));
     }
 }
Esempio n. 5
0
        public ActionResult Success(string orderNo)
        {
            VOrderModel order = null;;

            using (IT_Order repository = new T_OrderRepository())
            {
                order = repository.GetVOrderByOrderNo(orderNo);
            }
            return(View(order));
        }
Esempio n. 6
0
        public static void SendSMS(string shopAddress, string mobile, string shopMobile, DateTime orderBeginTime, DateTime orderEndTime, string url)
        {
            var msg = "【晓空间】您好您的茶室预订成功!\r\n";

            msg += "门店地址:" + shopAddress + "\r\n";
            msg += "预定手机:" + mobile + "\r\n";
            msg += "客服:" + shopMobile + "\r\n";
            msg += "预订时间:" + orderBeginTime.ToString("yyyy/MM/dd HH:mm") + "到" + orderEndTime.ToString("yyyy/MM/dd HH:mm") + "\r\n";
            msg += "请于开始时间15分钟前点开下面链接获取开门二维码:\r\n";
            msg += url;

            using (IT_Order repository = new T_OrderRepository())
            {
                var list = repository.C_SendSSM(mobile, msg);
            }
        }
Esempio n. 7
0
        public HttpResponseMessage GetOrderUsedTimes(int shopId, DateTime dateTime)
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                using (IT_Order repository = new T_OrderRepository())
                {
                    var list = repository.GetOrderTimeList(shopId, dateTime);
                    resultMsg.data = list;
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }
Esempio n. 8
0
        public HttpResponseMessage GetOrderList(int limit, int page, int?SearchShopID = null, string SearchDate = null)
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                if (limit < 1)
                {
                    limit = 10;
                }
                if (page < 1)
                {
                    page = 1;
                }
                OrderSearchModel search = new OrderSearchModel();
                search.ShopID = SearchShopID;

                if (!string.IsNullOrWhiteSpace(SearchDate))
                {
                    Regex reg   = new Regex(@"[0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2}");
                    var   dates = reg.Matches(SearchDate);
                    if (dates.Count > 1)
                    {
                        search.BTimeStart = Convert.ToDateTime(dates[0].Value);
                        search.BTimeEnd   = Convert.ToDateTime(dates[1].Value).AddDays(1);
                    }
                }
                search.limit = limit;
                search.page  = page;
                using (IT_Order repository = new T_OrderRepository())
                {
                    var pagelist = repository.GetVOrderPageList(search);
                    resultMsg.data  = pagelist.Data;
                    resultMsg.count = pagelist.TotalItemCount;
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }
Esempio n. 9
0
        public HttpResponseMessage GetOrderStatics()
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                using (IT_Order repository = new T_OrderRepository())
                {
                    var list = repository.GetOrderStatics();

                    resultMsg.data = new { orderDate = list.Select(c => c.OrderDate).ToList(), orderCount = list.Select(c => c.OrderCount).ToList(), orderAmount = list.Select(c => c.OrderAmount).ToList(), total = repository.GetOrderStaticsData() };
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }
Esempio n. 10
0
        public HttpResponseMessage DeleteOrder(int id)
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                using (IT_Order repository = new T_OrderRepository())
                {
                    T_Order order = new T_Order {
                        ID = id
                    };
                    repository.Delete(order);
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }
Esempio n. 11
0
        public HttpResponseMessage SearchOrderWX([FromBody] T_Order order)
        {
            ResultMsg resultMsg   = new ResultMsg();
            T_Order   orderResult = null;

            using (IT_Order repository = new T_OrderRepository())
            {
                orderResult = repository.FindAll(c => c.Mobile == order.Mobile && c.PayStatus == 1).OrderByDescending(c => c.ID).FirstOrDefault();
            }

            if (orderResult == null)
            {
                resultMsg.code = 500;
                resultMsg.msg  = "暂无订单信息";

                return(resultMsg.toJson());
            }

            resultMsg.code = 200;
            resultMsg.data = orderResult;

            return(resultMsg.toJson());
        }
Esempio n. 12
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());
        }
Esempio n. 13
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());
        }
Esempio n. 14
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());
        }
Esempio n. 15
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());
        }
Esempio n. 16
0
        public ActionResult Notify()
        {
            var doc   = XDocument.Load(Request.InputStream);
            var sPara = doc.Root.Descendants().ToDictionary(x => x.Name.LocalName, x => x.Value);

            if (sPara.Count <= 0)
            {
                throw new ArgumentNullException();
            }

            LogWriter.Default.WriteError("Notify Parameters:" + sPara.ToString());//记录请求关键信息到日志中去

            if (sPara["return_code"] == "SUCCESS" && sPara["result_code"] == "SUCCESS")
            {
                var  sign      = sPara["sign"];
                var  signValue = WxPayAPI.Sign(sPara, WeixinConfig.PartnerKey);
                bool isVerify  = sign == signValue;
                LogWriter.Default.WriteError("Verify:" + isVerify + "|sign/signValue:" + sign + "," + signValue);
                if (isVerify)
                {
                    string out_trade_no   = sPara["out_trade_no"];         //商户订单ID: 1.注意交易单不要重复处理;2.注意判断返回金额
                    string transaction_id = sPara["transaction_id"];       //微信支付订单号
                    string time_end       = sPara["time_end"];             //支付完成时间
                    int    total_fee      = int.Parse(sPara["total_fee"]); //总金额
                    string bank_type      = sPara["bank_type"];            //付款银行

                    var openid = sPara["openid"];

                    //****************************************************************************************
                    //TODO 商户处理订单逻辑: 1.注意交易单不要重复处理;2.注意判断返回金额
                    T_Order order = null;
                    using (IT_Order repository = new T_OrderRepository())
                    {
                        order = repository.FindFirstOrDefault(o => o.OrderNo == out_trade_no);
                    }

                    if (order != null)
                    {
                        order.PayStatus = 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);
                            }

                            order.CardNo = cardNo;
                            order.LockPW = code;

                            using (IT_Order repository = new T_OrderRepository())
                            {
                                repository.Update(order);
                            }

                            //TODO:postData中携带该次支付的用户相关信息,这将便于商家拿到openid,以便后续提供更好的售后服务,譬如:微信公众好通知用户付款成功。如果不提供服务则可以删除此代码
                            string url = "http://dc.orangenet.com.cn/Door/Qrcode?orderId=" + order.ID;
                            WeixinTempMsg.SendOrderPaySuccessMsg(openid, url, shop.ShopAddress, order.BTime, order.ETime, order.FeeCode.Value, order.OrderNo);
                            WeixinTempMsg.SendManagerOrderMsg(url, shop.ShopAddress, order.BTime, order.ETime, order.FeeCode.Value, order.OrderNo);
                            WeixinTempMsg.SendSMS(shop.ShopAddress, order.Mobile, shop.ShopPhoneNum, order.BTime, order.ETime, url);
                            //WeixinTempMsg.SendCleanMsg(shop.ShopAddress, order.OrderNo, order.BTime, order.ETime);
                        }
                        else
                        {
                            LogWriter.Default.WriteError("Shop Error, out_trade_no:" + out_trade_no + ", shop is null");
                        }
                    }
                    else
                    {
                        LogWriter.Default.WriteError("Order Error, out_trade_no:" + out_trade_no + ", order is null");
                    }


                    LogWriter.Default.WriteError("Notify Success, out_trade_no:" + out_trade_no + ",transaction_id" + transaction_id + ",time_end:" + time_end + ",total_fee:" + total_fee + ",bank_type:" + bank_type + ",openid:" + openid);
                    return(Content(string.Format("<xml><return_code><![CDATA[{0}]]></return_code><return_msg><![CDATA[{1}]]></return_msg></xml>", "SUCCESS", "OK")));
                }
            }
            return(Content(string.Format("<xml><return_code><![CDATA[{0}]]></return_code></xml>", "FAIL")));
        }
Esempio n. 17
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());
        }
Esempio n. 18
0
        /// <summary>
        /// 获取房卡示例
        /// </summary>
        public ActionResult Qrcode(int orderId)
        {
            using (IT_Order repository = new T_OrderRepository())
            {
                T_Order order = repository.FindFirstOrDefault(o => o.ID == orderId);
                if (order == null)
                {
                    ViewBag.Message = "订单不存在";
                }
                else
                {
                    T_Shop shop = null;
                    using (IT_Shop repositoryShop = new T_ShopRepository())
                    {
                        shop = repositoryShop.FindFirstOrDefault(o => o.ID == order.ShopID);
                    }
                    if (shop != null && shop.LockType == 1)
                    {
                        Dictionary <string, string> sortedParams = new Dictionary <string, string>()
                        {
                            { "APPID", "6005BAFEA0C54011B6602D7A70C36E6C" },
                            { "AT", WebApiHelper.CreateInstance().GetTimeStamp() },
                            { "NONCESTR", WebApiHelper.CreateInstance().GetRandom() },
                            { "USERID", "13311237111" },
                            { "TOKEN", WebApiHelper.CreateInstance().GetToken() },
                            { "KEYLOCKID", shop.LockID },
                            { "VALIDMINUTE", "30" }
                        };

                        DateTime nowTime1 = DateTime.Now;
                        if (nowTime1 > order.BTime.AddMinutes(-15) && nowTime1 < order.ETime.AddMinutes(10))
                        {
                            sortedParams.Add("STARTDATE", order.BTime.AddMinutes(-15).ToString("yyyyMMddHHmmss"));
                            sortedParams.Add("ENDDATE", order.ETime.AddMinutes(10).ToString("yyyyMMddHHmmss"));
                            var sign = WebApiHelper.CreateInstance().GetSignature(sortedParams);
                            sortedParams.Add("SIGN", sign);

                            var result = WebApiHelper.CreateInstance().Get("https://yylock.eeun.cn/dms/app/getLockQRCode", sortedParams);
                            var qcode  = JsonConvert.DeserializeObject <QCodeRespinse>(result).data;

                            ViewBag.qcode = "data:image/png;base64," + qcode;
                            ViewBag.pwd   = order.LockPW;
                            LogWriter.Default.WriteWarning(string.Format("uclbrt lock url: {0}", ViewBag.qcode));
                        }
                        else if (nowTime1 <= order.BTime.AddMinutes(-15))
                        {
                            ViewBag.Message = string.Format("您的预定的时间为:\n{0} - {1}\n门锁二维码可以提前15分钟获取!"
                                                            , order.BTime.ToString("MM/dd HH:mm"), order.ETime.ToString("MM/dd HH:mm"));
                        }
                        else
                        {
                            ViewBag.Message = string.Format("预定已过期!");
                        }

                        return(View());
                    }


                    DateTime nowTime = DateTime.Now;
                    if (nowTime > order.BTime.AddMinutes(-15) && nowTime < order.ETime.AddMinutes(10))
                    {
                        string mobile = string.IsNullOrWhiteSpace(order.Mobile) ? LockApiHelper.Mobile : order.Mobile;
                        string data   = LockApiHelper.WebApi.GetCardDataParams("1316882760",
                                                                               mobile, "86", order.CardNo);
                        ViewBag.Url = "http://cz.uclbrt.com/apiLogin?data=" + data;
                        LogWriter.Default.WriteWarning(string.Format("uclbrt lock url: {0}", ViewBag.Url));
                        return(Redirect(ViewBag.Url));
                    }
                    else if (nowTime <= order.BTime.AddMinutes(-15))
                    {
                        ViewBag.Message = string.Format("您的预定的时间为:\n{0} - {1}\n门锁二维码可以提前15分钟获取!"
                                                        , order.BTime.ToString("MM/dd HH:mm"), order.ETime.ToString("MM/dd HH:mm"));
                    }
                    else
                    {
                        ViewBag.Message = string.Format("预定已过期!");
                    }
                }
            }

            return(View());
        }
Esempio n. 19
0
        //public ActionResult Order()
        //{
        //    return View();
        //}

        public ActionResult Index(int id)
        {
            try
            {
                T_Order order = null;;
                using (IT_Order repository = new T_OrderRepository())
                {
                    order = repository.Find(id);
                }
                if (order != null)
                {
                    var out_trade_no       = order.OrderNo;
                    var domain             = System.Configuration.ConfigurationManager.AppSettings["Domain"];
                    var body               = "茶室预定";
                    var detail             = "倒茶茶室预定";
                    var attach             = "";
                    var product_id         = "1";
                    var openid             = User.Identity.Name;
                    var goods_tag          = "";
                    var fee_type           = "CNY";
                    var total_fee          = (int)(order.FeeCode.Value * 100);
                    var trade_type         = "JSAPI";
                    var appId              = System.Configuration.ConfigurationManager.AppSettings["AppId"];
                    var nonceStr           = Util.CreateNonce_str();
                    var timestamp          = Util.CreateTimestamp();
                    var success_redict_url = string.Format("{0}/WxPay/Success?orderNo={1}", domain, order.OrderNo);
                    var url              = domain + Request.Url.PathAndQuery;
                    var userAgent        = Request.UserAgent;
                    var userVersion      = userAgent.Substring(userAgent.LastIndexOf("MicroMessenger/") + 15, 3);//微信版本号高于或者等于5.0才支持微信支付
                    var spbill_create_ip = (trade_type == "APP" || trade_type == "NATIVE") ? Request.UserHostName : WeixinConfig.spbill_create_ip;
                    var time_start       = DateTime.Now.ToString("yyyyMMddHHmmss");
                    var time_expire      = DateTime.Now.AddMinutes(15).ToString("yyyyMMddHHmmss"); //默认1个小时订单过期,开发者可自定义其他超时机制,原则上微信订单超时时间不超过2小时

                    var notify_url   = string.Format("{0}/WxPay/Notify", domain);                  //与下面的Notify对应,开发者可自定义其他url地址
                    var partnerKey   = WeixinConfig.PartnerKey;
                    var mch_id       = WeixinConfig.mch_id;
                    var device_info  = WeixinConfig.device_info;
                    var returnXML    = "";
                    var paramaterXml = "";
                    var content      = WxPayAPI.UnifiedOrder(
                        appId, mch_id, device_info, nonceStr,
                        body, detail, attach, out_trade_no, fee_type, total_fee, spbill_create_ip, time_start, time_expire,
                        goods_tag, notify_url, trade_type, product_id, openid, partnerKey, out returnXML, out paramaterXml);
                    LogWriter.Default.WriteError(paramaterXml);
                    LogWriter.Default.WriteError(returnXML);
                    var prepay_id             = "";
                    var sign                  = "";
                    var return_code           = "";
                    var return_msg            = "";
                    var err_code              = "";
                    var err_code_des          = "";
                    var isUnifiedOrderSuccess = false;
                    if (content.return_code.Value == "SUCCESS" && content.result_code.Value == "SUCCESS")
                    {
                        prepay_id             = content.prepay_id.Value;
                        sign                  = WxPayAPI.SignPay(appId, timestamp.ToString(), nonceStr, prepay_id, partnerKey);
                        trade_type            = content.trade_type.Value;
                        isUnifiedOrderSuccess = true;
                    }
                    else
                    {
                        return_code           = content.return_code.Value;
                        return_msg            = content.return_msg.Value;
                        isUnifiedOrderSuccess = false;
                    }
                    if (!isUnifiedOrderSuccess)
                    {
                        return(RedirectToAction("Failed", new { msg = "(代码:101)服务器下单失败,请重试" }));
                    }
                    var model = new JSPayModel
                    {
                        appId              = appId,
                        nonceStr           = nonceStr,
                        timestamp          = timestamp,
                        userAgent          = userAgent,
                        userVersion        = userVersion,
                        attach             = "",
                        body               = body,
                        detail             = detail,
                        openid             = openid,
                        product_id         = out_trade_no,
                        goods_tag          = goods_tag,
                        price              = order.FeeCode.Value,
                        total_fee          = total_fee,
                        prepay_id          = prepay_id,
                        trade_type         = trade_type,
                        sign               = sign,
                        return_code        = return_code,
                        return_msg         = return_msg,
                        err_code           = err_code,
                        err_code_des       = err_code_des,
                        success_redict_url = success_redict_url
                    };

                    return(View(model));
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception ex)
            {
                LogWriter.Default.WriteError(ex.Message);
                return(RedirectToAction("Failed", new { msg = "(代码:200)" + ex.Message }));
            }
        }