Exemplo n.º 1
0
		public async Task<JsonResult> GetTable(GetTableViewModel model) {
			using(MrCyContext ctx = new MrCyContext()) {
				DeskInfo desk = await ctx.DeskInfo.Where(p => p.QRCode == model.qrCode).FirstOrDefaultAsync();
				Session["qrCode"] = desk.QRCode;
				return Json(desk);
			}
		}
Exemplo n.º 2
0
 public ActionResult WeixinCompleted()
 {
     if(Request.QueryString["id"] == null) {
         return Redirect("/#/");
     }
     if(Request.QueryString["cancel"].ToString() == "1") {
         using(MrCyContext ctx = new MrCyContext()) {
             int id = Convert.ToInt32(Request.QueryString["id"]);
             log(id.ToString());
             DineTempInfo info = ctx.DineTempInfo.Where(p => p.AutoID == id).FirstOrDefault();
             if(info != null) {
                 info.IsPaid = 1;
                 ctx.Entry<DineTempInfo>(info).Property(p => p.IsPaid).IsModified = true;
                 ctx.SaveChanges();
                 log("点击返回修改1");
                 autoPrint();
             }
             else {
                 log("点击返回未找到订单");
             }
         }
         return Redirect("/#/onlinepaysuccess?qrCode=" + Session["qrCode"]);
     }
     else {
         return Redirect("/#/onlinepayfail?qrCode=" + Session["qrCode"]);
     }
 }
Exemplo n.º 3
0
 public ActionResult GetTables()
 {
     using(MrCyContext ctx = new MrCyContext()) {
         var list = ctx.DeskInfo.Where(p => p.Usable).ToList();
         return Json(list);
     }
 }
Exemplo n.º 4
0
 public JsonResult IsAuthenticated()
 {
     using(MrCyContext ctx = new MrCyContext()) {
         if(User.Identity.IsAuthenticated) {
             return Json(new JsonSucceedObj(ctx.ClerkInfo.FirstOrDefault(p => p.ClerkId == User.Identity.Name)));
         }
         return Json(new JsonErrorObj());
     }
 }
Exemplo n.º 5
0
        public static void StartTimer(int id, string hotelid)
        {
            Timer t = new Timer(1000 * 10);
            t.Elapsed += (object sender, ElapsedEventArgs e) => {
                log("订单号:" + id);
                log(DateTime.Now.ToLocalTime().ToString());
                using(MrCyContext ctx = new MrCyContext()) {
                    DineTempInfo info = ctx.DineTempInfo.Where(p => p.AutoID == id).FirstOrDefault();
                    if(info == null) {
                        log("计时器 未找到订单");
                        ((Timer)sender).Stop();
                        return;
                    }
                    else if(info.IsPaid == 1) {
                        log("订单已经支付");
                        ((Timer)sender).Stop();
                        return;
                    }
                }
                try {
                    string result = HttpGet(String.Format("http://www.choice.shu.edu.cn/weixin/NotifyLocal.aspx?id={0}&hotelid={1}",
                        id,
                        hotelid
                    ));

                    log("接收到" + result);
                    result = result.Trim();
                    if(result == "1") {
                        using(MrCyContext ctx = new MrCyContext()) {
                            DineTempInfo info = ctx.DineTempInfo.Where(p => p.AutoID == id).FirstOrDefault();
                            log(info.AutoID.ToString());
                            info.IsPaid = 1;
                            ctx.Entry<DineTempInfo>(info).Property(p => p.IsPaid).IsModified = true;
                            ctx.SaveChanges();
                        }
                        log("计时器修改1");
                        autoPrint();
                        log("支付成功");
                        ((Timer)sender).Stop();
                    }
                    else if(result == "0") {
                        log("支付失败");
                        ((Timer)sender).Stop();
                    }
                    else {
                        log("未支付");
                    }
                }
                catch(Exception error) {
                    log(error.ToString());
                }
            };
            t.Start();
        }
Exemplo n.º 6
0
		public async Task<JsonResult> Forget(SignupViewModel model) {
			if(Session["SMSForgetCode"].ToString() != model.Code) {
				return Json(new JsonErrorObj("验证码不正确", "code"));
			}
			using(MrCyContext ctx = new MrCyContext()) {
				ClientInfo client = ctx.ClientInfo.Where(p => p.LoginName == model.Mobile).FirstOrDefault();
				client.LoginPwd = model.Password;
				ctx.Entry(client).Property(p => p.LoginPwd).IsModified = true;
				await ctx.SaveChangesAsync();
				return Json(new JsonSucceedObj());
			}
		}
Exemplo n.º 7
0
 public ActionResult Signin()
 {
     using(MrCyContext ctx = new MrCyContext()) {
         string username = Request.Form["username"].ToString();
         string password = Request.Form["password"].ToString();
         ClerkInfo clerk = ctx.ClerkInfo.Where(p => p.LoginName == username && p.LoginPwd == password).FirstOrDefault();
         if(clerk == null) {
             return Json(new JsonErrorObj("用户名或密码不正确"));
         }
         FormSignin(clerk);
         return Json(new JsonSucceedObj(clerk));
     }
 }
Exemplo n.º 8
0
		public JsonResult Signin(SigninViewModel model) {
			if(model.CodeImg.ToLower() != (string)Session["CodeImg"]) {
				return Json(new JsonErrorObj("验证码不正确"));
			}
			using(MrCyContext ctx = new MrCyContext()) {
				ClientInfo client = ctx.ClientInfo.Where(p => p.LoginName == model.Mobile && p.LoginPwd == model.Password).FirstOrDefault();
				if(client == null) {
					return Json(new JsonErrorObj("手机或密码不正确"));
				}
				FormSignin(client);
				return Json(new JsonSucceedObj());
			}
		}
Exemplo n.º 9
0
		public ActionResult SendForgetSMS(SMSSendViewModel model) {
			using(MrCyContext ctx = new MrCyContext()) {
				int count = ctx.ClientInfo.Where(p => p.LoginName == model.Mobile).ToList().Count;
				if(count == 0) {
					return Json(new JsonErrorObj("此号码未注册"), "Mobile");
				}
			}
			Random rand = new Random(unchecked((int)DateTime.Now.Ticks));
			string code = "";
			for(int i = 0; i < 6; i++) {
				code += rand.Next(10);
			}
			Session["SMSForgetCode"] = code;
			if(SMS.SMSSender.Send(model.Mobile, code)) {
				return Json(new JsonSucceedObj());
			}
			return Json(new JsonErrorObj());
		}
Exemplo n.º 10
0
		public async Task<JsonResult> GetHistoryMenu(GetHistoryMenuViewModel model) {
			using(MrCyContext ctx = new MrCyContext()) {
				HistoryMenuModel menuModel;

				DineInfoHistory dineInfo = await ctx.DineInfoHistory.Where(p => p.CheckID == model.CheckID).FirstOrDefaultAsync();
				DineInfo dineInfo2 = await ctx.DineInfo.Where(p => p.CheckID == model.CheckID).FirstOrDefaultAsync();
				if(dineInfo != null) {
					DeskInfo desk = await ctx.DeskInfo.Where(p => p.DeskId == dineInfo.DeskID).FirstOrDefaultAsync();
					menuModel = new HistoryMenuModel() {
						CheckID = dineInfo.CheckID,
						BeginTime = dineInfo.BeginTime.ToString(),
						PriceAll = (double)dineInfo.Subtotal,
						Table = desk,
						Customer = (int)dineInfo.ClientNum,
						PayKind = dineInfo.PayKind,
						Results = new List<HistoryMenuDetail>()
					};
				}
				else {
					if(dineInfo2 == null) {
						return Json(null);
					}
					DeskInfo desk = await ctx.DeskInfo.Where(p => p.DeskId == dineInfo2.DeskID).FirstOrDefaultAsync();
					menuModel = new HistoryMenuModel() {
						CheckID = dineInfo2.CheckID,
						BeginTime = dineInfo2.BeginTime.ToString(),
						PriceAll = (double)dineInfo2.Subtotal,
						Table = desk,
						Customer = (int)dineInfo2.ClientNum,
						PayKind = dineInfo2.PayKind,
						Results = new List<HistoryMenuDetail>()
					};
				}



				if(dineInfo != null) {
					List<DineDetailHistory> list = await ctx.DineDetailHistory.Where(p => p.CheckID == dineInfo.CheckID).ToListAsync();
					foreach(DineDetailHistory menu in list) {
						MenuDetail md = await ctx.MenuDetail.Where(p => p.DisherId == menu.DisherID).FirstOrDefaultAsync();
						HistoryMenuDetail newDetail = new HistoryMenuDetail() {
							DisherName = md.DisherName,
							DisherId = menu.DisherID,
							DisherPrice = menu.DisherPrice == null ? 0 : (double)menu.DisherPrice,
							DisherDiscount = (double)menu.SalesDiscount,
							Note = menu.Note,
							Ordered = (int)menu.DisherNum
						};
						menuModel.Results.Add(newDetail);
					}
				}
				else {
					List<DineDetail> list2 = await ctx.DineDetail.Where(p => p.CheckID == dineInfo2.CheckID).ToListAsync();
					foreach(DineDetail menu in list2) {
						MenuDetail md = await ctx.MenuDetail.Where(p => p.DisherId == menu.DisherID).FirstOrDefaultAsync();
						HistoryMenuDetail newDetail = new HistoryMenuDetail() {
							DisherName = md.DisherName,
							DisherId = menu.DisherID,
							DisherPrice = menu.DisherPrice == null ? 0 : (double)menu.DisherPrice,
							DisherDiscount = (double)menu.SalesDiscount,
							Note = menu.Note,
							Ordered = (int)menu.DisherNum
						};
						menuModel.Results.Add(newDetail);
					}
				}

				return Json(menuModel);
			}
		}
Exemplo n.º 11
0
		public async Task<JsonResult> GetNote() {
			using(MrCyContext ctx = new MrCyContext()) {
				List<Note> list = await ctx.Note.ToListAsync();
				return Json(list);
			}
		}
Exemplo n.º 12
0
		public async Task<JsonResult> GetSavedMenu(GetTableViewModel model) {
			SubmitViewModel tempMenu = (SubmitViewModel)Session["savedMenu"];
			if(tempMenu == null) {
				using(MrCyContext ctx = new MrCyContext()) {
					DeskInfo desk = await ctx.DeskInfo.Where(p => p.QRCode == model.qrCode).FirstOrDefaultAsync();
					DineTempInfo dineInfo = await ctx.DineTempInfo.Where(p => p.DeskID == desk.DeskId).FirstOrDefaultAsync();
					if(dineInfo == null) {
						return Json(null);
					}
					HistoryMenuModel menuModel = new HistoryMenuModel() {
						BeginTime = dineInfo.BeginTime.ToString(),
						PriceAll = (double)dineInfo.Subtotal,
						Table = desk,
						Customer = (int)dineInfo.peoplecount,
						PayKind = dineInfo.PayKind,
						Results = new List<HistoryMenuDetail>()
					};
					List<DineTempDetail> list = await ctx.DineTempDetail.Where(p => p.AutoID == dineInfo.AutoID).ToListAsync();
					foreach(DineTempDetail menu in list) {
						MenuDetail md = await ctx.MenuDetail.Where(p => p.DisherId == menu.DisherID).FirstOrDefaultAsync();
						HistoryMenuDetail newDetail = new HistoryMenuDetail() {
							DisherName = md.DisherName,
							DisherId = menu.DisherID,
							DisherPrice = menu.DisherPrice == null ? 0 : (double)menu.DisherPrice,
							DisherDiscount = (double)menu.SalesDiscount,
							Note = menu.Note,
							Ordered = (int)menu.DisherNum
						};
						menuModel.Results.Add(newDetail);
					}
					return Json(menuModel);
				}
			}
			HistoryMenuModel menuModelSession = new HistoryMenuModel() {
				PriceAll = (double)tempMenu.PriceAll,
				SizeAll = tempMenu.SizeAll,
				Table = tempMenu.Table,
				Customer = tempMenu.Customer,
				PayKind = tempMenu.PayKind,
				Results = new List<HistoryMenuDetail>()
			};
			foreach(SubmitMenuDetail menu in tempMenu.Results) {
				string note = "";
				if(menu.Additional.Notes != null) {
					foreach(Note n in menu.Additional.Notes) {
						note += (n.Note1 + " ");
					}
				}
				menuModelSession.Results.Add(new HistoryMenuDetail() {
					DisherId = menu.DisherId,
					DisherName = menu.DisherName,
					DisherDiscount = menu.DisherDiscount,
					DisherPrice = menu.DisherPrice,
					Note = note,
					Ordered = menu.Additional.Ordered
				});
			}
			return Json(menuModelSession);
		}
Exemplo n.º 13
0
		public async Task<JsonResult> GetTablewareFee() {
			using(MrCyContext ctx = new MrCyContext()) {
				BaseInfo info = await ctx.BaseInfo.Where(p => p.InfoName == "HasTablewareFee").FirstOrDefaultAsync();
				if(info.InfoContent == "false") {
					return Json(new {
						TablewareFee = 0
					});
				}
				info = await ctx.BaseInfo.Where(p => p.InfoName == "TablewareFee").FirstOrDefaultAsync();
				return Json(new {
					TablewareFee = info.InfoContent
				});
			}
		}
Exemplo n.º 14
0
		public async Task<JsonResult> GetPayName() {
			using(MrCyContext ctx = new MrCyContext()) {
				List<PayKind> list = await ctx.PayKind.Where(p => p.Usable == true && p.IsNetwork == true).ToListAsync();
				return Json(list);
			}
		}
Exemplo n.º 15
0
		public async Task<JsonResult> Signup(SignupViewModel model) {
			if(Session["SMSCode"].ToString() != model.Code) {
				return Json(new JsonErrorObj("验证码不正确", "code"));
			}
			using(MrCyContext ctx = new MrCyContext()) {
				ClientInfo client = new ClientInfo() {
					ClientId = (DateTime.Now.Year%100).ToString() + model.Mobile,
					ClientName = model.Mobile,
					LoginName = model.Mobile,
					LoginPwd = model.Password
				};
				ctx.ClientInfo.Add(client);
				await ctx.SaveChangesAsync();
				FormSignin(client);
				return Json(new JsonSucceedObj());
			}
		}
Exemplo n.º 16
0
		public async Task<JsonResult> GetMenuSubClass() {
			using(MrCyContext ctx = new MrCyContext()) {
				List<MenuSubClass> list = await ctx.MenuSubClass.Where(p=>p.Usable == true).ToListAsync();
				return Json(list);
			}
		}
Exemplo n.º 17
0
		public async Task<JsonResult> GetMenuDetail() {
			using(MrCyContext ctx = new MrCyContext()) {
				List<MenuDetail> list = await ctx.MenuDetail.Where(p=>p.Usable == true && p.CanSelect == true).ToListAsync();
				return Json(list);
			}
		}
Exemplo n.º 18
0
		public async Task<JsonResult> GetHistoryDineInfo() {
			if(!User.Identity.IsAuthenticated) {
				return Json(null);
			}
			string clientId = User.Identity.Name;
			using(MrCyContext ctx = new MrCyContext()) {
				List<HistoryDineInfoModel> infoList = new List<HistoryDineInfoModel>();

				List<DineInfoHistory> list = await ctx.DineInfoHistory.Where(p => p.ClientID == clientId).ToListAsync();
				List<DineInfo> list2 = await ctx.DineInfo.Where(p => p.ClientID == clientId).ToListAsync();

				foreach(DineInfo info in list2) {
					infoList.Add(new HistoryDineInfoModel() {
						CheckID = info.CheckID,
						BeginTime = info.BeginTime.ToString()
					});
				}

				foreach(DineInfoHistory info in list) {
					infoList.Add(new HistoryDineInfoModel() {
						CheckID = info.CheckID,
						BeginTime = info.BeginTime.ToString()
					});
				}

				return Json(infoList);
			}
		}
Exemplo n.º 19
0
		public JsonResult GetSetMeal() {
			using(MrCyContext ctx = new MrCyContext()) {
				List<MenuSet> setList = ctx.MenuSet.ToList();
				return Json(setList);
			}
		}
Exemplo n.º 20
0
		public ContentResult Submit(SubmitViewModel model) {
			DineTempInfo dti;
			int id;
			using(MrCyContext ctx = new MrCyContext()) {
				string client = null;
				if(User.Identity.IsAuthenticated) {
					client = User.Identity.Name;
				}
				dti = new DineTempInfo() {
					ClientID = client,
					DeskID = model.Table.DeskId,
					Roomid = model.Table.RoomId,
					peoplecount = (short)model.Customer,
					IsPaid = 0,
					PayKind = model.PayKind,
					Subtotal = (decimal)model.PriceAll,
					Invoice = model.Bill
				};
				ctx.DineTempInfo.Add(dti);
				ctx.SaveChanges();
				id = dti.AutoID;
				foreach(SubmitMenuDetail menu in model.Results) {
					string note = "";
					if(menu.Additional.Notes != null) {
						foreach(Note n in menu.Additional.Notes) {
							note += (n.Note1 + " ");
						}
					}
					DineTempDetail dtd = new DineTempDetail() {
						AutoID = dti.AutoID,
						DisherID = menu.DisherId,
						DisherNum = menu.Additional.Ordered,
						DisherPrice = (decimal)menu.DisherPrice,
						Note = note,
						SalesDiscount = menu.DisherDiscount
					};
					ctx.DineTempDetail.Add(dtd);
					// 增加已点人数
					MenuDetail m = ctx.MenuDetail.FirstOrDefault(p => p.DisherId == menu.DisherId);
					if(m.DisherPoint == null) {
						m.DisherPoint = 1;
					}
					else {
						m.DisherPoint++;
					}
					ctx.Entry<MenuDetail>(m).Property(p => p.DisherPoint).IsModified = true;
				}
				ctx.SaveChanges();

				DeskInfo d = ctx.DeskInfo.Where(p => p.DeskId == model.Table.DeskId).FirstOrDefault();
				d.Status = 1;
				ctx.Entry<DeskInfo>(d).Property(p => p.Status).IsModified = true;
				ctx.SaveChanges();

			}
			Session["savedMenu"] = model;
			Session["qrCode"] = model.Table.QRCode;

			string returnContent = "";
			if(model.PayKind == "支付宝") {

			}
			else if(model.PayKind == "微信支付") {
				
				log("send" + id.ToString());
				string hotelid = "";
				using(MrCyContext ctx = new MrCyContext()) {
					hotelid = ctx.BaseInfo.Where(p => p.InfoName == "HotelID").FirstOrDefault().InfoContent;
				}
				returnContent = String.Format(
					"http://www.choice.shu.edu.cn/weixin/Send.aspx?price={0}&hotelid={1}&id={2}&rediret={3}",
					Convert.ToInt32(Convert.ToDouble(dti.Subtotal.ToString()) * 100),
					hotelid,
					id,
					ConfigurationManager.AppSettings["WeixinRedirectUrl"].ToString()
				);
				PayController.StartTimer(id, hotelid);


			}
			else if(model.PayKind == "现场支付") {
				try {
					string conn = System.Configuration.ConfigurationManager.ConnectionStrings["sqlString"].ConnectionString;
					new PrintDineMenu(conn).Print();
				}
				catch(Exception e) {
					FileStream fs = new FileStream("d:/dll.txt", FileMode.Append);
					StreamWriter sw = new StreamWriter(fs);
					sw.WriteLine(e);
					sw.Close();
				}
			}

			return Content(returnContent);
		}