Esempio n. 1
0
        public int Add(bx_car_renewal carRenewal)
        {
            int num = 0;

            try
            {
                DataContextFactory.GetDataContext().bx_car_renewal.AddOrUpdate(carRenewal);
                num = DataContextFactory.GetDataContext().SaveChanges();
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(num);
        }
Esempio n. 2
0
        public static AppSaveQuoteViewModel AppConvetToViewModel(this bx_car_renewal savequote)
        {
            AppSaveQuoteViewModel model = new AppSaveQuoteViewModel();

            if (savequote != null)
            {
                model.BoLi = savequote.BoLi ?? 0;
                //model.CheDeng = savequote.CheDeng ?? 0;
                model.CheSun           = savequote.CheSun ?? 0;
                model.ChengKe          = savequote.ChengKe ?? 0;
                model.DaoQiang         = savequote.DaoQiang ?? 0;
                model.HuaHen           = savequote.HuaHen ?? 0;
                model.SanZhe           = savequote.SanZhe ?? 0;
                model.SheShui          = savequote.SheShui ?? 0;
                model.SiJi             = savequote.SiJi ?? 0;
                model.BuJiMianCheSun   = savequote.BuJiMianCheSun ?? 0;
                model.BuJiMianDaoQiang = savequote.BuJiMianDaoQiang ?? 0;
                //model.BuJiMianFuJia = savequote.BuJiMianFuJia ?? 0;
                //model.BuJiMianRenYuan = savequote.BuJiMianRenYuan ?? 0;
                model.BuJiMianSanZhe = savequote.BuJiMianSanZhe ?? 0;
                model.ZiRan          = savequote.ZiRan ?? 0;
                model.Source         = savequote.LastYearSource.Value;
                if (savequote.LastYearSource.HasValue)
                {
                    model.SourceName = savequote.LastYearSource.Value.ToEnumDescriptionString(typeof(EnumSource));
                    //Enum.GetName(typeof(EnumSource), savequote.LastYearSource.Value);
                }
                else
                {
                    model.SourceName = "";
                }
                //2.1.5修改 新增8个字段
                model.BuJiMianChengKe        = savequote.BuJiMianChengKe ?? 0;
                model.BuJiMianSiJi           = savequote.BuJiMianSiJi ?? 0;
                model.BuJiMianHuaHen         = savequote.BuJiMianHuaHen ?? 0;
                model.BuJiMianSheShui        = savequote.BuJiMianSheShui ?? 0;
                model.BuJiMianZiRan          = savequote.BuJiMianZiRan ?? 0;
                model.BuJiMianJingShenSunShi = savequote.BuJiMianJingShenSunShi ?? 0;
                model.HcSanFangTeYue         = savequote.SanFangTeYue ?? 0;
                model.HcJingShenSunShi       = savequote.JingShenSunShi ?? 0;
            }
            return(model);
        }
Esempio n. 3
0
        /// <summary>
        /// 续保信息的userinfo部分
        /// </summary>
        /// <param name="userinfo"></param>
        /// <param name="renewal"></param>
        /// <param name="carinfo"></param>
        /// <param name="lastinfo"></param>
        /// <param name="timeFormat"></param>
        /// <returns></returns>
        public static UserInfoViewModel ConvertToViewModel(this bx_userinfo userinfo, bx_car_renewal renewal, bx_carinfo carinfo, bx_lastinfo lastinfo, int timeFormat = 0)
        {
            var model = new UserInfoViewModel();

            model.Buid = userinfo.Id.ToString();
            try
            {
                if (renewal != null)
                {
                    model.BizNo         = string.IsNullOrWhiteSpace(renewal.BizNO) ? string.Empty : renewal.BizNO;
                    model.ForceNo       = string.IsNullOrWhiteSpace(renewal.ForceNO) ? string.Empty : renewal.ForceNO;
                    model.InsuredIdCard = string.IsNullOrWhiteSpace(renewal.InsuredIdCard)
                        ? string.Empty
                        : renewal.InsuredIdCard;
                    model.InsuredIdType = renewal.InsuredIdType.HasValue ? renewal.InsuredIdType.Value : 0;
                    //model.InsuredMobile = string.IsNullOrWhiteSpace(renewal.InsuredMobile)
                    //    ? string.Empty
                    //    : renewal.InsuredMobile.IndexOf("*", System.StringComparison.Ordinal) >= 0 ? string.Empty : renewal.InsuredMobile;
                    //model.HolderMobile = string.IsNullOrWhiteSpace(renewal.HolderMobile)
                    //    ? string.Empty
                    //    : renewal.HolderMobile.IndexOf("*", System.StringComparison.Ordinal) >= 0 ? string.Empty : renewal.HolderMobile;
                    model.InsuredMobile = string.Empty;
                    model.HolderMobile  = string.Empty;

                    model.HolderIdCard = string.IsNullOrWhiteSpace(renewal.HolderIdCard)
                        ? string.Empty
                        : renewal.HolderIdCard;
                    model.HolderIdType = renewal.HolderIdType.HasValue ? renewal.HolderIdType.Value : 0;
                    model.HolderName   = string.IsNullOrWhiteSpace(renewal.HolderName)
                        ? string.Empty
                        : renewal.HolderName;

                    //model.LicenseOwner = string.IsNullOrWhiteSpace(renewal) ? string.Empty : renewal.HolderName;
                    model.PostedName  = string.IsNullOrWhiteSpace(renewal.HolderName) ? string.Empty : renewal.HolderName;
                    model.InsuredName = string.IsNullOrWhiteSpace(renewal.InsuredName) ? string.Empty : renewal.InsuredName;
                    model.RateFactor1 = renewal.RateFactor1.HasValue ? renewal.RateFactor1.Value : 0;
                    model.RateFactor2 = renewal.RateFactor2.HasValue ? renewal.RateFactor2.Value : 0;
                    model.RateFactor3 = renewal.RateFactor3.HasValue ? renewal.RateFactor3.Value : 0;
                    model.RateFactor4 = renewal.RateFactor4.HasValue ? renewal.RateFactor4.Value : 0;


                    model.ForceExpireDate    = renewal.LastForceEndDate.HasValue ? (timeFormat == 1 ? renewal.LastForceEndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : renewal.LastForceEndDate.Value.ToString("yyyy-MM-dd")) : string.Empty;
                    model.BusinessExpireDate = renewal.LastBizEndDate.HasValue ? (timeFormat == 1 ? renewal.LastBizEndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : renewal.LastBizEndDate.Value.ToString("yyyy-MM-dd")) : string.Empty;
                    model.NextForceStartDate = (renewal.NextForceStartDate.HasValue
                        ? (timeFormat == 1 ? renewal.NextForceStartDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : renewal.NextForceStartDate.Value.ToString("yyyy-MM-dd"))
                        : string.Empty);
                    model.NextBusinessStartDate = (renewal.NextBizStartDate.HasValue
                        ? (timeFormat == 1 ? renewal.NextBizStartDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : renewal.NextBizStartDate.Value.ToString("yyyy-MM-dd"))
                        : string.Empty);

                    if (!string.IsNullOrWhiteSpace(model.ForceExpireDate))
                    {
                        var fd = DateTime.Parse(model.ForceExpireDate);
                        if (fd.Date == DateTime.MinValue.Date)
                        {
                            model.ForceExpireDate = "";
                        }
                        else
                        {
                            model.ForceExpireDate = timeFormat == 1 ? DateTime.Parse(model.ForceExpireDate).ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Parse(model.ForceExpireDate).ToString("yyyy-MM-dd");
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(model.BusinessExpireDate))
                    {
                        var bd = DateTime.Parse(model.BusinessExpireDate);
                        if (bd.Date == DateTime.MinValue.Date)
                        {
                            model.BusinessExpireDate = "";
                        }
                        else
                        {
                            model.BusinessExpireDate = timeFormat == 1 ? DateTime.Parse(model.BusinessExpireDate).ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Parse(model.BusinessExpireDate).ToString("yyyy-MM-dd");
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(model.NextForceStartDate))
                    {
                        var nf = DateTime.Parse(model.NextForceStartDate);
                        if (nf.Date == DateTime.MinValue.Date)
                        {
                            model.NextForceStartDate = "";
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(model.NextBusinessStartDate))
                    {
                        var nb = DateTime.Parse(model.NextBusinessStartDate);
                        if (nb.Date == DateTime.MinValue.Date)
                        {
                            model.NextBusinessStartDate = "";
                        }
                    }
                    model.Organization = renewal.Organization ?? string.Empty;
                    //新增的投保人生日和性别
                    model.HolderBirthday = renewal.HolderBirthday ?? string.Empty;
                    if (!string.IsNullOrEmpty(model.HolderBirthday) && Convert.ToDateTime(model.HolderBirthday).Year == DateTime.MinValue.Year)
                    {
                        model.HolderBirthday = string.Empty;
                    }
                    model.HolderSex = (renewal.HolderSex ?? 0).ToString();
                    //新增的被保险人生日和性别
                    model.InsuredBirthday = renewal.InsuredBirthday ?? string.Empty;
                    if (!string.IsNullOrEmpty(model.InsuredBirthday) && Convert.ToDateTime(model.InsuredBirthday).Year == DateTime.MinValue.Year)
                    {
                        model.InsuredBirthday = string.Empty;
                    }
                    model.InsuredSex = (renewal.InsuredSex ?? 0).ToString();
                }
                else
                {
                    model.ForceExpireDate       = string.Empty;
                    model.BusinessExpireDate    = string.Empty;
                    model.NextForceStartDate    = string.Empty;
                    model.NextBusinessStartDate = string.Empty;


                    model.InsuredIdCard = string.Empty;
                    model.InsuredIdType = 0;
                    model.InsuredMobile = string.Empty;
                    model.HolderMobile  = string.Empty;
                    model.HolderIdCard  = string.Empty;
                    model.HolderIdType  = 0;
                    model.HolderName    = string.Empty;
                    model.RateFactor1   = 0;
                    model.RateFactor2   = 0;
                    model.RateFactor3   = 0;
                    model.RateFactor4   = 0;
                    model.BizNo         = string.Empty;
                    model.ForceNo       = string.Empty;
                    model.PostedName    = string.Empty;
                    model.InsuredName   = string.Empty;
                    model.Organization  = string.Empty;

                    model.HolderBirthday  = string.Empty;
                    model.HolderSex       = string.Empty;
                    model.InsuredBirthday = string.Empty;
                    model.InsuredSex      = string.Empty;
                }
                if (carinfo != null)
                {
                    model.FuelType     = carinfo.fuel_type.HasValue ? carinfo.fuel_type.Value : 0;
                    model.ProofType    = carinfo.proof_type.HasValue ? carinfo.proof_type.Value : 0;
                    model.LicenseColor = carinfo.license_color.HasValue ? carinfo.license_color.Value : 0;
                    model.ClauseType   = carinfo.clause_type.HasValue ? carinfo.clause_type.Value : 0;
                    model.RunRegion    = carinfo.run_region.HasValue ? carinfo.run_region.Value : 0;

                    model.CarUsedType     = carinfo.car_used_type.HasValue ? carinfo.car_used_type.Value : 0;
                    model.CredentislasNum = string.IsNullOrWhiteSpace(carinfo.owner_idno) ? string.Empty : carinfo.owner_idno;
                    model.IdType          = carinfo.owner_idno_type.HasValue ? carinfo.owner_idno_type.Value : 0;
                    model.PurchasePrice   = (double)(carinfo.purchase_price.HasValue ? carinfo.purchase_price.Value : 0);
                    model.SeatCount       = carinfo.seat_count.HasValue ? carinfo.seat_count.Value : 0;
                    model.ExhaustScale    = carinfo.exhaust_scale.HasValue ? carinfo.exhaust_scale.ToString() : "0";
                    model.LicenseOwner    = string.IsNullOrWhiteSpace(carinfo.license_owner) ? string.Empty : carinfo.license_owner;
                    model.CarType         = (carinfo.car_type ?? 0).ToString();
                    model.CarVin          = carinfo.vin_no ?? string.Empty;
                    model.EngineNo        = carinfo.engine_no ?? string.Empty;
                    model.RegisterDate    = carinfo.register_date.HasValue ? carinfo.register_date.Value.ToString("yyyy-MM-dd") : string.Empty;
                    model.ModleName       = carinfo.mold_name ?? string.Empty;
                    //新增的车主生日和性别
                    model.OwnerBirthday = carinfo.OwnerBirthday ?? string.Empty;
                    if (!string.IsNullOrEmpty(model.OwnerBirthday) && Convert.ToDateTime(model.OwnerBirthday).Year == DateTime.MinValue.Year)
                    {
                        model.OwnerBirthday = string.Empty;
                    }
                    model.OwnerSex = (carinfo.OwnerSex ?? 0).ToString();
                }
                else
                {
                    model.FuelType     = 0;
                    model.ProofType    = 0;
                    model.LicenseColor = 0;
                    model.ClauseType   = 0;
                    model.RunRegion    = 0;

                    model.CarUsedType     = 0;
                    model.CredentislasNum = string.Empty;
                    model.IdType          = 0;
                    model.ExhaustScale    = string.Empty;
                    model.LicenseOwner    = string.Empty;
                    model.CarType         = string.Empty;
                    model.CarVin          = string.IsNullOrWhiteSpace(userinfo.CarVIN) ? string.Empty : userinfo.CarVIN;
                    model.EngineNo        = string.IsNullOrWhiteSpace(userinfo.EngineNo) ? string.Empty : userinfo.EngineNo;
                    model.RegisterDate    = string.IsNullOrWhiteSpace(userinfo.RegisterDate) ? string.Empty : userinfo.RegisterDate;
                    model.ModleName       = string.IsNullOrWhiteSpace(userinfo.MoldName) ? string.Empty : userinfo.MoldName;

                    model.OwnerSex      = string.Empty;
                    model.OwnerBirthday = string.Empty;
                }
                //model.CarVin = string.IsNullOrWhiteSpace(userinfo.CarVIN) ? string.Empty : userinfo.CarVIN;
                model.CityCode = !string.IsNullOrWhiteSpace(userinfo.CityCode) ? Convert.ToInt32(userinfo.CityCode) : 1;
                //model.EngineNo = string.IsNullOrWhiteSpace(userinfo.EngineNo) ? string.Empty : userinfo.EngineNo;
                model.LicenseNo = string.IsNullOrWhiteSpace(userinfo.LicenseNo) ? string.Empty : userinfo.LicenseNo;
                //model.LicenseOwner = string.IsNullOrWhiteSpace(userinfo.LicenseOwner) ? string.Empty : userinfo.LicenseOwner;
                //model.ModleName = string.IsNullOrWhiteSpace(userinfo.MoldName) ? string.Empty : userinfo.MoldName;
                //model.RegisterDate = string.IsNullOrWhiteSpace(userinfo.RegisterDate) ? string.Empty : userinfo.RegisterDate;
                if (!string.IsNullOrWhiteSpace(model.RegisterDate))
                {
                    if (model.RegisterDate.Equals(DateTime.MinValue.ToString("yyyy-MM-dd")))
                    {
                        model.RegisterDate = "";
                    }
                }
                //model.PostedName = model.HolderName;
                //model.InsuredName = string.IsNullOrWhiteSpace(userinfo.InsuredName) ? string.Empty : userinfo.InsuredName;
                model.HolderName     = null;
                model.RenewalCarType = (userinfo.RenewalCarType ?? 0).ToString();
            }
            catch (Exception ex)
            {
                log.Info("模型转换报错:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }



            return(model);
        }
Esempio n. 4
0
        public static SaveQuoteViewModel ConvetToViewModel(this bx_car_renewal savequote)
        {
            SaveQuoteViewModel model = new SaveQuoteViewModel();

            if (savequote != null)
            {
                model.BoLi = savequote.BoLi ?? 0;
                //model.CheDeng = savequote.CheDeng ?? 0;
                model.CheSun           = savequote.CheSun ?? 0;
                model.ChengKe          = savequote.ChengKe ?? 0;
                model.DaoQiang         = savequote.DaoQiang ?? 0;
                model.HuaHen           = savequote.HuaHen ?? 0;
                model.SanZhe           = savequote.SanZhe ?? 0;
                model.SheShui          = savequote.SheShui ?? 0;
                model.SiJi             = savequote.SiJi ?? 0;
                model.BuJiMianCheSun   = savequote.BuJiMianCheSun ?? 0;
                model.BuJiMianDaoQiang = savequote.BuJiMianDaoQiang ?? 0;
                //model.BuJiMianFuJia = savequote.BuJiMianFuJia ?? 0;
                //model.BuJiMianRenYuan = savequote.BuJiMianRenYuan ?? 0;
                model.BuJiMianSanZhe = savequote.BuJiMianSanZhe ?? 0;
                model.ZiRan          = savequote.ZiRan ?? 0;
                model.Source         = savequote.LastYearSource.Value;
                //2.1.5修改 新增8个字段
                model.BuJiMianChengKe        = savequote.BuJiMianChengKe ?? 0;
                model.BuJiMianSiJi           = savequote.BuJiMianSiJi ?? 0;
                model.BuJiMianHuaHen         = savequote.BuJiMianHuaHen ?? 0;
                model.BuJiMianSheShui        = savequote.BuJiMianSheShui ?? 0;
                model.BuJiMianZiRan          = savequote.BuJiMianZiRan ?? 0;
                model.BuJiMianJingShenSunShi = savequote.BuJiMianJingShenSunShi ?? 0;
                model.HcSanFangTeYue         = savequote.SanFangTeYue ?? 0;
                model.HcJingShenSunShi       = savequote.JingShenSunShi ?? 0;
                model.HcXiuLiChang           = (savequote.XiuLiChang ?? 0).ToString(CultureInfo.InvariantCulture);
                model.HcXiuLiChangType       = (savequote.XiuLiChangType ?? -1).ToString();
                model.Fybc            = (savequote.FeiYongBuChang ?? 0).ToString(CultureInfo.InvariantCulture);
                model.FybcDays        = (savequote.FeiYongBuChangDays ?? 0).ToString();
                model.SheBeiSunShi    = (savequote.SheBeiSunShi ?? 0).ToString(CultureInfo.InvariantCulture);
                model.BjmSheBeiSunShi = (savequote.BuJiMianSheBeiSunshi ?? 0).ToString(CultureInfo.InvariantCulture);
                List <SheBei> sheBeis = new List <SheBei>();
                if (!string.IsNullOrWhiteSpace(savequote.SheBeiSunShiConfig))
                {
                    if (!savequote.SheBeiSunShiConfig.ToUpper().Equals("NULL"))
                    {
                        var items = savequote.SheBeiSunShiConfig.FromJson <List <bx_devicedetail> >();
                        foreach (bx_devicedetail devicedetail in items)
                        {
                            var sb = new SheBei()
                            {
                                DN = string.IsNullOrWhiteSpace(devicedetail.device_name) ? string.Empty : devicedetail.device_name,
                                DA = devicedetail.device_amount ?? 0,
                                DD = devicedetail.device_depreciationamount ?? devicedetail.device_depreciationamount.Value,
                                DQ = devicedetail.device_quantity ?? devicedetail.device_quantity.Value,
                                DT = devicedetail.device_type ?? devicedetail.device_type.Value,
                                PD = devicedetail.purchase_date.HasValue ? devicedetail.purchase_date.Value.ToString("yyyy-MM-dd") : string.Empty
                            };
                            sheBeis.Add(sb);
                        }
                    }
                }
                model.SheBeis        = sheBeis;
                model.SanZheJieJiaRi = (savequote.SanZheJieJiaRi ?? 0).ToString();
            }
            return(model);
        }
        /// <summary>
        /// 续保返回保额+保费
        /// </summary>
        /// <param name="premiumModel"></param>
        /// <param name="carRenewal"></param>
        /// <returns></returns>
        public static XianZhong ConvetToViewModel(this bx_car_renewal_premium premiumModel, bx_car_renewal carRenewal)
        {
            XianZhong xianzhong = new XianZhong()
            {
                CheSun                 = new XianZhongUnit(),
                SanZhe                 = new XianZhongUnit(),
                DaoQiang               = new XianZhongUnit(),
                SiJi                   = new XianZhongUnit(),
                ChengKe                = new XianZhongUnit(),
                BoLi                   = new XianZhongUnit(),
                HuaHen                 = new XianZhongUnit(),
                BuJiMianCheSun         = new XianZhongUnit(),
                BuJiMianSanZhe         = new XianZhongUnit(),
                BuJiMianDaoQiang       = new XianZhongUnit(),
                BuJiMianFuJia          = new XianZhongUnit(),
                BuJiMianChengKe        = new XianZhongUnit(),
                BuJiMianSiJi           = new XianZhongUnit(),
                BuJiMianHuaHen         = new XianZhongUnit(),
                BuJiMianSheShui        = new XianZhongUnit(),
                BuJiMianZiRan          = new XianZhongUnit(),
                BuJiMianJingShenSunShi = new XianZhongUnit(),
                SheShui                = new XianZhongUnit(),
                ZiRan                  = new XianZhongUnit(),
                HcSheBeiSunshi         = new XianZhongUnit(),
                HcHuoWuZeRen           = new XianZhongUnit(),
                HcJingShenSunShi       = new XianZhongUnit(),
                HcSanFangTeYue         = new XianZhongUnit(),
                HcXiuLiChang           = new XianZhongUnit(),
                Fybc                   = new XianZhongUnit(),
                FybcDays               = new XianZhongUnit(),
                SheBeiSunShi           = new XianZhongUnit(),
                BjmSheBeiSunShi        = new XianZhongUnit(),
                HcXiuLiChangType       = "-1"
            };

            if (premiumModel == null)
            {
                premiumModel = new bx_car_renewal_premium();
            }
            if (carRenewal == null)
            {
                carRenewal = new bx_car_renewal();
            }

            try
            {
                xianzhong = new XianZhong()
                {
                    CheSun = new XianZhongUnit
                    {
                        //BaoE = carRenewal.CheSun.HasValue ? carRenewal.CheSun.Value : 0,
                        BaoE   = carRenewal.CheSun ?? 0,
                        BaoFei = premiumModel.CheSun
                    },
                    SanZhe = new XianZhongUnit
                    {
                        BaoE   = carRenewal.SanZhe.HasValue ? carRenewal.SanZhe.Value : 0,
                        BaoFei = premiumModel.SanZhe
                    },
                    DaoQiang = new XianZhongUnit
                    {
                        BaoE   = carRenewal.DaoQiang ?? 0,
                        BaoFei = premiumModel.DaoQiang
                    },
                    SiJi = new XianZhongUnit
                    {
                        BaoE   = carRenewal.SiJi.HasValue ? carRenewal.SiJi.Value : 0,
                        BaoFei = premiumModel.SiJi
                    },
                    ChengKe = new XianZhongUnit
                    {
                        BaoE   = carRenewal.ChengKe.HasValue ? carRenewal.ChengKe.Value : 0,
                        BaoFei = premiumModel.ChengKe
                    },
                    BoLi = new XianZhongUnit
                    {
                        BaoE   = carRenewal.BoLi.HasValue ? carRenewal.BoLi.Value : 0,
                        BaoFei = premiumModel.BoLi
                    },
                    HuaHen = new XianZhongUnit
                    {
                        BaoE   = carRenewal.HuaHen.HasValue ? carRenewal.HuaHen.Value : 0,
                        BaoFei = premiumModel.HuaHen
                    },


                    BuJiMianCheSun = new XianZhongUnit
                    {
                        BaoE   = carRenewal.BuJiMianCheSun.HasValue ? carRenewal.BuJiMianCheSun.Value : 0,
                        BaoFei = premiumModel.BuJiMianCheSun
                    },
                    BuJiMianSanZhe = new XianZhongUnit
                    {
                        BaoE   = carRenewal.BuJiMianSanZhe.HasValue ? carRenewal.BuJiMianSanZhe.Value : 0,
                        BaoFei = premiumModel.BuJiMianSanZhe
                    },
                    BuJiMianDaoQiang = new XianZhongUnit
                    {
                        BaoE   = carRenewal.BuJiMianDaoQiang.HasValue ? carRenewal.BuJiMianDaoQiang.Value : 0,
                        BaoFei = premiumModel.BuJiMianDaoQiang
                    },
                    //BuJiMianRenYuan = new XianZhongUnit
                    //{
                    //    BaoE = carRenewal.BuJiMianRenYuan.HasValue ? carRenewal.BuJiMianRenYuan.Value : 0,
                    //    BaoFei = premiumModel.BuJiMianRenYuan.HasValue ? premiumModel.BuJiMianRenYuan.Value : 0
                    //},

                    BuJiMianFuJia = new XianZhongUnit
                    {
                        BaoE   = carRenewal.BuJiMianFuJia ?? 0,
                        BaoFei = premiumModel.BuJiMianFuJia
                    },

                    //2.1.5版本 修改 增加6个字段
                    BuJiMianChengKe = new XianZhongUnit()
                    {
                        BaoE   = carRenewal.BuJiMianChengKe.HasValue ? carRenewal.BuJiMianChengKe.Value : 0,
                        BaoFei = premiumModel.BuJiMianChengKe
                    },
                    BuJiMianSiJi = new XianZhongUnit()
                    {
                        BaoE   = carRenewal.BuJiMianSiJi.HasValue ? carRenewal.BuJiMianSiJi.Value : 0,
                        BaoFei = premiumModel.BuJiMianSiJi
                    },
                    BuJiMianHuaHen = new XianZhongUnit()
                    {
                        BaoE   = carRenewal.BuJiMianHuaHen.HasValue ? carRenewal.BuJiMianHuaHen.Value : 0,
                        BaoFei = premiumModel.BuJiMianHuaHen
                    },
                    BuJiMianSheShui = new XianZhongUnit()
                    {
                        BaoE   = carRenewal.BuJiMianSheShui.HasValue ? carRenewal.BuJiMianSheShui.Value : 0,
                        BaoFei = premiumModel.BuJiMianSheShui
                    },
                    BuJiMianZiRan = new XianZhongUnit()
                    {
                        BaoE   = carRenewal.BuJiMianZiRan.HasValue ? carRenewal.BuJiMianZiRan.Value : 0,
                        BaoFei = premiumModel.BuJiMianZiRan
                    },
                    BuJiMianJingShenSunShi = new XianZhongUnit()
                    {
                        BaoE   = carRenewal.BuJiMianJingShenSunShi.HasValue ? carRenewal.BuJiMianJingShenSunShi.Value : 0,
                        BaoFei = premiumModel.BuJiMianJingShenSunShi
                    },
                    //2.1.5修改结束

                    SheShui = new XianZhongUnit
                    {
                        BaoE   = carRenewal.SheShui.HasValue ? carRenewal.SheShui.Value : 0,
                        BaoFei = premiumModel.SheShui
                    },
                    //CheDeng = new XianZhongUnit
                    //{
                    //    BaoE = carRenewal.CheDeng.HasValue ? carRenewal.CheDeng.Value : 0,
                    //    BaoFei = premiumModel.CheDeng.HasValue ? premiumModel.CheDeng.Value : 0
                    //},
                    ZiRan = new XianZhongUnit
                    {
                        BaoE   = carRenewal.ZiRan ?? 0,
                        BaoFei = premiumModel.ZiRan
                    },
                    HcSheBeiSunshi = new XianZhongUnit
                    {
                        BaoE   = carRenewal.SheBeiSunShi ?? 0,
                        BaoFei = premiumModel.SheBeiSunShi
                    },
                    HcHuoWuZeRen = new XianZhongUnit
                    {
                        BaoE   = carRenewal.HuoWuZeRen ?? 0,
                        BaoFei = premiumModel.HuoWuZeRen
                    },
                    //HcFeiYongBuChang = new XianZhongUnit
                    //{
                    //    BaoE = carRenewal.HcFeiYongBuChang.HasValue ? carRenewal.HcFeiYongBuChang.Value : 0,
                    //    BaoFei = premiumModel.HcFeiYongBuChang.HasValue ? premiumModel.HcFeiYongBuChang.Value : 0
                    //},
                    HcJingShenSunShi = new XianZhongUnit
                    {
                        BaoE   = carRenewal.JingShenSunShi ?? 0,
                        BaoFei = premiumModel.JingShenSunShi
                    },
                    HcSanFangTeYue = new XianZhongUnit
                    {
                        BaoE   = carRenewal.SanFangTeYue ?? 0,
                        BaoFei = premiumModel.SanFangTeYue
                    },
                    HcXiuLiChang = new XianZhongUnit
                    {
                        BaoE   = carRenewal.XiuLiChang ?? 0,
                        BaoFei = premiumModel.XiuLiChang
                    },
                    Fybc = new XianZhongUnit
                    {
                        BaoE   = carRenewal.FeiYongBuChang ?? 0,
                        BaoFei = premiumModel.FeiYongBuChang
                    },
                    FybcDays = new XianZhongUnit()
                    {
                        BaoE   = carRenewal.FeiYongBuChangDays ?? 0,
                        BaoFei = carRenewal.FeiYongBuChangDays ?? 0
                    },
                    SheBeiSunShi = new XianZhongUnit
                    {
                        BaoE   = carRenewal.SheBeiSunShi ?? 0,
                        BaoFei = premiumModel.SheBeiSunShi
                    },
                    BjmSheBeiSunShi = new XianZhongUnit
                    {
                        BaoE   = carRenewal.BuJiMianSheBeiSunshi ?? 0,
                        BaoFei = premiumModel.BuJiMianSheBeiSunshi
                    },
                    HcXiuLiChangType = (carRenewal.XiuLiChangType ?? -1).ToString()
                };
            }
            catch (Exception ex)
            {
                logError.Info("模型转换发生异常" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(xianzhong);
        }
        public ChangeReInfoAgentResponse ChangeReInfoAgent(ChangeReInfoAgentRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            var response   = new ChangeReInfoAgentResponse();
            var agentModel = GetAgentModelFactory(request.Agent);

            //参数校验
            if (agentModel == null)// || childAgent == null)
            {
                response.Status = HttpStatusCode.BadRequest;
                return(response);
            }
            if (!AppValidateReqest(pairs, request.SecCode))
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }
            try
            {
                //根据OpenId、车牌号、代理人Id找Buid
                bx_userinfo bxUserInfo = _userInfoRepository.FindByAgentLicense(request.LicenseNo, request.OwnerAgent.ToString());
                if (bxUserInfo == null)
                {
                    response.ErrCode = 0;
                    response.ErrMsg  = "查不到此续保信息";
                    return(response);
                }
                bx_agent bxAgent = _agentRepository.GetAgent(request.AssignId);
                if (bxAgent == null)
                {
                    response.ErrCode = 0;
                    response.ErrMsg  = "查不到分配人信息";
                    return(response);
                }
                bxUserInfo.Agent  = request.AssignId.ToString();
                bxUserInfo.OpenId = bxAgent.OpenId;
                if (_userInfoRepository.Update(bxUserInfo) > 0 || request.OwnerAgent == request.AssignId)
                {
                    AddChangeLog(bxUserInfo.Id, request.OwnerAgent, request.AssignId, 2); //第二步

                    //5,添加分配通知
                    //AddMessageRequest msgRequest = new AddMessageRequest();
                    //msgRequest.Body = request.LicenseNo;
                    //msgRequest.MsgType = 6;
                    //msgRequest.ToAgentId = request.AssignId;
                    //msgRequest.MsgLevel = 1;
                    //msgRequest.SendTime = DateTime.Now.ToString();
                    //msgRequest.ChildAgent = request.OwnerAgent;
                    //_messageService.AddMessage(msgRequest);

                    //bx_notice_xb xbmodel = _noticexbService.Find(bxUserInfo.Id);
                    bx_car_renewal bxCarRenewal = _carRenewalRepository.FindByLicenseno(bxUserInfo.LicenseNo);
                    if (bxCarRenewal != null)
                    {
                        _noticexbService.AddNoticexb(0, bxUserInfo.LicenseNo,
                                                     bxCarRenewal.LastBizEndDate.HasValue ? bxCarRenewal.LastBizEndDate.Value.ToString() : "",
                                                     bxCarRenewal.LastForceEndDate.HasValue ? bxCarRenewal.LastForceEndDate.Value.ToString() : "",
                                                     bxCarRenewal.NextBizStartDate.HasValue ? bxCarRenewal.NextBizStartDate.Value.ToString() : "",
                                                     bxCarRenewal.NextForceStartDate.HasValue ? bxCarRenewal.NextForceStartDate.Value.ToString() : "",
                                                     bxCarRenewal.LastYearSource.HasValue ? bxCarRenewal.LastYearSource.Value : -1, int.Parse(bxUserInfo.Agent), request.Agent, bxUserInfo.Id, 0);
                    }
                    response.ErrCode = 1;
                    response.ErrMsg  = "分配成功";
                    return(response);
                }
                else
                {
                    response.ErrCode = 0;
                    response.ErrMsg  = "分配失败";
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.ErrCode = -10003;
                logError.Info("分发接口异常,分发信息:" + request.ToJson() + "\n 异常信息:" + ex.StackTrace + " \n " + ex.Message);
            }
            return(response);
        }
        public async Task<GetIntelligentReInfoResponse> GetIntelligentReInfo(GetIntelligentReInfoRequest request, IEnumerable<KeyValuePair<string, string>> pairs)
        {
            var response = new GetIntelligentReInfoResponse();
            var isReadCache = true;
            try
            {
                //代理人校验
                IBxAgent agentModel = _getAgentInfoService.GetAgentModelFactory(request.Agent);
                if (!agentModel.AgentCanUse())
                {
                    response.Status = HttpStatusCode.Forbidden;
                    if (agentModel.endDate.HasValue && agentModel.endDate.Value < DateTime.Now)
                    {
                        response.ErrMsg = string.Format("参数校验错误,账号已过期。过期时间为:{0}", agentModel.endDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                        return response;
                    }
                    response.ErrMsg = "参数校验错误,账号已禁用。";
                    return response;
                }
                if (!ValidateReqest(pairs, agentModel.SecretKey, request.SecCode))
                {
                    response.Status = HttpStatusCode.Forbidden;
                    return response;
                }
                //微信端逻辑 次级代理
                if (request.ChildAgent > 0)
                {
                    var item = _agentRepository.GetAgent(request.ChildAgent);
                    if (item != null && item.IsUsed == 1)
                    {
                        request.Agent = request.ChildAgent;
                    }
                    else
                    {
                        return new GetIntelligentReInfoResponse
                        {
                            ErrMsg = "您的账号已被禁用,如有疑问请联系管理员。",
                            Status = HttpStatusCode.Forbidden
                        };
                    }
                }
                ///先从库里读取,没有在走后续流程
                if (request.IsCarVin == 1)
                {
                    //根据车架号查询
                    response.CarInfo = _carInfoRepository.FindVinCarInfo(request.CarVin, request.RenewalCarType);

                }
                else
                {
                    //车牌号查询
                    response.CarInfo = _carInfoRepository.FindOrderDate(request.LicenseNo, request.RenewalCarType);
                }

                response.Status = HttpStatusCode.OK;
                if (response.CarInfo != null)
                {
                    response.ErrCode = 1;
                    response.ErrMsg = "成功获取信息";
                    //然后调用中心取险种推荐的逻辑
                    response.SaveQuote = new SaveQuoteViewModel();
                    bx_car_renewal car_Renewal = _carRenewalRepository.FindByLicenseno(response.CarInfo.license_no);
                    if (car_Renewal != null)
                    {
                        response.SaveQuote = car_Renewal.ConvetToViewModel();
                    }
                    else
                    {
                        request.MoldName = response.CarInfo.mold_name;
                        request.RegisterDate = response.CarInfo.register_date.HasValue ? response.CarInfo.register_date.Value.ToString("yyyy-MM-dd") : string.Empty;
                        response.IsIntelligent = 1;
                        //获取推荐信息失败,也返回1
                        var tuple = await _getIntelligentInsurance.GetCenterInsurance(request);
                        response.SaveQuote = tuple.Item1;
                        if (!tuple.Item2) {
                            response.ErrCode = 2;
                            response.ErrMsg = "成功获取车辆信息,未获取到险种信息";
                        }
                    }
                }
                else
                {
                    response.ErrCode = 0;
                    response.ErrMsg = "未获取到车辆信息";
                }
#pragma warning disable CS4014 // 由于此调用不会等待,因此在调用完成前将继续执行当前方法
                Task.Factory.StartNew(() =>
                {
                    GetReInfoRequest requestNew = new GetReInfoRequest()
                    {
                        LicenseNo = request.LicenseNo,
                        Agent = request.Agent
                    };
                    int datastatus = int.Parse(response.ErrCode.ToString() + response.IsIntelligent.ToString());
                    _renewalStatusService.AddRenewalStatus(response.ErrCode, requestNew);
                });
#pragma warning restore CS4014 // 由于此调用不会等待,因此在调用完成前将继续执行当前方法
                return response;
            }
            catch (Exception ex)
            {
                response = new GetIntelligentReInfoResponse();
                response.Status = HttpStatusCode.ExpectationFailed;
                logError.Info("获取简易续保信息发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return response;
        }