public string RemoveHeBao(PostSubmitInfoRequest request) { //清理缓存 string baojiaCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.ChildAgent, request.CustKey + request.RenewalCarType); string hebaokey = string.Format("{0}-{1}", baojiaCacheKey, SourceGroupAlgorithm.GetOldSource(request.Source)); //using (var client = RedisManager.GetClient()) //{ // using (var tran = client.CreatePipeline()) // { try { // tran.QueueCommand(p => // { RedisManager.Remove(string.Format("{0}-hb-{1}", hebaokey, "key")); //}); //tran.Flush(); } catch (Exception ex) { _logError.Info("重新核保清空缓存失败:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); throw new Exception("Redis 清理核保key发生异常", new RedisOperateException()); } //} //} return(hebaokey); }
public async Task <GetRepeatSubmitResponse> GetRepeatSubmitInfo(GetRepeatSubmitRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { var response = new GetRepeatSubmitResponse(); try { var privilegeResulst = _agentPrivilege.CanUse(request.Agent); if (!privilegeResulst.CheckResult) { response.Status = HttpStatusCode.Forbidden; return(response); } if (!_validService.ValidateReqest(pairs, privilegeResulst.Model.SecretKey, request.SecCode)) { response.Status = HttpStatusCode.Forbidden; return(response); } //微信端逻辑 次级代理 if (request.ChildAgent > 0) { request.Agent = request.ChildAgent; } var queryAgent = request.Agent.ToString(); var userinfo = _userInfoRepository.Search( x => x.Agent == queryAgent && x.OpenId == request.CustKey && x.RenewalCarType == request.RenewalCarType && x.IsTest == 0 && x.LicenseNo == request.LicenseNo).FirstOrDefault(); if (userinfo == null) { response.Status = HttpStatusCode.NoContent; return(response); } if (userinfo.IsSingleSubmit > 0 && userinfo.QuoteStatus == -1 && userinfo.UpdateTime.GetValueOrDefault().AddMinutes(5) > DateTime.Now) { response.Status = HttpStatusCode.Conflict; return(response); } string baojiaCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType); var lastinfo = await _getExpireDate.GetDate(baojiaCacheKey); var formatInfo = _repeatInfoFormat.FormatRepeatInfo(userinfo.IsSingleSubmit.GetValueOrDefault(), baojiaCacheKey); response = RepeatSubmitResponseFactory(lastinfo, formatInfo); } catch (Exception ex) { response.Status = HttpStatusCode.ExpectationFailed; _logError.Info("获取重复投保请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException + ",请求对象信息:" + request.ToJson() + ";返回对象信息" + response.ToJson()); } return(response); }
public async Task <GetEscapedInfoResponse> GetList(GetEscapedInfoRequest request) { GetEscapedInfoResponse response = new GetEscapedInfoResponse(); var chuxianCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType); var chuxianKey = string.Format("{0}-claimdetai-key", chuxianCacheKey); var cacheValue = string.Format("{0}-claimdetail", chuxianCacheKey); //var chuxianKey = string.Format("{0}-claimdetail", chuxianCacheKey); //var cacheKey = CacheProvider.Get<IEnumerable<bx_claim_detail>>(chuxianKey); var cacheKey = CacheProvider.Get <string>(chuxianKey); if (cacheKey == null) { for (int i = 0; i < 100; i++) { cacheKey = CacheProvider.Get <string>(chuxianKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } if (cacheKey != null) { if (cacheKey == "1") { response.List = CacheProvider.Get <IEnumerable <bx_claim_detail> >(cacheValue).ToList(); } else { response.List = new List <bx_claim_detail>(); } } else { response.List = null; } try { response.Lastinfo = CacheProvider.Get <bx_lastinfo>(string.Format("{0}-{1}", chuxianCacheKey, "lastinfo")); } catch (Exception ex) { response.Lastinfo = new bx_lastinfo(); } return(response); }
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); }
public async Task <GetViolationInfoResponse> GetList(GetViolationInfoRequest request) { GetViolationInfoResponse response = new GetViolationInfoResponse(); var chuxianCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType); var chuxianKey = string.Format("{0}-violation-key", chuxianCacheKey); ; var cacheValue = string.Format("{0}-violationl", chuxianCacheKey); var cacheKey = CacheProvider.Get <string>(chuxianKey); if (cacheKey == null) { for (int i = 0; i < 100; i++) { cacheKey = CacheProvider.Get <string>(chuxianKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } if (cacheKey != null) { if (cacheKey == "1") { response.List = CacheProvider.Get <IEnumerable <bx_violationlog> >(cacheValue).ToList(); } else { response.List = new List <bx_violationlog>(); } } else { response.List = null; } return(response); }
/// <summary> /// 从缓存中取续保的bussinessstatus /// </summary> /// <param name="licenseNo"></param> /// <returns></returns> public int GetReInfoStatus(string licenseNo) { string xuBaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(licenseNo); var xuBaoKey = string.Format("{0}-xb-{1}", xuBaoCacheKey, "key"); var cacheKey = CacheProvider.Get <string>(xuBaoKey); if (string.IsNullOrWhiteSpace(cacheKey)) { return(10000002); //缓存异常 } if (cacheKey == "1") { return(1); } var userInfo = CacheProvider.Get <bx_userinfo>(string.Format("{0}-{1}", xuBaoCacheKey, "userinfo")); switch (cacheKey) { case "0": switch (userInfo.NeedEngineNo) { case 1: return(2); case 0: return(3); default: return(4); } case "2": return(8); } return(10000002);//缓存异常 }
public async Task <BaseViewModel> RecordNewCar(RecordNewCarRequest request) { int source = SourceGroupAlgorithm.GetOldSource(request.Source); bx_car_record model = _carRecordRepository.GetModel(request.CarVin, request.EngineNo); if (model != null && model.Id > 0) { if (model.RecordStatus > 0) { //如果1分钟之内提交过,则不允许再请求 return(new BaseViewModel() { BusinessStatus = -10001, StatusMessage = "该车已提交过备案,请勿重复提交!" }); } if (model.UpdateTime.Value.AddSeconds(30) > DateTime.Now) { //如果30s之内提交过,则不允许再请求 return(new BaseViewModel() { BusinessStatus = -10001, StatusMessage = "刚提交过新车备案,请稍后再试!" }); } //此处else省略是因为下面可以通用,只修改updatetime } #region 初始化字段,存数据库值 else { model = new bx_car_record(); model.CreateTime = DateTime.Now; } model.CarVin = request.CarVin; model.EngineNo = request.EngineNo; model.DriveLicenseCarTypeName = request.DriveLicenseCarTypeName; model.DriveLicenseCarTypeValue = request.DriveLicenseCarTypeValue; model.LicenseOwner = request.LicenseOwner; model.LicenseOwnerIdType = request.LicenseOwnerIdType; model.LicenseOwnerIdTypeValue = request.LicenseOwnerIdTypeValue; model.LicenseOwnerIdNo = request.LicenseOwnerIdNo; model.TonCountflag = request.TonCountflag; model.CarTonCount = request.CarTonCount; model.CarLotEquQuality = request.CarLotEquQuality; model.VehicleExhaust = request.VehicleExhaust; model.FuelType = request.FuelType; model.FuelTypeValue = request.FuelTypeValue; model.ProofType = request.ProofType; model.ProofTypeValue = request.ProofTypeValue; model.ProofNo = request.ProofNo; model.ProofTime = !string.IsNullOrWhiteSpace(request.ProofTime) ? DateTime.Parse(request.ProofTime) : DateTime.MinValue; model.CarPrice = request.CarPrice; model.VehicleYear = request.VehicleYear; model.VehicleName = request.VehicleName; model.ModelCode = request.ModelCode; model.RecordStatus = 0;//初始化时是0 model.UpdateTime = DateTime.Now; model.Source = source; int record = _carRecordRepository.AddUpdateCarRecord(model); #endregion if (record == 0) { return(new BaseViewModel() { BusinessStatus = 0, StatusMessage = "请求失败,数据未保存成功" }); } #region 给中心发消息 string xuBaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(request.CarVin); var xuBaoKey = string.Format("{0}-CarRecord", xuBaoCacheKey); CacheProvider.Remove(xuBaoKey); var msgBody = new { Source = source, //哪家渠道 ChannelId = request.ChannelId, CarVin = request.CarVin, //车架号 EngineNo = request.EngineNo, //发动机号 NotifyCacheKey = xuBaoCacheKey, RequestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; //发送续保信息 var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["BxCarRecord"]); try { var cacheKey = CacheProvider.Get <string>(xuBaoKey); if (cacheKey == null) { for (int i = 0; i < 60; i++) { cacheKey = CacheProvider.Get <string>(xuBaoKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } if (cacheKey == null) { return(new BaseViewModel() { BusinessStatus = -1, StatusMessage = "请求失败,数据与保司交互超时。" }); } else { WaBaseResponse response = new WaBaseResponse(); response = cacheKey.FromJson <WaBaseResponse>(); if (response.ErrCode == 1) { return(new BaseViewModel() { BusinessStatus = 1, StatusMessage = "请求成功" }); } else { logError.Info(string.Format("新车备案请求调用中心失败:请求参数为:{0},返回值:{1}", request.ToJson(), cacheKey)); return(new BaseViewModel() { BusinessStatus = 0, StatusMessage = response.ErrMsg }); } } } catch (Exception ex) { logError.Info("新车备案请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); return(new BaseViewModel() { BusinessStatus = -10003, StatusMessage = "请求发生异常!" }); } #endregion }
public async Task <GetSubmitInfoResponse> GetSubmitInfo(GetSubmitInfoRequest request) { GetSubmitInfoResponse response = new GetSubmitInfoResponse(); //获取核保信息 //需要的表 //bx_userinfo //bx_SubmitInfo //步骤1 续保的时候 会发送消息队列 ,这个时候 会把 key传过去eg:cccc。 //步骤2 中心在续保的时候 ,需要根据这个key 设置1(因为最多只有一家核保)个开关 eg:cccc-hb-key:1,放在缓存中,成功的时候要置1,刚开始是空值 //等续保结束后,先将上面列出的表写入缓存 //其中: 键值分别是: //bx_SubmitInfo :cccc-submitinfo //步骤3: 讲开关缓存设置核保完成标识:cccc-hb-0-key:1 string hebaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType); var hebaoKey = string.Format("{0}-{1}-hb-{2}", hebaoCacheKey, request.IntentionCompany, "key"); //ExecutionContext.SuppressFlow(); var cacheKey = CacheProvider.Get <string>(hebaoKey); if (cacheKey == null) { for (int i = 0; i < 220; i++) { cacheKey = CacheProvider.Get <string>(hebaoKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } //ExecutionContext.RestoreFlow(); string baojiaCacheOrderIdKey = string.Format("{0}OrderIdKey", hebaoCacheKey); var ck = CacheProvider.Get <string>(baojiaCacheOrderIdKey); string baojiaCacheCheckCodeIdKey = string.Format("{0}CheckCodeKey", hebaoCacheKey); var bk = CacheProvider.Get <string>(baojiaCacheCheckCodeIdKey); //CacheProvider.Set(baojiaCacheOrderIdKey, request.OrderId, 10800);//orderid 滴滴用 ,缓存3小时 if (cacheKey == "1") { response.SubmitInfo = CacheProvider.Get <bx_submit_info>(string.Format("{0}-{1}-{2}", hebaoCacheKey, request.IntentionCompany, "submitinfo")); response.BusinessStatus = 1; } else if (cacheKey == "0") { response.SubmitInfo = CacheProvider.Get <bx_submit_info>(string.Format("{0}-{1}-{2}", hebaoCacheKey, request.IntentionCompany, "submitinfo")); response.CustKey = request.CustKey; response.BusinessStatus = 3; } response.CustKey = request.CustKey; if (!string.IsNullOrWhiteSpace(ck)) { response.OrderId = ck; } if (!string.IsNullOrWhiteSpace(bk)) { response.CheckCode = bk; } return(response); }
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); }
public async Task <GetSpecialAssumpsitResponse> GetSpecialAssumpsit(GetSpecialAssumpsitRequest request, IEnumerable <KeyValuePair <string, string> > pair) { GetSpecialAssumpsitResponse response = new GetSpecialAssumpsitResponse(); //校验:1基础校验 BaseResponse baseResponse = _validateService.Validate(request, pair); if (baseResponse.Status == HttpStatusCode.Forbidden) { response.Status = HttpStatusCode.Forbidden; 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.NotAcceptable; return(response); } //正式逻辑============= string baojiaCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType); //通知中心 var msgBody = new { B_Uid = validateResult.Item2.Id, Source = SourceGroupAlgorithm.GetOldSource(request.Source), NotifyCacheKey = baojiaCacheKey, }; //发送安心核保消息 try { var baojiaKey = string.Format("{0}-GenerateSpecial-key", baojiaCacheKey); CacheProvider.Remove(baojiaKey); var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["bxAnXinTeYue"]); var cacheKey = CacheProvider.Get <string>(baojiaKey); if (cacheKey == null) { for (int i = 0; i < 180; i++) { cacheKey = CacheProvider.Get <string>(baojiaKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } if (cacheKey == "1") { var msgModel = CacheProvider.Get <AXGainFixSpecInfoResponse>(string.Format("{0}-GenerateSpecial", baojiaCacheKey)); List <SpecialVO> SpecialContents = new List <SpecialVO>(); if (msgModel != null) { //取交强模型 if (msgModel.PackageJQVO != null) { if (msgModel.PackageJQVO.FixSpecList != null) { foreach (var item in msgModel.PackageJQVO.FixSpecList) { SpecialContents.Add(new SpecialVO() { CSpecNo = item.cSpecNo, CSysSpecContent = item.cSysSpecContent, Type = 1 }); } } } //取商业模型 if (msgModel.PackageSYVO != null) { if (msgModel.PackageSYVO.FixSpecList != null) { foreach (var item in msgModel.PackageSYVO.FixSpecList) { SpecialContents.Add(new SpecialVO() { CSpecNo = item.cSpecNo, CSysSpecContent = item.cSysSpecContent, Type = 2 }); } } } } response.SpecialContents = SpecialContents; } } catch (MessageException exception) { response.Status = HttpStatusCode.ExpectationFailed; response.ErrMsg = exception.Message; return(response); } return(response); }
/// <summary> /// 从中心获取品牌型号 /// </summary> /// <param name="carVin"></param> /// <param name="moldName"></param> /// <param name="agent">顶级代理Id</param> /// <param name="cityCode"></param> /// <returns></returns> public async Task <GetMoldNameResponse> GetMoldNameService(string carVin, string moldName, int agent, int cityCode) { GetMoldNameResponse response = new GetMoldNameResponse(); if (string.IsNullOrWhiteSpace(carVin) || carVin.Length <= 5 || string.IsNullOrWhiteSpace(moldName)) { response.MoldName = string.Empty; response.BusinessMessage = "不符合查询条件,不返回对应的品牌型号"; response.BusinessStatus = -10000; return(response); } var frontCarVin = carVin.ToUpper().Substring(0, 5); if (carVin.StartsWith("L") || moldName.ToUpper().IndexOf(frontCarVin, System.StringComparison.Ordinal) < 0) { response.MoldName = string.Empty; response.BusinessMessage = "不符合查询条件,不返回对应的品牌型号"; response.BusinessStatus = -10000; return(response); } string xuBaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(carVin); var xuBaoKey = string.Format("{0}-ModelName-key", xuBaoCacheKey); CacheProvider.Remove(xuBaoKey); var msgBody = new { Agent = agent,//顶级 CarVin = carVin, cityId = cityCode, NotifyCacheKey = xuBaoCacheKey, RequestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; //发送续保信息 var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["FindMoldName"]); try { var cacheKey = CacheProvider.Get <string>(xuBaoKey); if (cacheKey == null) { for (int i = 0; i < 60; i++) { cacheKey = CacheProvider.Get <string>(xuBaoKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(0.5)); } } } if (cacheKey == null) { response.BusinessStatus = -1;//超时 response.BusinessMessage = "请求超时"; response.MoldName = string.Empty; } else { WaPaAutoModelResponse model = new WaPaAutoModelResponse(); string itemsCache = string.Format("{0}-ModelName", xuBaoCacheKey); if (cacheKey == "1") { var temp = CacheProvider.Get <string>(itemsCache); model = temp.FromJson <WaPaAutoModelResponse>(); if (model.ErrCode == 0) { response.MoldName = model.AutoModeType != null ? model.AutoModeType.autoModelName : string.Empty; if (model.AutoModeType == null) { response.BusinessMessage = "没有取到对应的品牌型号"; } else { response.BusinessMessage = "获取成功"; } } else { response.MoldName = string.Empty; response.BusinessMessage = "没有取到对应的品牌型号"; response.BusinessStatus = -10002; } } else { response.MoldName = string.Empty; response.BusinessMessage = "没有取到对应的品牌型号"; response.BusinessStatus = -10002; } } } catch (Exception ex) { response = new GetMoldNameResponse(); response.Status = HttpStatusCode.ExpectationFailed; logError.Info("获取车型请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); } return(response); #region 以前的逻辑 //if (!string.IsNullOrWhiteSpace(carVin) && carVin.Length > 5) //{ // var frontCarVin = carVin.Substring(0, 5); // if (!carVin.StartsWith("L") && moldName.ToUpper().IndexOf(frontCarVin, System.StringComparison.Ordinal) >= 0) // { // using (HttpClient client = new HttpClient()) // { // client.BaseAddress = new Uri(_url); // var getUrl = string.Format("api/taipingyang/gettaipycarinfoby?carvin={0}", carVin); // HttpResponseMessage responseVin = client.GetAsync(getUrl).Result; // var resultVin = responseVin.Content.ReadAsStringAsync().Result; // var carinfo = resultVin.FromJson<WaGetTaiPyCarInfoResponse>(); // if (carinfo != null && carinfo.CarInfo != null) // { // return carinfo.CarInfo.moldName; // } // } // } //} #endregion }
public async Task <GetFloatingInfoResponse> GetFloatingInfo(GetFloatingInfoRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { GetFloatingInfoResponse response = new GetFloatingInfoResponse(); //校验:1基础校验 BaseResponse baseResponse = _validateService.Validate(request, pairs); if (baseResponse.Status == HttpStatusCode.Forbidden) { response.Status = HttpStatusCode.Forbidden; 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.NotAcceptable; return(response); } //校验:4是否存在核保记录 bx_submit_info submitInfo = _submitInfoRepository.GetSubmitInfo(validateResult.Item2.Id, SourceGroupAlgorithm.GetOldSource(request.Source)); string baojiaCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType); string notifyCacheKey = string.Format("{0}-gzd", baojiaCacheKey); //通知中心 var msgBody = new { B_Uid = validateResult.Item2.Id, Source = SourceGroupAlgorithm.GetOldSource(request.Source), BiztNo = submitInfo != null ? submitInfo.biz_tno : "", ForcetNo = submitInfo != null ? submitInfo.force_tno : "", NotifyCacheKey = notifyCacheKey }; //发送安心核保消息 try { string baojiaKey = string.Format("{0}-Informing", notifyCacheKey); CacheProvider.Remove(baojiaKey); var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["bxAnXinGaoZhi"]); var cacheKey = CacheProvider.Get <string>(baojiaKey); if (cacheKey == null) { for (int i = 0; i < 180; i++) { cacheKey = CacheProvider.Get <string>(baojiaKey); if (cacheKey != null) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } JSFloatingNotificationPrintListResponse jsonModel = new JSFloatingNotificationPrintListResponse(); if (!string.IsNullOrEmpty(cacheKey)) { jsonModel = cacheKey.FromJson <JSFloatingNotificationPrintListResponse>(); } response.JSFloatingNotificationPrintList = jsonModel.JSFloatingNotificationPrintListResponseMain; } catch (MessageException exception) { response.Status = HttpStatusCode.ExpectationFailed; response.ErrMsg = exception.Message; return(response); } return(response); }
public GetReInfoResponse GetReInfo(GetReInfoRequest request) { var xubaokey = new { LicenseNo = request.LicenseNo, Agent = request.Agent }; var xuBaoCacheKey = CommonCacheKeyFactory.MakeCacheKey(xubaokey); var xuBaoKey = string.Format("{0}-{1}", xuBaoCacheKey, "key"); var cacheKey = CacheProvider.Get <string>(xuBaoKey); if (cacheKey == null) { for (int i = 0; i < 30; i++) { cacheKey = CacheProvider.Get <string>(xuBaoKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { Task.Delay(TimeSpan.FromSeconds(1)); } } } if (!string.IsNullOrWhiteSpace(cacheKey)) { GetReInfoResponse response = new GetReInfoResponse(); //续保 需要的表 //bx_userinfo //bx_renewalquote //bx_carinfo //步骤1 续保的时候 会发送消息队列 ,这个时候 会把 key传过去eg:aaaa。 //步骤2 中心在续保的时候 ,需要根据这个key 设置一个开关 eg:aaaa-key:1,放在缓存中,成功的时候要置1,刚开始是空值 //等续保结束后,先将上面列出的表写入缓存 //其中: 键值分别是: //bx_userinfo :aaaa-userinfo //bx_renewalquote :aaaa-renewal //bx_carinfo :aaaa-carinfo //步骤3: 讲开关缓存设置续保完成标识:aaaa-key:1 //续保缓存标示(是否成功) if (cacheKey == "1") { response.UserInfo = CacheProvider.Get <bx_userinfo>(string.Format("{0}-{1}", xuBaoCacheKey, "userinfo")); response.SaveQuote = CacheProvider.Get <bx_renewalquote>(string.Format("{0}-{1}", xuBaoCacheKey, "renewal")); response.CarInfo = CacheProvider.Get <bx_carinfo>(string.Format("{0}-{1}", xuBaoCacheKey, "carinfo")); response.BusinessStatus = 1; } else { response = null; } return(response); } else { return(null); } }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <returns></returns> public bool BackTempDemoShow(PostPrecisePriceRequest request, out string tempshowKey) { tempshowKey = string.Empty; //1是否吉利代理 if (!_proxyAgent.Equals(request.Agent.ToString())) { return(false); } if (!_proxyLicense.Contains(request.LicenseNo)) { return(false); } //2是否开启配置;1开启0关闭,控制权限请联系中心 string isOpen = _getCenterValueService.GetValue("独立KV", "", "TempDemoShow"); if (isOpen.Equals("0")) { logError.Info(string.Format("请求{0},{1},{2},中心开关开启", request.CustKey, request.LicenseNo, request.CarVin)); return(false); } //3是否存在历史报价 PostPrecisePriceRequest req = new PostPrecisePriceRequest(); req = request; //... req.SecCode = null; //... req.InsuredMobile = null; req.InsuredAddress = null; req.InsuredEmail = null; req.InsuredCertiStartdate = null; req.InsuredCertiEnddate = null; //... req.HolderMobile = null; req.HolderAddress = null; req.HolderEmail = null; req.HolderCertiStartdate = null; req.HolderCertiEnddate = null; //... req.InsuredSex = 0; req.HolderSex = 0; req.OwnerSex = 0; req.InsuredAuthority = null; req.HolderAuthority = null; req.OwnerAuthority = null; req.InsuredNation = null; req.HolderNation = null; req.OwnerNation = null; req.InsuredBirthday = null; req.HolderBirthday = null; req.OwnerBirthday = null; //... req.BhToken = null; //... req.Mobile = null; req.Email = null; req.MultiChannels = null; req.IsOrderChangeRelation = 0; tempshowKey = string.Format("{0}_{1}_{2}", request.Agent, request.CustKey.ToUpper(), req.ToJson().GetMd5());//顶级+custkey+seccode logError.Info(string.Format("缓存md5前的串:{0}", req.ToJson())); string cacheValue = CacheProvider.Get <string>(tempshowKey); if (string.IsNullOrWhiteSpace(cacheValue)) { logError.Info(string.Format("请求{0},{1},{2},不存在历史报价", request.CustKey, request.LicenseNo, request.CarVin)); //如果中间缓存报过价,继续往下走;如果没报过价,直接返回false return(false); } #region 4历史报价是否报价成功&&核保成功 //4历史报价是否报价成功&&核保成功 if (req.ChildAgent > 0) { req.Agent = req.ChildAgent; } //报价key string baojiaCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, req.Agent, request.CustKey + request.RenewalCarType); List <int> oldquote = SourceGroupAlgorithm.ParseOldSource(request.QuoteGroup); if (!oldquote.Any()) { //如果报价没值,直接返回false。<不过该情况不存在,quotegroup需要大于0> return(false); } foreach (var item in oldquote) { //取不同的保司,看缓存key是否都存在 var baojiaKey = string.Format("{0}-{1}-bj-{2}", baojiaCacheKey, item, "key"); var cachebaojiavalue = CacheProvider.Get <string>(baojiaKey); if (string.IsNullOrWhiteSpace(cachebaojiavalue)) { cachebaojiavalue = "0"; } if (!cachebaojiavalue.Equals("1")) { logError.Info(string.Format("请求{0},{1},{2},报价{3},历史报价{4}失败", request.CustKey, request.LicenseNo, request.CarVin, request.QuoteGroup, item)); return(false); } } List <int> oldsubmit = SourceGroupAlgorithm.ParseOldSource(request.SubmitGroup); if (!oldsubmit.Any()) { //如果核保没值,直接返回false return(false); } foreach (var item in oldquote) { //取不同的保司,看缓存key是否都存在 var baojiaKey = string.Format("{0}-{1}-hb-{2}", baojiaCacheKey, item, "key"); var cachehebaovalue = CacheProvider.Get <string>(baojiaKey); if (string.IsNullOrWhiteSpace(cachehebaovalue)) { cachehebaovalue = "0"; } if (!cachehebaovalue.Equals("1")) { logError.Info(string.Format("请求{0},{1},{2},核保{3},历史核保{4}失败", request.CustKey, request.LicenseNo, request.CarVin, request.SubmitGroup, item)); return(false); } } #endregion //5如果成功,则保存seccode //6以上均成立返回true return(true); }
public async Task <SpecialListResponse> GetSpeciaList(GetSpecialListRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { SpecialListResponse response = new SpecialListResponse(); string ukeyId; var agentConfig = _agentConfig.FindBy(request.AgentId, request.CityId).FirstOrDefault(conf => conf.source == SourceGroupAlgorithm.GetOldSource(request.Source)); if (agentConfig == null) { response.Status = HttpStatusCode.Forbidden; response.BusinessStatus = -10001; response.BusinessMessage = "没有找到代理人配置"; return(response); } else { ukeyId = agentConfig.ukey_id.ToString(); } bx_agent agentModel = GetAgent(request.AgentId); //参数校验 if (agentModel == null) { response.Status = HttpStatusCode.Forbidden; response.BusinessStatus = -10001; response.BusinessMessage = "没有找到代理人"; return(response); } if (!ValidateReqest(pairs, agentModel.SecretKey, request.SecCode)) { response.Status = HttpStatusCode.Forbidden; response.BusinessStatus = -10001; response.BusinessMessage = "参数校验失败"; return(response); } string SpecicalCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(request.AgentId.ToString() + request.CityId.ToString() + request.Source.ToString()); var key = string.Format("{0}-SpecialOptions-key", SpecicalCacheKey); string cacheKey = CacheProvider.Get <string>(key); if (cacheKey != null) { if (cacheKey == "1") { string listcachekey = string.Format("{0}-SpecialOptions", SpecicalCacheKey); response = CacheProvider.Get <SpecialListResponse>(listcachekey); response.Status = HttpStatusCode.OK; response.BusinessStatus = 1; response.BusinessMessage = "获取特约成功"; response.Key = listcachekey; return(response); } else { CacheProvider.Remove(key); } } object msgBody; msgBody = new { Source = SourceGroupAlgorithm.GetOldSource(request.Source), CityId = request.CityId, TopAgentId = request.AgentId, ukeyId = ukeyId, NotifyCacheKey = SpecicalCacheKey }; _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["SpecialOption"]); for (int i = 0; i < 115; i++) { cacheKey = CacheProvider.Get <string>(key); //step1val = xuBaoKey; //step1va2 = cacheKey; if (!string.IsNullOrWhiteSpace(cacheKey)) { if (cacheKey == "0" || cacheKey == "1") { break; } } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } if (cacheKey == null) { response.Status = HttpStatusCode.Forbidden; response.BusinessStatus = -10003;//缓存异常 response.BusinessMessage = "请求超时或缓存异常,请重试"; response.Key = ""; return(response); } else if (cacheKey == "0") { response.Status = HttpStatusCode.Forbidden; response.BusinessStatus = 0; response.BusinessMessage = "获取特约检索失败"; response.Key = ""; return(response); } else { string listcachekey = string.Format("{0}-SpecialOptions", SpecicalCacheKey); response = CacheProvider.Get <SpecialListResponse>(listcachekey); response.Status = HttpStatusCode.OK; response.BusinessStatus = 1; response.BusinessMessage = "获取特约成功"; response.Key = listcachekey; return(response); } }
public async Task <GetReInfoResponse> GetReInfo(GetReInfoRequest request, long?buid = null) { ILog logInfo = LogManager.GetLogger("ERROR"); //logInfo.Info("读取缓存数据开始" + request.ToJson()); string xuBaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(request.LicenseNo + request.RenewalCarType); var xuBaoKey = string.Format("{0}-xb-{1}", xuBaoCacheKey, "key"); var cacheKey = CacheProvider.Get <string>(xuBaoKey); #region //var step1val = string.Empty; //var step1va2 = string.Empty; //var step1va3 = string.Empty; //var step1va4 = string.Empty; StringBuilder sb = new StringBuilder(); #endregion if (cacheKey == null) { for (int i = 0; i < 115; i++) { cacheKey = CacheProvider.Get <string>(xuBaoKey); //step1val = xuBaoKey; //step1va2 = cacheKey; if (!string.IsNullOrWhiteSpace(cacheKey)) { if (cacheKey == "0" || cacheKey == "1" || cacheKey == "2") { break; } } else { //ExecutionContext.SuppressFlow(); await Task.Delay(TimeSpan.FromSeconds(1)); //ExecutionContext.RestoreFlow(); } //logInfo.Info("读取缓存数据循环"+i+" "+ request.ToJson() + "; 缓存key是step1va2:" + step1va2 + " -- key:step1va1" + step1val); //sb.AppendLine("读取缓存数据循环" + i + " " + request.ToJson() + "; 缓存key是step1va2:" + step1va2 + // " -- key:step1va1" + step1val); } } GetReInfoResponse response = new GetReInfoResponse(); try { if (!string.IsNullOrWhiteSpace(cacheKey)) { //续保 需要的表 //bx_userinfo //bx_renewalquote //bx_carinfo //步骤1 续保的时候 会发送消息队列 ,这个时候 会把 key传过去eg:aaaa。 //步骤2 中心在续保的时候 ,需要根据这个key 设置一个开关 eg:aaaa-key:1,放在缓存中,成功的时候要置1,刚开始是空值 //等续保结束后,先将上面列出的表写入缓存 //其中: 键值分别是: //bx_userinfo :aaaa-userinfo //bx_car_renewal :aaaa-renewal //bx_carinfo :aaaa-carinfo //步骤3: 讲开关缓存设置续保完成标识:aaaa-key:1 //续保缓存标示(是否成功) var renwal = CommonCacheKeyFactory.CreateKeyWithLicense(request.LicenseNo + request.RenewalCarType); if (cacheKey == "1") { response.UserInfo = CacheProvider.Get <bx_userinfo>(string.Format("{0}-{1}", xuBaoCacheKey, "userinfo")); response.SaveQuote = CacheProvider.Get <bx_car_renewal>(string.Format("{0}-{1}", renwal, "renewal")); response.CarInfo = CacheProvider.Get <bx_carinfo>(string.Format("{0}-{1}", renwal, "carinfo")); response.LastInfo = CacheProvider.Get <bx_lastinfo>(string.Format("{0}-{1}", renwal, "lastinfo")); //续保返回保费addbygpj20180926 response.RenewalPremium = CacheProvider.Get <bx_car_renewal_premium>(string.Format("{0}-{1}", renwal, "premium")); response.BusinessStatus = 1; } else if (cacheKey == "0") { #region 先获取平安验证码 if (buid != null) { if (request.ShowPACheckCode == 1 && string.IsNullOrWhiteSpace(request.RequestKey) && request.PAUKey == 0 && request.YZMArea == null) { /* * 如果平安续保返回需要验证码,缓存平安验证码信息 */ string payzmkey = string.Format("{0}-PAYZM", buid); CenterPicCodeCacheModel payzmvalue = CacheProvider.Get <CenterPicCodeCacheModel>(payzmkey); if (payzmvalue != null) { response = new GetReInfoResponse(); response.UserInfo = new bx_userinfo(); response.CenterPicCodeCacheModel = payzmvalue; if (response.CenterPicCodeCacheModel.ErrCode == -210002) { response.BusinessStatus = -10009; response.BusinessMessage = "获取续保信息失败,请输入验证码坐标"; } else if (response.CenterPicCodeCacheModel.ErrCode == -210003) { response.BusinessStatus = 0; response.BusinessMessage = "输入验证码错误"; } else if (response.CenterPicCodeCacheModel.ErrCode == -210004) { response.BusinessStatus = 0; response.BusinessMessage = "输入超时"; } response.Status = HttpStatusCode.OK; response.UserInfo.Id = (long)buid; return(response); } } } #endregion response.UserInfo = CacheProvider.Get <bx_userinfo>(string.Format("{0}-{1}", xuBaoCacheKey, "userinfo")); response.CarInfo = CacheProvider.Get <bx_carinfo>(string.Format("{0}-{1}", renwal, "carinfo")); if (response.UserInfo.NeedEngineNo == 1) { response.BusinessStatus = 2; } else if (response.UserInfo.NeedEngineNo == 0) //去掉 && response.UserInfo.QuoteStatus == 0 { response.BusinessStatus = 3; } else { response.BusinessStatus = 4; } } else if (cacheKey == "2") { response.UserInfo = CacheProvider.Get <bx_userinfo>(string.Format("{0}-{1}", xuBaoCacheKey, "userinfo")); //var renwal = CommonCacheKeyFactory.CreateKeyWithLicense(request.LicenseNo); response.SaveQuote = new bx_car_renewal(); response.RenewalPremium = new bx_car_renewal_premium(); //CacheProvider.Get<bx_car_renewal>(string.Format("{0}-{1}", renwal, "renewal")); response.BusinessStatus = 8; response.LastInfo = CacheProvider.Get <bx_lastinfo>(string.Format("{0}-{1}", renwal, "lastinfo")); response.BusinessMessage = CacheProvider.Get <string>(string.Format("{0}-xb-company", xuBaoCacheKey)); } //过户车的模型 response.TransferModelList = CacheProvider.Get <List <TransferModel> >(string.Format("{0}-xb-key-newcarinfo", xuBaoCacheKey)); return(response); } else { response.UserInfo = new bx_userinfo(); //如果没拿到值,初始化以下基础信息字段 response.UserInfo.LicenseNo = request.LicenseNo; response.UserInfo.CarVIN = request.CarVin; response.UserInfo.EngineNo = request.EngineNo; response.BusinessStatus = 0;//缓存异常 response.BusinessMessage = "请求超时或缓存异常,请重试"; return(response); } } catch (Exception ex) { logInfo.Info("读取缓存发生异常" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); } return(response); }
public async Task <WaBxSysJyxResponse> GetAccidentList(GetAccidentListRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { WaBxSysJyxResponse response = new WaBxSysJyxResponse(); //参数校验 BaseResponse baseResponse = _validateService.Validate(request, pairs); if (baseResponse.Status == HttpStatusCode.Forbidden) { //response.Status = HttpStatusCode.Forbidden; response.ErrCode = -1; return(response); } string SpecicalCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(request.Agent.ToString() + request.CityCode.ToString() + request.Source.ToString()); var key = string.Format("{0}-RiskOfdrive-key", SpecicalCacheKey); string cacheKey = CacheProvider.Get <string>(key); if (cacheKey != null) { if (cacheKey == "1") { string listcachekey = string.Format("{0}-RiskOfdrive", SpecicalCacheKey); response = CacheProvider.Get <WaBxSysJyxResponse>(listcachekey); //response.Status = HttpStatusCode.OK; response.ErrCode = 1; response.ErrMsg = "获取成功"; //response.Key = listcachekey; return(response); } else { CacheProvider.Remove(key); } } object msgBody; msgBody = new { Source = SourceGroupAlgorithm.GetOldSource(request.Source), CityId = request.CityCode, TopAgentId = request.Agent, NotifyCacheKey = SpecicalCacheKey }; _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["JYOption"]); for (int i = 0; i < 115; i++) { cacheKey = CacheProvider.Get <string>(key); //step1val = xuBaoKey; //step1va2 = cacheKey; if (!string.IsNullOrWhiteSpace(cacheKey)) { if (cacheKey == "0" || cacheKey == "1") { break; } } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } if (cacheKey == null) { //response.Status = HttpStatusCode.Forbidden; response.ErrCode = -10003;//缓存异常 response.ErrMsg = "请求超时或缓存异常,请重试"; //response.Key = ""; return(response); } else if (cacheKey == "0") { //response.Status = HttpStatusCode.Forbidden; response.ErrCode = 0; response.ErrMsg = "获取特约检索失败"; //response.Key = ""; return(response); } else { string listcachekey = string.Format("{0}-RiskOfdrive", SpecicalCacheKey); response = CacheProvider.Get <WaBxSysJyxResponse>(listcachekey); //response.Status = HttpStatusCode.OK; response.ErrCode = 1; response.ErrMsg = "获取特约成功"; //response.Key = listcachekey; return(response); } }
/// <summary> /// 普通查询车型接口,第二版 /// </summary> /// <param name="request"></param> /// <param name="pairs"></param> /// <returns></returns> public async Task <GetNewCarVehicleInfoResponse> GetCarVehicle(GetVehicleRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { GetNewCarVehicleInfoResponse response = new GetNewCarVehicleInfoResponse(); //校验:1基础校验 BaseResponse baseResponse = _validateService.Validate(request, pairs); if (baseResponse.Status == HttpStatusCode.Forbidden) { response.Status = HttpStatusCode.Forbidden; return(response); } var topagent = request.Agent; //微信端逻辑 次级代理 if (request.ChildAgent > 0) { request.Agent = request.ChildAgent; } //针对车架号+发动机号的逻辑 bx_userinfo userinfo = null; string xuBaoCacheKey; if (!string.IsNullOrWhiteSpace(request.EngineNo) && !string.IsNullOrWhiteSpace(request.CarVin)) { userinfo = _userInfoRepository.FindByCarvin(request.CarVin, request.EngineNo, request.CustKey, request.Agent.ToString(), request.CarType); xuBaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(string.Format("{0}-{1}-{2}-{3}", topagent, request.CarVin, request.EngineNo, "moldname" + request.CarType)); } else { userinfo = _userInfoRepository.FindByOpenIdAndLicense(request.CustKey, request.LicenseNo, request.Agent.ToString(), request.CarType); xuBaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(string.Format("{0}-{1}-{2}", topagent, request.LicenseNo, "moldname" + request.CarType)); } #region 新增逻辑 平安报价需要区分类型 if (userinfo != null) { var reqItem = _quoteReqCarinfoRepository.Find(userinfo.Id); if (reqItem != null) { reqItem.pingan_quote_type = request.IsNeedCarVin; _quoteReqCarinfoRepository.Update(reqItem); } else { reqItem = new bx_quotereq_carinfo { pingan_quote_type = request.IsNeedCarVin }; _quoteReqCarinfoRepository.Add(reqItem); } } #endregion if (request.IsNeedCarVin == 0 && request.MoldName.Trim().Length == 0) { response.Status = HttpStatusCode.Forbidden; return(response); } var xuBaoKey = string.Format("{0}-{1}-carmodelListV2-key", xuBaoCacheKey, request.IsNeedCarVin); CacheProvider.Remove(xuBaoKey); //获取品牌型号 var moldNameViewModle = await _getMoldNameFromCenter.GetMoldNameService(request.CarVin, request.MoldName, topagent, request.CityCode); if (moldNameViewModle != null && !string.IsNullOrEmpty(moldNameViewModle.MoldName)) { request.MoldName = moldNameViewModle.MoldName; } var msgBody = new { Agent = topagent, B_Uid = 0, VehicleName = request.MoldName, cityId = request.CityCode.ToString(), NotifyCacheKey = xuBaoCacheKey, IsNeedVin = request.IsNeedCarVin, CarVin = request.CarVin, //安心保险需要的2个参数 LicenseNo = request.LicenseNo, RegisterDate = request.RegisterDate }; //发送信息 //var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), // ConfigurationManager.AppSettings["MessageCenter"], // ConfigurationManager.AppSettings["BxVechileQueue2"]); try { string strurl = string.Format("{0}/service/carModelsv2queue", ConfigurationManager.AppSettings["CenterNewUrl"]); string returnServerIpPort = string.Empty; string result = ProxyCenterHttpClient.Post(strurl, msgBody.ToJson(), 60, ref returnServerIpPort); var cacheKey = CacheProvider.Get <string>(xuBaoKey); if (cacheKey == null) { for (int i = 0; i < 60; i++) { cacheKey = CacheProvider.Get <string>(xuBaoKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } response.Vehicles = new List <NewBxCarVehicleInfo>(); if (cacheKey == null) { response.BusinessStatus = -1;//超时 response.BusinessMessage = "请求超时"; } else { string itemsCache = string.Format("{0}-{1}-carmodelListV2", xuBaoCacheKey, request.IsNeedCarVin); response.BusinessStatus = 1; if (cacheKey == "1") { var temp = CacheProvider.Get <string>(itemsCache); response.Vehicles = temp.FromJson <List <NewBxCarVehicleInfo> >(); if (response.Vehicles != null && response.Vehicles.Count > 1) { response.Vehicles = response.Vehicles.OrderBy(x => x.PriceT).ToList(); } } } } catch (Exception ex) { response = new GetNewCarVehicleInfoResponse(); response.Status = HttpStatusCode.ExpectationFailed; logError.Info("获取车型请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); } return(response); }
public async Task <GetReInfoResponse> PushCenterService(GetReInfoRequest request, long buid, string reqCacheKey) { var response = new GetReInfoResponse(); //续保选择其他保司续保时,只取行驶本信息,不发续保请求 #region 发送续保消息 string xuBaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(request.LicenseNo + request.RenewalCarType); var xuBaoKey = string.Format("{0}-xb-{1}", xuBaoCacheKey, "key"); CacheProvider.Remove(xuBaoKey); object msgBody; if (request.RenewalSource <= 0) { msgBody = new { B_Uid = buid, IsCloseSms = 0, NotifyCacheKey = xuBaoCacheKey, IsForceRenewal = request.IsForceRenewal == 1//是否强制刷新续保 }; } else { msgBody = new { B_Uid = buid, IsCloseSms = 0, //改为help类里面通用方法 by.20180904.gpj RenewalSource = SourceGroupAlgorithm.ParseOldSource(request.RenewalSource).ToHashSet(), NotifyCacheKey = xuBaoCacheKey, IsForceRenewal = request.IsForceRenewal == 1//是否强制刷新续保 }; ///如果传进来的三个值都不为空 ShowPACheckCode=1 if (!string.IsNullOrWhiteSpace(request.RequestKey) && request.PAUKey != 0 && request.YZMArea != null) { msgBody = new { B_Uid = buid, IsCloseSms = 0, //改为help类里面通用方法 by.20180904.gpj RenewalSource = SourceGroupAlgorithm.ParseOldSource(request.RenewalSource).ToHashSet(), NotifyCacheKey = xuBaoCacheKey, RequestKey = request.RequestKey, PAUKey = request.PAUKey, YZMArea = request.YZMArea, IsForceRenewal = request.IsForceRenewal == 1//是否强制刷新续保 }; } } //发送续保信息 //var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["BxXuBaoName"]); string strurl = string.Format("{0}/service/getrenewal", ConfigurationManager.AppSettings["CenterNewUrl"]); string returnServerIpPort = string.Empty; string result = ProxyCenterHttpClient.Post(strurl, msgBody.ToJson(), 60, ref returnServerIpPort); #endregion #region 缓存读取 ExecutionContext.SuppressFlow(); response = await _carInsuranceCache.GetReInfo(request, buid); #region 改由中心 写 缓存 response.ReqCarinfo = CacheProvider.Get <bx_quotereq_carinfo>(reqCacheKey); #endregion #endregion return(response); }
/// <summary> /// 新车查询车型接口第一步 /// </summary> /// <param name="request"></param> /// <param name="pairs"></param> /// <returns></returns> public async Task <GetCarVehicleInfoResponse> GetNewCarVehicle(GetNewCarVehicleRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { GetCarVehicleInfoResponse response = new GetCarVehicleInfoResponse(); //校验:1基础校验 BaseResponse baseResponse = _validateService.Validate(request, pairs); if (baseResponse.Status == HttpStatusCode.Forbidden) { response.Status = HttpStatusCode.Forbidden; return(response); } //微信端逻辑 次级代理 if (request.ChildAgent > 0) { request.Agent = request.ChildAgent; } //if (request.MoldName.Trim().Length == 0) //{ // response.Status = HttpStatusCode.Forbidden; // return response; //} string xuBaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(string.Format("{0}{1}{2}", request.CarVin, request.EngineNo, request.MoldName)); var xuBaoKey = string.Format("{0}-{1}-carmodel-key", xuBaoCacheKey, request.IsNeedCarVin); CacheProvider.Remove(xuBaoKey); var msgBody = new { Agent = request.Agent, CarVin = request.CarVin, VehicleName = request.MoldName, cityId = request.CityCode, NotifyCacheKey = xuBaoCacheKey, RequestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; //发送续保信息 //var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["BxVechileQueue"]); try { string strurl = string.Format("{0}/service/carmodelsrecord", ConfigurationManager.AppSettings["CenterNewUrl"]); string returnServerIpPort = string.Empty; string result = ProxyCenterHttpClient.Post(strurl, msgBody.ToJson(), 60, ref returnServerIpPort); var cacheKey = CacheProvider.Get <string>(xuBaoKey); if (cacheKey == null) { for (int i = 0; i < 60; i++) { cacheKey = CacheProvider.Get <string>(xuBaoKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(0.5)); } } } response.Vehicles = new List <BxCarVehicleInfo>(); if (cacheKey == null) { response.BusinessStatus = -1;//超时 response.BusinessMessage = "请求超时"; } else { string itemsCache = string.Format("{0}-{1}-carmodel", xuBaoCacheKey, request.IsNeedCarVin); response.BusinessStatus = 1; if (cacheKey == "1") { var temp = CacheProvider.Get <string>(itemsCache); response.Vehicles = temp.FromJson <List <BxCarVehicleInfo> >(); } else if (cacheKey == "-10002") { response.BusinessStatus = -10002; } else if (cacheKey == "-10003") { response.BusinessStatus = -10003; } else if (cacheKey == "-10004") { response.BusinessStatus = -10004; } } } catch (Exception ex) { response = new GetCarVehicleInfoResponse(); response.Status = HttpStatusCode.ExpectationFailed; logError.Info("获取车型请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); } return(response); }