示例#1
0
        public ActionResult QuickOrder(string SourceAccountId, string RestaurantId, string Date = null, string Time = null)
        {
            string BookTime = "";

            if (Time.Equals("0"))
            {
                DateTime data = Convert.ToDateTime(Date);
                data     = data.AddHours(9);
                BookTime = data.ToString();
            }
            else if (Time.Equals("1"))
            {
                DateTime data = Convert.ToDateTime(Date);
                data     = data.AddHours(16);
                BookTime = data.ToString();
            }
            Session["begindm"] = RestaurantId;
            Guid OrderId = this.SaveOrders("Insert", SourceAccountId, BookTime, "Quick");

            ViewBag.isQuick = "Quick";
            CrmMemberModel   cdb = new CrmMemberModel();
            List <CrmMember> crm = cdb.getCrmMemberListInfoData(SourceAccountId);

            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 = SourceAccountId }));
            }
            return(View());
        }
示例#2
0
        /// <summary>
        /// 消费记录
        /// </summary>
        /// <param name="id">Uid</param>
        /// <param name="name">SourceAccountId</param>
        /// <param name="companyId">CompanyId</param>
        /// <returns></returns>
        public ActionResult ConsumptionRecords(string id, string name, string companyId)
        {
            List <PrepayRecord> p = null;

            try
            {
                Session["SourceAccountId"] = name;
                CrmMemberModel   cmm = new CrmMemberModel();
                List <CrmMember> crm = cmm.getCrmMemberListInfoData(name);
                ViewBag.PrepayAccount = 0;
                if (crm.Count() > 0)
                {
                    decimal dec = cmm.GetPrepayAccount(crm.First().Uid).AccountMoney;
                    ViewBag.PrepayAccount = dec;
                }
                ViewBag.Uid       = id;
                ViewBag.CompanyId = companyId;
                PrepayRecordModel prm = new PrepayRecordModel();
                p = prm.getConsumptionRecordsListInfoData(id);
            }
            catch
            {
            }
            finally
            {
            }

            return(View(p));
        }
        /// <summary>
        /// 订单详情(已付款)页面
        /// </summary>
        /// <returns></returns>

        public ActionResult Detail(string id, string name, string orderId)
        {
            var orderManager = new OrderManager();

            try
            {
                CrmMemberModel crmMemberModel = new CrmMemberModel();
                var            member         = crmMemberModel.getCrmMemberListInfoData(name).First();

                ViewBag.Uid             = member.Uid;
                ViewBag.SourceAccountId = name;

                Guid orderGuid = Guid.Empty;
                if (Guid.TryParse(orderId, out orderGuid))
                {
                    var detail = orderManager.GetOrderDetailById(orderGuid);

                    return(View(detail));
                }
                else
                {
                    return(Redirect("/"));
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(Redirect("/"));
            }
        }
示例#4
0
        public ActionResult Index2(string id, string name, string peopleCount, string Type, string CompanyId = null, string RstType = null, string IsOrder = null)
        {
            ViewBag.SourceAccountId = name;
            ViewBag.RestaurantId    = id;
            ViewBag.Type            = Type;
            ViewBag.peopleCount     = peopleCount;
            ViewBag.CompanyId       = CompanyId;
            //  Session["CompanyId"] = id;
            ViewBag.RstType = RstType;
            CrmMemberModel   cdb = new CrmMemberModel();
            List <CrmMember> crm = cdb.getCrmMemberListInfoData(name);

            ViewBag.MemberCardNo = crm.First().Uid;
            AutoMenusModel am           = new AutoMenusModel();
            string         RestaurantId = id;
            //判断此用户有没有有效的订单。如果有则显示有订单的菜。
            Order      FastFoodOrder = null;
            OrderModel odm           = new OrderModel();

            FastFoodOrder = odm.SelectUnFinishedFastFoodOrder(crm.First().Uid);
            if (FastFoodOrder != null)
            {
                //ViewBag.OrderId = FastFoodOrder.First().Id;
                // return View(FastFoodOrder);
                ViewBag.Orders = FastFoodOrder;
            }



            List <AutoMenuAndProduct> list = am.getAutoProduct(RestaurantId, peopleCount);

            Session["begindm"] = RestaurantId;
            return(View(list));
        }
        public ActionResult Join()
        {
            ActionResult result = null;

            var model = new JoinActivityModel();

            var userManager    = new UserManager();
            var orderManager   = new OrderManager();
            var crmMemberModel = new CrmMemberModel();

            var uid = userManager.GetUid(Constants.CompanyId, Request.Cookies["FromUserName"].Value);

            ViewBag.Uid = uid;
            PrepayRecord prepayRecord = crmMemberModel.HasJoinedOnlineVipGroup(uid);

            if (prepayRecord != null)
            {
                ViewBag.VerifyCode = prepayRecord.SId;

                result = View("Pass");
            }
            else
            {
                result = View(model);
            }


            return(result);
        }
        public JsonResult SubmitOrder(SubmitOrderEntity order)
        {
            string msg = string.Empty;

            try
            {
                CrmMemberModel cdb1 = new CrmMemberModel();

                if (string.IsNullOrEmpty(order.SourceAccountId))
                {
                    order.SourceAccountId = Session["SourceAccountId"] as string;
                }
                //var currentUser = cdb1.getCrmMemberListInfoData(order.SourceAccountId).FirstOrDefault();
                //decimal dec = cdb1.GetPrepayAccount(currentUser.Uid).AccountMoney;
                if (!SubmitOrderDBModel.UpdateOrderInfo(order))
                {
                    msg = "提交订单失败,请检查网络连接。如频繁不能提交,请联系客服";
                }
            }
            catch (Exception ex)
            {
                msg = "提交订单失败,请检查网络连接。如频繁不能提交,请联系客服";
                Logger.Log(LoggingLevel.Normal, ex);
            }
            return(Json(msg));
        }
示例#7
0
        public ActionResult member(string id, string name)
        {
            List <CrmMember> p   = null;
            CrmMemberModel   cdb = new CrmMemberModel();

            p = cdb.getCrmMemberListInfoData(name);
            ViewBag.SourceAccountId = name;
            ViewBag.CompanyId       = id;
            return(View(p));
        }
示例#8
0
        public ActionResult My(string id, string name)
        {
            ViewBag.CompanyId       = id;
            ViewBag.SourceAccountId = name;
            OrderModel       odm = new OrderModel();
            CrmMemberModel   cdb = new CrmMemberModel();
            List <CrmMember> crm = cdb.getCrmMemberListInfoData(name);
            //Order info = new Order();
            //List<Order> order = odm.selOrderId(crm.First().Uid);
            //List<FastFoodOrder> Quickorder = odm.selOrderByMemberId(crm.First().Uid);
            //string OrderId = "", QuickorderId="";
            //if (order.Count > 0 || Quickorder.Count>0)
            //{

            //    ViewBag.OrderId = order.First().Id;
            //    OrderId = order.First().Id.ToString();
            //    ViewBag.QuickorderId = order.First().Id;
            //    QuickorderId = order.First().Id.ToString();
            //    if (OrderId == null || OrderId == "" || QuickorderId == null || QuickorderId == "")
            //    {
            //        ViewBag.MyOrderListData = null;
            //        return View("myOrder");

            //    }
            string MemberCardNo = crm.First().Uid;

            ViewBag.MemberCardNo = crm.First().Uid;

            MyMenuModel odb = new MyMenuModel();

            List <MyOrder> myOrder      = odb.getMyOrderListData(MemberCardNo);
            List <MyOrder> myQuickOrder = odb.getMyOrderListData(MemberCardNo, "FastFood");

            if (myQuickOrder != null && myQuickOrder.Count > 0)
            {
                ViewBag.MyQuickOrderListData = myQuickOrder;
            }
            if (myOrder != null && myOrder.Count > 0)
            {
                ViewBag.MyOrderListData = myOrder;
            }
            //decimal sum = 0;
            //if (myOrder.Count > 0)
            //{
            //    for (int i = 0; i < myOrder.Count; i++)
            //    {
            //        sum += myOrder[i].UnitPrice*myOrder[i].;
            //    }
            //}
            //ViewBag.total = sum;
            //  }


            return(View("myOrder"));
        }
示例#9
0
        public ActionResult SaveMem(string CompanyId, string SourceAccountId, string id, string name, string phone, string sex, string bir, string addr)
        {
            Session["SourceAccountId"] = SourceAccountId;
            CrmMemberModel cdb = new CrmMemberModel();
            int            i   = cdb.Save(id, name, phone, sex, bir, addr);

            if (i == 1)
            {
            }
            return(RedirectToAction("Info", "Member", new { id = CompanyId, name = SourceAccountId }));
        }
示例#10
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));
        }
示例#11
0
        public ActionResult stage2(string RestaurantId, string ProductTypeId, string TypeName, string SourceAccountId, string Status, string Type = null, string imgid = null, string peopleCount = 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();
            List <CrmMember> crm = cdb.getCrmMemberListInfoData(SourceAccountId);

            ViewBag.MemberCardNo    = crm.First().Uid;
            ViewBag.TypeName        = TypeName;
            ViewBag.Type            = Type;
            ViewBag.imgid           = imgid;
            ViewBag.peopleCount     = peopleCount;
            ViewBag.SourceAccountId = SourceAccountId;
            ViewBag.RestaurantId    = RestaurantId;
            /* 显示用户已点菜数量*/
            OrderModel odm           = new OrderModel();
            Order      FastFoodOrder = null;

            ViewBag.OrderId = null;
            FastFoodOrder   = odm.SelectUnFinishedFastFoodOrder(crm.First().Uid);
            if (FastFoodOrder != null)
            {
                if (Type == "Auto")
                {
                    Type = "FastFood";
                }

                string OrderId = FastFoodOrder.Id.ToString();
                ViewBag.OrderId = FastFoodOrder.Id;
                /* 显示用户已点菜数量*/
                MyMenuModel   myMenu     = new MyMenuModel();
                List <MyMenu> myAutoMenu = myMenu.getMyMenuListData(crm.First().Uid, OrderId, Type);
                ViewBag.MyAutoMenuListData = myAutoMenu;
            }
            return(View(p));
        }
示例#12
0
        public override IResponseMessageBase OnEvent_UnsubscribeRequest(RequestMessageEvent_Unsubscribe requestMessage)
        {
            var responseMessage = base.CreateResponseMessage <ResponseMessageText>();

            responseMessage.Content = "有空再来";
            try
            {
                CrmMemberModel cdb = new CrmMemberModel();
                cdb.DiscardMember(requestMessage.FromUserName, Constants.CompanyId.ToString());
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
            return(responseMessage);
        }
示例#13
0
        /// <summary>
        /// 订阅(关注)事件
        /// </summary>
        /// <returns></returns>
        public override IResponseMessageBase OnEvent_SubscribeRequest(RequestMessageEvent_Subscribe requestMessage)
        {
            var strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();

            strongResponseMessage.Articles.Add(GetWelcomeInfo());
            try
            {
                CrmMemberModel cdb = new CrmMemberModel();
                cdb.SaveMember(requestMessage.FromUserName, Constants.CompanyId.ToString());
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
            return(strongResponseMessage);
        }
示例#14
0
        public ActionResult Info(string id, string name)
        {
            Session["SourceAccountId"] = name;
            CrmMember model = null;

            ViewBag.AccountMoney    = 0;
            ViewBag.Score           = 0;
            ViewBag.PresentMoney    = 0;
            ViewBag.CompanyId       = id;
            ViewBag.SourceAccountId = name;

            try
            {
                CrmMemberModel      cmModel  = new CrmMemberModel();
                CrmMemberScoreModel cmsModel = new CrmMemberScoreModel();

                if (!string.IsNullOrEmpty(name))
                {
                    model = cmModel.getCrmMemberListInfoData(name).FirstOrDefault();

                    var prepayAccount = cmModel.GetPrepayAccount(model.Uid);
                    var memberScore   = cmsModel.SelCrmMemberScoreInfo(model.Uid).FirstOrDefault();

                    if (prepayAccount != null)
                    {
                        ViewBag.AccountMoney = prepayAccount.AccountMoney;
                        ViewBag.PresentMoney = prepayAccount.PresentMoney;
                    }
                    if (memberScore != null)
                    {
                        ViewBag.Score = memberScore.Score;
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(View(model));
        }
示例#15
0
        public ActionResult getMemProducts(string id, string name)
        {
            ProductModel p = new ProductModel();

            ViewBag.Uid       = name;
            ViewBag.CompanyId = id;
            List <MemProduct> result = p.getMemProducts(id);

            ViewBag.PrepayAccount = 0;
            CrmMemberModel   cdb = new CrmMemberModel();
            List <CrmMember> crm = cdb.getCrmMemberListInfoData(name);

            if (crm.Count() > 0)
            {
                decimal dec = cdb.GetPrepayAccount(crm.First().Uid).AccountMoney;
                ViewBag.PrepayAccount = dec;
            }
            return(View(result));
        }
示例#16
0
        public ActionResult Index3(string id, string name, string peopleCount, string Type)
        {
            ViewBag.SourceAccountId = name;
            ViewBag.RestaurantId    = id;
            ViewBag.Type            = Type;
            ViewBag.peopleCount     = peopleCount;
            //  Session["CompanyId"] = id;

            CrmMemberModel   cdb = new CrmMemberModel();
            List <CrmMember> crm = cdb.getCrmMemberListInfoData(name);

            ViewBag.MemberCardNo = crm.First().Uid;
            AutoMenusModel am           = new AutoMenusModel();
            string         RestaurantId = id;

            List <AutoMenuAndProduct> list = am.getAutoProduct(RestaurantId, peopleCount);

            Session["begindm"] = RestaurantId;
            return(View(list));
        }
示例#17
0
        public ActionResult editMemberInfo(string id, string name)
        {
            List <CrmMember> p = null;

            try
            {
                CrmMemberModel cmm = new CrmMemberModel();
                p = cmm.getCrmMemberListInfoData(name);
                decimal dec = cmm.GetPrepayAccount(p.First().Uid).AccountMoney;
                ViewBag.PrepayAccount   = dec;
                ViewBag.SourceAccountId = name;
                ViewBag.CompanyId       = id;
            }
            catch
            { }
            finally
            { }

            return(View(p));
        }
示例#18
0
        public override IResponseMessageBase OnEvent_ClickRequest(RequestMessageEvent_Click requestMessage)
        {
            IResponseMessageBase reponseMessage = null;

            switch (requestMessage.EventKey)
            {
            case "BeginOrderClick":
            {
                var strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();
                strongResponseMessage.Articles.Add(new Article
                    {
                        Title       = "开始预定",
                        Description = "通过微信预订点餐",
                        PicUrl      = ImgUrl + "wxbeginorder.jpg",
                        Url         = string.Format(Constants.HostDomain + "/order/begin/" + Constants.CompanyId + "/{0}?type=Quick", requestMessage.FromUserName)
                    });
                reponseMessage = strongResponseMessage;
            }
            break;

            case "ActivityClick":
            {
                var    strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();
                string picUrl = Constants.HostDomain + "/NewContent/images/w.png";
                string uid    = "";

                try
                {
                    CrmMemberModel model = new CrmMemberModel();
                    uid = model.getCrmMemberListInfoData(requestMessage.FromUserName).FirstOrDefault().Uid;
                    var prepayAccount = model.GetPrepayAccount(uid);
                    if (prepayAccount != null && prepayAccount.AccountMoney > 0)
                    {
                        picUrl = Constants.HostDomain + "/NewContent/images/chu.png";
                    }
                }
                catch (Exception ex)
                {
                    LogException(ex);
                    uid = ex.StackTrace;
                }
                Article article = new Article();

                article.Title       = "小场合活动·微观时代";
                article.Description = "小场合活动·微观时代";
                article.PicUrl      = picUrl;
                article.Url         = string.Format(Constants.HostDomain + "/Jump/To?fromUserName={0}&url=/Activity/Index?activityState=1", requestMessage.FromUserName);

                strongResponseMessage.Articles.Add(article);

                reponseMessage = strongResponseMessage;
            }
            break;

            case "AccountInfoClick":
            {
                var    strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();
                string uid    = string.Empty;
                string picUrl = Constants.HostDomain + "/NewContent/images/w.png";;
                try
                {
                    CrmMemberModel model = new CrmMemberModel();
                    uid = model.getCrmMemberListInfoData(requestMessage.FromUserName).FirstOrDefault().Uid;
                    var prepayAccount = model.GetPrepayAccount(uid);
                    if (prepayAccount != null && prepayAccount.AccountMoney > 0)
                    {
                        picUrl = Constants.HostDomain + "/NewContent/images/chu.png";
                    }
                }
                catch (Exception ex)
                {
                    LogException(ex);
                    uid = ex.StackTrace;
                }
                strongResponseMessage.Articles.Add(new Article
                    {
                        Title       = "会员信息",
                        Description = "您的会员号:" + uid,
                        PicUrl      = picUrl,
                        Url         = string.Format(Constants.HostDomain + "/Member/Info/" + Constants.CompanyId + "/{0}", requestMessage.FromUserName)
                    });
                reponseMessage = strongResponseMessage;
            }
            break;

            case "VipPay":
            {
                string picUrl = Constants.HostDomain + "/NewContent/images/w.png";
                string uid    = "";

                try
                {
                    CrmMemberModel model = new CrmMemberModel();
                    uid = model.getCrmMemberListInfoData(requestMessage.FromUserName).FirstOrDefault().Uid;
                    var prepayAccount = model.GetPrepayAccount(uid);
                    if (prepayAccount != null && prepayAccount.AccountMoney > 0)
                    {
                        picUrl = Constants.HostDomain + "/NewContent/images/chu.png";
                    }
                }
                catch (Exception ex)
                {
                    LogException(ex);
                }
                var strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();

                DateTime     dt          = DateTime.Now.AddMinutes(-15);
                PrepayRecord rec         = new PrepayRecordModel().GetUserLastUnPaidComsumingPrepayRecordWithin5Minutes(requestMessage.FromUserName);
                string       description = string.Empty;
                string       title       = string.Empty;
                string       url         = "";

                if (rec != null)
                {
                    title       = "支付确认";
                    description = "您本次的消费:现金¥" + (0 - rec.PrepayMoney.Value).ToString() +
                                  "/赠送¥" + (0 - rec.PresentMoney.Value).ToString() +
                                  (rec.PayByScore > 0 ? "/积分" + rec.PayByScore.ToString() : "") +
                                  (rec.DiscountlMoeny > 0 ? ",本次优惠:" + rec.DiscountlMoeny.ToString() : "") +
                                  ",账单时间:" + rec.PrepayDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + ",点击本条消息,完成支付!";
                    url = string.Format(Constants.HostDomain + "/pay/payview/?id={0}&value={1}", requestMessage.FromUserName, rec.RecordId + "|" + DateTime.Now.Ticks);

                    strongResponseMessage.Articles.Add(new Article
                        {
                            Title       = title,
                            Description = description,
                            PicUrl      = picUrl,
                            Url         = url
                        });
                    reponseMessage = strongResponseMessage;
                }
                else
                {
                    description = "未查询到未结账单,可能原因为:\n1.您没有未结账单。\n2.您的账单还未生成。\n3.为保护您账号安全,您的生成的账单已经超期!";

                    var result = CreateResponseMessage <ResponseMessageText>();
                    result.Content = description;

                    reponseMessage = result;
                }
            }
            break;

            case "MyOrder":    //我的订单
            {
                var    strongResponseMessage = CreateResponseMessage <ResponseMessageNews>();
                string picUrl = Constants.HostDomain + "/NewContent/images/w.png";
                string uid    = "";

                try
                {
                    CrmMemberModel model = new CrmMemberModel();
                    uid = model.getCrmMemberListInfoData(requestMessage.FromUserName).FirstOrDefault().Uid;
                    var prepayAccount = model.GetPrepayAccount(uid);
                    if (prepayAccount != null && prepayAccount.AccountMoney > 0)
                    {
                        picUrl = Constants.HostDomain + "/NewContent/images/chu.png";
                    }
                }
                catch (Exception ex)
                {
                    LogException(ex);
                    uid = ex.StackTrace;
                }

                strongResponseMessage.Articles.Add(new Article
                    {
                        Title       = "我的订单",
                        Description = "我的订单:",
                        PicUrl      = picUrl,
                        Url         = string.Format(Constants.HostDomain + "/NewOrder/My/" + Constants.CompanyId + "/{0}", requestMessage.FromUserName)
                    });
                reponseMessage = strongResponseMessage;
            }
            break;

            case "CompanyInfo":    //成都印象餐饮有限公司
            {
                //TODO
            }
            break;

            case "Xiaochanghe":    //成都印象小场合
            {
                //TODO
            }
            break;

            case "Culture":    //小场合文化
            {
                //TODO
            }
            break;

            default:
            {
                var strongResponseMessage = CreateResponseMessage <ResponseMessageText>();
                strongResponseMessage.Content = "您点击了按钮,EventKey:" + requestMessage.EventKey;
                reponseMessage = strongResponseMessage;
            }
            break;
            }

            return(reponseMessage);
        }
        public ActionResult CancelOrder(string uid, string orderId, bool isEdit)
        {
            ActionResult result = Content("FAILED");

            try
            {
                bool success      = true;
                var  orderManager = new OrderManager();
                var  order        = orderManager.GetOrderSummary(Guid.Parse(orderId));

                if (order != null)
                {
                    OrderModel orderModel = new OrderModel();

                    using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                    {
                        PrepayRecordModel prepayRecordModel = new PrepayRecordModel();
                        CrmMemberModel    crmMemberModel    = new CrmMemberModel();

                        if (isEdit)
                        {
                            if (order.Status == OrderStatus.New)
                            {
                                success = orderModel.UpdateOrderStatus(Guid.Parse(orderId), OrderStatus.Cancelled);

                                var prepayRecord = prepayRecordModel.GetPrepayRecordByOrderId(orderId);

                                if (prepayRecord != null)
                                {
                                    //取消订单,支付失败
                                    prepayRecord.AsureDate = DateTime.Now;
                                    prepayRecord.RState    = "99";
                                    success = success && prepayRecordModel.UpdatePrepayRecord(prepayRecord);
                                }
                            }
                            else
                            {
                                success = false;
                            }
                        }
                        else
                        {
                            if (OrderStatus.Paid == order.Status)
                            {
                                PrepayRecord  prepayRecord    = null;
                                PrepayRecord  newPrepayRecord = null;
                                PrepayAccount prepayAccount   = null;

                                prepayAccount = crmMemberModel.GetPrepayAccount(uid);
                                prepayRecord  = prepayRecordModel.GetPrepayRecordByOrderId(orderId);

                                //已退款
                                prepayRecord.RState    = "02";
                                prepayRecord.AsureDate = DateTime.Now;

                                newPrepayRecord = new PrepayRecord();

                                newPrepayRecord.AddMoney       = -prepayRecord.AddMoney;
                                newPrepayRecord.AsureDate      = DateTime.Now;
                                newPrepayRecord.BillPayId      = Guid.NewGuid();
                                newPrepayRecord.DiscountlMoeny = 0;
                                newPrepayRecord.PayByScore     = 0;
                                newPrepayRecord.PayModel       = "02";
                                newPrepayRecord.PrepayDate     = DateTime.Now;
                                newPrepayRecord.PrepayMoney    = -0;
                                newPrepayRecord.PresentMoney   = 0;
                                newPrepayRecord.PromotionId    = 0;
                                newPrepayRecord.RecMoney       = 0;
                                newPrepayRecord.RecordId       = -1;
                                newPrepayRecord.RState         = "";
                                newPrepayRecord.RstId          = order.RestaurantId;
                                newPrepayRecord.ScoreVip       = 0;
                                newPrepayRecord.SId            = "";
                                newPrepayRecord.Uid            = uid;
                                newPrepayRecord.UserId         = "System";

                                prepayAccount.AccountMoney += newPrepayRecord.AddMoney.Value;
                                newPrepayRecord.PrepayDate  = DateTime.Now;
                                newPrepayRecord.AsureDate   = DateTime.Now;

                                success = orderModel.UpdateOrderStatus(Guid.Parse(orderId), OrderStatus.Refunded);
                                success = success && prepayRecordModel.AddPrepayRecord(newPrepayRecord);
                                success = success && crmMemberModel.UpdatePrepayAccount(prepayAccount);
                                success = success && prepayRecordModel.UpdatePrepayRecord(prepayRecord);
                            }
                            else
                            {
                                success = false;
                            }
                        }

                        if (success)
                        {
                            result = Content("SUCCESS");
                            scope.Complete();
                        }
                        else
                        {
                            result = Content("FAILED");
                            scope.Dispose();
                        }
                    }
                }
                else
                {
                    result = Content("FAILED");
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }

            return(result);
        }
示例#20
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"));
        }
示例#21
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("页面加载错误"));
            }
        }
        public ActionResult Join(JoinActivityModel model)
        {
            ActionResult result = null;

            try
            {
                var            verifyCodes    = new string[] { "M2J6", "N4W2", "YW45", "32KU", "L624", "8B8C", "92M2", "9P62", "C9X6", "527H", "5C32", "LP52", "5W2Q", "HK66", "67AM", "E6R3" };
                CrmMemberModel crmMemberModel = new CrmMemberModel();

                string uid = crmMemberModel.getCrmMemberListInfoData(Request.Cookies["FromUserName"].Value).First().Uid;

                PrepayRecord prepayRecord = crmMemberModel.HasJoinedOnlineVipGroup(uid);

                if (prepayRecord == null)
                {
                    if (ModelState.IsValid)
                    {
                        var pass = verifyCodes.FirstOrDefault(v => v.Equals(model.VerifyCode, StringComparison.OrdinalIgnoreCase));

                        if (pass != null)
                        {
                            #region 在这里面去给用户加钱

                            if (crmMemberModel.JoinOnlineVipGroup(uid, pass))
                            {
                                //验证功过并且钱加好了之后跳转到这个页面,让用户分享
                                ViewBag.VerifyCode = pass;
                                result             = View("Pass");
                            }

                            #endregion
                        }
                        else//验证失败
                        {
                            var famous = FamousManList[random.Next(FamousManList.Count)];

                            result = View("Failed", famous);
                        }
                    }
                    else
                    {
                        var famous = FamousManList[random.Next(FamousManList.Count)];

                        result = View("Failed", famous);
                    }
                }
                else
                {
                    ViewBag.VerifyCode = prepayRecord.SId;

                    var famous = FamousManList[random.Next(FamousManList.Count)];

                    result = View("Failed", famous);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                result = Content("页面加载出错");
            }

            return(result);
        }