Beispiel #1
0
        /// <summary>
        /// 我的订单
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public ActionResult MyOrder(int?page)
        {
            if (!OperateHelper.IsLogin())
            {
                return(View());
            }
            var model = BLLSession.IOrderService.GetListBy(m => m.UserID == CurrentUser.UserID).OrderByDescending(m => m.OrderID).ToList();

            return(View(model.ToPagedList(page ?? 1, 15)));
        }
Beispiel #2
0
        //
        // GET: /Admin/User/
        /// <summary>
        /// 我的消费
        /// </summary>
        /// <returns></returns>
        public ActionResult ExpendLog(int?page)
        {
            if (!OperateHelper.IsLogin())
            {
                return(View());
            }
            var model = BLLSession.IExpendLogService.GetListBy(m => m.UserID == CurrentUser.UserID).OrderByDescending(m => m.ExpendLogID);

            //剩余总金额
            ViewBag.RemainAmount = model.Sum(m => m.RechargeAmount) - model.Sum(m => m.ConsumeAmount);
            return(View(model.ToPagedList(page ?? 1, 15)));
        }
Beispiel #3
0
 public ActionResult RechargeAmount(Recharge model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             //开启事务,保证数据的一致性
             using (var scope = new TransactionScope())
             {
                 if (!OperateHelper.IsLogin())
                 {
                     return(JsonMsgNoOk("对不起,你没权限操作"));
                 }
                 if (!OperateHelper.User.IsAdmin)
                 {
                     return(JsonMsgNoOk("对不起,你没权限操作"));
                 }
                 var userModel = BLLSession.IUserService.GetModel(m => m.UserID == model.UserID);
                 //插入充值表
                 model.Status           = (int)RechargeStatusEnum.Succeed;
                 model.IsDel            = false;
                 model.CreateDate       = DateTime.Now;
                 model.OpeningBalance   = userModel.Amount;
                 model.CurrentBalance   = userModel.Amount + model.RechargeAmount;
                 model.RechargeUserName = "******";
                 BLLSession.IRechargeService.Add(model);
                 //更新用户剩余金额
                 userModel.Amount = model.CurrentBalance;
                 BLLSession.IUserService.ModifyModel(userModel);
                 //插入数据到消费流水表
                 BLLSession.IExpendLogService.Add(new ExpendLog()
                 {
                     UserID          = model.UserID,
                     ConsumeAmount   = 0,
                     RechargeAmount  = model.RechargeAmount,
                     CreateDate      = DateTime.Now,
                     ExpendLogTypeID = model.RechargeID,
                     ExpendLogType   = (int)ExpendLogTypeEnum.Recharge,
                     Description     = "充值完成增加金额"
                 });
                 scope.Complete();//提交事务
             }
             return(JsonMsgOk("充值成功"));
         }
         catch (Exception ex)
         {
             return(JsonMsgNoOk(ex.Message));
         }
     }
     return(JsonMsgNoOk("充值失败,信息填写有误"));
 }
Beispiel #4
0
        public ActionResult UpdateUserInfo()
        {
            if (!OperateHelper.IsLogin())
            {
                return(View());
            }

            var userInfo = BLLSession.IUserService.GetListBy(m => m.UserID == CurrentUser.UserID).FirstOrDefault();
            UpdateUserInfoModel model = new UpdateUserInfoModel();

            model.UserName       = userInfo.UserName;
            model.DepartmentType = userInfo.DepartmentType;
            return(View(model));
        }
Beispiel #5
0
        public ActionResult Feedback(string contentMsg)
        {
            if (string.IsNullOrEmpty(contentMsg))
            {
                return(JsonMsgNoOk("请填写反馈内容"));
            }
            Feedback model = new Feedback();

            model.ContentMsg = contentMsg;
            model.CreateTime = DateTime.Now;
            if (OperateHelper.IsLogin())
            {
                model.UserID = CurrentUser.UserID;
            }
            BLLSession.IFeedbackService.Add(model);
            return(JsonMsgOk("反馈成功"));
        }
Beispiel #6
0
        public ActionResult ResetPassword(int userID)
        {
            if (!OperateHelper.IsLogin())
            {
                return(JsonMsgNoOk("对不起,你没权限操作"));
            }
            if (!OperateHelper.User.IsAdmin)
            {
                return(JsonMsgNoOk("对不起,你没权限操作"));
            }
            var resetPassword = UEncypt.MD5("pp123456");

            BLLSession.IUserService.Modify(new Model.User()
            {
                UserID = userID, Password = resetPassword
            }, "Password");
            return(JsonMsgOk("重置密码成功,下次登陆生效"));
        }
Beispiel #7
0
        public ActionResult CheckOrder(string beginTime, string endTime, string userName)
        {
            try
            {
                if (!OperateHelper.IsLogin())
                {
                    return(JsonMsgNoOk("对不起,你没权限操作"));
                }
                if (!OperateHelper.User.IsAdmin)
                {
                    return(JsonMsgNoOk("对不起,你没权限操作"));
                }
                //当前只是在内存里过滤,修改的朋友,可以改为按条件过滤
                var modelOrder = BLLSession.IOrderService.GetListBy(m => true).ToList();
                if (!string.IsNullOrEmpty(beginTime))
                {
                    DateTime beginTime1 = DateTime.Parse(beginTime);
                    modelOrder = modelOrder.Where(m => m.CreateDate >= beginTime1).ToList();
                }
                if (!string.IsNullOrEmpty(endTime))
                {
                    DateTime endTime1 = DateTime.Parse(endTime);
                    modelOrder = modelOrder.Where(m => m.CreateDate <= endTime1).ToList();
                }
                if (!string.IsNullOrEmpty(userName))
                {
                    modelOrder = modelOrder.Where(m => m.User.UserName.Contains(userName)).ToList();
                }
                var orderIdList = modelOrder.Select(m => m.OrderID).ToList();

                var model = BLLSession.IOrderService.ModifyBy(new Order()
                {
                    OrderStatus = (int)OrderStatusEnum.Succeed
                }
                                                              , m => m.OrderStatus == (int)OrderStatusEnum.Handle && orderIdList.Contains(m.OrderID)
                                                              , new string[] { "OrderStatus" });

                return(JsonMsgOk());
            }
            catch (Exception ex)
            {
                return(JsonMsgErr(ex.Message));
            }
        }
Beispiel #8
0
 public ActionResult ChangePassword(ChangePasswordViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (!OperateHelper.IsLogin())
         {
             return(JsonMsgNoOk("请先登陆"));
         }
         var oldPassword = UEncypt.MD5(model.OldPassword);
         var newModel    = BLLSession.IUserService.GetListBy(m => m.UserID == OperateHelper.User.UserID && m.Password == oldPassword).FirstOrDefault();
         if (newModel != null)
         {
             newModel.Password = UEncypt.MD5(model.NewPassword);
             BLLSession.IUserService.ModifyModel(newModel);
             return(JsonMsgOk("修改密码成功,下次登陆生效"));
         }
         return(JsonMsgErr("原密码错误"));
     }
     return(JsonMsgErr("修改密码失败,请联系管理员"));
 }
Beispiel #9
0
        public ActionResult Publish(SarcasmViewModel model)
        {
            if (!OperateHelper.IsLogin())
            {
                return(RedirectToAction("Login", "Account", new { ReturnUrl = Url.Action("Publish") }));
            }
            if (ModelState.IsValid)
            {
                Sarcasm sarcasmModel = new Sarcasm();
                sarcasmModel.Content    = model.Content;
                sarcasmModel.CreateDate = DateTime.Now;
                sarcasmModel.IsDel      = false;
                //2为匿名用户
                sarcasmModel.UserID = (model.Type == 2) ? 2 : CurrentUser.UserID;

                BLLSession.ISarcasmService.Add(sarcasmModel);
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Beispiel #10
0
        public ActionResult Comment(int sarcasmID, string content)
        {
            if (!OperateHelper.IsLogin())
            {
                return(JsonMsgNoOk("请先登陆"));
            }
            if (content == null || sarcasmID == 0)
            {
                return(JsonMsgNoOk("请填写评论内容"));
            }

            Comment model = new Model.Comment();

            model.Content    = content;
            model.CreateTime = DateTime.Now;
            model.IsDel      = false;
            model.SarcasmID  = sarcasmID;
            model.UserID     = CurrentUser.UserID;
            BLLSession.ICommentService.Add(model);


            //获取当前吐槽所有的评论
            var CurCommentList = BLLSession.ICommentService.GetListBy(m => m.SarcasmID == sarcasmID && !m.IsDel);
            var UserIDs        = CurCommentList.Select(m => m.UserID).Distinct();
            var UserList       = BLLSession.IUserService.GetListBy(m => UserIDs.Contains(m.UserID));

            var CommnetList = (from a in CurCommentList
                               join c in UserList on a.UserID equals c.UserID
                               select new
            {
                a.Content,
                CreateTime = a.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                c.UserName
            }).OrderByDescending(m => m.CreateTime).ToList();

            return(JsonMsgOk("评论成功", null, JsonConvert.SerializeObject(CommnetList)));
        }
Beispiel #11
0
 public ActionResult OrderCancel(int id)
 {
     try
     {
         if (!OperateHelper.IsLogin())
         {
             return(JsonMsgNoOk("对不起,请先登陆"));
         }
         if (!OperateHelper.User.IsAdmin)
         {
             return(JsonMsgNoOk("对不起,你没权限操作,请找系统管理员"));
         }
         var isSucceed = BLLSession.IOrderService.OrderCancel(id);
         if (isSucceed)
         {
             return(JsonMsgOk("取消成功", "/Admin/Restaurant"));
         }
         return(JsonMsgNoOk("取消失败,该订单状态已变更,请刷新页面重试"));
     }
     catch (Exception ex)
     {
         return(JsonMsgNoOk(ex.Message));
     }
 }
Beispiel #12
0
        public ActionResult Add(Order model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var isDo         = true;
                    var doOrderValue = BLLSession.IConfigService.GetModel(m => m.ConfigName == "DoOrder").ConfigValue;
                    if (doOrderValue != null)
                    {
                        var doOrderModel = JsonConvert.DeserializeObject <ConfigDoOrderViewModel>(doOrderValue);
                        if (doOrderModel.DoTime == DateTime.Now.ToShortDateString())
                        {
                            isDo = doOrderModel.IsDo;
                        }
                    }
                    if (!isDo)
                    {
                        return(JsonMsgNoOk("订餐已停止,系统关闭中"));
                    }

                    //开启事务,保证数据的一致性
                    using (var scope = new TransactionScope())
                    {
                        if (!OperateHelper.IsLogin())
                        {
                            return(JsonMsgNoOk("请先登陆"));
                        }
                        var userModel = BLLSession.IUserService.GetModel(m => m.UserID == OperateHelper.User.UserID);

                        if (userModel.Amount < model.TotalPrice)
                        {
                            return(JsonMsgNoOk("当前余额为" + userModel.Amount + "元,余额不足,请先充值"));
                        }
                        //插入数据到订单
                        model.UserID     = OperateHelper.User.UserID;
                        model.TotalCount = 1;
                        model.CreateDate = DateTime.Now;
                        model.IsDel      = false;
                        model.Version    = 1;
                        var result = BLLSession.IOrderService.Add(model);
                        //更新用户剩余金额
                        userModel.Amount = userModel.Amount - model.TotalPrice;
                        BLLSession.IUserService.ModifyModel(userModel);
                        //插入数据到消费流水表
                        BLLSession.IExpendLogService.Add(new ExpendLog()
                        {
                            UserID          = CurrentUser.UserID,
                            ConsumeAmount   = model.TotalPrice,
                            RechargeAmount  = 0,
                            CreateDate      = DateTime.Now,
                            ExpendLogTypeID = model.OrderID,
                            ExpendLogType   = (int)ExpendLogTypeEnum.Order,
                            Description     = "订餐完成消耗金额"
                        });
                        scope.Complete();//提交事务
                    }
                    return(JsonMsgOk("下单成功", "/Order/Index"));
                }
                catch (Exception ex)
                {
                    return(JsonMsgNoOk(ex.Message));
                }
            }
            return(JsonMsgNoOk("下单失败"));
        }