public MyBaoJiaViewModel SetPrecisePriceItem(MyBaoJiaViewModel my, bx_userinfo userinfo, GetMyBjdDetailRequest request, List <bx_quoteresult_carinfo> quoteresultCarinfo, int reqseatcount)
        {
            var sourceList = _setPrecisePriceItem.FindSource(userinfo, request);
            //获取图片bx_picture
            List <bx_picture> picList = _pictureRepository.GetAllList(o => o.b_uid == userinfo.Id);
            //报价单资源对象
            bx_savequote          sq      = _saveQuoteRepository.GetSavequoteByBuid(userinfo.Id);
            List <bx_quoteresult> qrList  = _quoteResultRepository.GetQuoteResultList(userinfo.Id);
            List <bx_submit_info> siList  = _submitInfoRepository.GetSubmitInfoList(userinfo.Id);
            List <bx_ywxdetail>   ywxList = _ywxdetailRepository.GetList(userinfo.Id);
            //渠道列表
            List <AgentConfigNameModel> agentChannelList = new List <AgentConfigNameModel>();

            if (siList.Any())
            {
                agentChannelList = _agentConfigRepository.FindListById(siList.Select(l => l.channel_id).Join(","));
            }
            //图片url
            List <IsUploadImg> isUploadImg = new List <IsUploadImg>();
            //报价信息模型,包括险种和报价
            List <MyPrecisePriceItemViewModel> listquoteTotal = new List <MyPrecisePriceItemViewModel>();

            var hebaodianweis = _hebaoDianweiRepository.FindList(userinfo.Id, SourceGroupAlgorithm.GetOldSources(sourceList.ToArray()));

            if (sourceList.Any() && userinfo.QuoteStatus > -1)
            {
                foreach (int itk in sourceList)
                {
                    //20160905修改source1248=>0123,传入的新数据转换
                    var oit    = SourceGroupAlgorithm.GetOldSource(itk);//获取到旧的source值
                    var submit = siList.FirstOrDefault(i => i.source == oit);
                    var qr     = qrList.FirstOrDefault(i => i.Source == oit);
                    var jy     = ywxList.Where(i => i.source == oit).ToList();
                    if (oit == 3)
                    {
                        if (!string.IsNullOrEmpty(request.NewRate) && qr != null)
                        {
                            qr.NewRate = decimal.Parse(request.NewRate);
                            _quoteResultRepository.Update(qr);
                        }
                        else if (string.IsNullOrEmpty(request.NewRate) && qr != null && qr.NewRate != 0 && qr.NewRate != null)
                        {
                            request.NewRate = qr.NewRate.ToString();
                        }
                        if (!string.IsNullOrEmpty(request.NewRate))
                        {
                            my.NewRate = double.Parse(request.NewRate).ToString("#0.00000");
                        }
                    }
                    var model = ConvertToViewModelNew(oit, sq,
                                                      qr, submit, userinfo.QuoteStatus.Value, agentChannelList, userinfo.CarVIN, jy, request.NewRate);

                    var hebaodianwei = hebaodianweis.FirstOrDefault(heb => heb.source == oit);
                    if (hebaodianwei != null && my.IsShowCalc == 0)
                    {
                        model.BizSysRate = hebaodianwei.system_biz_rate.HasValue
                            ? Convert.ToDecimal(hebaodianwei.system_biz_rate.Value)
                            : 0;
                        model.ForceSysRate = hebaodianwei.system_force_rate.HasValue
                            ? Convert.ToDecimal(hebaodianwei.system_force_rate.Value)
                            : 0;
                        //优惠费率
                        model.BenefitRate = hebaodianwei.agent_id == hebaodianwei.parent_agent_id
                            ? Convert.ToDecimal(hebaodianwei.zhike_biz_rate.Value)
                            : Convert.ToDecimal(hebaodianwei.agent_biz_rate.Value);
                    }
                    var qcinfo = quoteresultCarinfo.FirstOrDefault(l => l.source == oit);
                    if (qcinfo != null)
                    {
                        model.CarUsedType = qcinfo.car_used_type ?? 0;
                        model.SeatCount   = qcinfo.seat_count ?? 0;//座位数赋值
                    }
                    if (model.SeatCount == 0)
                    {
                        //如果报价结果没拿到座位数,将请求的赋值进去
                        model.SeatCount = reqseatcount;
                    }
                    model.JingSuanKouJing = submit != null ? (submit.RbJSKJ ?? "") : "";
                    listquoteTotal.Add(model);

                    //拼装上传的图片模型
                    if (picList.Any())
                    {
                        bx_picture picture = picList.FirstOrDefault(l => l.source == oit);
                        if (picture != null && picture.id != 0)
                        {
                            IsUploadImg newmodel = new IsUploadImg()
                            {
                                IsUpload = 1,
                                Source   = itk
                            };
                            isUploadImg.Add(newmodel);
                        }
                    }
                }
                my.PrecisePriceItem = listquoteTotal;
                my.IsUploadImg      = isUploadImg;
            }
            else
            {
                my.PrecisePriceItem = new List <MyPrecisePriceItemViewModel>();
            }
            return(my);
        }
        public void SetPrecisePriceItem_AllNull_QuoteStatusLessNegative1()
        {
            _setPrecisePriceItem.FindSource(Arg.Any <bx_userinfo>(), Arg.Any <GetMyBjdDetailRequest>()).Returns(x => new List <long> {
                1, 4
            });
            _submitInfoRepository.GetSubmitInfoList(Arg.Any <long>()).Returns(x => new List <bx_submit_info>());
            setPrecisePriceItemService.ConvertToViewModelNew(Arg.Any <int>(), Arg.Any <bx_savequote>(), Arg.Any <bx_quoteresult>(), Arg.Any <bx_submit_info>(), Arg.Any <int>(), Arg.Any <List <AgentConfigNameModel> >(), Arg.Any <string>(), Arg.Any <List <bx_ywxdetail> >(), Arg.Any <string>()).Returns(x => null);
            _pictureRepository.GetAllList(Arg.Any <Expression <Func <bx_picture, bool> > >()).Returns(x => null);
            _agentConfigRepository.FindListById(Arg.Any <string>()).Returns(x => null);
            _quoteResultRepository.GetQuoteResultList(Arg.Any <long>()).Returns(x => null);
            _hebaoDianweiRepository.FindList(Arg.Any <long>(), Arg.Any <long[]>()).Returns(x => null);
            _saveQuoteRepository.GetSavequoteByBuid(Arg.Any <long>()).Returns(x => null);
            var result = _setPrecisePriceItemService.SetPrecisePriceItem(new MyBaoJiaViewModel(), new bx_userinfo()
            {
                Id = 1, QuoteStatus = -1
            }, new GetMyBjdDetailRequest()
            {
                Buid = 1
            }, new List <bx_quoteresult_carinfo>(), 1);

            Assert.AreEqual(null, result.PurchasePrice);
            Assert.AreEqual(0, result.PrecisePriceItem.Count);
            Assert.AreEqual(null, result.AutoMoldCode);
            Assert.AreEqual(null, result.BizStartDate);
            Assert.AreEqual(null, result.Buid);
            Assert.AreEqual(0, result.BusinessStatus);
            Assert.AreEqual(null, result.CarInfos);
            Assert.AreEqual(null, result.CarOwnerPerson);
            Assert.AreEqual(null, result.CarUsedType);
            Assert.AreEqual(null, result.CarVin);
            Assert.AreEqual(null, result.CityCode);
            Assert.AreEqual(0, result.ClaimCount);
            Assert.AreEqual(null, result.ClaimDetail);
            Assert.AreEqual(0, result.CoRealValue);
            Assert.AreEqual(null, result.CredentislasNum);
            Assert.AreEqual(null, result.CurAgent);
            Assert.AreEqual(null, result.CurAgentMobile);
            Assert.AreEqual(null, result.CurAgentName);
            Assert.AreEqual(null, result.CurOpenId);
            Assert.AreEqual(null, result.Email);
            Assert.AreEqual(null, result.EngineNo);
            Assert.AreEqual(null, result.ForceStartDate);
            Assert.AreEqual(0, result.HasBaojia);
            Assert.AreEqual(0, result.HasOrder);
            Assert.AreEqual(null, result.Holder);
            Assert.AreEqual(null, result.HolderPerson);
            Assert.AreEqual(null, result.IdCard);
            Assert.AreEqual(null, result.IdType);
            Assert.AreEqual(null, result.Images);
            Assert.AreEqual(0, result.Imgs.Count);
            Assert.AreEqual(null, result.InsuredAddress);
            Assert.AreEqual(null, result.InsuredIdCard);
            Assert.AreEqual(0, result.InsuredIdType);
            Assert.AreEqual(null, result.InsuredMobile);
            Assert.AreEqual(null, result.InsuredName);
            Assert.AreEqual(null, result.InsuredPerson);
            Assert.AreEqual(0, result.IsHolder);
            Assert.AreEqual(0, result.IsNewCar);
            Assert.AreEqual(0, result.IsPublic);
            Assert.AreEqual(0, result.IsShowCalc);
            Assert.AreEqual(0, result.IsTempInsured);
            Assert.AreEqual(0, result.IsTheDay);
            Assert.AreEqual(0, result.IsUploadImg.Count);
            Assert.AreEqual(null, result.LastBusinessEndDdate);
            Assert.AreEqual(null, result.LastEndDate);
            Assert.AreEqual(null, result.LicenseNo);
            Assert.AreEqual(null, result.LicenseOwner);
            Assert.AreEqual(null, result.MoldName);
            Assert.AreEqual(null, result.NewRate);
            Assert.AreEqual(0, result.OrderId);
            Assert.AreEqual(0, result.OrderStatus);
            Assert.AreEqual(null, result.PostedName);
            Assert.AreEqual(null, result.PostStartDate);
            Assert.AreEqual(0, result.PrecisePriceItem.Count);
            Assert.AreEqual(null, result.PurchasePrice);
            Assert.AreEqual(0, result.QuoteGroup);
            Assert.AreEqual(null, result.QuoteTime);
            Assert.AreEqual(null, result.RegisterDate);
            Assert.AreEqual(null, result.ReqInfo);
            Assert.AreEqual(null, result.SeatCount);
            Assert.AreEqual(null, result.SixDigitsAfterIdCard);
            Assert.AreEqual(null, result.StatusMessage);
            Assert.AreEqual(0, result.SubmitGroup);
            Assert.AreEqual(null, result.UpdateTime);
            Assert.AreEqual(null, result.UserName);
        }
예제 #3
0
        public MyBaoJiaViewModel SetPrecisePriceItem(MyBaoJiaViewModel my, bx_userinfo userinfo,
                                                     List <bx_quoteresult_carinfo> quoteresultCarinfo,
                                                     List <long> listquote01, bool allfail,
                                                     bx_savequote sq, List <bx_quoteresult> qrList, List <bx_submit_info> siList)
        {
            string newRate = string.Empty;
            //var sourceList = _setPrecisePriceItem.FindSource(userinfo, request);
            //获取图片bx_picture
            //List<bx_picture> picList = _pictureRepository.GetAllList(o => o.b_uid == userinfo.Id);
            //报价单资源对象
            //bx_savequote sq = _saveQuoteRepository.GetSavequoteByBuid(userinfo.Id);
            //List<bx_quoteresult> qrList = _quoteResultRepository.GetQuoteResultList(userinfo.Id);
            //List<bx_submit_info> siList = _submitInfoRepository.GetSubmitInfoList(userinfo.Id);
            //渠道列表
            List <AgentConfigNameModel> agentChannelList = new List <AgentConfigNameModel>();

            if (siList.Any())
            {
                agentChannelList = _agentConfigRepository.FindListById(siList.Select(l => l.channel_id).Join(","));
            }
            //图片url
            List <IsUploadImg> isUploadImg = new List <IsUploadImg>();
            //报价信息模型,包括险种和报价
            List <MyPrecisePriceItemViewModel> listquoteTotal = new List <MyPrecisePriceItemViewModel>();

            var hebaodianweis = _hebaoDianweiRepository.FindList(userinfo.Id, listquote01.ToArray());

            if (listquote01.Any())
            {
                foreach (int oit in listquote01)
                {
                    //20160905修改source1248=>0123,传入的新数据转换
                    var submit = siList.FirstOrDefault(i => i.source == oit);
                    var qr     = qrList.FirstOrDefault(i => i.Source == oit);
                    if (oit == 3)
                    {
                        if (!string.IsNullOrEmpty(newRate) && qr != null)
                        {
                            qr.NewRate = decimal.Parse(newRate);
                            _quoteResultRepository.Update(qr);
                        }
                        else if (string.IsNullOrEmpty(newRate) && qr != null && qr.NewRate != 0 && qr.NewRate != null)
                        {
                            newRate = qr.NewRate.ToString();
                        }
                        if (!string.IsNullOrEmpty(newRate))
                        {
                            my.NewRate = double.Parse(newRate).ToString("#0.00000");
                        }
                    }
                    var model = ConvertToViewModelNew(oit, sq,
                                                      qr, submit, allfail, agentChannelList, userinfo.CarVIN, newRate);

                    var hebaodianwei = hebaodianweis.FirstOrDefault(heb => heb.source == oit);
                    if (hebaodianwei != null && my.IsShowCalc == 0)
                    {
                        model.BizSysRate = hebaodianwei.system_biz_rate.HasValue
                            ? Convert.ToDecimal(hebaodianwei.system_biz_rate.Value)
                            : 0;
                        model.ForceSysRate = hebaodianwei.system_force_rate.HasValue
                            ? Convert.ToDecimal(hebaodianwei.system_force_rate.Value)
                            : 0;
                        //优惠费率
                        model.BenefitRate = hebaodianwei.agent_id == hebaodianwei.parent_agent_id
                            ? Convert.ToDecimal(hebaodianwei.zhike_biz_rate.Value)
                            : Convert.ToDecimal(hebaodianwei.agent_biz_rate.Value);
                    }
                    var qcinfo = quoteresultCarinfo.FirstOrDefault(l => l.source == oit);
                    if (qcinfo != null)
                    {
                        model.CarUsedType = qcinfo.car_used_type.HasValue ? qcinfo.car_used_type.Value : 0;
                    }
                    model.JingSuanKouJing = submit != null ? (submit.RbJSKJ ?? "") : "";
                    listquoteTotal.Add(model);
                }
                my.PrecisePriceItem = listquoteTotal;
                my.IsUploadImg      = new List <IsUploadImg>();
            }
            else
            {
                my.PrecisePriceItem = new List <MyPrecisePriceItemViewModel>();
            }
            return(my);
        }