/// <summary> /// 修改奖品 /// </summary> /// <param name="model"></param> /// <returns></returns> public TResult UpdatePrize(PrizeDto model) { TResult result = new TResult(); try { var tbl_WeiXinPrize = _prizeRepository.Get(model.Id); if (tbl_WeiXinPrize == null) { return(result.FailureResult()); } tbl_WeiXinPrize.Name = model.Name; tbl_WeiXinPrize.PrizeName = model.PrizeName; tbl_WeiXinPrize.PrizeProbability = model.PrizeProbability; tbl_WeiXinPrize.Money = model.Money; tbl_WeiXinPrize.PrizeType = model.PrizeType; tbl_WeiXinPrize.Stock = model.Stock; tbl_WeiXinPrize.IsEnable = model.IsEnable; tbl_WeiXinPrize.MinUseAmount = model.MinUseAmount; tbl_WeiXinPrize.StartDate = model.StartDate; tbl_WeiXinPrize.EndDate = model.EndDate; _prizeRepository.Update(tbl_WeiXinPrize); return(result.SuccessResult()); } catch { return(result.FailureResult()); } }
public TResult Print(string orderNo, string printKey) { var result = new TResult(); try { var printConfigData = _printGateway.Get(printKey); if (printConfigData == null) { return(result.FailureResult("打印机编号不存在,请进行补打")); } var tbl_Order = _orderService.Get(orderNo); if (tbl_Order == null) { return(result.FailureResult("订单不存在")); } var tbl_Scenic = _scenicService.Get(tbl_Order.ScenicId); var tbl_OrderDetails = _orderDetailService.GetList(orderNo); foreach (var row in tbl_OrderDetails) { Print(printConfigData, tbl_Scenic, row); } return(result.SuccessResult()); } catch (Exception e) { return(result.FailureResult("打印系统繁忙,请稍后进行补打.")); } }
public TResult <LoginUser> Login(UserLoginModel userLoginModel) { var result = new TResult <LoginUser>(); var code = HttpContext.Current.Request.Cookies[SessionKey.ManagerUserLoginCode]; if (code == null || (string.IsNullOrEmpty(code.Value))) { return(result.FailureResult(null, "验证码已过期,请重新输入验证码!")); } if (!String.Equals(code.Value, userLoginModel.Code.Trim(), StringComparison.CurrentCultureIgnoreCase)) { return(result.FailureResult(null, "请输入正确的验证码!")); } var passWord = Md5HashHelper.HashPassword(userLoginModel.PassWord + SessionKey.CloudUserInfo); var adminUser = _otaBusinessUserService.Get(userLoginModel.UserName, passWord); if (adminUser == null) { return(result.FailureResult(null, "用户名或密码不正确!")); } //adminUser.LastLoginTime = DateTime.Now; //_otaBusinessUserService.Update(adminUser); var businesss = _otaBusinessService.Get(adminUser.OtaBusinessId); var userInfo = new LoginUser { Id = adminUser.Id, OtaBusinessId = adminUser.OtaBusinessId, UserName = adminUser.UserName, RealName = businesss.FullName }; HttpContext.Current.Session[SessionKey.ManagerUserInfo] = userInfo; return(result.SuccessResult(userInfo, "登陆成功")); }
/// <summary> /// 下移 /// </summary> /// <param name="id"></param> /// <returns></returns> public TResult MoveDown(int id) { TResult result = new TResult(); try { var nowBanner = _bannerRepository.Get(id); if (nowBanner == null) { return(result.FailureResult()); } var banner = _bannerRepository.GetOrderByOrFirst(a => a.Order > nowBanner.Order); if (banner == null) { return(result.FailureResult("当前已经是最后一位")); } int bannerOrder = banner.Order; banner.Order = nowBanner.Order; nowBanner.Order = bannerOrder; using (TransactionScope transaction = new TransactionScope()) { _bannerRepository.Update(nowBanner); _bannerRepository.Update(banner); _bannerRepository.SaveChanges(); transaction.Complete(); } return(result.SuccessResult("下移成功")); } catch { return(result.FailureResult()); } }
public TResult Print(int orderDetailId, string printKey) { var result = new TResult(); var printConfigData = _printGateway.Get(printKey); if (printConfigData == null) { return(result.FailureResult("打印机配置不正确")); } var tbl_OrderDetail = _orderDetailService.Get(orderDetailId); if (tbl_OrderDetail == null) { return(result.FailureResult("订单不存在")); } if ((tbl_OrderDetail.OrderStatus == (int)OrderDetailsDataStatus.Activate || tbl_OrderDetail.OrderStatus == (int)OrderDetailsDataStatus.IsTaken) && tbl_OrderDetail.ValidityDateEnd.Date >= DateTime.Now.Date) { var tbl_Scenic = _scenicService.Get(tbl_OrderDetail.ScenicId); var printResult = Print(printConfigData, tbl_Scenic, tbl_OrderDetail); if (!printResult.Success) { return(result.FailureResult(printResult.Message)); } return(result.SuccessResult()); } else { return(result.FailureResult("该订单,不能进行打印")); } }
/// <summary> /// 登录 /// </summary> /// <param name="model"></param> /// <returns></returns> public TResult <EnterpriseUser> Login(EnterpriseUserLoginModel UserModel) { var result = new TResult <EnterpriseUser>(); if (string.IsNullOrEmpty(UserModel.UserName) || string.IsNullOrEmpty(UserModel.PassWord)) { return(result.FailureResult(null, "用户名和密码不能为空!")); } if (string.IsNullOrEmpty(UserModel.Code)) { return(result.FailureResult(null, "请输入验证码!")); } var code = HttpContext.Current.Request.Cookies[SessionKey.ManagerUserLoginCode]; if (code == null || (string.IsNullOrEmpty(code.Value))) { return(result.FailureResult(null, "验证码已过期,请重新输入验证码!")); } if (!String.Equals(code.Value, UserModel.Code.Trim(), StringComparison.CurrentCultureIgnoreCase)) { return(result.FailureResult(null, "请输入正确的验证码!")); } var password = Md5HashHelper.HashPassword(UserModel.PassWord); //当前景区下未停用的售票员 var model = Get(UserModel.UserName, password); if (model != null) { //var tbl_Scenic = Repository.First<Tbl_Scenic>(a => a.ScenicId == model.ScenicId); //UserInfoDTO dto = new UserInfoDTO(model, (int)SystemType.Sale, tbl_Scenic.ScenicName); //model.LastLoginTime = DateTime.Now; //Repository.Update(model); var userInfo = new EnterpriseUser { UserId = model.EnterpriseUserId, UserName = model.UserName, RealName = model.RealName, ScenicId = model.ScenicId }; //设置Session HttpContext.Current.Session[SessionKey.UserInfo] = userInfo; //设置登录信息cookie 1天有效 HttpCookie hc = new HttpCookie(SessionKey.SaleUserLoginCookie); hc.Value = DesHelper.Encrypt(model.UserName + "|" + model.PassWord, SessionKey.ManagerUserLoginCookieKey); //设置cookie信息在第二天凌晨过期 //(用户每天都需要输入密码登录一次,而且不会出现,在某一天中间某一刻时间,突然cookie过期) hc.Expires = DateTime.Now.AddDays(1); HttpContext.Current.Response.Cookies.Add(hc); return(result.SuccessResult(userInfo, "登录成功")); } return(result.FailureResult(null, "用户名或密码错误")); }
/// <summary> /// 添加奖品 /// </summary> /// <param name="model"></param> /// <returns></returns> public TResult AddPrize(PrizeDto model) { TResult result = new TResult(); try { _prizeRepository.Add(new Tbl_Prize { Name = model.Name, PrizeName = model.PrizeName, PrizeProbability = model.PrizeProbability, Money = model.Money, PrizeType = model.PrizeType, Stock = model.Stock, IsEnable = model.IsEnable, MinUseAmount = model.MinUseAmount, StartDate = model.StartDate, EndDate = model.EndDate, CreateTime = DateTime.Now, CreateUserId = 0 }); return(result.SuccessResult()); } catch { return(result.FailureResult()); } }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); var controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName.ToLower(); var actionName = filterContext.ActionDescriptor.ActionName.ToLower(); if (controllerName == "login") { return; } var isAjaxRequst = filterContext.HttpContext.Request.IsAjaxRequest(); #region 验证登录 TResult result = new TResult(); if (UserInfo == null) { if (filterContext.HttpContext.Request.IsAjaxRequest()) { filterContext.Result = Json(result.FailureResult("登录失效,请刷新页面", "304"), JsonRequestBehavior.AllowGet); return; } filterContext.Result = new RedirectResult("/Login/Index"); return; } #endregion }
public TResult Add(OrderAddModel model) { var result = new TResult(); var ticketIds = model.TicketItem.Select(a => a.TicketId).ToList(); if (ticketIds.Count <= 0) { result.FailureResult("请选择您要购买的产品"); } var tickets = _ticketService.GetList(ticketIds); foreach (var row in model.TicketItem) { var ticket = tickets.First(a => a.TicketId == row.TicketId); row.TicketName = ticket.TicketName; row.Price = ticket.SalePrice; } try { _travelAgencyOrderService.BeginTran(); var order = _travelAgencyOrderService.Add(model); _travelAgencyOrderDetailService.Add(model, order); //提交事物 _travelAgencyOrderService.CommitTran(); } catch { _travelAgencyOrderService.RollbackTran(); } return(result.SuccessResult()); }
/// <summary> /// 保存抽奖配置信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public TResult UpdatePrizeConfig(PrizeConfigDto model) { TResult result = new TResult(); try { var tbl_WeiXinPrizeConfig = _prizeConfigRepository.FirstOrDefault(); if (tbl_WeiXinPrizeConfig == null) { _prizeConfigRepository.Add(new Tbl_PrizeConfig { Frequency = model.Frequency, IsEnable = model.IsEnable, StartDate = model.StartDate, EndDate = model.EndDate }); } else { tbl_WeiXinPrizeConfig.Frequency = model.Frequency; tbl_WeiXinPrizeConfig.IsEnable = model.IsEnable; tbl_WeiXinPrizeConfig.StartDate = model.StartDate; tbl_WeiXinPrizeConfig.EndDate = model.EndDate; _prizeConfigRepository.Update(tbl_WeiXinPrizeConfig); } return(result.SuccessResult("保存成功")); } catch { return(result.FailureResult("保存失败")); } }
protected override void OnException(ExceptionContext filterContext) { var exception = filterContext.Exception; var exceptionType = exception.GetType(); //对于Ajax请求,直接返回一个用于封装异常的JsonResult if (filterContext.HttpContext.Request.IsAjaxRequest()) { TResult result = new TResult(); if (exceptionType == typeof(SimpleBadRequestException)) { filterContext.Result = Json(result.FailureResult(exception.Message), JsonRequestBehavior.AllowGet); } else { filterContext.Result = Json(result.ErrorResult("服务器错误,请联系管理员!"), JsonRequestBehavior.AllowGet); } //当结果为json时,设置异常已处理 filterContext.ExceptionHandled = true; } else { //否则调用原始设置 base.OnException(filterContext); } }
public TResult Update(OrderDetailViewModel model) { var result = new TResult(); if (model.TicketItem.Count <= 0) { return(result.FailureResult("请选择您要购买的产品")); } var ticketIds = model.TicketItem.Select(a => a.TicketId).ToList(); if (ticketIds.Count <= 0) { result.FailureResult("请选择您要购买的产品"); } var tickets = _ticketService.GetTicketIds(ticketIds, model.ValidityDate); foreach (var row in model.TicketItem) { var ticket = tickets.First(a => a.TicketId == row.TicketId); row.TicketName = ticket.TicketName; row.Price = ticket.SalePrice; } var order = _travelAgencyOrderService.Get(model.Id); try { _travelAgencyOrderService.BeginTran(); _travelAgencyOrderService.Update(order, model); _travelAgencyOrderDetailService.Delete(order.OrderNo); _travelAgencyOrderDetailService.Add(new OrderAddModel { ValidityDate = model.ValidityDate, TicketItem = model.TicketItem }, order); //提交事物 _travelAgencyOrderService.CommitTran(); } catch { _travelAgencyOrderService.RollbackTran(); } return(result.SuccessResult()); }
public TResult UpdateIsEnable(int id) { TResult result = new TResult(); try { var banner = _bannerRepository.Get(id); if (banner == null) { return(result.FailureResult()); } banner.IsEnable = !banner.IsEnable; _bannerRepository.Update(banner); return(result.SuccessResult()); } catch { return(result.FailureResult()); } }
public TResult Delete(int id) { var result = new TResult(); var guide = _travelAgencyGuideRepository.FirstOrDefault(a => a.Id == id); if (guide == null) { return(result.FailureResult()); } _travelAgencyGuideRepository.Delete(guide); return(result.SuccessResult()); }
public TResult OrderCancel(int id) { var result = new TResult(); var order = _travelAgencyOrderService.Get(id); if (order.AuditStatus != (int)TraveAgencyAuditStatus.Audited) { return(result.FailureResult("已审核的订单,才能申请取消订单")); } _travelAgencyOrderService.UpdateForOrderCancel(order); return(result.SuccessResult()); }
protected override void OnException(ExceptionContext filterContext) { var exception = filterContext.Exception; var exceptionType = exception.GetType(); //对于Ajax请求,直接返回一个用于封装异常的JsonResult if (filterContext.HttpContext.Request.IsAjaxRequest()) { TResult result = new TResult(); if (exceptionType == typeof(SimpleBadRequestException)) { filterContext.Result = Json(result.FailureResult(exception.Message), JsonRequestBehavior.AllowGet); } else { filterContext.Result = Json(result.FailureResult("服务器错误,请联系管理员!"), JsonRequestBehavior.AllowGet); } //当结果为json时,设置异常已处理 filterContext.ExceptionHandled = true; } else { //ErrorMessage msg = new ErrorMessage(filterContext.Exception, "页面"); //msg.ShowException = MvcException.IsExceptionEnabled(); ////错误记录 ////设置为true阻止golbal里面的错误执行 //filterContext.ExceptionHandled = true; //filterContext.Result = new ViewResult() //{ // ViewName = "/Views/Error/ISE.cshtml", // ViewData = new ViewDataDictionary<ErrorMessage>(msg) //}; //否则调用原始设置 base.OnException(filterContext); } }
public TResult Update(UserUpdateModel model) { var result = new TResult(); var passWord = Md5HashHelper.HashPassword(model.PassWord + SessionKey.CloudUserInfo); var adminUser = _otaBusinessUserService.Get(model.UserName, passWord); if (adminUser == null) { return(result.FailureResult("旧密码不正确")); } adminUser.PassWord = Md5HashHelper.HashPassword(model.NowPassWord + SessionKey.CloudUserInfo); _otaBusinessUserService.Update(adminUser); return(result.SuccessResult()); }
/// <summary> /// 修改轮播图 /// </summary> /// <param name="model"></param> /// <returns></returns> public TResult Update(BannerDto model) { TResult result = new TResult(); try { var tbl_WeiXinBanner = _bannerRepository.Get(model.Id); if (tbl_WeiXinBanner == null) { return(result.FailureResult()); } tbl_WeiXinBanner.Title = model.Title; tbl_WeiXinBanner.ImgPath = model.ImgPath; tbl_WeiXinBanner.IsEnable = model.IsEnable; tbl_WeiXinBanner.Url = model.Url; _bannerRepository.Update(tbl_WeiXinBanner); return(result.SuccessResult()); } catch { return(result.FailureResult()); } }
public TResult Update(GuideUpdateModel model) { var result = new TResult(); var guide = _travelAgencyGuideRepository.FirstOrDefault(a => a.Id == model.Id); if (guide == null) { return(result.FailureResult()); } guide.Name = model.Name; guide.Mobile = model.Mobile; guide.IdCard = model.IdCard; guide.GuideType = model.GuideType; _travelAgencyGuideRepository.Update(guide); return(result.SuccessResult()); }
/// <summary> /// 保存积分 /// </summary> /// <param name="model"></param> /// <returns></returns> public TResult Save(IntegralConfigDto model) { var result = new TResult(); var list = _integralConfigRepository.GetList(); try { using (TransactionScope tran = new TransactionScope()) { SaveEverydayLogin(model, list); SaveRecharge(model, list); SaveConsumption(model, list); _integralConfigRepository.SaveChanges(); tran.Complete(); } return(result.SuccessResult()); } catch (Exception e) { //Logger.Info("微信会员积分保存失败:" + e.Message); return(result.FailureResult()); } }
public TResult Delete(int id) { var result = new TResult(); var order = _travelAgencyOrderService.Get(id); if (order.AuditStatus != (int)TraveAgencyAuditStatus.WaitAudit && order.AuditStatus != (int)TraveAgencyAuditStatus.Reject && order.AuditStatus != (int)TraveAgencyAuditStatus.OrderCancel) { return(result.FailureResult("待审核和审核驳回的订单,才能删除")); } try { _travelAgencyOrderService.BeginTran(); _travelAgencyOrderService.Delete(order); _travelAgencyOrderDetailService.Delete(order.OrderNo); //提交事物 _travelAgencyOrderService.CommitTran(); } catch { _travelAgencyOrderService.RollbackTran(); } return(result.SuccessResult()); }
/// <summary> /// 添加轮播图 /// </summary> /// <param name="model"></param> /// <returns></returns> public TResult Add(BannerDto model) { TResult result = new TResult(); try { var tbl_WeiXinBanner = _bannerRepository.GetOrderByDescendingOrFirst(); _bannerRepository.Add(new Tbl_Banner { ImgPath = model.ImgPath, Url = model.Url, Order = tbl_WeiXinBanner == null ? 1 : tbl_WeiXinBanner.Order + 1, Title = model.Title, IsEnable = model.IsEnable, CreateTime = DateTime.Now, CreateUserId = 0 }); return(result.SuccessResult()); } catch { return(result.FailureResult()); } }
/// <summary> /// 打印日结报表 /// </summary> /// <returns></returns> public TResult Daily(string printKey) { var result = new TResult(); var printConfigData = _printGateway.Get(printKey); if (printConfigData == null) { return(result.FailureResult("打印机配置不正确")); } var reportList = new ReportStatisticsModel { List = new List <TicketSaleCount>() }; var user = _enterpriseUserService.LoginForSession(); var nowDate = DateTime.Now.Date; var endTime = nowDate.AddDays(1); var list = _orderDetailRepository.db.Queryable <Tbl_OrderDetail, Tbl_Ticket, Tbl_Order, Tbl_TicketType>((a, b, c, d) => new object[] { JoinType.Left, a.TicketId == b.TicketId, JoinType.Inner, a.OrderNo == c.OrderNo, JoinType.Left, b.TypeId == d.Id }) .Where((a, b, c, d) => a.ScenicId == user.ScenicId && a.SellerId == user.UserId && c.SellerId == user.UserId && a.TicketSource == (int)TicketSourceStatus.ScenicSpot && a.CreateTime >= nowDate && a.CreateTime < endTime && ((a.OrderStatus == (int)OrderDetailsDataStatus.IsTaken) || (a.OrderStatus == (int)OrderDetailsDataStatus.Activate) || (a.OrderStatus == (int)OrderDetailsDataStatus.Consume) || (a.OrderStatus == (int)OrderDetailsDataStatus.Canncel) || (a.OrderStatus == (int)OrderDetailsDataStatus.Refund))) .Select((a, b, c, d) => new { OrderDtlId = a.OrderDetailId, TicketId = a.TicketId, TicketName = a.TicketName, TicketType = d.TicketType, OrderNo = a.OrderNo, PayType = (PayStatus)c.PayType, OrderType = a.OrderType, Price = a.Price, Quantity = a.Quantity, ShelvesChannel = b.ShelvesChannel, OrderStatus = a.OrderStatus, CreateTime = a.CreateTime }).ToList(); if (list.Count <= 0) { return(result.FailureResult("今天售卖门票数量为0,不能打印")); } var refundList = list.Where(p => p.OrderStatus == (int)OrderDetailsDataStatus.Refund).ToList(); var startData = list.OrderBy(a => a.CreateTime).FirstOrDefault(); var endData = list.OrderByDescending(a => a.CreateTime).FirstOrDefault(); PrintReportData printData = new PrintReportData { RealName = user.RealName, StartTime = startData.CreateTime.ToString("yyyy-MM-dd HH:dd:ss"), EndTime = endData.CreateTime.ToString("yyyy-MM-dd HH:dd:ss"), TotalCount = list.Sum(p => p.Quantity), TotalAmount = list.Sum(p => p.Quantity * p.Price), RefundTotalCount = refundList.Sum(p => p.Quantity), RefundTotalAmount = refundList.Sum(p => p.Quantity * p.Price), PrintBulkTicket = new PrintTicketList(), PrintTeamTicket = new PrintTicketList() }; var totalList = list.GroupBy(a => new { a.TicketId, a.TicketName, a.PayType, a.TicketType }).Select(a => new PrintTicketData { TicketId = a.Key.TicketId, TicketName = a.Key.TicketName, TotalCount = a.Sum(b => b.Quantity), TotalAmount = a.Sum(b => b.Quantity * b.Price), TicketType = a.Key.TicketType, PayType = (int)a.Key.PayType }).ToList(); //散客票 printData.PrintBulkTicket.Alipay = totalList.Where(p => p.PayType == (int)PayStatus.Alipay && p.TicketType == (int)ShelvesChannelEnum.IndividualTicket).ToList(); printData.PrintBulkTicket.ReadyMoney = totalList.Where(p => p.PayType == (int)PayStatus.ReadyMoney && p.TicketType == (int)ShelvesChannelEnum.IndividualTicket).ToList(); printData.PrintBulkTicket.Wechat = totalList.Where(p => p.PayType == (int)PayStatus.Wechat && p.TicketType == (int)ShelvesChannelEnum.IndividualTicket).ToList(); //团队票 printData.PrintTeamTicket.Alipay = totalList.Where(p => p.PayType == (int)PayStatus.Alipay && p.TicketType == (int)ShelvesChannelEnum.TeamTicket).ToList(); printData.PrintTeamTicket.ReadyMoney = totalList.Where(p => p.PayType == (int)PayStatus.ReadyMoney && p.TicketType == (int)ShelvesChannelEnum.TeamTicket).ToList(); printData.PrintTeamTicket.Wechat = totalList.Where(p => p.PayType == (int)PayStatus.Wechat && p.TicketType == (int)ShelvesChannelEnum.TeamTicket).ToList(); _printGateway.Send(printData, printConfigData); return(result.SuccessResult()); }