public ResultMsg Delete(int id) { ResultMsg msg = new ResultMsg(); try { var posEndPoint = PosEndPointService.GetById(id); if (posEndPoint != null) { var shop = ShopService.GetById(posEndPoint.ShopId); Logger.LogWithSerialNo(LogTypes.PosDelete, SerialNoHelper.Create(), id, posEndPoint.Name, shop.Name); //AddMessage("delete.success", posEndPoint.Name, shop.Name); msg.Code = 1; msg.CodeText = "删除终端 " + posEndPoint.DisplayName + " 成功"; PosEndPointService.Delete(posEndPoint); CacheService.Refresh(CacheKeys.PosKey); } else { msg.CodeText = "不好意思,没有找到终端"; } return(msg); } catch (Exception ex) { msg.CodeText = "不好意思,系统异常"; Logger.Error("删除终端", ex); return(msg); } }
public ResultMsg Suspend(int id) { ResultMsg msg = new ResultMsg(); try { var posEndPoint = PosEndPointService.GetById(id); if (posEndPoint != null && posEndPoint.State == PosEndPointStates.Normal) { posEndPoint.State = PosEndPointStates.Invalid; PosEndPointService.Update(posEndPoint); var shop = ShopService.GetById(posEndPoint.ShopId); Logger.LogWithSerialNo(LogTypes.PosSuspend, SerialNoHelper.Create(), id, posEndPoint.Name, shop.Name); // AddMessage("suspend.success", posEndPoint.Name, shop.Name); msg.Code = 1; msg.CodeText = "停用终端 " + posEndPoint.DisplayName + " 成功"; CacheService.Refresh(CacheKeys.PosKey); } else { msg.CodeText = "不好意思,没有找到终端"; } return(msg); } catch (Exception ex) { msg.CodeText = "不好意思,系统异常"; Logger.Error("停用终端", ex); return(msg); } }
public void Ready() { var defaultPos = PosEndPointService.Query(new PosEndPointRequest()).FirstOrDefault(); if (defaultPos != null) { PosName = defaultPos.Name; } }
public void Ready() { var user = SecurityHelper.GetCurrentUser().CurrentUser; string posName = ""; // debug AdminUser adminUser = user as AdminUser; if (adminUser != null) { _sourceShopName = Constants.SystemShopName; var pos = this.PosEndPointService.GetByCurrentUserId(adminUser.UserId); if (pos == null) { Error = "请先创建终端,再进行交易!"; return; } posName = pos.Name; } ShopUser shopUser = user as ShopUser; if (shopUser != null) { var pos = PosEndPointService.Query(new PosEndPointRequest() { ShopId = shopUser.ShopId, State = PosEndPointStates.Normal }).FirstOrDefault(); if (pos == null) { Error = "请先创建终端,再进行交易!"; return; } var shop = ShopService.GetById(shopUser.ShopId); _sourceShopName = shop.Name; ShopName = shop.Name; posName = pos.Name; } // debug end IPasswordService passwordService = UnityContainer.Resolve <IPasswordService>(HostSite.PasswordType); var password = passwordService.Decrypto(Password); Response = InnerCall(AccountToken, posName, password); this.Code = Response.Code; SerialNo = Response.SerialServerNo; if (Response.Code == ResponseCode.InvalidatePassword) { IsRetry = true; Error = ModelHelper.GetBoundText(this, x => x.Code); } else if (Response.Code != ResponseCode.Success) { Error = ModelHelper.GetBoundText(this, x => x.Code); } }
public IEnumerable <ValidationError> Validate() { if (PosEndPointService.Query(new PosEndPointRequest { Name = Name, ShopId = this.Shop }).Count() > 0) { yield return (new ValidationError("Name", string.Format(Localize("messages.duplicationPos"), InnerObject.Name))); } }
public void Read(int id) { PosEndPoint item = PosEndPointService.GetById(id); if (item != null) { Shop shop = ShopService.GetById(item.ShopId); InnerShop = shop; base.InnerObject = item; } }
public List <ListPosEndPoint> AjaxGet(PosEndPointRequest request, out string pageHtml) { pageHtml = string.Empty; if (request.PageIndex == null || request.PageIndex <= 0) { request.PageIndex = 1; } if (request.PageSize == null || request.PageSize <= 0) { request.PageSize = 10; } var currentUser = SecurityHelper.GetCurrentUser(); ShopUser shopUser = currentUser.CurrentUser as ShopUser; if (shopUser != null) { request.ShopId = shopUser.ShopId; } var _tables = PosEndPointService.New_Query(request); var datas = _tables.ModelList.Select(x => new ListPosEndPoint(x)).ToList(); var shops = ShopService.Query(new ShopRequest() { ShopIds = datas.Select(x => x.InnerObject.ShopId).ToArray() }).ToList(); datas.Merge(shops, (p, s) => p.InnerObject.ShopId == s.ShopId, (p, ss) => p.Shop = ss.FirstOrDefault() ); foreach (var item in datas) { item.boor += "<a href='#' onclick=OperatorThis('Edit','/PosEndPoint/Edit/" + item.PosEndPointId + "') class='tablelink'>编辑 </a> "; if (item.InnerObject.State == UserStates.Normal) { item.boor += "<a href='#' onclick=OperatorThis('Suspend','/PosEndPoint/Suspend/" + item.PosEndPointId + "') class='tablelink'>停用 </a> "; } if (item.InnerObject.State == UserStates.Invalid) { item.boor += "<a href='#' onclick=OperatorThis('Resume','/PosEndPoint/Resume/" + item.PosEndPointId + "') class='tablelink'>启用 </a> "; } item.boor += "<a href='#' onclick=OperatorThis('Delete','/PosEndPoint/Delete/" + item.PosEndPointId + "') class='tablelink'>删除 </a> "; } if (_tables != null) { pageHtml = MvcPage.AjaxPager((int)request.PageIndex, (int)request.PageSize, _tables.TotalCount); } return(datas); }
public void Query(out string pageHtml) { PosEndPointRequest request = new PosEndPointRequest(); pageHtml = string.Empty; request.NameWith = Name; if (State != PosEndPointStates.All) { request.State = State; } if (Shop != Globals.All) { request.ShopId = Shop; } if (request.PageIndex == null || request.PageIndex <= 0) { request.PageIndex = 1; } if (request.PageSize == null || request.PageSize <= 0) { request.PageSize = 10; } var currentUser = SecurityHelper.GetCurrentUser(); ShopUser shopUser = currentUser.CurrentUser as ShopUser; if (shopUser != null) { request.ShopId = shopUser.ShopId; } var _tables = PosEndPointService.New_Query(request); List = _tables.ModelList.ToList(this, x => new ListPosEndPoint(x)); var shops = ShopService.Query(new ShopRequest() { ShopIds = List.Select(x => x.InnerObject.ShopId).ToArray() }).ToList(); List.Merge(shops, (p, s) => p.InnerObject.ShopId == s.ShopId, (p, ss) => p.Shop = ss.FirstOrDefault() ); if (_tables != null) { pageHtml = MvcPage.AjaxPager((int)request.PageIndex, (int)request.PageSize, _tables.TotalCount); } }
public IMessageProvider Save() { var serialNo = SerialNoHelper.Create(); Shop shop = ShopService.GetById(Shop.Key); if (shop != null) { InnerObject.ShopId = shop.ShopId; InnerObject.State = States.Normal; PosEndPointService.Create(InnerObject); AddMessage("success", Name, shop.DisplayName); Logger.LogWithSerialNo(LogTypes.PosCreate, serialNo, InnerObject.PosEndPointId, Name, shop.DisplayName); CacheService.Refresh(CacheKeys.PosKey); } return(this); }
public IMessageProvider Save() { var serialNo = SerialNoHelper.Create(); PosEndPoint item = PosEndPointService.GetById(PosEndPointId); if (item != null) { var shop = ShopService.GetById(item.ShopId); item.DisplayName = DisplayName; if (!string.IsNullOrEmpty(DataKey)) { item.DataKey = DataKey; } PosEndPointService.Update(item); AddMessage("success", item.Name); Logger.LogWithSerialNo(LogTypes.PosEdit, serialNo, item.PosEndPointId, item.Name, shop.DisplayName); CacheService.Refresh(CacheKeys.PosKey); } return(this); }
public void Query() { var request = new DealLogRequest(); if (State != DealLogStates.All) { request.State = State; } request.AccountName = this.AccountName; //if (DealLogQueryType != DealLogQueryTypes.All) //{ // request.DealLogQueryType = DealLogQueryType; //} request.SubmitTimeMin = Data.Start; request.SubmitTimeMax = Data.GetEnd(); request.ShopName = this.ShopName; if (this.AccountShop != Globals.All) { //var user = (AdminUser)MembershipService.GetUserById(this.Pos); //var pos = PosEndPointService.GetByName(user.PosName); request.ShopId = AccountShop.Key; } if (this.PosId != Globals.All) { request.PosId = this.PosId; } if (DealType.Key != 0) { request.DealType = DealType.Key; } var currentUser = SecurityHelper.GetCurrentUser(); var shopUser = currentUser as ShopUserModel; if (shopUser != null) { request.ShopId = shopUser.ShopId; } var accountUser = currentUser as AccountUserModel; if (accountUser != null) { var accountId = accountUser.Accounts.Select(x => x.AccountId).First(); request.AccountId = accountId; } if (AccountShop != Globals.All) { request.AccountShopId = AccountShop; } var query = this.DealLogService.Query(request); List = query.ToList(this, x => new ListDealLog(x)); var NewItem = new ListDealLog(); NewItem.SerialNo = "汇 总"; foreach (var item in List) { NewItem.Amount += item.Amount; NewItem.Point += item.Point; } List.Add(NewItem); //var shopIds = List.Select(x => x.InnerObject.ShopId).Distinct(); //var shops = ShopService.Query(new ShopRequest() { ShopIds = shopIds.ToArray() }).ToList(); //foreach (var log in List) //{ // var shop = shops.FirstOrDefault(x => x.ShopId == log.InnerObject.ShopId); // if (shop != null) // log.TempShop = shop; //} // ready // var queryPos = PosEndPointService.Query(new PosEndPointRequest() { State = PosEndPointStates.Normal }).ToList(); this.PosId.Bind(queryPos.Select(x => new IdNamePair { Key = x.PosEndPointId, Name = x.Name }), true); var users = MembershipService.QueryUsers <AdminUser>(new UserRequest() { State = UserStates.Normal }).ToList(); var poss = PosEndPointService.Query(new PosEndPointRequest() { State = PosEndPointStates.Normal }).ToList(); var adminusers = from x in users let p = poss.FirstOrDefault(y => y.CurrentUserId == x.UserId) select new IdNamePair { Key = x.UserId, Name = string.Format("{0} - {1}", x.DisplayName, p == null ? "" : p.Name) }; this.Pos.Bind(adminusers, true); // var q = (from x in ShopService.Query(new ShopRequest() { IsBuildIn = false }) select new IdNamePair { Key = x.ShopId, Name = x.FormatedName }).ToList(); q.Insert(0, new IdNamePair { Key = Ecard.Models.Shop.Default.ShopId, Name = Ecard.Models.Shop.Default.FormatedName }); this.AccountShop.Bind(q, true); IdNamePair ii = new IdNamePair(); ii.Key = 0; ii.Name = "全部"; DealType.Items.Add(ii); IdNamePair ip = new IdNamePair(); ip.Key = DealTypes.Deal; ip.Name = "会员卡支付"; DealType.Items.Add(ip); IdNamePair ip2 = new IdNamePair(); ip2.Key = DealTypes.Integral; ip2.Name = "现金支付"; DealType.Items.Add(ip2); IdNamePair ip1 = new IdNamePair(); ip1.Key = DealTypes.CancelDeal; ip1.Name = "撤销交易"; DealType.Items.Add(ip1); IdNamePair ip3 = new IdNamePair(); ip3.Key = DealTypes.PayIntegral; ip3.Name = "积分消费"; DealType.Items.Add(ip3); IdNamePair ip4 = new IdNamePair(); ip4.Key = DealTypes.Recharging; ip4.Name = "充值"; DealType.Items.Add(ip4); IdNamePair ip5 = new IdNamePair(); ip5.Key = DealTypes.CancelRecharging; ip5.Name = "取消充值"; DealType.Items.Add(ip5); IdNamePair ip6 = new IdNamePair(); ip6.Key = DealTypes.Invalid; ip6.Name = "冲正"; DealType.Items.Add(ip6); }
public DataAjaxResult Print() { try { IPasswordService passwordService = UnityContainer.Resolve <IPasswordService>(HostSite.PasswordType); var password = passwordService.Decrypto(this.Password); if (string.IsNullOrWhiteSpace(this.HostSite.TicketTemplateOfDeal)) { return(new DataAjaxResult(Localize("nonTemplateOfDeal", "请先设置消费打印模板"))); } var shopDealLog = this.ShopDealLogService.GetById(Id); if (shopDealLog == null) { return(new DataAjaxResult(Localize("nonShopDealLog", "指定商户交易未找到"))); } var deallog = this.DealLogService.GetById(shopDealLog.Addin); if (deallog == null) { return(new DataAjaxResult(Localize("nonShopDealLog", "指定会员交易未找到"))); } var account = this.AccountService.GetById(deallog.AccountId); if (account == null) { return(new DataAjaxResult(Localize("nonAccount", "指定会员未找到"))); } if (User.SaltAndHash(password, account.PasswordSalt) != account.Password) { return(new DataAjaxResult(Localize("invalidPassword", "密码错误"))); } var shop = this.ShopService.GetById(deallog.ShopId); if (shop == null) { return(new DataAjaxResult(Localize("nonShop", "指定商户未找到"))); } var dealWay = this.DealWayService.GetById(shop.DealWayId); if (dealWay == null) { return(new DataAjaxResult(Localize("nonDealWay", "指定支付渠道未找到"))); } var msg = this.HostSite.TicketTemplateOfDeal.Trim(); msg = MessageFormator.FormatTickForDeal(msg, HostSite, deallog, account, ShopService.GetById(deallog.ShopId), PosEndPointService.GetById(deallog.SourcePosId), SecurityHelper.GetCurrentUser()); return(new DataAjaxResult() { Data1 = msg }); } catch (System.Exception ex) { return(new DataAjaxResult(ex.Message)); } }