public HttpResponseMessage Get([FromUri] GetBjdItemRequest request) { logInfo.Info(string.Format("获取报价单信息接口请求串:{0}", Request.RequestUri)); var item = new BaojiaItemViewModel(); if (!ModelState.IsValid) { item.BusinessStatus = -10000; string msg = ModelState.Values.Where(a => a.Errors.Count == 1).Aggregate(string.Empty, (current, a) => current + (a.Errors[0].ErrorMessage + "; ")); item.StatusMessage = "输入参数错误," + msg; return(item.ResponseToJson()); } try { var response = _bjdService.GetBjdInfo(request, Request.GetQueryNameValuePairs()); item.BusinessStatus = 1; if (request.Test == 1) {//调试用 response.Baodanxinxi = null; } if (response.Baodanxinxi != null && response.Baodanxinxi.Id > 0) { item = response.Baodanxinxi.ConvertToViewModel(response.Baodanxianzhong, response.ClaimDetail, response.Savequote, response.AgentDetail, response.Activitys); } else if (request.JieKouUrl == 0) {//JieKouUrl为防止南北方都没数据循环调用 //南北方机房互相调用 var jifangConfig = ConfigurationManager.AppSettings["JiFangUrl"]; string jifangUrl = string.Empty; if (jifangConfig != null) { jifangUrl = jifangConfig.ToString(); } if (!string.IsNullOrEmpty(jifangUrl)) { string geturl = string.Format("{0}/api/Bjd/Get?JieKouUrl=1&Bxid={1}", jifangUrl, request.Bxid); string result = HttpWebAsk.HttpGet(geturl); item = result.FromJson <BaojiaItemViewModel>(); return(item.ResponseToJson()); } } logInfo.Info(string.Format("获取报价单信息接口返回值:{0}", item.ToJson())); } catch (Exception ex) { item.BusinessStatus = -10003; item.StatusMessage = "服务器发生异常"; logError.Info("获取报价单信息单发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); } return(item.ResponseToJson()); }
public HttpResponseMessage GetShare([FromUri] GetBjdItemRequest request) { _logAppInfo.Info(string.Format("获取分享接口请求串:{0}", Request.RequestUri)); var viewModel = new BaojiaItemViewModel(); if (!ModelState.IsValid) { viewModel.BusinessStatus = -10000; string msg = ModelState.Values.Where(a => a.Errors.Count == 1).Aggregate(string.Empty, (current, a) => current + (a.Errors[0].ErrorMessage + "; ")); viewModel.StatusMessage = "输入参数错误," + msg; return(viewModel.ResponseToJson()); } viewModel = _appAchieveService.GetShare(request, Request.GetQueryNameValuePairs(), Request.RequestUri); //_logAppInfo.Info(string.Format("获取分享接口返回值:{0}", viewModel.ToJson())); return(viewModel.ResponseToJson()); }
public BaojiaItemViewModel GetShare(GetBjdItemRequest request, IEnumerable <KeyValuePair <string, string> > pairs, Uri uri) { var viewModel = new BaojiaItemViewModel(); #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/Bjd/Get", uri.Host, uri.Port); //3,续保请求 BaseResponse rep = SimulateSyncGet(strUrl, pairs); if (rep.ErrCode == 1) { viewModel = rep.ErrMsg.FromJson <BaojiaItemViewModel>(); } else { viewModel.BusinessStatus = rep.ErrCode; viewModel.StatusMessage = rep.ErrMsg; } //bx_userinfo userinfo = _userInfoRepository.FindByOpenIdAndLicense(request.CustKey, request.LicenseNo, request.ChildAgent.ToString()); //viewModel.Buid = userinfo != null ? userinfo.Id : 0; //viewModel.Agent = baseResponse.Agent; //viewModel.AgentName = baseResponse.AgentName; #endregion return(viewModel); }
public BaojiaItemViewModel GetBjdInfo(GetBjdItemRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { var response = new BaojiaItemViewModel() { BusinessStatus = 0 }; try { var bjdCheck = _getBjdCheck.BjdCheckMessage(request.Bxid); if (bjdCheck.State == 0) { response.BusinessStatus = 0; return(response); } var bjdItemResponse = new GetBjdItemResponse(); bjdItemResponse.Baodanxinxi = bjdCheck.Baodanxinxi; bjdItemResponse.Baodanxianzhong = bjdCheck.Baodanxianzhong; if (bjdItemResponse.Baodanxinxi != null && !string.IsNullOrEmpty(bjdItemResponse.Baodanxinxi.activity_ids)) { bjdItemResponse.Activitys = _preferentialActivityRepository.GetActivityByIdsAsync(bjdItemResponse.Baodanxinxi.activity_ids).Result; } if (bjdCheck.BjUnion != null) { bjdItemResponse.ClaimDetail = _userClaimRepository.FindListAsync(bjdCheck.BjUnion.b_uid).Result; bjdItemResponse.Savequote = _saveQuoteRepository.GetSavequoteByBuidAsync(bjdCheck.BjUnion.b_uid).Result; } response.BusinessStatus = 1; response = _mapBjdInfoRecord.ConvertToViewModel(bjdItemResponse); } catch (Exception ex) { response.BusinessStatus = -1; logErr.Info("获取分享报价单单发生异常,请求串为:" + request.ToJson() + "/n错误信息:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); } return(response); }
public BaojiaItemViewModel ConvertToViewModel(GetBjdItemResponse bjdItemResponse) { bj_baodanxinxi xinxi = bjdItemResponse.Baodanxinxi; bj_baodanxianzhong xianzhong = bjdItemResponse.Baodanxianzhong; List <bx_claim_detail> claimDetail = bjdItemResponse.ClaimDetail; bx_savequote savequote = bjdItemResponse.Savequote; AgentViewModelByBJ AgentDetail = bjdItemResponse.AgentDetail; List <bx_preferential_activity> Activitys = bjdItemResponse.Activitys; var item = new BaojiaItemViewModel(); #region BaoJiaInfo item.BaoJiaInfo = new BaojiaInfoViewModel { CarOwner = xinxi.CarOwner, BizStartDate = xinxi.BizStartDate.ToString(), ForceStartDate = xinxi.ForceStartDate.ToString(), CarBrandModel = xinxi.CarBrandModel, CarLicense = xinxi.CarLicense, CompanyId = xinxi.CompanyId.HasValue ? SourceGroupAlgorithm.GetNewSource(xinxi.CompanyId.Value) : 0, // CompanyName = xinxi., ChannelId = xinxi.ChannelId.HasValue ? xinxi.ChannelId.Value : 0, InsureIdType = xinxi.InsureIdType, InsureIdNum = xinxi.InsureIdNum, //新增的4个费率 NonClaimRate = xinxi.NonClaimRate.HasValue ? xinxi.NonClaimRate.Value : 0, MultiDiscountRate = xinxi.MultiDiscountRate.HasValue ? xinxi.MultiDiscountRate.Value : 0, AvgMileRate = xinxi.AvgMileRate.HasValue ? xinxi.AvgMileRate.Value : 0, RiskRate = xinxi.RiskRate.HasValue ? xinxi.RiskRate.Value : 0, BizNum = xinxi.BizNum, ForceNum = xinxi.ForceNum, //座位数 CarSeat = xinxi.CarSeated, VehicleInfo = xinxi.VehicleInfo, JqVehicleClaimType = xinxi.JqVehicleClaimType, SyVehicleClaimType = xinxi.SyVehicleClaimType, LastBizEndDate = xinxi.BizEndDate.HasValue ? xinxi.BizEndDate.Value.Date == DateTime.MinValue.Date ? "" : xinxi.BizEndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", LastForceEndDate = xinxi.ForceEndDate.HasValue ? xinxi.ForceEndDate.Value.Date == DateTime.MinValue.Date ? "" : xinxi.ForceEndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", ActivityContent = string.IsNullOrEmpty(xinxi.activity_content) ? "" : xinxi.activity_content }; if (!string.IsNullOrEmpty(xinxi.TotalRate)) { item.BaoJiaInfo.TotalRate = xinxi.TotalRate; } else { item.BaoJiaInfo.TotalRate = (item.BaoJiaInfo.NonClaimRate * item.BaoJiaInfo.MultiDiscountRate * item.BaoJiaInfo.AvgMileRate * item.BaoJiaInfo.RiskRate).ToString("f4"); } #endregion #region XianZhongInfo item.XianZhongInfo = new BaoxianXianZhongViewModel { //BizRate = xinxi.BizRate.HasValue ? xinxi.BizRate.Value : 0, //ForceRate = xinxi.ForceRate.HasValue?xinxi.ForceRate.Value:0, BizRate = xinxi.ManualBizRate.HasValue ? xinxi.ManualBizRate.Value : 0, ForceRate = xinxi.ManualForceRate.HasValue ? xinxi.ManualForceRate.Value : 0, //20170221新增增值税 AddValueTaxRate = xinxi.AddValueTaxRate.HasValue ? xinxi.AddValueTaxRate.Value : 0, BizTotal = xianzhong.BizTotal.HasValue ? xianzhong.BizTotal.Value : 0, BoLi = new XianZhongUnit { BaoE = xianzhong.BoLiBaoE.HasValue ? xianzhong.BoLiBaoE.Value : 0, BaoFei = xianzhong.BoLiBaoFei.HasValue ? xianzhong.BoLiBaoFei.Value : 0 }, BuJiMianCheSun = new XianZhongUnit { BaoE = (xianzhong.BuJiMianCheSun.HasValue ? xianzhong.BuJiMianCheSun.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianCheSun.HasValue ? xianzhong.BuJiMianCheSun.Value : 0 }, //BuJiMianCheSun = xianzhong.BuJiMianCheSun.HasValue ? xianzhong.BuJiMianCheSun.Value : 0, BuJiMianDaoQiang = new XianZhongUnit { BaoE = (xianzhong.BuJiMianDaoQiang.HasValue ? xianzhong.BuJiMianDaoQiang.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianDaoQiang.HasValue ? xianzhong.BuJiMianDaoQiang.Value : 0 }, //BuJiMianDaoQiang = xianzhong.BuJiMianDaoQiang.HasValue ? xianzhong.BuJiMianDaoQiang.Value : 0, BuJiMianFuJia = new XianZhongUnit { BaoE = (xianzhong.BuJiMianFuJian.HasValue ? xianzhong.BuJiMianFuJian.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianFuJian.HasValue ? xianzhong.BuJiMianFuJian.Value : 0 }, //BuJiMianFuJia = xianzhong.BuJiMianFuJian.HasValue ? xianzhong.BuJiMianFuJian.Value : 0, BuJiMianRenYuan = new XianZhongUnit { BaoE = (xianzhong.BuJiMianRenYuan.HasValue ? xianzhong.BuJiMianRenYuan.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianRenYuan.HasValue ? xianzhong.BuJiMianRenYuan.Value : 0 }, //BuJiMianRenYuan = xianzhong.BuJiMianRenYuan.HasValue ? xianzhong.BuJiMianRenYuan.Value : 0, BuJiMianSanZhe = new XianZhongUnit { BaoE = (xianzhong.BuJiMianSanZhe.HasValue ? xianzhong.BuJiMianSanZhe.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianSanZhe.HasValue ? xianzhong.BuJiMianSanZhe.Value : 0 }, //BuJiMianSanZhe = xianzhong.BuJiMianSanZhe.HasValue ? xianzhong.BuJiMianSanZhe.Value : 0, CheDeng = new XianZhongUnit { BaoE = xianzhong.CheDengBaoE.HasValue ? xianzhong.CheDengBaoE.Value : 0, BaoFei = xianzhong.CheDengBaoFei.HasValue ? xianzhong.CheDengBaoFei.Value : 0 }, ChengKe = new XianZhongUnit { BaoE = xianzhong.ChengKeBaoE.HasValue ? xianzhong.ChengKeBaoE.Value : 0, BaoFei = xianzhong.ChengKeBaoFei.HasValue ? xianzhong.ChengKeBaoFei.Value : 0 }, ChengKeBaoENum = xianzhong.ChengKeBaoENum.HasValue ? xianzhong.ChengKeBaoENum.Value : 0, CheSun = new XianZhongUnit { BaoE = xianzhong.CheSunBaoE.HasValue ? xianzhong.CheSunBaoE.Value : 0, BaoFei = xianzhong.CheSunBaoFei.HasValue ? xianzhong.CheSunBaoFei.Value : 0 }, DaoQiang = new XianZhongUnit { BaoE = xianzhong.DaoQiangBaoE.HasValue ? xianzhong.DaoQiangBaoE.Value : 0, BaoFei = xianzhong.DaoQiangBaoFei.HasValue ? xianzhong.DaoQiangBaoFei.Value : 0 }, ForceTotal = xianzhong.ForceTotal.HasValue ? xianzhong.ForceTotal.Value : 0, HuaHen = new XianZhongUnit { BaoE = xianzhong.HuaHenBaoE.HasValue ? xianzhong.HuaHenBaoE.Value : 0, BaoFei = xianzhong.HuaHenBaoFei.HasValue ? xianzhong.HuaHenBaoFei.Value : 0 }, SanZhe = new XianZhongUnit { BaoE = xianzhong.SanZheBaoE.HasValue ? xianzhong.SanZheBaoE.Value : 0, BaoFei = xianzhong.SanZheBaoFei.HasValue ? xianzhong.SanZheBaoFei.Value : 0 }, SheShui = new XianZhongUnit { BaoE = xianzhong.SheShuiBaoE.HasValue ? xianzhong.SheShuiBaoE.Value : 0, BaoFei = xianzhong.SheShuiBaoFei.HasValue ? xianzhong.SheShuiBaoFei.Value : 0 }, SiJi = new XianZhongUnit { BaoE = xianzhong.SiJiBaoE.HasValue ? xianzhong.SiJiBaoE.Value : 0, BaoFei = xianzhong.SiJiBaoFei.HasValue ? xianzhong.SiJiBaoFei.Value : 0, }, TaxTotal = xianzhong.TaxTotal.HasValue ? xianzhong.TaxTotal.Value : 0, TeYue = new XianZhongUnit { BaoE = xianzhong.TeYueBaoE.HasValue ? xianzhong.TeYueBaoE.Value : 0, BaoFei = xianzhong.TeYueBaoFei.HasValue ? xianzhong.TeYueBaoFei.Value : 0 }, ZiRan = new XianZhongUnit { BaoE = xianzhong.ZiRanBaoE.HasValue ? xianzhong.ZiRanBaoE.Value : 0, BaoFei = xianzhong.ZiRanBaoFei.HasValue ? xianzhong.ZiRanBaoFei.Value : 0 }, //2.1.5版本修改 新增6个字段 BuJiMianChengKe = new XianZhongUnit { BaoE = (xianzhong.BuJiMianChengKe.HasValue ? xianzhong.BuJiMianChengKe.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianChengKe.HasValue ? xianzhong.BuJiMianChengKe.Value : 0 }, BuJiMianSiJi = new XianZhongUnit { BaoE = (xianzhong.BuJiMianSiJi.HasValue ? xianzhong.BuJiMianSiJi.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianSiJi.HasValue ? xianzhong.BuJiMianSiJi.Value : 0 }, BuJiMianHuaHen = new XianZhongUnit { BaoE = (xianzhong.BuJiMianHuaHen.HasValue ? xianzhong.BuJiMianHuaHen.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianHuaHen.HasValue ? xianzhong.BuJiMianHuaHen.Value : 0 }, BuJiMianSheShui = new XianZhongUnit { BaoE = (xianzhong.BuJiMianSheShui.HasValue ? xianzhong.BuJiMianSheShui.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianSheShui.HasValue ? xianzhong.BuJiMianSheShui.Value : 0 }, BuJiMianZiRan = new XianZhongUnit { BaoE = (xianzhong.BuJiMianZiRan.HasValue ? xianzhong.BuJiMianZiRan.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianZiRan.HasValue ? xianzhong.BuJiMianZiRan.Value : 0 }, BuJiMianJingShenSunShi = new XianZhongUnit { BaoE = (xianzhong.BuJiMianJingShenSunShi.HasValue ? xianzhong.BuJiMianJingShenSunShi.Value : 0) > 0 ? 1 : 0, BaoFei = xianzhong.BuJiMianJingShenSunShi.HasValue ? xianzhong.BuJiMianJingShenSunShi.Value : 0 }, SanFangTeYue = new XianZhongUnit { BaoE = xianzhong.SanFangTeYueBaoE.HasValue ? xianzhong.SanFangTeYueBaoE.Value : 0, BaoFei = xianzhong.SanFangTeYueBaoFei.HasValue ? xianzhong.SanFangTeYueBaoFei.Value : 0 }, JingShenSunShi = new XianZhongUnit { BaoE = xianzhong.JingShenSunShiBaoE.HasValue ? xianzhong.JingShenSunShiBaoE.Value : 0, BaoFei = xianzhong.JingShenSunShiBaoFei.HasValue ? xianzhong.JingShenSunShiBaoFei.Value : 0 }, HuoWuZeRen = new XianZhongUnit { BaoE = xianzhong.HuoWuZeRenBaoE.HasValue ? xianzhong.HuoWuZeRenBaoE.Value : 0, BaoFei = xianzhong.HuoWuZeRenBaoFei.HasValue ? xianzhong.HuoWuZeRenBaoFei.Value : 0 }, SheBeiSunShi = new XianZhongUnit { BaoE = xianzhong.SheBeiSunShiBaoE.HasValue ? xianzhong.SheBeiSunShiBaoE.Value : 0, BaoFei = xianzhong.SheBeiSunShiBaoFei.HasValue ? xianzhong.SheBeiSunShiBaoFei.Value : 0 }, BuJiMianSheBeiSunShi = new XianZhongUnit { BaoE = xianzhong.BuJiMianSheBeiSunShiBaoE.HasValue ? xianzhong.BuJiMianSheBeiSunShiBaoE.Value : 0, BaoFei = xianzhong.BuJiMianSheBeiSunShiBaoFei.HasValue ? xianzhong.BuJiMianSheBeiSunShiBaoFei.Value : 0 }, XiuLiChang = new XianZhongUnit { BaoE = xianzhong.XiuLiChangBaoE.HasValue ? xianzhong.XiuLiChangBaoE.Value : 0, BaoFei = xianzhong.XiuLiChangBaoFei.HasValue ? xianzhong.XiuLiChangBaoFei.Value : 0 }, FeiYongBuChang = new XianZhongUnit { BaoE = xianzhong.FeiYongBuChangBaoE.HasValue ? xianzhong.FeiYongBuChangBaoE.Value : 0, BaoFei = xianzhong.FeiYongBuChangBaoFei.HasValue ? xianzhong.FeiYongBuChangBaoFei.Value : 0 }, SanZheJieJiaRi = new XianZhongUnit { BaoE = xianzhong.SanZheJieJiaRiBaoE.HasValue ? xianzhong.SanZheJieJiaRiBaoE.Value : 0, BaoFei = xianzhong.SanZheJieJiaRiBaoFei.HasValue ? xianzhong.SanZheJieJiaRiBaoFei.Value : 0 }, FybcDays = xianzhong.FybcDays.HasValue ? xianzhong.FybcDays.Value : 0, //2.1.5修改 结束 JiaYiTotal = xianzhong.JiaYiTotal ?? 0 }; #endregion #region 业务员信息 2017-09-06 item.AgentDetail = new AgentViewModelByBJ { AgentId = xinxi.AgentId ?? 0 }; #endregion #region 优惠活动信息 2017-09-06 if (Activitys != null) { item.ActivityCount = Activitys.Count; #region ActivityDetail List <PreActivity> list = new List <PreActivity>(); PreActivity Activitydetail; foreach (var i in Activitys) { Activitydetail = new PreActivity(); Activitydetail.ActivityName = i.activity_name; Activitydetail.ActivityContent = i.activity_content; list.Add(Activitydetail); } item.Activitys = list; #endregion } #endregion #region 出险信息 item.ClaimInfo = new ClaimInfo { LossBizCount = xinxi.loss_biz_count, LossBizAmount = String.Format("{0:F}", xinxi.loss_biz_amount), LossForceCount = xinxi.loss_force_count, LossForceAmount = String.Format("{0:F}", xinxi.loss_force_amount) }; #endregion if (savequote != null) { item.XianZhongInfo.XiuLiChangType = savequote.HcXiuLiChangType ?? -1; } if (claimDetail != null) { item.ClaimCount = claimDetail.Count; #region ClaimDetail List <ClaimDetailViewModel> list = new List <ClaimDetailViewModel>(); ClaimDetailViewModel detail; foreach (var i in claimDetail) { detail = new ClaimDetailViewModel(); detail.Buid = i.b_uid; detail.CreateTime = i.create_time; detail.StrCreateTime = i.create_time.HasValue ? i.create_time.Value.ToString("yyyy-MM-dd") : ""; detail.EndCaseTime = i.endcase_time; detail.StrEndCaseTime = i.endcase_time.HasValue ? i.endcase_time.Value.ToString("yyyy-MM-dd") : ""; detail.Id = i.id; detail.Liid = i.li_id; detail.LossTime = i.loss_time; detail.StrLossTime = i.loss_time.HasValue ? i.loss_time.Value.ToString("yyyy-MM-dd") : ""; detail.PayAmount = i.pay_amount; detail.PayCompanyName = i.pay_company_name; detail.PayCompanyNo = i.pay_company_no; list.Add(detail); } item.ClaimDetail = list; #endregion } return(item); }