示例#1
0
        /// <summary>
        /// 获取代理人资源
        /// </summary>
        /// <param name="request"></param>
        /// <param name="pairs"></param>
        /// <returns></returns>
        public GetAgentSourceResponse GetAgentSource(GetAgentResourceRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            var response = new GetAgentSourceResponse();

            //根据经纪人获取手机号
            bx_agent agentModel = GetAgent(request.Agent);

            //logInfo.Info("获取到的经纪人信息:"+agentModel.ToJson());
            //参数校验
            if (agentModel == null)
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }

            if (!ValidateReqest(pairs, agentModel.SecretKey, request.SecCode))
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }
            var sourceList = _agentConfig.Find(int.Parse(_agentRepository.GetTopAgentId(request.Agent)));
            var list       = sourceList.Select(x => (x.source.HasValue ? x.source.Value : 0)).ToList().Distinct();

            response.ComList = list.ToList();

            return(response);
        }
示例#2
0
        /// <summary>
        /// 获取代理人资源
        /// </summary>
        /// <param name="request"></param>
        /// <param name="pairs"></param>
        /// <returns></returns>
        public GetAgentSourceResponse GetAgentNewSource(GetAgentResourceRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            var response = new GetAgentSourceResponse();

            //根据经纪人获取手机号
            bx_agent agentModel = GetAgent(request.Agent);

            //logInfo.Info("获取到的经纪人信息:"+agentModel.ToJson());
            //参数校验
            if (agentModel == null)
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }
            if (agentModel.IsUsed != 1)
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }

            if (!ValidateReqest(pairs, agentModel.SecretKey, request.SecCode))
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }

            //var agentsourcekey = string.Format("agent_source_key_{0}", request.Agent);
            var agentsourcekey = string.Format("agent_source_key_{0}_{1}", request.Agent, request.CityCode);
            var list           = CacheProvider.Get <List <int> >(agentsourcekey);

            if (list == null)
            {
                var sourceList = _agentConfig.FindCities(int.Parse(_agentRepository.GetTopAgentId(request.Agent)), request.CityCode);
                // var sourceList = _agentConfig.FindNewCity(int.Parse(_agentRepository.GetTopAgentId(request.Agent)));
                list = sourceList.Where(x => x.is_used == 1).Select(x => (x.source.HasValue ? x.source.Value : 0)).Distinct().ToList();
                CacheProvider.Set(agentsourcekey, list, 600);
            }
            response.ComList = new List <int>();
            for (int i = 0; i < list.Count(); i++)
            {
                if (list[i] == 0)
                {
                    response.ComList.Add(2);
                }
                else if (list[i] == 1)
                {
                    response.ComList.Add(1);
                }
                else if (list[i] == 2)
                {
                    response.ComList.Add(4);
                }
                else if (list[i] == 3)
                {
                    response.ComList.Add(8);
                }
                else if (list[i] == 4)
                {
                    response.ComList.Add(16);
                }
                else if (list[i] == 5)
                {
                    response.ComList.Add(32);
                }
                else if (list[i] == 6)
                {
                    response.ComList.Add(64);
                }
                else if (list[i] == 7)
                {
                    response.ComList.Add(128);
                }
                else if (list[i] == 8)
                {
                    response.ComList.Add(256);
                }
                else if (list[i] == 9)
                {
                    response.ComList.Add(512);
                }
            }
            response.ComList = response.ComList.OrderBy(x => x).ToList();
            return(response);
        }