public HttpResponseMessage SearchBankCardsByUserID(string userId = null, int page = 1, int pageSize = 10) { if (string.IsNullOrEmpty(userId) || !PageHelper.ValidateNumber(userId)) { return PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误!")); } var bankcardSearchCon = new BankCardSearchCondition { Brokers = _brokerService.GetBrokerById(Convert.ToInt32(userId)), Page = Convert.ToInt32(page), PageCount = pageSize }; var bankList = _bankcardService.GetBankCardsByCondition(bankcardSearchCon).Select(p => new { Id = p.Id, bankName = p.Bank.Codeid, p.Num, p.Addtime }).ToList(); var bankListCount = _bankcardService.GetBankCardCount(bankcardSearchCon); return PageHelper.toJson(new { List = bankList, Condition = bankcardSearchCon, totalCount1 = bankListCount }); }
public IQueryable<BankCardEntity> GetBankCardsByCondition(BankCardSearchCondition condition) { var query = _bankcardRepository.Table; try { if (condition.DeadlineBegin.HasValue) { query = query.Where(q => q.Deadline>= condition.DeadlineBegin.Value); } if (condition.DeadlineEnd.HasValue) { query = query.Where(q => q.Deadline < condition.DeadlineEnd.Value); } if (condition.AddtimeBegin.HasValue) { query = query.Where(q => q.Addtime>= condition.AddtimeBegin.Value); } if (condition.AddtimeEnd.HasValue) { query = query.Where(q => q.Addtime < condition.AddtimeEnd.Value); } if (condition.UptimeBegin.HasValue) { query = query.Where(q => q.Uptime>= condition.UptimeBegin.Value); } if (condition.UptimeEnd.HasValue) { query = query.Where(q => q.Uptime < condition.UptimeEnd.Value); } if (!string.IsNullOrEmpty( condition.Type)) { query = query.Where(q =>q.Type ==condition.Type); } if (condition.Ids != null && condition.Ids.Any()) { query = query.Where(q => condition.Ids.Contains(q.Id)); } if (condition.Banks != null) { query = query.Where(q => condition.Banks==q.Bank); } if (condition.Brokers != null) { query = query.Where(q => (q.Broker.Id == condition.Brokers.Id)); } if (!string.IsNullOrEmpty( condition.Nums) ) { query = query.Where(q => (q.Num == condition.Nums)); } if (condition.Addusers != null && condition.Addusers.Any()) { query = query.Where(q => condition.Addusers.Contains(q.Adduser)); } if (condition.Upusers != null && condition.Upusers.Any()) { query = query.Where(q => condition.Upusers.Contains(q.Upuser)); } if(condition.OrderBy.HasValue) { switch (condition.OrderBy.Value) { case EnumBankCardSearchOrderBy.OrderById: query = condition.isDescending?query.OrderByDescending(q=>q.Id):query.OrderBy(q=>q.Id); break; } } else { query = query.OrderBy(q=>q.Id); } if (condition.Page.HasValue && condition.PageCount.HasValue) { query = query.Skip((condition.Page.Value - 1)*condition.PageCount.Value).Take(condition.PageCount.Value); } return query; } catch(Exception e) { _log.Error(e,"数据库操作出错"); return null; } }
public int GetBankCardCount (BankCardSearchCondition condition) { var query = _bankcardRepository.Table; try { if (condition.DeadlineBegin.HasValue) { query = query.Where(q => q.Deadline>= condition.DeadlineBegin.Value); } if (condition.DeadlineEnd.HasValue) { query = query.Where(q => q.Deadline < condition.DeadlineEnd.Value); } if (condition.AddtimeBegin.HasValue) { query = query.Where(q => q.Addtime>= condition.AddtimeBegin.Value); } if (condition.AddtimeEnd.HasValue) { query = query.Where(q => q.Addtime < condition.AddtimeEnd.Value); } if (condition.UptimeBegin.HasValue) { query = query.Where(q => q.Uptime>= condition.UptimeBegin.Value); } if (condition.UptimeEnd.HasValue) { query = query.Where(q => q.Uptime < condition.UptimeEnd.Value); } if (!string.IsNullOrEmpty(condition.Type)) { query = query.Where(q => q.Type == condition.Type); } if (condition.Ids != null && condition.Ids.Any()) { query = query.Where(q => condition.Ids.Contains(q.Id)); } if (condition.Banks != null ) { query = query.Where(q => condition.Banks==(q.Bank)); } if (condition.Brokers != null ) { query = query.Where(q => condition.Brokers.Id ==(q.Broker.Id )); } if (!string.IsNullOrEmpty(condition.Nums)) { query = query.Where(q => (q.Num == condition.Nums)); } if (condition.Addusers != null && condition.Addusers.Any()) { query = query.Where(q => condition.Addusers.Contains(q.Adduser)); } if (condition.Upusers != null && condition.Upusers.Any()) { query = query.Where(q => condition.Upusers.Contains(q.Upuser)); } return query.Count(); } catch(Exception e) { _log.Error(e,"数据库操作出错"); return -1; } }
public HttpResponseMessage SearchAllBankByUser() { var user = (UserBase)_workContext.CurrentUser; if (user != null) { var broker = _brokerService.GetBrokerByUserId(user.Id);//获取当前经纪人 if (broker == null) { return PageHelper.toJson(PageHelper.ReturnValue(false, "获取用户失败,请检查是否登陆")); } else { var bankcardSearchCon = new BankCardSearchCondition { Brokers = broker }; var bankList = _bankcardService.GetBankCardsByCondition(bankcardSearchCon).Select(p => new { Id = p.Id, bankName = p.Bank.Codeid, Num = p.Num.ToString().Substring(p.Num.ToString().Length - 4, 4) }).ToList(); return PageHelper.toJson(new { List = bankList, AmountMoney = broker.Amount }); } } return PageHelper.toJson(PageHelper.ReturnValue(false, "获取用户失败,请检查是否登陆")); }
public HttpResponseMessage DeleteBankCard([FromBody] string id) { if (!string.IsNullOrEmpty(id) && id!="0") { int Id; if (!Int32.TryParse(id, out Id)) { return PageHelper.toJson(PageHelper.ReturnValue(false, "数据异常")); } var user = (UserBase)_workContext.CurrentUser; if (user != null) { var broker = _brokerService.GetBrokerByUserId(user.Id);//获取当前经纪人 if (broker == null) { return PageHelper.toJson(PageHelper.ReturnValue(false, "获取用户失败,请检查是否登陆")); } else { int [] ids={Id}; var bankcardSearchCon = new BankCardSearchCondition { Brokers = broker, Ids=ids }; if( _bankcardService.GetBankCardCount(bankcardSearchCon)>0)//判断是否是自己的卡 { var Bank=_bankcardService.GetBankCardById(Id); if (Bank==null) { return PageHelper.toJson(PageHelper.ReturnValue(false, "数据异常")); } BankCardEntity[] banks={Bank}; BrokerWithdrawSearchCondition bwithSearchCon=new BrokerWithdrawSearchCondition{ Brokers=broker, BankCards=banks }; if (_brokerwithdrawService.GetBrokerWithdrawCount(bwithSearchCon) > 0)//判断用户提现表是否使用此卡 { return PageHelper.toJson(PageHelper.ReturnValue(false, "有该银行相关提现数据不能删除")); } _bankcardService.Delete(Bank); return PageHelper.toJson(PageHelper.ReturnValue(true, "删除成功")); } else { return PageHelper.toJson(PageHelper.ReturnValue(false, "数据异常")); } } } } return PageHelper.toJson(PageHelper.ReturnValue(false, "数据异常")); }