Example #1
0
        public long UpdateBjdInfo(CreateOrUpdateBjdInfoRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            //校验
            #region
            //bx_claim_detail
            long baodanxinxiid = 0;

            //20160905修改source1248=>0123,传入的新数据转换
            var checkResult = _bjdCheck.Valid(request);
            if (checkResult.State == 0)
            {
                logErr.Info(checkResult.Message);
                return(checkResult.State);
            }

            #endregion
            try
            {
                //新增
                if (request.BxId == 0)
                {
                    //单独写一个接口  实现
                    bx_preferential_activity model = _createActivity.AddActivity(request, 5);
                    //单独写一个接口  实现

                    var baodanxinxi = _mapBaoDanXinXiRecord.MapBaodanxinxi(request, checkResult.SubmitInfo, checkResult.Quoteresult,
                                                                           checkResult.Savequote, checkResult.Userinfo, checkResult.ReqCarInfo, model);
                    var item = _baodanxinxiRepository.Add(baodanxinxi);

                    var agentinfo = _agentRepository.GetAgent(checkResult.Userinfo.Agent);

                    Task.Factory.StartNew(() =>
                    {
                        _addCrmStepsService.AddCrmSteps(request.ChildAgent, agentinfo == null ? "" : agentinfo.AgentName, "",
                                                        checkResult.Userinfo.LicenseNo, request.Source, request.BizRate, request.ForceRate,
                                                        model.id, request.Buid, item.Id, request.CityCode);
                    });

                    List <bx_ywxdetail> ywxList = _ywxdetailRepository.GetList(request.Buid);

                    var baodanxianzhong = _mapBaoDanXianZhongRecord.MapBaodanxianzhong(baodanxinxi, checkResult.Quoteresult, checkResult.Savequote,
                                                                                       checkResult.SubmitInfo, ywxList);
                    _baodanXianZhongRepository.Add(baodanxianzhong);

                    _bjxUnionRepository.Add(request.Buid, item.Id);
                    baodanxinxiid = item.Id;
                }
            }
            catch (Exception ex)
            {
                baodanxinxiid = -1;
                logErr.Info("创建报价单发生异常,请求串为:" + request.ToJson() + "/n错误信息:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(baodanxinxiid);
        }
        public bx_preferential_activity AddActivity(bx_preferential_activity request)
        {
            bx_preferential_activity response = new bx_preferential_activity();

            try
            {
                response = DataContextFactory.GetDataContext().bx_preferential_activity.Add(request);
                DataContextFactory.GetDataContext().SaveChanges();
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(response);
        }
Example #3
0
        public bx_preferential_activity AddActivity(CreateOrUpdateBjdInfoRequest request, int aciivityType)
        {
            var model = new bx_preferential_activity();

            try
            {
                if (!string.IsNullOrWhiteSpace(request.ActivityContent))
                {
                    bx_preferential_activity modelactivity = _preferentialActivityRepository.GetListByType(5,
                                                                                                           request.ActivityContent);
                    if (modelactivity != null)
                    {
                        model = modelactivity;
                    }
                    else
                    {
                        var agentinfo = _agentRepository.GetAgent(request.ChildAgent);
                        model.top_agent_id     = request.Agent;
                        model.agent_id         = request.ChildAgent;
                        model.activity_type    = 5;
                        model.activity_name    = "";
                        model.activity_content = request.ActivityContent;
                        model.activity_status  = 1;
                        model.create_time      = DateTime.Now;
                        model.create_name      = agentinfo == null ? "" : agentinfo.AgentName;
                        model.modify_time      = DateTime.Now;
                        model.modify_name      = agentinfo == null ? "" : agentinfo.AgentName;
                        _preferentialActivityRepository.AddActivity(model);
                    }
                }
            }
            catch (Exception ex)
            {
                logErr.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
                return(new bx_preferential_activity());
            }

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