Пример #1
0
        public void Valid_savequoteIsNull_Return0()
        {
            #region 配置  Substitute
            ISaveQuoteRepository   _saveQuoteRepository   = Substitute.For <ISaveQuoteRepository>();
            ISubmitInfoRepository  _submitInfoRepository  = Substitute.For <ISubmitInfoRepository>();
            IQuoteResultRepository _quoteResultRepository = Substitute.For <IQuoteResultRepository>();
            IUserInfoRepository    _userInfoRepository    = Substitute.For <IUserInfoRepository>();

            _submitInfoRepository.GetSubmitInfo(Arg.Any <long>(), Arg.Any <int>()).Returns(x => new bx_submit_info());
            _quoteResultRepository.GetQuoteResultByBuid(Arg.Any <long>(), Arg.Any <int>()).Returns(x => new bx_quoteresult());
            _saveQuoteRepository.GetSavequoteByBuid(Arg.Any <long>()).Returns(x => null);

            UpdateBjdCheck updateBjdCheck = new UpdateBjdCheck(_saveQuoteRepository, _submitInfoRepository,
                                                               _quoteResultRepository, _userInfoRepository);
            #endregion

            #region 操作  Arg

            bx_submit_info submitInfo  = new bx_submit_info();
            bx_quoteresult quoteresult = new bx_quoteresult();
            bx_savequote   savequote   = new bx_savequote();
            bx_userinfo    userinfo    = new bx_userinfo();
            var            result      = updateBjdCheck.Valid(new CreateOrUpdateBjdInfoRequest());

            #endregion

            #region 断言  Assert

            Assert.AreEqual(0, result.State);

            #endregion
        }
Пример #2
0
        public UpdateBjdCheckMessage Valid(CreateOrUpdateBjdInfoRequest request)
        {
            UpdateBjdCheckMessage message = new UpdateBjdCheckMessage();

            message.State = 1;

            try
            {
                message.SubmitInfo = _submitInfoRepository.GetSubmitInfo(request.Buid, SourceGroupAlgorithm.GetOldSource(request.Source));
                if (message.SubmitInfo == null)
                {
                    message.Message = string.Format("Buid为{0}Source为{1}的记录submitinfo为空", request.Buid, request.Source);
                    message.State   = 0;
                    return(message);
                }

                message.Quoteresult = _quoteResultRepository.GetQuoteResultByBuid(request.Buid, SourceGroupAlgorithm.GetOldSource(request.Source));
                if (message.Quoteresult == null)
                {
                    message.Message = string.Format("Buid为{0}Source为{1}的记录quoteinfo为空", request.Buid, request.Source);
                    message.State   = 0;
                    return(message);
                }

                message.ReqCarInfo = _quoteReqCarinfoRepository.Find(request.Buid);
                if (message.ReqCarInfo == null)
                {
                    message.Message = string.Format("Buid为{0}Source为{1}的记录quotereqcarinfo为空", request.Buid, request.Source);
                    message.State   = 0;
                    return(message);
                }

                message.Savequote = _saveQuoteRepository.GetSavequoteByBuid(request.Buid);
                if (message.Savequote == null)
                {
                    message.Message = string.Format("Buid为{0}Source为{1}的记录saveinfo为空", request.Buid, request.Source);
                    message.State   = 0;
                    return(message);
                }

                message.Userinfo = _userInfoRepository.FindByBuid(request.Buid);
                if (message.Userinfo == null)
                {
                    message.Message = string.Format("Buid为{0}Source为{1}的记录userinfo为空", request.Buid, request.Source);
                    message.State   = 0;
                    return(message);
                }
            }
            catch (Exception ex)
            {
                message.Message = string.Format("程序出险异常,错误信息为:{0}", ex.Message);
                message.State   = -1;
                return(message);
            }


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