/// <summary>
        /// 判断是否在90天之内的续保
        /// </summary>
        /// <param name="userinfo"></param>
        /// <returns></returns>
        public bool IsInTime(long buid)
        {
            //return true;
            var lastinfo = _lastInfoRepository.GetByBuid(buid);

            if (lastinfo == null)
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(lastinfo.last_business_end_date) && string.IsNullOrWhiteSpace(lastinfo.last_end_date))
            {
                return(false);
            }
            return(true);
        }
        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);
        }
示例#3
0
        public ReListViewModel GetReInfoList(GetReInfoListRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            var model = new ReListViewModel();

            var list       = new List <Re>();
            int totalCount = 0;

            IBxAgent agentModel = GetAgentModelFactory(request.Agent);

            //参数校验
            if (!agentModel.AgentCanUse())
            {
                model.BusinessStatus = -10001;
                model.StatusMessage  = "参数校验错误,请检查您的校验码";
                return(model);
            }
            //此处对续保消费系统不做校验
            //if (!AppValidateReqest(pairs, request.SecCode))
            //{
            //    model.BusinessStatus = -10001;
            //    model.StatusMessage = "参数校验错误,请检查您的校验码";
            //    return model;
            //}
            try
            {
                //拼接where语句
                var sbWhere = new StringBuilder();
                sbWhere.Append(" QuoteStatus = -1 AND LENGTH(OpenId) > 9 AND IsTest=0 ");

                if (request.LastYearSource > -1)
                {
                    sbWhere.Append(string.Format(" AND LastYearSource = {0} ", request.LastYearSource));
                }
                if (request.RenewalStatus == 1)
                {
                    //sbWhere.Append(" AND (( NeedEngineNo=0 AND RenewalStatus!=1 ) ")
                    //    .Append(" OR ( NeedEngineNo=0 AND LastYearSource>-1 ) ")
                    //.Append(" OR ( RenewalStatus=1 )) ");
                    sbWhere.Append(" AND (( NeedEngineNo=0 AND RenewalStatus=0 ) ")
                    .Append(" OR ( RenewalStatus=1 )) ");
                }
                else if (request.RenewalStatus == 0)
                {
                    //sbWhere.Append(" AND NeedEngineNo=1 AND RenewalStatus=0 "); //sbWhere.Append(" AND ( NeedEngineNo=1 OR RenewalStatus!=1 )");
                    sbWhere.Append(" AND (( NeedEngineNo=1 AND RenewalStatus=0 )")
                    .Append(" OR ( RenewalStatus=-1 )) ");
                }
                if (request.IsOnlyMine.HasValue)
                {
                    if (request.IsOnlyMine.Value == 0)
                    {
                        //查询当前代理人及子集的agent
                        string agentids = _agentRepository.GetSonsIdToString(request.ChildAgent, true);
                        if (!string.IsNullOrEmpty(agentids))
                        {
                            sbWhere.Append(" AND Agent in (")
                            .Append(agentids)
                            .Append(") ");
                        }
                    }
                }
                else
                {
                    sbWhere.Append(string.Format(" AND Agent ='{0}' ", request.ChildAgent));
                }
                if (!string.IsNullOrWhiteSpace(request.LicenseNo))
                {
                    sbWhere.Append(string.Format(" AND (LicenseNo like '%{0}%' OR LicenseOwner like '%{0}%') ", request.LicenseNo.ToUpper()));
                }

                //查询列表
                var userinfo = new List <bx_userinfo>();
                userinfo = _userInfoRepository.FindReList(sbWhere.ToString(), request.PageSize, request.CurPage, out totalCount);

                //续保总数
                model.TotalCount = totalCount;
                if (totalCount < 0)
                {
                    model.BusinessStatus = 0;
                    model.StatusMessage  = "没有续保记录";
                    return(model);
                }
                if (userinfo.Count > 0)
                {
                    Re re;
                    foreach (var item in userinfo)
                    {
                        if (string.IsNullOrWhiteSpace(item.LicenseNo))
                        {
                            continue;
                        }
                        re      = new Re();
                        re.Buid = item.Id;
                        //创建时间
                        if (item.CreateTime != null)
                        {
                            re.CreateTime = item.UpdateTime.HasValue ? item.UpdateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
                        }
                        re.LastYearSource = item.LastYearSource;
                        //配置基础信息
                        re.UserInfo =
                            item.ConvertToViewModel(_carRenewalRepository.FindCarRenewal(item.Id),
                                                    _carInfoRepository.Find(item.LicenseNo),
                                                    _lastInfoRepository.GetByBuid(item.Id));
                        //续保状态,默认情况是0,如果是获取到车辆信息和正常续保成功,会返回1
                        re.RenewalStatus = 0;
                        //续保判断返回信息
                        if (item.RenewalStatus == 1)
                        {
                            //续保成功
                            re.BusinessStatus = 1;
                            re.StatusMessage  = "续保成功";
                            re.RenewalStatus  = 1;
                        }
                        else//0和-1
                        {
                            if (item.NeedEngineNo == 1)
                            {
                                //需要完善行驶证信息
                                re.BusinessStatus = 2;
                                re.StatusMessage  = "需要完善行驶证信息(车辆信息和险种都没有获取到)";
                                re.UserInfo.BusinessExpireDate    = "";
                                re.UserInfo.ForceExpireDate       = "";
                                re.UserInfo.NextBusinessStartDate = "";
                                re.UserInfo.NextForceStartDate    = "";
                            }
                            if (item.NeedEngineNo == 0)
                            {
                                //获取车辆信息成功,但获取险种失败
                                re.BusinessStatus = 3;
                                re.StatusMessage  = "获取车辆信息成功(车架号,发动机号,品牌型号及初登日期),险种获取失败";
                                re.RenewalStatus  = 1;//该情况属于续保成功
                                re.UserInfo.BusinessExpireDate    = "";
                                re.UserInfo.ForceExpireDate       = "";
                                re.UserInfo.NextBusinessStartDate = "";
                                re.UserInfo.NextForceStartDate    = "";
                            }
                            //if (item.NeedEngineNo == 0 && item.LastYearSource > -1)
                            //{
                            //    //续保成功
                            //    re.BusinessStatus = 1;
                            //    re.StatusMessage = "续保成功";
                            //    re.RenewalStatus = 1;
                            //}
                            if (item.RenewalStatus == -1)
                            {
                                re.BusinessStatus = 0;
                                re.StatusMessage  = "获取续保信息失败";
                                re.UserInfo.BusinessExpireDate    = "";
                                re.UserInfo.ForceExpireDate       = "";
                                re.UserInfo.NextBusinessStartDate = "";
                                re.UserInfo.NextForceStartDate    = "";
                            }
                        }
                        #region 以前续保状态判断 注释掉
                        //if (item.NeedEngineNo == 1 && item.RenewalStatus == 0)//if (item.NeedEngineNo == 1)
                        //{
                        //    //需要完善行驶证信息
                        //    re.BusinessStatus = 2;
                        //    re.StatusMessage = "需要完善行驶证信息(车辆信息和险种都没有获取到)";
                        //    re.UserInfo.BusinessExpireDate = "";
                        //    re.UserInfo.ForceExpireDate = "";
                        //    re.UserInfo.NextBusinessStartDate = "";
                        //    re.UserInfo.NextForceStartDate = "";
                        //}
                        //if (item.RenewalStatus == -1)//if (item.LastYearSource == -1)
                        //{
                        //    re.BusinessStatus = 0;
                        //    re.StatusMessage = "获取续保信息失败";
                        //    re.UserInfo.BusinessExpireDate = "";
                        //    re.UserInfo.ForceExpireDate = "";
                        //    re.UserInfo.NextBusinessStartDate = "";
                        //    re.UserInfo.NextForceStartDate = "";
                        //}
                        //if (item.NeedEngineNo == 0 && item.RenewalStatus == 0)
                        //{
                        //    //获取车辆信息成功,但获取险种失败
                        //    re.BusinessStatus = 3;
                        //    re.StatusMessage = "获取车辆信息成功(车架号,发动机号,品牌型号及初登日期),险种获取失败";
                        //    re.RenewalStatus = 1;//该情况属于续保成功
                        //    re.UserInfo.BusinessExpireDate = "";
                        //    re.UserInfo.ForceExpireDate = "";
                        //    re.UserInfo.NextBusinessStartDate = "";
                        //    re.UserInfo.NextForceStartDate = "";
                        //}
                        //if ((item.NeedEngineNo == 0 && item.LastYearSource > -1) || item.RenewalStatus == 1)//if (item.RenewalStatus == 1)//
                        //{
                        //    //续保成功
                        //    re.BusinessStatus = 1;
                        //    re.StatusMessage = "续保成功";
                        //    re.RenewalStatus = 1;
                        //}
                        #endregion
                        list.Add(re);
                    }
                    model.BusinessStatus = 1;
                    model.ReList         = list;
                }
            }
            catch (Exception ex)
            {
                model.BusinessStatus = -10003;
                model.StatusMessage  = "服务发生异常";
                logError.Info("续保列表接口请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(model);
        }