Exemplo n.º 1
0
        /// <summary>
        /// 获取渠道及状态
        /// </summary>
        /// <param name="request"></param>
        /// <param name="pairs"></param>
        /// <returns></returns>
        public GetChannelStatusResponse GetChannelStatus(GetChannelStatusRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            GetChannelStatusResponse response = new GetChannelStatusResponse();

            try
            {
                //参数校验
                BaseResponse baseResponse = _validateService.Validate(request, pairs);
                if (baseResponse.Status == HttpStatusCode.Forbidden)
                {
                    response.Status = HttpStatusCode.Forbidden;
                    return(response);
                }
                if (request.CityCode == 0)
                {
                    //request.CityCode = _agentConfigByCityService.GetAgentCityCodeByChannelId(request.Agent,
                    //request.ChannelId);
                    //当CityCode=0时候,需要根据ChannelId获得CityCode。而ChannelId对应bx_agent_ukey.Id
                    request.CityCode = _agentUKeyService.GetAgentCityCodeByUKId((int)request.ChannelId);
                }
                //查询ukey信息
                List <bx_agent_config> configModel = _agentConfigByCityService.GetAgentConfigByCity(request.Agent, request.CityCode);
                //如果configModel为空,返回错误
                if (configModel == null)
                {
                    response.ErrCode = -1;
                    response.ErrMsg  = "未查到代理人配置信息";
                    return(response);
                }
                //取缓存渠道模型
                var list = _channelModelMapRedisService.GetAgentCacheChannelList(configModel);
                //判断是否有值
                if (list.Any())
                {
                    //如果修改成功,则保存用户名
                    response.Status           = HttpStatusCode.OK;
                    response.CacheChannelList = list;
                }
                else
                {
                    //修改失败
                    response.ErrCode = 0;
                    response.ErrMsg  = "获取信息失败";
                }
            }
            catch (Exception ex)
            {
                response.Status = HttpStatusCode.ExpectationFailed;
                logError.Info("获取渠道及状态请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException + ",返回对象信息:" + request.ToJson());
            }
            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取报价渠道
        /// </summary>
        /// <param name="agentId"></param>
        /// <param name="cityCode"></param>
        /// <returns></returns>
        public ResponseMultiQuotedChannelsViewModel GetAgentConfigByCityResponse(int agentId, int cityCode)
        {
            try
            {
                var listCcnfigModel = _agentConfigByCityService.GetAgentConfigByCity(agentId, cityCode);
                if (listCcnfigModel == null)
                {
                    return(new ResponseMultiQuotedChannelsViewModel()
                    {
                        BusinessStatus = 0,
                        StatusMessage = "查询成功",
                        ListModels = new List <MultiQuotedChannelsViewModel>()
                    });
                }

                var lista = _channelModelMapRedisService.GetAgentCacheChannelList(listCcnfigModel);

                var list = lista.ConverToViewModel(agentId);

                return(new ResponseMultiQuotedChannelsViewModel()
                {
                    BusinessStatus = 1,
                    StatusMessage = "查询成功",
                    ListModels = list
                });
            }
            catch (Exception ex)
            {
                _logError.Info("获取报价渠道接口请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
                return(new ResponseMultiQuotedChannelsViewModel()
                {
                    BusinessStatus = -10003,
                    StatusMessage = "查询失败,异常信息:" + ex.Message
                });
            }
        }
        public BaseViewModel CheckMultiChannelsUsed(string multiChannels, int agent, int citycode, long quotegroup, out string newMultiChannels)
        {
            newMultiChannels = string.Empty;
            BaseViewModel viewModel = new BaseViewModel();
            //用户未指定渠道,系统默认选择创建时间最老的渠道拼串请求
            //渠道请求模型转换
            List <MultiChannels> models    = multiChannels.FromJson <List <MultiChannels> >(); //请求模型转换为渠道
            List <MultiChannels> newModels = new List <MultiChannels>();                       //转换成需要保存到库里的集合

            //取值判断在bx_agent_config是否有值
            if (models.Any())
            {
                #region 判断前端传的渠道是否在该顶级下可用
                List <long> listChannels = models.Select(o => o.ChannelId).ToList();
                var         agentconfig  = _agentConfigByCityService.GetAgentConfigByCity(agent, citycode);
                List <long> listconfig   = agentconfig.Select(o => o.id).ToList();
                List <long> diff         = GetDiffrent(listChannels, listconfig);
                if (diff.Any())
                {//如果不同的list集合里有值,说明有数据不一样,则返回错误
                    viewModel.BusinessStatus = -10000;
                    viewModel.StatusMessage  = "输入参数错误,报价渠道不可用";
                    return(viewModel);
                }
                #endregion
                #region 判断前端传的请求报价渠道是否与多渠道报价的数量匹配
                List <long> listSource       = models.Select(o => o.Source).ToList();
                List <long> quoteSourceGroup = SourceGroupAlgorithm.ParseNewSource(quotegroup);
                diff = new List <long>();
                diff = GetDiffrent(quoteSourceGroup, listSource);
                if (diff.Any())
                {//如果不同的list集合里有值,说明有数据不一样,则返回错误
                    viewModel.BusinessStatus = -10000;
                    viewModel.StatusMessage  = "输入参数错误,请求报价渠道的QuoteGroup值与多渠道报价的MultiChannels值不匹配";
                    return(viewModel);
                }
                #endregion
                foreach (var item in models)
                {
                    MultiChannels newItem = new MultiChannels();
                    newItem        = item;
                    newItem.Source = SourceGroupAlgorithm.GetOldSource(item.Source);
                    newModels.Add(newItem);
                }
                newMultiChannels = newModels.ToJson();
            }
            return(viewModel);
        }