// 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)); }
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()); }
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()); }
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"))); }