Ejemplo n.º 1
0
        //       public ActionResult Quick(string id, string name) {
        //           Guid OrderId = this.SaveOrders("Insert", name);
        //              CrmMemberModel cdb = new CrmMemberModel();
        //           List<CrmMember> crm = cdb.getCrmMemberListInfoData(name);
        //           if (OrderId != new Guid("00000000-0000-0000-0000-000000000000")){
        //// /book/book?MemberCardNo=@(ViewBag.MemberCardNo)&OrderId=@(ViewBag.OrderId)&SourceAccountId=@(ViewBag.SourceAccountId)
        //             return RedirectToAction("book","book", new { MemberCardNo = crm.First().Uid, OrderId = OrderId,SourceAccountId=name });
        //           }
        //               return View();
        //       }
        public Guid SaveOrders(string type, string SourceAccountId, string bookTime = null, string isQuick = null, string peopleCont = null, string Remark = null, string OrderId = null)
        {
            int i;
            try
            {

                Session["SourceAccountId"] = SourceAccountId;
                OrderModel odm = new OrderModel();
                CrmMemberModel cdb = new CrmMemberModel();
                List<CrmMember> crm = cdb.getCrmMemberListInfoData(SourceAccountId);
                Order order = null;
                Order FastFoodOrder = null;
                Order info = new Order();

                //isQuick=="Quick" 表明此订单为快捷预定  isQuick==null表明为预定订单  isQuick=Auto 表明是智能点餐
                if (string.IsNullOrEmpty(isQuick))
                {

                    order = odm.SelectUnFinishedOrder(crm.First().Uid);
                }
                else
                {

                    FastFoodOrder = odm.SelectUnFinishedFastFoodOrder(crm.First().Uid);
                }

                if (order != null)
                {
                    type = "Update";
                    //  i = odm.SaveOrders(type, info);

                    return order.Id;

                }
                else if (FastFoodOrder != null)
                {

                    type = "UpdateFastFood";
                    info.CreateDate = DateTime.Now;
                    if (string.IsNullOrEmpty(OrderId))
                    {
                        info.Id = Guid.NewGuid();
                    }
                    else
                    {
                        info.Id = new Guid(OrderId);
                    }
                    info.Remark = Remark;
                    i = odm.SaveOrders(type, info);
                    return FastFoodOrder.Id;
                }

            //if ((order!=null&&order.Count > 0)||(FastFoodOrder != null && FastFoodOrder.Count > 0))
                //{
                //    type = "Update";
                //   // i = odm.SaveOrders(type, info);

            //    return order.First().Id;

            //}
                else
                {
                    info.Id = Guid.NewGuid();
                    //info.Id = crm.First().Uid;
                    info.ContactName = string.IsNullOrEmpty(crm.First().MemberName) ? "" : crm.First().MemberName;
                    info.ContactPhone = crm.First().Tel;
                    info.MemberCardNo = crm.First().Uid;
                    info.OperatorId = Guid.NewGuid();//new Guid("6E4DE867-4AF0-2DEA-FC5C-036EB8637CAB")
                    info.OperatorName = "xxx";
                    info.CreateDate = DateTime.Now;
                    if (!string.IsNullOrEmpty(isQuick) && isQuick == "FastFood")
                    {
                        info.DiningDate = string.IsNullOrEmpty(bookTime) ? DateTime.Now : Convert.ToDateTime(bookTime);
                        //if (!string.IsNullOrEmpty(bookTime))
                        //{
                        //    info.DiningDate = Convert.ToDateTime(bookTime);
                        //}
                        //else {
                        //    info.DiningDate = Convert.ToDateTime("1997-10-1");
                        //}
                    }
                    else if (!string.IsNullOrEmpty(isQuick) && isQuick == "Auto")
                    {
                        info.PersonCount = Convert.ToInt32(peopleCont);
                        info.DiningDate = DateTime.Now;
                        //info.DiningDate = string.IsNullOrEmpty(bookTime) ? DateTime.Now : Convert.ToDateTime(bookTime);

                    }
                    else
                    {
                        info.DiningDate = string.IsNullOrEmpty(bookTime) ? DateTime.Now : Convert.ToDateTime(bookTime);

                    }

                    info.Status = OrderStatus.New;
                    info.ReserveType = "01";
                    string RestaurantId = Session["begindm"] != null ? Session["begindm"].ToString() : "";
                    if (!string.IsNullOrEmpty(RestaurantId))
                    {
                        info.RstId = new Guid(RestaurantId);
                    }
                    else
                    {
                        info.RstId = Guid.NewGuid();
                    }
                    i = odm.SaveOrders(type, info);
                    //ViewBag.MemberCardNo = info.MemberCardNo;
                    //ViewBag.OrderId = info.Id;
                }
                if (i == 1)
                {

                    return info.Id;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return new Guid("00000000-0000-0000-0000-000000000000");
            }

            return new Guid("00000000-0000-0000-0000-000000000000");
        }
Ejemplo n.º 2
0
        //
        // GET: /Order/
        //public ActionResult Index(string SourceAccountId, string RestaurantId, string Status = null, string Date = null, string Time = null, string Type = null)
        //{
        //    if (Date != null & Time != null)
        //    {
        //        if (Time.Equals("0"))
        //        {
        //            DateTime data = Convert.ToDateTime(Date);
        //            data = data.AddHours(9);
        //            ViewBag.BookTime = data;
        //        }
        //        else if (Time.Equals("1"))
        //        {
        //            DateTime data = Convert.ToDateTime(Date);
        //            data = data.AddHours(16);
        //            ViewBag.BookTime = data;
        //        }
        //    }
        //    OrderModel odb = new OrderModel();
        //    ViewBag.ProductListData = odb.getProductListInfoData(RestaurantId);
        //    Session["begindm"] = RestaurantId;
        //    ViewBag.SourceAccountId = SourceAccountId;
        //    ViewBag.RestaurantId = RestaurantId;
        //    ViewBag.Status = Status;
        //    ViewBag.RstType = Type;
        //    CrmMemberModel cdb = new CrmMemberModel();
        //    if (SourceAccountId != null && SourceAccountId != "")
        //    {
        //        List<CrmMember> crm = cdb.getCrmMemberListInfoData(SourceAccountId);
        //        ViewBag.MemberCardNo = crm.First().Uid;
        //        string MemberCardNo = crm.First().Uid;
        //        OrderModel odm = new OrderModel();
        //        List<Order> order = null;
        //        List<FastFoodOrder> FastFoodOrder = null;
        //        if (!string.IsNullOrEmpty(Type) && Type == "FastFood")
        //        {
        //            FastFoodOrder = odm.selOrderByMemberId(crm.First().Uid);
        //        }
        //        else { order = odm.SelUnFinValidOrder(crm.First().Uid); }
        //        string OrderId = "";
        //        if ((order != null && order.Count > 0) || (FastFoodOrder != null && FastFoodOrder.Count > 0))
        //        {
        //            ViewBag.OrderId = order.First().Id;
        //            OrderId = order.First().Id.ToString();
        //            /* 显示用户已点菜数量*/
        //            MyMenuModel myMenu = new MyMenuModel();
        //            List<MyMenu> mymenu = myMenu.getMyMenuListData(MemberCardNo, OrderId);
        //            ViewBag.MyMenuListData = mymenu;
        //        }
        //    }
        //    return View();
        //}
        public ActionResult Begin(string id, string name, string type = null, string CityId = null, string CityName = null)
        {
            try
            {
                Session["SourceAccountId"] = name;
                Session["CompanyId"] = id;
                ViewBag.CompanyId = id;
                OrderModel odm = new OrderModel();
                CrmMemberModel cdb = new CrmMemberModel();
                List<CrmMember> crm = cdb.getCrmMemberListInfoData(name);
                ViewBag.MemberCardNo = crm.First().Uid;

                Session["CrmMember"] = crm.First();

                //  Session["MemberCardNo"] = crm.First().Uid;
                if (!string.IsNullOrEmpty(CityName)) { ViewBag.cityName = CityName; }

                //根据type来判断是否是快捷预定(Quick)或智能点餐(Auto)
                if (string.IsNullOrEmpty(type) && type != "Quick" && type != "Auto")
                {
                    //判断该用户在该店面预定的时间是否小于当前时间,如果是,弹出“我的订单”选择“修改”
                    //或者“新预定”框体。修改默认显示当前订单内容   如果订单是未完成状态则直接跳转到点餐页面

                    //  ViewBag.CompanyId = id;

                    Order info = new Order();
                    Order unFinishedOrder = odm.SelectUnFinishedOrder(crm.First().Uid);
                    int status = 0;
                    if (unFinishedOrder != null)
                    {
                        DateTime bookTime = unFinishedOrder.DiningDate;

                        if (DateTime.Now < bookTime.AddHours(5))
                        {
                            ViewBag.RecOrder = 1;
                            status = 1;
                            //return RedirectToAction("MY", "Order", new { id = id, name = name });
                        }
                    }
                    if (status != 1)
                    {
                        Order paidOrder = odm.SelectPaidOrder(crm.First().Uid);
                        ViewBag.isCurTime = 0;
                        if (paidOrder != null)
                        {
                            DateTime bookTime = paidOrder.DiningDate;

                            if (DateTime.Now < bookTime)
                            {
                                ViewBag.isCurTime = 1;

                            }
                        }
                    }
                }
                Order FastFoodOrder = null;

                //如果为自动点餐和快捷点餐。如果还有未过期的订单则跳转到订单详情 ViewBag.AutoOrderCount=1 有订单
                ViewBag.AutoOrderCount = 0;
                if (!string.IsNullOrEmpty(type) && (type == "Auto" || type == "Quick"))
                {

                    FastFoodOrder = odm.SelectUnFinishedFastFoodOrder(crm.First().Uid);
                    if (FastFoodOrder != null)
                    {
                        ViewBag.AutoOrderCount = 1;
                        ViewBag.OrderId = FastFoodOrder.Id;
                    }
                }

                string dm = Session["begindm"] != null ? Session["begindm"].ToString() : "";
                // if (string.IsNullOrEmpty(dm))
                //  {

                //  List<RestaurantAbstract> p = null;
                // object obj = System.Web.HttpRuntime.Cache.Get("id" + id);
                // if (obj != null)
                // {
                //   p = obj as List<RestaurantAbstract>;
                // }
                // if (p == null)
                // {
                RestaurantModel rdb = new RestaurantModel();
                //CityId = string.IsNullOrEmpty(CityId) ? "510100" : CityId;
                List<RestaurantAbstract> p = rdb.getRestaurentState(id);
                // System.Web.HttpRuntime.Cache.Add("id" + id, p, null, DateTime.Now.AddHours(2),
                // TimeSpan.Zero, CacheItemPriority.Normal, null);
                //  }
                ViewBag.SourceAccountId = name;
                ViewBag.type = type;
                return View(p);
                // }
                //  return RedirectToAction("Index","Order", new { SourceAccountId = id, RestaurantId = dm });
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return Content("页面加载错误");
            }
        }
Ejemplo n.º 3
0
        //
        // GET: /Product/
        public ActionResult getProductByProductTypeId(string RestaurantId, string ProductTypeId, string SourceAccountId, string Status, string Type = null)
        {
            List<ProductNew> p = null;
            //object obj = System.Web.HttpRuntime.Cache.Get("ProductType" + ProductTypeId);

            //if (obj != null)
            //{
            //    p = obj as List<ProductNew>;
            //}
            //if (p == null)
            //{
            ProductModel pm = new ProductModel();
            p = pm.getProductByProductTypeId(RestaurantId, ProductTypeId);
            //  System.Web.HttpRuntime.Cache.Add("ProductType" + ProductTypeId, p, null, DateTime.Now.AddHours(2),
            //  TimeSpan.Zero, CacheItemPriority.Normal, null);
            //}
            CrmMemberModel cdb = new CrmMemberModel();
            if (SourceAccountId != null && SourceAccountId != "")
            {
                List<CrmMember> crm = cdb.getCrmMemberListInfoData(SourceAccountId);
                ViewBag.MemberCardNo = crm.First().Uid;
                string MemberCardNo = crm.First().Uid;
                OrderModel odm = new OrderModel();
                Order order = null;
                Order FastFoodOrder = null;
                //Type == "FastFood"表明此店为快餐店。
                if (!string.IsNullOrEmpty(Type) && Type == "FastFood")
                {

                    FastFoodOrder = odm.SelectUnFinishedFastFoodOrder(crm.First().Uid);
                }
                else
                {
                    order = odm.SelectUnFinishedOrder(crm.First().Uid);
                }

                string OrderId = "";
                if (order != null || FastFoodOrder != null)
                {
                    OrderId = order != null ? order.Id.ToString() : FastFoodOrder.Id.ToString();
                    ViewBag.OrderId = OrderId;
                    /* 显示用户已点菜数量*/
                    MyMenuModel myMenu = new MyMenuModel();
                    List<MyMenu> mymenu = myMenu.getMyMenuListData(MemberCardNo, OrderId, Type);
                    ViewBag.MyMenuListData = mymenu;
                }
            }
            ViewBag.Status = Status;
            return View(p);
        }