public async Task <GetPrecisePriceNewViewModel> GetPrecisePrice(GetPrecisePriceRequest request, IEnumerable <KeyValuePair <string, string> > pairs, Uri uri)
        {
            var viewModel = new GetPrecisePriceNewViewModel();

            #region 参数校验
            //校验请求串
            var baseRequest = new AppBaseRequest()
            {
                Agent      = request.Agent,
                SecCode    = request.SecCode,
                CustKey    = request.CustKey,
                BhToken    = request.BhToken,
                ChildAgent = request.ChildAgent
            };
            //校验返回值
            var baseResponse = _appVerifyService.Verify(baseRequest, pairs);
            if (baseResponse.ErrCode != 1)
            {
                viewModel.BusinessStatus = baseResponse.ErrCode;
                viewModel.StatusMessage  = baseResponse.ErrMsg;
                return(viewModel);
            }
            #endregion
            #region 业务逻辑
            //拼接请求串
            string strUrl = string.Format("http://{0}:{1}/api/CarInsurance/GetPrecisePrice", uri.Host, uri.Port);
            //3,续保请求
            BaseResponse rep = await SimulateGet(strUrl, pairs);

            if (rep.ErrCode == 1)
            {
                viewModel = rep.ErrMsg.FromJson <GetPrecisePriceNewViewModel>();
            }
            else
            {
                viewModel.BusinessStatus = rep.ErrCode;
                viewModel.StatusMessage  = rep.ErrMsg;
            }
            bx_userinfo userinfo = _userInfoRepository.FindByOpenIdAndLicense(request.CustKey, request.LicenseNo, request.ChildAgent.ToString(), request.RenewalCarType);
            viewModel.Buid      = userinfo != null ? userinfo.Id : 0;
            viewModel.Agent     = baseResponse.Agent;
            viewModel.AgentName = baseResponse.AgentName;
            #endregion
            return(viewModel);
        }
Ejemplo n.º 2
0
        public async Task <HttpResponseMessage> GetSpecialPrecisePrice([FromUri] GetPrecisePriceRequest request)
        {
            _logAppInfo.Info(string.Format("获取报价信息接口请求串:{0}", Request.RequestUri));
            var viewModel = new GetPrecisePriceNewViewModel();

            if (!ModelState.IsValid)
            {
                viewModel.BusinessStatus = -10000;
                string msg = ModelState.Values.Where(item => item.Errors.Count == 1).Aggregate(string.Empty, (current, item) => current + (item.Errors[0].ErrorMessage + ";   "));
                viewModel.StatusMessage = "输入参数错误," + msg;
                return(viewModel.ResponseToJson());
            }
            //此处调用未带special的方法,是因为该service返回值已经增加了buid
            viewModel = await _appAchieveService.GetPrecisePrice(request, Request.GetQueryNameValuePairs(), Request.RequestUri);

            //_logAppInfo.Info(string.Format("获取报价信息接口返回值:{0}", viewModel.ToJson()));
            return(viewModel.ResponseToJson());
        }