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 <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); }
/// <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); }