public HttpResponseMessage GetRecommendAgentList(EnumRecommendAgentSearchOrderBy orderByAll = EnumRecommendAgentSearchOrderBy.OrderById, bool isDes = true, string name = null, int page = 1, int pageSize = 10)
        {
            var recomagmentsearchcon = new RecommendAgentSearchCondition
            {

                Brokername = name,
                Page = Convert.ToInt32(page),
                PageCount = pageSize,
                OrderBy =orderByAll ,
                isDescending =isDes 
            };
            var recommendAgentList = _recommendagentService.GetRecommendAgentsByCondition(recomagmentsearchcon).Select(p => new
            {
                BBrokername = p.Brokername,
                PresenteebId = p.PresenteebId,
                Brokername = p.Broker.Brokername,


            }).ToList();
            var partnerListCount = _recommendagentService.GetRecommendAgentCount(recomagmentsearchcon);
            return PageHelper.toJson(new { List = recommendAgentList, Condition = recomagmentsearchcon, totalCount = partnerListCount });

        }
        public HttpResponseMessage GetRecommendAgentListById(int id = 0)
        {
            var recomagmentsearchcon = new RecommendAgentSearchCondition
            {
                PresenteebId = id

            };
            var recommendAgentList = _recommendagentService.GetRecommendAgentsByCondition(recomagmentsearchcon).Select(p => new
            {
                BBrokername = p.Brokername,
                phone = p.Broker.Phone,
                regtime = p.Broker.Regtime,
                agentlevel = p.Broker.Agentlevel,
                Brokername = p.Broker.Brokername,
                Nickname = p.Broker.Nickname,
                Headphono = p.Broker.Headphoto,
                Amount = p.Broker.Amount,
                Sfz = p.Broker.Sfz,


            }).ToList();
            var partnerListCount = _recommendagentService.GetRecommendAgentCount(recomagmentsearchcon);
            return PageHelper.toJson(new { List = recommendAgentList, Condition = recomagmentsearchcon, totalCount = partnerListCount });

        }
        public HttpResponseMessage GetRecommendAgentListByUserId(string userId)
        {


            var recomagmentsearchcon = new RecommendAgentSearchCondition
            {
                BrokerId = Convert.ToInt32(userId)
            };


            return PageHelper.toJson(_recommendagentService.GetRecommendAgentsByCondition(recomagmentsearchcon).Select(p => new
            {
                p.Phone,
                p.Qq,
                p.Brokername,
                p.Agentlevel,
                p.Id
            }).ToList());
        }
Пример #4
0
        public HttpResponseMessage GetBrokerDetails()
        {
            var user = (UserBase)_workContext.CurrentUser;
            if (user != null)
            {
                var broker = _brokerService.GetBrokerByUserId(user.Id);//获取当前经纪人
                if (broker == null)
                {
                    return PageHelper.toJson(PageHelper.ReturnValue(false, "获取用户失败,请检查是否登陆"));
                }
                else
                {
                    //更新到经纪人表中 可用金额
                    broker.Amount = Convert.ToDecimal(GetBrokerAmount());
                    _brokerService.Update(broker);


                    var partnerCount = 0;//合伙人个数
                    var refereeCount = 0;//推荐人个数
                    var customerCount = 0;//客户个数
                    var levelStr = "";//等级
                    var orderStr = "0";//排名
                    var allMoneys = "0";//总佣金

                    var partnerlistsearchcon = new PartnerListSearchCondition
                    {
                        Brokers = broker,
                        Status = EnumPartnerType.同意
                    };
                    partnerCount = _partnerlistService.GetPartnerListCount(partnerlistsearchcon);

                    var recomagmentsearchcon = new RecommendAgentSearchCondition
                    {
                        BrokerId = broker.Id
                    };
                    refereeCount = _recommendagentService.GetRecommendAgentCount(recomagmentsearchcon);

                    var condition = new ClientInfoSearchCondition
                    {
                        Addusers = broker.Id
                    };
                    customerCount = _clientInfoService.GetClientInfoCount(condition);

                    levelStr = broker.Level.Name;

                    allMoneys = broker.Amount.ToString();

                    orderStr = GetOrdersByuserId(broker.Id.ToString());

                    return PageHelper.toJson(new { partnerCount = partnerCount, refereeCount = refereeCount, customerCount = customerCount, levelStr = levelStr, orderStr = orderStr, allMoneys = allMoneys, photo = broker.Headphoto, Name = broker.Brokername });
                }
            }
            return PageHelper.toJson(PageHelper.ReturnValue(false, "获取用户失败,请检查是否登陆"));
        }
Пример #5
0
		public IQueryable<RecommendAgentEntity> GetRecommendAgentsByCondition(RecommendAgentSearchCondition condition)
		{
			var query = _recommendagentRepository.Table;
			try
			{
				if (condition.RegtimeBegin.HasValue)
                {
                    query = query.Where(q => q.Regtime>= condition.RegtimeBegin.Value);
                }
                if (condition.RegtimeEnd.HasValue)
                {
                    query = query.Where(q => q.Regtime < condition.RegtimeEnd.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.Phone))
                {
                    query = query.Where(q => q.Phone == condition.Phone);
                }
				if (!string.IsNullOrEmpty(condition.Qq))
                {
                    query = query.Where(q => q.Qq == condition.Qq);
                }
                if (condition.PresenteebId>0)
                {
                    query = query.Where(q => q.PresenteebId  == condition.PresenteebId );
                }
				if (!string.IsNullOrEmpty(condition.Brokername))
                {
                    query = query.Where(q => q.Brokername.Contains(condition.Brokername));
                }
				if (!string.IsNullOrEmpty(condition.Agentlevel))
                {
                    query = query.Where(q => q.Agentlevel.Contains(condition.Agentlevel));
                }
				if (condition.Ids != null && condition.Ids.Any())
                {
                    query = query.Where(q => condition.Ids.Contains(q.Id));
                }
				if (!string.IsNullOrEmpty(condition.BrokerId.ToString())  && condition.BrokerId!=0 )
                {
                    query = query.Where(q => q.Broker.Id == condition.BrokerId);
                }
				if (condition.PresenteebIds != null && condition.PresenteebIds.Any())
                {
                    query = query.Where(q => condition.PresenteebIds.Contains(q.PresenteebId));
                }
				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 EnumRecommendAgentSearchOrderBy.OrderById:
							query = condition.isDescending?query.OrderByDescending(q=>q.Id):query.OrderBy(q=>q.Id);
							break;
                        case EnumRecommendAgentSearchOrderBy.OrderByBBrokername:
                            query = condition.isDescending ? query.OrderByDescending(q => q.Brokername) : query.OrderBy(q => q.Brokername);
                            break;
                        case EnumRecommendAgentSearchOrderBy.OrderByBrokername:
                            query = condition.isDescending ? query.OrderByDescending(q => q.Broker.Brokername) : query.OrderBy(q => q.Broker.Brokername);
                            break;
                        case EnumRecommendAgentSearchOrderBy.OrderByPresenteebId:
                            query = condition.isDescending ? query.OrderByDescending(q => q.PresenteebId) : query.OrderBy(q => q.PresenteebId);
                            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;
			}
		}
Пример #6
0
		public int GetRecommendAgentCount (RecommendAgentSearchCondition condition)
		{
			var query = _recommendagentRepository.Table;
			try
			{
				if (condition.RegtimeBegin.HasValue)
                {
                    query = query.Where(q => q.Regtime>= condition.RegtimeBegin.Value);
                }
                if (condition.RegtimeEnd.HasValue)
                {
                    query = query.Where(q => q.Regtime < condition.RegtimeEnd.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.Phone))
                {
                    query = query.Where(q => q.Phone == condition.Phone);
                }
                if (!string.IsNullOrEmpty(condition.Qq))
                {
                    query = query.Where(q => q.Qq == condition.Qq);
                }
				if (!string.IsNullOrEmpty(condition.Brokername))
                {
                    query = query.Where(q => q.Brokername.Contains(condition.Brokername));
                }
				if (!string.IsNullOrEmpty(condition.Agentlevel))
                {
                    query = query.Where(q => q.Agentlevel.Contains(condition.Agentlevel));
                }
				if (condition.Ids != null && condition.Ids.Any())
                {
                    query = query.Where(q => condition.Ids.Contains(q.Id));
                }
				if (   !string.IsNullOrEmpty( condition.BrokerId.ToString()) )
                {
                    query = query.Where(q =>q.Broker.Id==condition.BrokerId);
                }
				if (condition.PresenteebIds != null && condition.PresenteebIds.Any())
                {
                    query = query.Where(q => condition.PresenteebIds.Contains(q.PresenteebId));
                }
				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;
			}
		}