コード例 #1
0
        public GetPrecisePriceReponse GetPrecisePrice(GetPrecisePriceRequest request)
        {
            ///获取报价信息和 核保信息,我发送的key都是一样的 ,不能按照险种信息hash,因为我取的时候 ,请求参数是没有险种的 ,
            /// 如果换成的key跟险种信息有关,导致缓存中 会有过的垃圾数据,客户端用不到 。
            /// 也就是说  缓存只存放最新的一条报价信息和核保信息
            GetPrecisePriceReponse response = new GetPrecisePriceReponse();

            var baojiaKey = new
            {
                LicenseNo        = request.LicenseNo,
                IntentionCompany = request.IntentionCompany,
                Agent            = request.Agent
            };
            var baojiaCacheKey = CommonCacheKeyFactory.MakeCacheKey(baojiaKey);
            var xuBaoKey       = string.Format("{0}-bj-{1}-{2}", baojiaCacheKey, request.IntentionCompany, "key");

            //获取报价信息
            //需要的表
            //bx_userinfo
            //bx_LastInfo
            //bx_SaveQuote
            //bx_QuoteResult
            //bx_SubmitInfo
            //bx_renewalquote

            //步骤1  续保的时候 会发送消息队列 ,这个时候 会把 key传过去eg:bbbb。

            //步骤2   中心在续保的时候 ,需要根据这个key 设置3个开关(人太平)
            //eg:
            //bbbb-bj-0-key:,
            //bbbb-bj-1-key:,
            //bbbb-bj-2-key:,
            //放在缓存中,人太平报价成功的时候分别要置1,刚开始是空值
            //等报价结束后,先将上面列出的表写入缓存
            //其中: 键值分别是:
            //bx_userinfo        :bbbb-userinfo
            //bx_LastInfo        :bbbb-lastinfo
            //bx_renewalquote    :bbbb-renewal
            //bx_SaveQuote       :bbbb-savequote

            //bx_QuoteResult     :bbbb-0-quoteresult
            //bx_SubmitInfo      :bbbb-0-submitinfo



            return(response);
        }
コード例 #2
0
        public BaseResponse CheckRequest(GetPrecisePriceRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            BaseResponse response = new BaseResponse();

            response.Status = HttpStatusCode.OK;
            //校验:1基础校验
            BaseResponse baseResponse = _validateService.Validate(request, pairs);

            if (baseResponse.Status == HttpStatusCode.Forbidden)
            {
                response.Status = HttpStatusCode.Forbidden;
                response.ErrMsg = baseResponse.ErrMsg;
                logError.Info(request.ToJson() + ";校验错误:" + response.ErrMsg);
                return(response);
            }
            return(response);
        }
コード例 #3
0
        public BaseResponse CheckRequest(GetPrecisePriceRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            BaseResponse response = new BaseResponse();

            response.Status = HttpStatusCode.OK;
            //校验:1基础校验
            BaseResponse baseResponse = _validateService.Validate(request, pairs);

            if (baseResponse.Status == HttpStatusCode.Forbidden)
            {
                response.Status = HttpStatusCode.Forbidden;
                response.ErrMsg = baseResponse.ErrMsg;
                logError.Info(request.ToJson() + ";校验错误:" + response.ErrMsg);
                return(response);
            }
            //校验:2报价基础信息
            UserInfoValidateRequest validateRequest = new UserInfoValidateRequest()
            {
                LicenseNo      = request.LicenseNo,
                CustKey        = request.CustKey,
                ChildAgent     = request.ChildAgent == 0 ? request.Agent : request.ChildAgent,
                RenewalCarType = request.RenewalCarType
            };
            //校验2
            var validateResult = _userInfoValidateService.UserInfoValidate(validateRequest);

            if (validateResult.Item1.Status == HttpStatusCode.NotAcceptable)
            {
                response.Status = HttpStatusCode.Forbidden;
                response.ErrMsg = validateResult.Item1.ErrMsg;
                logError.Info(request.ToJson() + ";校验错误:" + response.ErrMsg);
                return(response);
            }
            //校验3:报价数据
            baseResponse = _checkQuoteValidService.Validate(validateResult.Item2, request.QuoteGroup, 1);
            if (baseResponse.Status == HttpStatusCode.NotAcceptable)
            {
                response.Status = HttpStatusCode.Forbidden;
                response.ErrMsg = baseResponse.ErrMsg;
                logError.Info(request.ToJson() + ";校验错误:" + validateResult.Item2.Id + ":" + response.ErrMsg);
                return(response);
            }
            response.ErrMsg = baseResponse.ErrMsg;
            return(response);
        }
コード例 #4
0
        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);
        }
コード例 #5
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());
        }
コード例 #6
0
        public static GetPrecisePriceViewModel GetPrecisePrice(GetPrecisePriceRequest request)
        {
            var viewModel = new GetPrecisePriceViewModel();
            GetPrecisePriceOfUserInfoViewModel UserInfo = new GetPrecisePriceOfUserInfoViewModel();

            UserInfo.LicenseNo          = "京FF1234";
            UserInfo.ForceExpireDate    = "2017-01-19";
            UserInfo.BusinessExpireDate = "2017-01-19";
            UserInfo.BusinessStartDate  = "2016-07-17";
            UserInfo.ForceStartDate     = "";
            UserInfo.InsuredName        = "姚毅";
            UserInfo.InsuredIdCard      = "110108196905241319";
            UserInfo.InsuredIdType      = 1;
            UserInfo.InsuredMobile      = "13154582463";
            UserInfo.HolderName         = "姚毅";
            UserInfo.HolderIdCard       = "110108196905241319";
            UserInfo.HolderIdType       = 1;
            UserInfo.HolderMobile       = "13154582463";

            viewModel.UserInfo = UserInfo;

            PrecisePriceItemViewModel Item = new PrecisePriceItemViewModel();

            Item.BizRate     = 0;;
            Item.ForceRate   = 0;
            Item.BizTotal    = 8438.24;
            Item.ForceTotal  = 0;
            Item.TaxTotal    = 0;
            Item.Source      = 1;
            Item.QuoteStatus = 1;
            Item.QuoteResult = "成功";

            XianZhongUnit CheSun = new XianZhongUnit();

            CheSun.BaoE   = 358244;
            CheSun.BaoFei = 4234.46;
            Item.CheSun   = CheSun;

            XianZhongUnit SanZhe = new XianZhongUnit();

            SanZhe.BaoE   = 500000;
            SanZhe.BaoFei = 1063.52;
            Item.SanZhe   = SanZhe;

            XianZhongUnit DaoQiang = new XianZhongUnit();

            DaoQiang.BaoE   = 358244;
            DaoQiang.BaoFei = 1458.49;
            Item.DaoQiang   = DaoQiang;

            XianZhongUnit SiJi = new XianZhongUnit();

            SiJi.BaoE   = 0;
            SiJi.BaoFei = 0;
            Item.SiJi   = SiJi;

            XianZhongUnit ChengKe = new XianZhongUnit();

            ChengKe.BaoE   = 0;
            ChengKe.BaoFei = 0;
            Item.ChengKe   = ChengKe;

            XianZhongUnit BoLi = new XianZhongUnit();

            BoLi.BaoE   = 1;
            BoLi.BaoFei = 595.38;
            Item.BoLi   = BoLi;

            XianZhongUnit HuaHen = new XianZhongUnit();

            HuaHen.BaoE   = 0;
            HuaHen.BaoFei = 0;
            Item.HuaHen   = HuaHen;

            XianZhongUnit SheShui = new XianZhongUnit();

            SheShui.BaoE   = 0;
            SheShui.BaoFei = 0;
            Item.SheShui   = SheShui;

            //XianZhongUnit CheDeng = new XianZhongUnit();
            //CheDeng.BaoE = 0;
            //CheDeng.BaoFei = 0;
            //Item.CheDeng = CheDeng;

            XianZhongUnit ZiRan = new XianZhongUnit();

            ZiRan.BaoE   = 0;
            ZiRan.BaoFei = 0;
            Item.ZiRan   = ZiRan;

            XianZhongUnit BuJiMianChengKe = new XianZhongUnit();

            BuJiMianChengKe.BaoE   = 0;
            BuJiMianChengKe.BaoFei = 0;
            Item.BuJiMianChengKe   = BuJiMianChengKe;

            XianZhongUnit BuJiMianSiJi = new XianZhongUnit();

            BuJiMianSiJi.BaoE   = 0;
            BuJiMianSiJi.BaoFei = 0;
            Item.BuJiMianSiJi   = BuJiMianSiJi;

            XianZhongUnit BuJiMianHuaHen = new XianZhongUnit();

            BuJiMianHuaHen.BaoE   = 0;
            BuJiMianHuaHen.BaoFei = 0;
            Item.BuJiMianHuaHen   = BuJiMianHuaHen;

            XianZhongUnit BuJiMianSheShui = new XianZhongUnit();

            BuJiMianSheShui.BaoE   = 0;
            BuJiMianSheShui.BaoFei = 0;
            Item.BuJiMianSheShui   = BuJiMianSheShui;

            XianZhongUnit BuJiMianZiRan = new XianZhongUnit();

            BuJiMianZiRan.BaoE   = 0;
            BuJiMianZiRan.BaoFei = 0;
            Item.BuJiMianZiRan   = BuJiMianZiRan;

            XianZhongUnit BuJiMianJingShenSunShi = new XianZhongUnit();

            BuJiMianJingShenSunShi.BaoE   = 0;
            BuJiMianJingShenSunShi.BaoFei = 0;
            Item.BuJiMianJingShenSunShi   = BuJiMianJingShenSunShi;

            XianZhongUnit BuJiMianCheSun = new XianZhongUnit();

            BuJiMianCheSun.BaoE   = 1;
            BuJiMianCheSun.BaoFei = 635.16;
            Item.BuJiMianCheSun   = BuJiMianCheSun;

            XianZhongUnit BuJiMianSanZhe = new XianZhongUnit();

            BuJiMianSanZhe.BaoE   = 1;
            BuJiMianSanZhe.BaoFei = 159.53;
            Item.BuJiMianSanZhe   = BuJiMianSanZhe;

            XianZhongUnit BuJiMianDaoQiang = new XianZhongUnit();

            BuJiMianDaoQiang.BaoE   = 1;
            BuJiMianDaoQiang.BaoFei = 291.69;
            Item.BuJiMianDaoQiang   = BuJiMianDaoQiang;

            //XianZhongUnit BuJiMianRenYuan = new XianZhongUnit();
            //BuJiMianRenYuan.BaoE = 0;
            //BuJiMianRenYuan.BaoFei = 0;
            //Item.BuJiMianRenYuan = BuJiMianRenYuan;

            //XianZhongUnit BuJiMianFuJia = new XianZhongUnit();
            //BuJiMianFuJia.BaoE = 0;
            //BuJiMianFuJia.BaoFei = 0;
            //Item.BuJiMianFuJia = BuJiMianFuJia;

            XianZhongUnit HcSheBeiSunshi = new XianZhongUnit();

            HcSheBeiSunshi.BaoE   = 0;
            HcSheBeiSunshi.BaoFei = 0;
            Item.HcSheBeiSunshi   = HcSheBeiSunshi;

            XianZhongUnit HcHuoWuZeRen = new XianZhongUnit();

            HcHuoWuZeRen.BaoE   = 0;
            HcHuoWuZeRen.BaoFei = 0;
            Item.HcHuoWuZeRen   = HcHuoWuZeRen;

            XianZhongUnit HcFeiYongBuChang = new XianZhongUnit();

            HcFeiYongBuChang.BaoE   = 0;
            HcFeiYongBuChang.BaoFei = 0;
            Item.HcFeiYongBuChang   = HcFeiYongBuChang;

            XianZhongUnit HcJingShenSunShi = new XianZhongUnit();

            HcJingShenSunShi.BaoE   = 0;
            HcJingShenSunShi.BaoFei = 0;
            Item.HcJingShenSunShi   = HcJingShenSunShi;

            XianZhongUnit HcSanFangTeYue = new XianZhongUnit();

            HcSanFangTeYue.BaoE   = 0;
            HcSanFangTeYue.BaoFei = 0;
            Item.HcSanFangTeYue   = HcSanFangTeYue;

            XianZhongUnit HcXiuLiChang = new XianZhongUnit();

            HcXiuLiChang.BaoE   = 0;
            HcXiuLiChang.BaoFei = 0;
            Item.HcXiuLiChang   = HcXiuLiChang;

            Item.RateFactor1 = 0;
            Item.RateFactor2 = decimal.Parse("0.85");
            Item.RateFactor3 = decimal.Parse("0.85");
            Item.RateFactor4 = 0;

            viewModel.Item = Item;

            QuoteResultCarInfoViewModel CarInfo = new QuoteResultCarInfoViewModel();

            viewModel.CarInfo = CarInfo;

            viewModel.CustKey   = request.CustKey;
            viewModel.CheckCode = request.CheckCode;

            return(viewModel);
        }
コード例 #7
0
        public async Task <GetPrecisePriceReponse> GetPrecisePrice(GetPrecisePriceRequest request)
        {
            //获取报价信息和 核保信息,我发送的key都是一样的 ,不能按照险种信息hash,因为我取的时候 ,请求参数是没有险种的 ,
            // 如果换成的key跟险种信息有关,导致缓存中 会有过的垃圾数据,客户端用不到 。
            // 也就是说  缓存只存放最新的一条报价信息和核保信息
            GetPrecisePriceReponse response = new GetPrecisePriceReponse();

            //Stopwatch stopwatch = new Stopwatch();
            //stopwatch.Start();

            try
            {
                string baojiaCacheKey =
                    CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType);
                var baojiaKey = string.Format("{0}-{1}-bj-{2}", baojiaCacheKey, request.IntentionCompany, "key");
                //获取报价信息
                //需要的表
                //bx_userinfo
                //bx_LastInfo
                //bx_SaveQuote
                //bx_QuoteResult
                //bx_SubmitInfo
                //bx_renewalquote

                //步骤1  续保的时候 会发送消息队列 ,这个时候 会把 key传过去eg:bbbb。

                //步骤2   中心在续保的时候 ,需要根据这个key 设置3个开关(人太平)
                //eg:
                //bbbb-bj-0-key:,
                //bbbb-bj-1-key:,
                //bbbb-bj-2-key:,
                //放在缓存中,人太平报价成功的时候分别要置1,刚开始是空值
                //等报价结束后,先将上面列出的表写入缓存
                //其中: 键值分别是:
                //bx_userinfo        :bbbb-userinfo
                //bx_LastInfo        :bbbb-lastinfo
                //bx_car_renewal     :bbbb-renewal
                //bx_SaveQuote       :bbbb-savequote

                //bx_QuoteResult     :bbbb-0-quoteresult
                //bx_SubmitInfo      :bbbb-0-submitinfo
                var cacheKey = CacheProvider.Get <string>(baojiaKey);
                //ExecutionContext.SuppressFlow();

                if (cacheKey == null)
                {
                    for (int i = 0; i < 210; i++)
                    {
                        cacheKey = CacheProvider.Get <string>(baojiaKey);
                        if (!string.IsNullOrWhiteSpace(cacheKey))
                        {
                            break;
                        }
                        else
                        {
                            await Task.Delay(TimeSpan.FromSeconds(1));
                        }
                    }
                }
                //ExecutionContext.RestoreFlow();
                if (cacheKey == "1")
                {
                    response.UserInfo = CacheProvider.Get <bx_userinfo>(string.Format("{0}-{1}", baojiaCacheKey, "userinfo"));
                    response.LastInfo = CacheProvider.Get <bx_lastinfo>(string.Format("{0}-{1}", baojiaCacheKey, "lastinfo"));
                    var renewal = CommonCacheKeyFactory.CreateKeyWithLicense(request.LicenseNo);
                    response.Renewal   = CacheProvider.Get <bx_car_renewal>(string.Format("{0}-{1}", renewal, "renewal"));
                    response.SaveQuote =
                        CacheProvider.Get <bx_savequote>(string.Format("{0}-{1}", baojiaCacheKey, "savequote"));

                    response.QuoteResult =
                        CacheProvider.Get <bx_quoteresult>(string.Format("{0}-{1}-{2}", baojiaCacheKey,
                                                                         request.IntentionCompany, "quoteresult"));
                    response.CarInfo = CacheProvider.Get <bx_quoteresult_carinfo>(string.Format("{0}-{1}-{2}", baojiaCacheKey,
                                                                                                request.IntentionCompany, "quoteresultcarinfo"));
                    response.SubmitInfo = CacheProvider.Get <bx_submit_info>(string.Format("{0}-{1}-{2}", baojiaCacheKey,
                                                                                           request.IntentionCompany, "submitinfo"));
                    response.BusinessStatus = 1;
                }
                else if (cacheKey == "0")
                {
                    response.UserInfo  = CacheProvider.Get <bx_userinfo>(string.Format("{0}-{1}", baojiaCacheKey, "userinfo"));
                    response.LastInfo  = CacheProvider.Get <bx_lastinfo>(string.Format("{0}-{1}", baojiaCacheKey, "lastinfo"));
                    response.SaveQuote =
                        CacheProvider.Get <bx_savequote>(string.Format("{0}-{1}", baojiaCacheKey, "savequote"));
                    var renewal = CommonCacheKeyFactory.CreateKeyWithLicense(request.LicenseNo);
                    response.Renewal    = CacheProvider.Get <bx_car_renewal>(string.Format("{0}-{1}", renewal, "renewal"));
                    response.SubmitInfo = CacheProvider.Get <bx_submit_info>(string.Format("{0}-{1}-{2}", baojiaCacheKey,
                                                                                           request.IntentionCompany, "submitinfo"));
                    response.QuoteResult =
                        CacheProvider.Get <bx_quoteresult>(string.Format("{0}-{1}-{2}", baojiaCacheKey,
                                                                         request.IntentionCompany, "quoteresult"));
                    response.BusinessStatus = 3;
                }
                string baojiaCacheCheckCodeIdKey = string.Format("{0}CheckCodeKey", baojiaCacheKey);
                var    bk = CacheProvider.Get <string>(baojiaCacheCheckCodeIdKey);
                if (!string.IsNullOrWhiteSpace(bk))
                {
                    response.CheckCode = bk;
                }
                #region 新增请求记录
                var reqkey = string.Format("{0}-reqcarinfo", response.UserInfo.Id);
                response.ReqInfo = CacheProvider.Get <bx_quotereq_carinfo>(reqkey);
                #endregion
                //addby gpj 20181122 驾意险
                response.YwxDetails = CacheProvider.Get <List <bx_ywxdetail> >(string.Format("{0}-{1}-jyxinfos", baojiaCacheKey, request.IntentionCompany));
            }
            catch (Exception ex)
            {
                //stopwatch.Stop();

                ILog logError = LogManager.GetLogger("ERROR");

                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException + " 请求数据:" + request.ToJson() + "  响应结果:" + response.ToJson());
                throw;
            }
            //stopwatch.Stop();
            return(response);
        }