public HttpResponseMessage GetReInfoDetails([FromUri] GetReInfoDetailRequest request)
        {
            _logInfo.Info(string.Format("获取续保详情接口请求串:{0}", Request.RequestUri));
            var model = new GetReInfoViewModel();

            if (!ModelState.IsValid)
            {
                model.BusinessStatus = -10000;
                string msg = ModelState.Values.Where(a => a.Errors.Count == 1).Aggregate(string.Empty, (current, a) => current + (a.Errors[0].ErrorMessage + ";   "));
                model.StatusMessage = "输入参数错误," + msg;
                return(model.ResponseToJson());
            }
            if (!request.LicenseNo.IsValidLicenseno())
            {
                model.BusinessStatus = -10000;
                model.StatusMessage  = "参数校验错误,请检查车牌号";
                return(model.ResponseToJson());
            }
            var response = _chargingSystemService.GetReInfoDetail(request, Request.GetQueryNameValuePairs());

            //_logInfo.Info(string.Format("获取续保详情接口返回结果:{0}", response.ToJson()));
            if (response.Status == HttpStatusCode.BadRequest || response.Status == HttpStatusCode.Forbidden)
            {
                model.BusinessStatus = -10001;
                model.StatusMessage  = "参数校验错误,请检查您的校验码";
                return(model.ResponseToJson());
            }
            if (response.Status == HttpStatusCode.ExpectationFailed)
            {
                model.BusinessStatus = -10003;
                model.StatusMessage  = "服务发生异常";
                return(model.ResponseToJson());
            }

            if (response.Status == HttpStatusCode.OK)
            {
                model.BusinessStatus = response.BusinessStatus;
                model.StatusMessage  = response.BusinessMessage;
                model.UserInfo       = response.UserInfo.ConvertToViewModel(response.SaveQuote, response.CarInfo,
                                                                            response.LastInfo);
                if (response.BusinessStatus == 1)
                {
                    model.SaveQuote = response.SaveQuote.ConvetToViewModel();
                }
                else
                {
                    model.UserInfo.BusinessExpireDate    = "";
                    model.UserInfo.ForceExpireDate       = "";
                    model.UserInfo.NextBusinessStartDate = "";
                    model.UserInfo.NextForceStartDate    = "";
                }
            }
            else
            {
                model.BusinessStatus = -10002;
                model.StatusMessage  = "没有续保信息";
            }
            return(model.ResponseToJson());
        }
        public HttpResponseMessage GetReInfoDetail([FromUri] GetReInfoDetailRequest request)
        {
            logInfo.Info(string.Format("获取续保详情接口请求串:{0}", Request.RequestUri));
            var model = new AppReInfoViewModel();

            if (!ModelState.IsValid)
            {
                model.BusinessStatus = -10000;
                string msg = ModelState.Values.Where(a => a.Errors.Count == 1).Aggregate(string.Empty, (current, a) => current + (a.Errors[0].ErrorMessage + ";   "));
                model.StatusMessage = "输入参数错误," + msg;
                return(model.ResponseToJson());
            }
            var response = _bjdService.GetReInfoDetail(request, Request.GetQueryNameValuePairs());

            //logInfo.Info(string.Format("获取续保详情接口返回结果:{0}", response.ToJson()));
            if (response.Status == HttpStatusCode.BadRequest || response.Status == HttpStatusCode.Forbidden)
            {
                model.BusinessStatus = -10001;
                model.StatusMessage  = "参数校验错误,请检查您的校验码";
                return(model.ResponseToJson());
            }
            if (response.Status == HttpStatusCode.ExpectationFailed)
            {
                model.BusinessStatus = -10003;
                model.StatusMessage  = "服务发生异常";
                return(model.ResponseToJson());
            }

            if (response.Status == HttpStatusCode.OK)
            {
                model.BusinessStatus = response.BusinessStatus == 8 ? 1 : response.BusinessStatus;
                model.StatusMessage  = response.BusinessMessage;
                model.UserInfo       = response.UserInfo.ConvertToViewModel(response.SaveQuote, response.CarInfo,
                                                                            response.LastInfo);
                model.SaveQuote   = response.SaveQuote.ConvetToViewModel();
                model.WorkOrder   = response.WorkOrder.ConverToViewModel();
                model.DetailList  = response.DetailList.ConverToViewModel();
                model.IsDistrib   = response.IsDistrib;
                model.Buid        = response.Buid;
                model.Agent       = response.Agent;
                model.AgentName   = response.AgentName;
                model.SaAgent     = response.SaAgent;
                model.SaAgentName = response.SaAgentName;

                //当获取续保信息失败(包括状态是3),将去年source制为-1,以免与 平安的0值混淆
                if (response.BusinessStatus != 1)
                {
                    model.SaveQuote.Source = -1;
                }
            }
            else
            {
                model.BusinessStatus = -10002;
                model.StatusMessage  = "没有续保信息";
            }
            return(model.ResponseToJson());
        }
Beispiel #3
0
        public AppGetReInfoResponse GetReInfoDetail(GetReInfoDetailRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            var response = new AppGetReInfoResponse();
            //bhToken校验
            //if (!AppTokenValidateReqest(request.BhToken, request.ChildAgent))
            //{
            //    response.BusinessStatus = -300;
            //    response.BusinessMessage = "登录信息已过期,请重新登录";
            //    return response;
            //}
            IBxAgent agentModel = GetAgentModelFactory(request.Agent);

            //参数校验
            if (!agentModel.AgentCanUse())
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }
            //if (!AppValidateReqest(pairs, request.SecCode))
            //{
            //    response.Status = HttpStatusCode.Forbidden;
            //    return response;
            //}

            try
            {
                //取bx_userinfo对象
                var userinfo = new bx_userinfo();
                if (request.Buid.HasValue && request.Buid.Value != 0)
                {
                    //如果传buid过来,重新赋值request
                    userinfo = _userInfoRepository.FindByBuid(request.Buid.Value);
                    if (userinfo != null)
                    {
                        request.LicenseNo  = userinfo.LicenseNo;
                        request.ChildAgent = int.Parse(userinfo.Agent);
                    }
                }
                //else
                //{
                //    if (request.ChildAgent.HasValue)
                //    {
                //        //根据OpenId、车牌号、代理人Id找userinfo对象
                //        userinfo = _userInfoRepository.FindByAgentLicense(request.LicenseNo, request.ChildAgent.Value.ToString());
                //    }
                //}

                if (userinfo == null)
                {
                    response.Status = HttpStatusCode.NoContent;
                    return(response);
                }
                else
                {
                    response.Buid = userinfo.Id;
                    //UserInfo
                    response.UserInfo = userinfo;
                    //增加当前userinfo的代理人返回
                    response.Agent = int.Parse(userinfo.Agent);

                    response.Status = HttpStatusCode.OK;
                    if (!string.IsNullOrEmpty(userinfo.LicenseNo))
                    {
                        response.SaveQuote = _carRenewalRepository.FindByLicenseno(userinfo.LicenseNo);
                        response.CarInfo   = _carInfoRepository.Find(userinfo.LicenseNo);
                    }

                    if (userinfo.NeedEngineNo == 1)
                    {
                        //需要完善行驶证信息
                        response.BusinessStatus  = 2;
                        response.BusinessMessage = "需要完善行驶证信息(车辆信息和险种都没有获取到)";
                    }
                    if (userinfo.NeedEngineNo == 0 && userinfo.RenewalStatus != 1)
                    {
                        //获取车辆信息成功,但获取险种失败
                        response.BusinessStatus  = 3;
                        response.BusinessMessage = "获取车辆信息成功(车架号,发动机号,品牌型号及初登日期),险种获取失败";
                    }
                    if ((userinfo.NeedEngineNo == 0 && userinfo.LastYearSource > -1) || userinfo.RenewalStatus == 1)
                    {
                        //续保成功
                        response.BusinessStatus  = 1;
                        response.BusinessMessage = "续保成功";
                    }
                    if (userinfo.LastYearSource == -1)
                    {
                        response.BusinessStatus  = 0;
                        response.BusinessMessage = "获取续保信息失败";
                    }
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response        = new AppGetReInfoResponse();
                response.Status = HttpStatusCode.ExpectationFailed;
                logError.Info("APP续保详情接口请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(response);
        }