// GET: 店小二点菜系统入口 Home/Index/[hotelId]/[qrCode] public async Task <ActionResult> Index(int?hotelId, string qrCode) { if (hotelId == null || qrCode == null) { if (CurrHotel != null && Session["CurrentDesk"] != null) { return(View()); } return(RedirectToAction("HotelMissing", "Error")); } Hotel hotel = await YummyOnlineManager.GetHotelById(Convert.ToInt32(hotelId)); if (hotel == null) { return(RedirectToAction("HotelMissing", "Error")); } if (!hotel.Usable) { return(RedirectToAction("HotelUnavailable", "Error")); } CurrHotel = new CurrHotelInfo(hotel.Id, hotel.ConnectionString); Desk desk = await new HotelManager(hotel.ConnectionString).GetDeskByQrCode(qrCode); if (desk == null) { return(RedirectToAction("HotelMissing", "Error")); } Session["CurrentDesk"] = desk; return(View()); }
/// <summary> /// 收银员台支付 /// </summary> public async Task <ActionResult> ManagerPay(Cart cart, ManagerCartAddition cartAddition) { SystemConfig system = await YummyOnlineManager.GetSystemConfig(); if (system.Token != cartAddition.Token) { return(Json(new JsonError("身份验证失败"))); } var hotel = await YummyOnlineManager.GetHotelById(cartAddition.HotelId); CurrHotel = new CurrHotelInfo(hotel.Id, hotel.ConnectionString); if (!hotel.Usable) { return(RedirectToAction("HotelUnavailable", "Error")); } cart.PayKindId = await new HotelManager(CurrHotel.ConnectionString).GetOtherPayKindId(); CartAddition addition = new CartAddition { WaiterId = cartAddition.WaiterId, DineType = cartAddition.DineType, Discount = cartAddition.Discount, DiscountName = cartAddition.DiscountName, GiftMenus = cartAddition.GiftMenus, From = DineFrom.Manager }; User user = await UserManager.FindByIdAsync(cartAddition.UserId); addition.UserId = user?.Id; // 创建新订单 FunctionResult result = await OrderManager.CreateDine(cart, addition); if (!result.Succeeded) { if (await UserManager.IsInRoleAsync(user.Id, Role.Nemo)) { await UserManager.DeleteAsync(user); await YummyOnlineManager.RecordLog(YummyOnlineDAO.Models.Log.LogProgram.Identity, YummyOnlineDAO.Models.Log.LogLevel.Warning, $"Anonymous User Deleted {user.Id}, Via Manager"); } await HotelManager.RecordLog(HotelDAO.Models.Log.LogLevel.Error, $"{result.Detail}, Host:{Request.UserHostAddress}", HttpPost.GetPostData(Request)); return(Json(new JsonError(result.Message))); } Dine dine = ((Dine)result.Data); await newDineInform(dine, "Manager"); return(Json(new JsonSuccess { Data = dine.Id })); }
/// <summary> /// 打印完成 /// </summary> public async Task <JsonResult> PrintCompleted(int hotelId, string dineId) { CurrHotel = new CurrHotelInfo(await YummyOnlineManager.GetHotelById(hotelId)); if (dineId == "00000000000000") { await HotelManager.RecordLog(HotelDAO.Models.Log.LogLevel.Success, $"Print Test Dine Completed"); return(Json(new JsonSuccess())); } await OrderManager.PrintCompleted(dineId); await HotelManager.RecordLog(HotelDAO.Models.Log.LogLevel.Success, $"PrintCompleted DineId: {dineId}"); return(Json(new JsonSuccess())); }
/// <summary> /// 支付完成异步通知 /// </summary> public async Task <JsonResult> OnlineNotify(string encryptedInfo) { string decryptedInfo = DesCryptography.DesDecrypt(encryptedInfo); NetworkNotifyViewModels model = null; try { model = JsonConvert.DeserializeObject <NetworkNotifyViewModels>(decryptedInfo); } catch { return(Json(new JsonError())); } CurrHotel = new CurrHotelInfo(await YummyOnlineManager.GetHotelById(model.HotelId)); await HotelManager.RecordLog(HotelDAO.Models.Log.LogLevel.Info, $"Notified DineId: {model.DineId}"); await onlinePayCompleted(model.DineId, model.RecordId); return(Json(new JsonSuccess())); }