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