Exemplo n.º 1
0
        public bj_baodanxinxi Add(bj_baodanxinxi baodanxinxi)
        {
            var item = new bj_baodanxinxi();

            try
            {
                item = DataContextFactory.GetDataContext().bj_baodanxinxi.Add(baodanxinxi);
                DataContextFactory.GetDataContext().SaveChanges();
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        logError.Info(string.Format("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage));
                    }
                }
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }

            return(item);
        }
Exemplo n.º 2
0
        public int Update(bj_baodanxinxi baodanxinxi)
        {
            int count = 0;

            try
            {
                DataContextFactory.GetDataContext().bj_baodanxinxi.AddOrUpdate(baodanxinxi);
                count = DataContextFactory.GetDataContext().SaveChanges();
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(count);
        }
Exemplo n.º 3
0
        public bj_baodanxianzhong MapBaodanxianzhong(bj_baodanxinxi baodanxinxi, bx_quoteresult quoteresult, bx_savequote savequote, bx_submit_info submitInfo, List <bx_ywxdetail> jylist)
        {
            var baodanxianzhong = new bj_baodanxianzhong()
            {
                BaoDanXinXiId  = baodanxinxi.Id,
                BizTotal       = quoteresult.BizTotal.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BizTotal.Value : System.Math.Round((double)quoteresult.BizTotal.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                BoLiBaoE       = savequote.BoLi,
                BoLiBaoFei     = quoteresult.BoLi.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BoLi.Value : System.Math.Round((double)quoteresult.BoLi.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                BuJiMianCheSun =
                    quoteresult.BuJiMianCheSun.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianCheSun.Value : System.Math.Round((double)quoteresult.BuJiMianCheSun.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                BuJiMianDaoQiang =
                    quoteresult.BuJiMianDaoQiang.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianDaoQiang.Value : System.Math.Round((double)quoteresult.BuJiMianDaoQiang.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                BuJiMianFuJian =
                    quoteresult.BuJiMianFuJian.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianFuJian.Value : System.Math.Round((double)quoteresult.BuJiMianFuJian.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                BuJiMianRenYuan =
                    quoteresult.BuJiMianRenYuan.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianRenYuan.Value : System.Math.Round((double)quoteresult.BuJiMianRenYuan.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                BuJiMianSanZhe =
                    quoteresult.BuJiMianSanZhe.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianSanZhe.Value : System.Math.Round((double)quoteresult.BuJiMianSanZhe.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                //2.1.5版本修改 新增6个字段
                BuJiMianChengKe =
                    quoteresult.BuJiMianChengKe.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianChengKe.Value : System.Math.Round((double)quoteresult.BuJiMianChengKe.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                BuJiMianSiJi =
                    quoteresult.BuJiMianSiJi.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianSiJi.Value : System.Math.Round((double)quoteresult.BuJiMianSiJi.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                BuJiMianHuaHen =
                    quoteresult.BuJiMianHuaHen.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianHuaHen.Value : System.Math.Round((double)quoteresult.BuJiMianHuaHen.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                BuJiMianSheShui =
                    quoteresult.BuJiMianSheShui.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianSheShui.Value : System.Math.Round((double)quoteresult.BuJiMianSheShui.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                BuJiMianZiRan =
                    quoteresult.BuJiMianZiRan.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianZiRan.Value : System.Math.Round((double)quoteresult.BuJiMianZiRan.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                BuJiMianJingShenSunShi =
                    quoteresult.BuJiMianJingShenSunShi.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianJingShenSunShi.Value : System.Math.Round((double)quoteresult.BuJiMianJingShenSunShi.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                SanFangTeYueBaoE   = savequote.HcSanFangTeYue.HasValue ? savequote.HcSanFangTeYue.Value : 0,
                SanFangTeYueBaoFei =
                    quoteresult.HcSanFangTeYue.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.HcSanFangTeYue.Value : System.Math.Round((double)quoteresult.HcSanFangTeYue.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                JingShenSunShiBaoE   = savequote.HcJingShenSunShi.HasValue ? savequote.HcJingShenSunShi.Value : 0,
                JingShenSunShiBaoFei =
                    quoteresult.HcJingShenSunShi.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.HcJingShenSunShi.Value : System.Math.Round((double)quoteresult.HcJingShenSunShi.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                HuoWuZeRenBaoE   = savequote.HcHuoWuZeRen.HasValue ? savequote.HcHuoWuZeRen.Value : 0,
                HuoWuZeRenBaoFei =
                    quoteresult.HcHuoWuZeRen.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.HcHuoWuZeRen.Value : System.Math.Round((double)quoteresult.HcHuoWuZeRen.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                //设备损失
                SheBeiSunShiBaoE   = savequote.HcSheBeiSunshi.HasValue ? savequote.HcSheBeiSunshi.Value : 0,
                SheBeiSunShiBaoFei =
                    quoteresult.HcSheBeiSunshi.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.HcSheBeiSunshi.Value : System.Math.Round((double)quoteresult.HcSheBeiSunshi.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                //不计免设备损失
                BuJiMianSheBeiSunShiBaoE   = savequote.BuJiMianSheBeiSunshi.HasValue ? savequote.BuJiMianSheBeiSunshi.Value : 0,
                BuJiMianSheBeiSunShiBaoFei =
                    quoteresult.BuJiMianSheBeiSunshi.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.BuJiMianSheBeiSunshi.Value : System.Math.Round((double)quoteresult.BuJiMianSheBeiSunshi.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                XiuLiChangBaoE   = savequote.HcXiuLiChang,
                XiuLiChangBaoFei =
                    quoteresult.HcXiuLiChang.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.HcXiuLiChang.Value : System.Math.Round((double)quoteresult.HcXiuLiChang.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                FeiYongBuChangBaoE   = savequote.HcFeiYongBuChang,
                FeiYongBuChangBaoFei =
                    quoteresult.HcFeiYongBuChang.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.HcFeiYongBuChang.Value : System.Math.Round((double)quoteresult.HcFeiYongBuChang.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                //2.1.5修改结束
                //费用补偿天数
                FybcDays = savequote.FeiYongBuChangDays.HasValue ? savequote.FeiYongBuChangDays.Value : 0,

                CheDengBaoE   = savequote.CheDeng,
                CheDengBaoFei =
                    quoteresult.CheDeng.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.CheDeng.Value : System.Math.Round((double)quoteresult.CheDeng.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                ChengKeBaoE   = savequote.ChengKe,
                ChengKeBaoFei =
                    quoteresult.ChengKe.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.ChengKe.Value : System.Math.Round((double)quoteresult.ChengKe.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                //CheSunBaoE = savequote.CheSun,//车损保额修改quoteresult
                CheSunBaoE   = quoteresult.CheSunBE.HasValue ? quoteresult.CheSunBE.Value : 0,
                CheSunBaoFei =
                    quoteresult.CheSun.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.CheSun.Value : System.Math.Round((double)quoteresult.CheSun.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                //DaoQiangBaoE = savequote.DaoQiang,//盗抢保额修改quoteresult
                DaoQiangBaoE   = quoteresult.DaoQiangBE.HasValue ? quoteresult.DaoQiangBE : 0,
                DaoQiangBaoFei =
                    quoteresult.DaoQiang.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.DaoQiang.Value : System.Math.Round((double)quoteresult.DaoQiang.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                ForceTotal =
                    quoteresult.ForceTotal.HasValue ? quoteresult.ForceTotal.Value : 0,

                HuaHenBaoE   = savequote.HuaHen,
                HuaHenBaoFei =
                    quoteresult.HuaHen.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.HuaHen.Value : System.Math.Round((double)quoteresult.HuaHen.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                SanZheBaoE   = savequote.SanZhe,
                SanZheBaoFei =
                    quoteresult.SanZhe.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.SanZhe.Value : System.Math.Round((double)quoteresult.SanZhe.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                SheShuiBaoE   = savequote.SheShui,
                SheShuiBaoFei =
                    quoteresult.SheShui.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.SheShui.Value : System.Math.Round((double)quoteresult.SheShui.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                SiJiBaoE   = savequote.SiJi,
                SiJiBaoFei =
                    quoteresult.SiJi.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.SiJi.Value : System.Math.Round((double)quoteresult.SiJi.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                Source   = submitInfo.source,
                TaxTotal = quoteresult.TaxTotal.HasValue ? quoteresult.TaxTotal.Value : 0,
                //ZiRanBaoE = savequote.ZiRan,//自燃保额修改quoteresult
                ZiRanBaoE   = quoteresult.ZiRanBE.HasValue ? quoteresult.ZiRanBE.Value : 0,
                ZiRanBaoFei =
                    quoteresult.ZiRan.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.ZiRan.Value : System.Math.Round((double)quoteresult.ZiRan.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,

                SanZheJieJiaRiBaoE   = savequote.SanZheJieJiaRi,
                SanZheJieJiaRiBaoFei =
                    quoteresult.SanZheJieJiaRi.HasValue ? ((!quoteresult.NewRate.HasValue || quoteresult.NewRate == 0) ? quoteresult.SanZheJieJiaRi.Value : System.Math.Round((double)quoteresult.SanZheJieJiaRi.Value / (double)quoteresult.TotalRate * (double)quoteresult.NewRate, 2)) : 0,
                CreateTime = DateTime.Now,
                JiaoQiang  = savequote.JiaoQiang
            };

            #region  计免重新赋值,针对人保3.5代系统不计免赔合并展示的问题
            if (baodanxianzhong.Source == 2 && baodanxianzhong.BuJiMianFuJian > 0)
            {
                //车损
                if (savequote.BuJiMianCheSun > 0 && quoteresult.BuJiMianCheSun == 0)
                {
                    baodanxianzhong.BuJiMianCheSun = -1;
                }
                //盗抢
                if (savequote.BuJiMianDaoQiang > 0 && quoteresult.BuJiMianDaoQiang == 0)
                {
                    baodanxianzhong.BuJiMianDaoQiang = -1;
                }
                //人员
                if (savequote.BuJiMianRenYuan > 0 && quoteresult.BuJiMianRenYuan == 0)
                {
                    baodanxianzhong.BuJiMianRenYuan = -1;
                }
                //三者
                if (savequote.BuJiMianSanZhe > 0 && quoteresult.BuJiMianSanZhe == 0)
                {
                    baodanxianzhong.BuJiMianSanZhe = -1;
                }
                //乘客
                if (savequote.BuJiMianChengKe > 0 && quoteresult.BuJiMianChengKe == 0)
                {
                    baodanxianzhong.BuJiMianChengKe = -1;
                }
                //司机
                if (savequote.BuJiMianSiJi > 0 && quoteresult.BuJiMianSiJi == 0)
                {
                    baodanxianzhong.BuJiMianSiJi = -1;
                }
                //划痕
                if (savequote.BuJiMianHuaHen > 0 && quoteresult.BuJiMianHuaHen == 0)
                {
                    baodanxianzhong.BuJiMianHuaHen = -1;
                }
                //涉水
                if (savequote.BuJiMianSheShui > 0 && quoteresult.BuJiMianSheShui == 0)
                {
                    baodanxianzhong.BuJiMianSheShui = -1;
                }
                //自燃
                if (savequote.BuJiMianZiRan > 0 && quoteresult.BuJiMianZiRan == 0)
                {
                    baodanxianzhong.BuJiMianZiRan = -1;
                }
                //精神损失
                if (savequote.BuJiMianJingShenSunShi > 0 && quoteresult.BuJiMianJingShenSunShi == 0)
                {
                    baodanxianzhong.BuJiMianJingShenSunShi = -1;
                }
            }
            //设备损失在上文已赋值,此处无需处理
            //baodanxianzhong.BuJiMianSheBeiSunShiBaoE
            #endregion
            if (jylist != null && jylist.Any())
            {
                jylist = jylist.Where(w => w.source == baodanxianzhong.Source).ToList();
                if (jylist != null && jylist.Any())
                {
                    baodanxianzhong.JiaYiTotal = jylist.Sum(l => l.amount ?? 0);
                }
            }

            return(baodanxianzhong);
        }
        public bj_baodanxinxi MapBaodanxinxi(CreateOrUpdateBjdInfoRequest request, bx_submit_info submitInfo,
                                             bx_quoteresult quoteresult, bx_savequote savequote, bx_userinfo userinfo, bx_quotereq_carinfo reqCarInfo, bx_preferential_activity activity)
        {
            var quotecarinfo = _quoteResultCarinfoRepository.Find(request.Buid, SourceGroupAlgorithm.GetOldSource(request.Source));
            var lastinfo     = _lastInfoRepository.GetByBuid(request.Buid);

            var    listClaim       = _userClaimRepository.FindList(request.Buid);
            int    lossBizCount    = listClaim.Where(n => n.pay_type == 0).ToList().Count;                  //商业出险次数
            double?lossBizAmount   = listClaim.Where(n => n.pay_type == 0).ToList().Sum(n => n.pay_amount); //商业出险金额
            int    lossForceCount  = listClaim.Where(n => n.pay_type == 1).ToList().Count;                  //交强出险次数
            double?lossForceAmount = listClaim.Where(n => n.pay_type == 1).ToList().Sum(n => n.pay_amount); //交强出险金额

            var baodanxinxi = new bj_baodanxinxi
            {
                //BEGIN 2017-09-06新增字段   20170909L 当前后期修改中去掉了代理人信息(电话等)
                AgentId = request.ChildAgent == 0 ? int.Parse(userinfo.Agent) : request.ChildAgent,
                //END

                //BEGIN 2017-09-09新增字段
                //activity_content = request.ActivityContent,
                activity_ids = activity.id.ToString(),
                //END

                // AgentId = int.Parse(userinfo.Agent),
                BizEndDate      = lastinfo == null ? DateTime.MinValue : Convert.ToDateTime(lastinfo.last_business_end_date), //submitinfo.biz_end_time,
                BizNum          = submitInfo.biz_tno,
                BizPrice        = quoteresult.BizTotal.HasValue ? quoteresult.BizTotal.Value : 0,
                BizRate         = double.Parse(submitInfo.biz_rate.HasValue ? submitInfo.biz_rate.Value.ToString() : "0"),
                BizStartDate    = quoteresult.BizStartDate.HasValue ? quoteresult.BizStartDate.Value : (reqCarInfo.biz_start_date.HasValue?reqCarInfo.biz_start_date.Value:DateTime.MinValue),//submitInfo.biz_start_time,
                CarBrandModel   = userinfo.MoldName,
                CarEngineNo     = userinfo.EngineNo,
                CarLicense      = userinfo.LicenseNo,
                CarOwner        = userinfo.LicenseOwner,
                CarRegisterDate = string.IsNullOrEmpty(userinfo.RegisterDate) ? DateTime.MinValue : DateTime.Parse(userinfo.RegisterDate),
                CarVIN          = userinfo.CarVIN,
                ChannelId       = submitInfo.channel_id,
                CompanyId       = submitInfo.source,
                CreateTime      = DateTime.Now,
                ForceEndDate    = lastinfo == null ? DateTime.MinValue : Convert.ToDateTime(lastinfo.last_end_date),                                                                                       //submitinfo.force_end_time,
                ForceStartDate  = quoteresult.ForceStartDate.HasValue ? quoteresult.ForceStartDate.Value : (reqCarInfo.force_start_date.HasValue ? reqCarInfo.force_start_date.Value : DateTime.MinValue), //submitInfo.force_start_time,
                ForceNum        = submitInfo.force_tno,
                ForcePrice      = (quoteresult.ForceTotal.HasValue ? quoteresult.ForceTotal.Value : 0),
                ForceRate       =
                    double.Parse(submitInfo.force_rate.HasValue ? submitInfo.force_rate.Value.ToString() : "0"),
                InsuredName     = userinfo.InsuredName,
                InsureIdNum     = userinfo.InsuredIdCard,
                ManualBizRate   = request.BizRate,
                ManualTaxRate   = request.TaxRate,
                ManualForceRate = request.ForceRate,
                ObjectId        = int.Parse(userinfo.Agent),
                ObjectType      = 1,
                SubmitStatus    = submitInfo.submit_status,
                TaxPrice        = quoteresult.TaxTotal.HasValue ? quoteresult.TaxTotal.Value : 0,

                //新增的4个费率
                NonClaimRate      = (double)(quoteresult.RateFactor1.HasValue ? quoteresult.RateFactor1 : 0),
                MultiDiscountRate = (double)(quoteresult.RateFactor2.HasValue ? quoteresult.RateFactor2 : 0),
                AvgMileRate       = (double)(quoteresult.RateFactor3.HasValue ? quoteresult.RateFactor3 : 0),
                RiskRate          = (double)(quoteresult.RateFactor4.HasValue ? quoteresult.RateFactor4 : 0),
                //总费率系数
                TotalRate = (quoteresult.NewRate.HasValue && quoteresult.NewRate != 0) ? quoteresult.NewRate.Value.ToString() : (quoteresult.TotalRate.HasValue ? quoteresult.TotalRate.Value.ToString() : "0"),
                //20170221新增增值税
                AddValueTaxRate = request.AddValueTaxRate,
                //载客//+载质量
                CarSeated = quotecarinfo != null ? (quotecarinfo.seat_count.HasValue ? quotecarinfo.seat_count.Value.ToString() : "0") : "0",
                //+ "/" + (quotecarinfo.car_equ_quality.HasValue ? quotecarinfo.car_equ_quality.Value.ToString() : "0")
                VehicleInfo        = VehicleInfoMapper.VehicleInfoMethod(quotecarinfo),
                JqVehicleClaimType = quotecarinfo != null ? quotecarinfo.JqVehicleClaimType : "",
                SyVehicleClaimType = quotecarinfo != null ? quotecarinfo.SyVehicleClaimType : "",
                loss_biz_count     = lossBizCount,
                loss_biz_amount    = lossBizAmount.HasValue ? lossBizAmount.Value : 0,
                loss_force_count   = lossForceCount,
                loss_force_amount  = lossForceAmount.HasValue ? lossForceAmount.Value : 0
            };

            return(baodanxinxi);
        }
        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);
        }