public bx_car_order FindBy(long orderId, string openId)
        {
            bx_car_order carOrder = new bx_car_order();

            try
            {
                carOrder = DataContextFactory.GetDataContext().bx_car_order.FirstOrDefault(x => x.id == orderId && x.openid == openId && x.order_status > 0);
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(carOrder);
        }
        /// <summary>
        /// 根据车牌号、openid、顶级代理人来获取预约单
        /// 下单的时候判断是否存在该预约单
        /// </summary>
        /// <param name="licenseNo"></param>
        /// <param name="openId"></param>
        /// <param name="topAgent"></param>
        /// <returns></returns>
        public bx_car_order FindOrder(string licenseNo, int curAgent)
        {
            bx_car_order carOrder = new bx_car_order();

            try
            {
                carOrder = DataContextFactory.GetDataContext().bx_car_order.FirstOrDefault(x => x.LicenseNo == licenseNo && x.cur_agent == curAgent && x.order_status > 0);
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(carOrder);
        }
        public bx_car_order FindBy(string orderNo)
        {
            bx_car_order carOrder = new bx_car_order();

            try
            {
                carOrder = DataContextFactory.GetDataContext().bx_car_order.FirstOrDefault(x => x.order_num == orderNo);
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(carOrder);
        }
        public bx_car_order FindBy(long orderId, int topagent)
        {
            bx_car_order carOrder = new bx_car_order();

            try
            {
                carOrder = DataContextFactory.GetDataContext().bx_car_order.FirstOrDefault(x => x.id == orderId && x.top_agent == topagent);
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(carOrder);
        }
        public bx_car_order GetOrderByBuidAgent(long buid, int topAgentId)
        {
            bx_car_order carOrder = new bx_car_order();

            try
            {
                carOrder = DataContextFactory.GetDataContext().bx_car_order.FirstOrDefault(x => x.buid == buid && x.top_agent == topAgentId && x.order_status > 0);
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(carOrder);
        }
        public int Update(bx_car_order order)
        {
            int count = 0;

            try
            {
                DataContextFactory.GetDataContext().bx_car_order.AddOrUpdate(order);
                count = DataContextFactory.GetDataContext().SaveChanges();
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(count);
        }
        public Int64 Add(bx_car_order order)
        {
            Int64 orderid = 0;

            try
            {
                var tt = DataContextFactory.GetDataContext().bx_car_order.Add(order);
                DataContextFactory.GetDataContext().SaveChanges();
                orderid = tt.id;
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }

            return(orderid);
        }
Пример #8
0
        public static OrderDetail ConverToViewModel(this bx_car_order carOrder, int agent)
        {
            OrderDetail      order  = new OrderDetail();
            IAgentRepository _agent = new AgentRepository();

            if (carOrder != null)
            {
                order.OrderId     = carOrder.id;
                order.InsuredName = carOrder.insured_name;
                order.LicenseNo   = carOrder.LicenseNo;
                int s = carOrder.source.HasValue ? carOrder.source.Value : 0;
                order.Source      = SourceGroupAlgorithm.GetNewSource(s);
                order.OrderStatus = carOrder.order_status.HasValue ? carOrder.order_status.Value : 0;
                order.CreateTime  = carOrder.create_time.HasValue ? carOrder.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : string.Empty;
                int curAgent = carOrder.cur_agent.HasValue ? carOrder.cur_agent.Value : agent;
                order.Agent     = curAgent;
                order.AgentName = _agent.GetAgentName(curAgent);
            }
            IOrderRepository _order = new OrderRepository();

            bx_order_submit_info orderSubmitInfo = new bx_order_submit_info();

            orderSubmitInfo = _order.GetSubmitInfo(carOrder.id);
            bx_order_quoteresult orderQuoteResult = new bx_order_quoteresult();

            orderQuoteResult = _order.GetQuoteResult(carOrder.id);
            if (orderSubmitInfo != null)
            {
                order.BizSysRate   = orderSubmitInfo.biz_rate.HasValue ? orderSubmitInfo.biz_rate.Value : 0;
                order.ForceSysRate = orderSubmitInfo.force_rate.HasValue ? orderSubmitInfo.force_rate.Value : 0;
                order.BizTno       = orderSubmitInfo.biz_tno;
                order.ForceTno     = orderSubmitInfo.force_tno;
            }
            if (orderQuoteResult != null)
            {
                order.BizTotal   = orderQuoteResult.BizTotal.HasValue ? orderQuoteResult.BizTotal.Value : 0;
                order.ForceTotal = orderQuoteResult.ForceTotal.HasValue ? orderQuoteResult.ForceTotal.Value : 0;
                order.TaxTotal   = orderQuoteResult.TaxTotal.HasValue ? orderQuoteResult.TaxTotal.Value : 0;
            }
            return(order);
        }
Пример #9
0
        public static OrderDetailResponse ConverToViewModel(this OrderCacheResponse orderModel)
        {
            OrderDetailResponse orderDetail = new OrderDetailResponse();

            #region 实例化

            //新实例start
            var carOrder     = new CarOrder();
            var userInfo     = new UserInfo();
            var claimDetails = new List <ClaimDetail>();
            var precisePrice = new PrecisePrice();
            //新实例end
            //原有实例start
            bx_car_order           bxCarOrder     = orderModel.BxCarOrder;
            bx_userinfo            bxUserInfo     = orderModel.BxUserInfo;
            bx_quoteresult         bxQuoteResult  = orderModel.BxQuoteResult;
            bx_savequote           bxSaveQuote    = orderModel.BxSaveQuote;
            bx_submit_info         bxSubmitInfo   = orderModel.BxSubmitInfo;
            bx_lastinfo            bxLastInfo     = orderModel.BxLastInfo;
            bx_quoteresult_carinfo bxCarInfo      = orderModel.BxCarInfo;
            List <bx_claim_detail> bxClaimDetails = orderModel.BxClaimDetails;
            InsuranceStartDate     qrStartDate    = orderModel.QrStartDate;
            //原有实例end

            #endregion

            #region CarOrder转换

            if (bxCarOrder != null)
            {
                carOrder.AgentName   = string.Empty;
                carOrder.AgentMobile = string.Empty;
                if (bxCarOrder.cur_agent.HasValue)
                {
                    carOrder.Agent = bxCarOrder.cur_agent.Value;
                    //调用代理人列表
                    IAgentRepository agentRepository = new AgentRepository();
                    var curAgent = agentRepository.GetAgent(bxCarOrder.cur_agent.Value);
                    if (curAgent != null)
                    {
                        carOrder.AgentName   = curAgent.AgentName;
                        carOrder.AgentMobile = curAgent.Mobile;
                    }
                }
                carOrder.OpenId              = bxCarOrder.openid;
                carOrder.Mobile              = bxCarOrder.mobile;
                carOrder.ContactsName        = bxCarOrder.contacts_name;
                carOrder.OrderStatus         = bxCarOrder.order_status.HasValue ? bxCarOrder.order_status.Value : 0;
                carOrder.GetOrderTime        = bxCarOrder.GetOrderTime.ToString();
                carOrder.CreateTime          = bxCarOrder.create_time.ToString();
                carOrder.OrderId             = bxCarOrder.id;
                carOrder.Buid                = bxCarOrder.buid.HasValue ? bxCarOrder.buid.Value : 0;
                carOrder.Source              = bxCarOrder.source.HasValue ? bxCarOrder.source.Value : 0;
                carOrder.Source              = SourceGroupAlgorithm.GetNewSource((int)carOrder.Source);
                carOrder.InsuredName         = bxCarOrder.insured_name;
                carOrder.IdType              = bxCarOrder.id_type.HasValue ? bxCarOrder.id_type.Value : 2; //默认空时,赋值个“其他”
                carOrder.IdNum               = bxCarOrder.id_num;
                carOrder.IdImgFirst          = bxCarOrder.id_img_firs;
                carOrder.IdImgSecond         = bxCarOrder.id_img_secd;
                carOrder.ImageUrls           = bxCarOrder.imageUrls;
                carOrder.ProvinceName        = string.Empty;
                carOrder.CityName            = string.Empty;
                carOrder.AreaName            = string.Empty;
                carOrder.DistributionAddress = bxCarOrder.distribution_address;
                carOrder.DistributionName    = bxCarOrder.distribution_name;
                carOrder.DistributionPhone   = bxCarOrder.distribution_phone;
                carOrder.DistributionTime    = bxCarOrder.distribution_time.HasValue
                    ? bxCarOrder.distribution_time.Value.ToString("yyyy-MM-dd HH:mm:ss")
                    : string.Empty;
                carOrder.InsurancePrice = bxCarOrder.insurance_price.HasValue
                    ? (double)bxCarOrder.insurance_price.Value
                    : 0;
                carOrder.CarriagePrice = bxCarOrder.carriage_price.HasValue
                    ? (double)bxCarOrder.carriage_price.Value
                    : 0;
                carOrder.TotalPrice = bxCarOrder.total_price.HasValue
                    ? (double)bxCarOrder.total_price.Value
                    : 0;
                carOrder.Receipt          = bxCarOrder.receipt_title;
                carOrder.ReceiptHead      = bxCarOrder.receipt_head.HasValue ? bxCarOrder.receipt_head.Value : 0;
                carOrder.PayType          = bxCarOrder.pay_type.HasValue ? bxCarOrder.pay_type.Value : 0;
                carOrder.DistributionType = bxCarOrder.distribution_type.HasValue
                    ? bxCarOrder.distribution_type.Value
                    : 0;
            }

            #endregion

            #region UserInfo转换

            if (bxUserInfo != null)
            {
                userInfo.LicenseNo      = bxUserInfo.LicenseNo;
                userInfo.LicenseOwner   = bxUserInfo.LicenseOwner;
                userInfo.IdType         = bxUserInfo.OwnerIdCardType; //默认空时,赋值个“其他”
                userInfo.InsuredName    = bxUserInfo.InsuredName;
                userInfo.InsuredMobile  = bxUserInfo.InsuredMobile;
                userInfo.InsuredAddress = bxUserInfo.InsuredAddress;
                userInfo.InsuredIdType  = bxUserInfo.InsuredIdType.HasValue ? bxUserInfo.InsuredIdType.Value : 6;
                //默认空时,赋值个“其他”
                userInfo.CredentislasNum = bxUserInfo.InsuredIdCard;
                userInfo.Email           = bxUserInfo.Email;
                userInfo.CityCode        = !string.IsNullOrEmpty(bxUserInfo.CityCode)
                    ? int.Parse(bxUserInfo.CityCode)
                    : 0;
                //CarUsedType如下
                userInfo.EngineNo = bxUserInfo.EngineNo;
                userInfo.CarVin   = bxUserInfo.CarVIN;
                //PurchasePrice如下
                //SeatCount如下
                userInfo.ModleName    = bxUserInfo.MoldName;
                userInfo.RegisterDate = bxUserInfo.RegisterDate;
                //LastEndDate如下
                //LastBusinessEndDdate如下
                //ForceStartDate如下
                //BizStartDate如下
                //ClaimCount如下
            }

            #endregion

            #region QuoteResultCarInfo转换

            if (bxCarInfo != null)
            {
                userInfo.CarUsedType   = bxCarInfo.car_used_type.HasValue ? bxCarInfo.car_used_type.Value : 0;
                userInfo.PurchasePrice = bxCarInfo.purchase_price.HasValue ? (double)bxCarInfo.purchase_price.Value : 0;
                userInfo.SeatCount     = bxCarInfo.seat_count.HasValue ? bxCarInfo.seat_count.Value : 0;
            }

            #endregion

            #region ClaimDetails转换

            if (bxClaimDetails != null)
            {
                userInfo.ClaimCount = bxClaimDetails.Count;
                var claim       = new ClaimDetail();
                var claimDetail = new bx_claim_detail();
                for (int i = 0; i < userInfo.ClaimCount; i++)
                {
                    claim             = new ClaimDetail();
                    claimDetail       = new bx_claim_detail();
                    claimDetail       = bxClaimDetails[i];
                    claim.EndcaseTime = claimDetail.endcase_time.HasValue
                        ? claimDetail.endcase_time.Value.ToString()
                        : string.Empty;
                    claim.LossTime = claimDetail.loss_time.HasValue
                        ? claimDetail.loss_time.Value.ToString()
                        : string.Empty;
                    claim.PayAmount      = claimDetail.pay_amount.HasValue ? claimDetail.pay_amount.Value : 0;
                    claim.PayCompanyName = claimDetail.pay_company_name;
                    claimDetails.Add(claim);
                }
            }

            #endregion

            #region SaveQuote、QuoteResult、SubmitInfo转换

            if (bxSaveQuote != null)
            {
                bool isquoteresult = true;
                if (bxQuoteResult == null)
                {
                    isquoteresult = false;
                    bxQuoteResult = new bx_quoteresult();
                }
                precisePrice.BizTotal   = bxQuoteResult.BizTotal.HasValue ? bxQuoteResult.BizTotal.Value : 0;
                precisePrice.ForceTotal = bxQuoteResult.ForceTotal ?? 0;
                precisePrice.TaxTotal   = bxQuoteResult.TaxTotal ?? 0;
                precisePrice.Source     = bxQuoteResult.Source ?? 0;
                precisePrice.Source     = SourceGroupAlgorithm.GetNewSource((int)precisePrice.Source);
                precisePrice.JiaoQiang  = bxSaveQuote.JiaoQiang.HasValue ? bxSaveQuote.JiaoQiang.Value : 1;
                if (bxSubmitInfo != null)
                {
                    precisePrice.QuoteStatus = bxSubmitInfo.quote_status.HasValue
                        ? bxSubmitInfo.quote_status.Value
                        : 0;
                    precisePrice.QuoteResult  = bxSubmitInfo.quote_result;
                    precisePrice.SubmitStatus = bxSubmitInfo.submit_status.HasValue
                        ? bxSubmitInfo.submit_status.Value
                        : 0;
                    precisePrice.SubmitResult = bxSubmitInfo.submit_result;
                    precisePrice.BizTno       = bxSubmitInfo.biz_tno;
                    precisePrice.ForceTno     = bxSubmitInfo.force_pno;
                    precisePrice.BizSysRate   = bxSubmitInfo.biz_rate.HasValue ? (double)bxSubmitInfo.biz_rate.Value : 0;
                    precisePrice.ForceSysRate = bxSubmitInfo.force_rate.HasValue ? (double)bxSubmitInfo.force_rate.Value : 0;
                    //BenefitRate
                }
                precisePrice.CheSun = new XianZhongUnit
                {
                    BaoE =
                        isquoteresult
                            ? (bxQuoteResult.CheSunBE.HasValue ? bxQuoteResult.CheSunBE.Value : 0)
                            : (bxSaveQuote.CheSun.HasValue ? bxSaveQuote.CheSun.Value : 0),
                    BaoFei = bxQuoteResult.CheSun.HasValue ? bxQuoteResult.CheSun.Value : 0
                };
                precisePrice.SanZhe = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.SanZhe.HasValue ? bxSaveQuote.SanZhe.Value : 0,
                    BaoFei = bxQuoteResult.SanZhe.HasValue ? bxQuoteResult.SanZhe.Value : 0
                };
                precisePrice.DaoQiang = new XianZhongUnit
                {
                    BaoE =
                        isquoteresult
                            ? (bxQuoteResult.DaoQiangBE.HasValue ? bxQuoteResult.DaoQiangBE.Value : 0)
                            : (bxSaveQuote.DaoQiang.HasValue ? bxSaveQuote.DaoQiang.Value : 0),
                    BaoFei = bxQuoteResult.DaoQiang.HasValue ? bxQuoteResult.DaoQiang.Value : 0
                };
                precisePrice.SiJi = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.SiJi.HasValue ? bxSaveQuote.SiJi.Value : 0,
                    BaoFei = bxQuoteResult.SiJi.HasValue ? bxQuoteResult.SiJi.Value : 0
                };
                precisePrice.ChengKe = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.ChengKe.HasValue ? bxSaveQuote.ChengKe.Value : 0,
                    BaoFei = bxQuoteResult.ChengKe.HasValue ? bxQuoteResult.ChengKe.Value : 0
                };
                precisePrice.BoLi = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.BoLi.HasValue ? bxSaveQuote.BoLi.Value : 0,
                    BaoFei = bxQuoteResult.BoLi.HasValue ? bxQuoteResult.BoLi.Value : 0
                };
                precisePrice.HuaHen = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.HuaHen.HasValue ? bxSaveQuote.HuaHen.Value : 0,
                    BaoFei = bxQuoteResult.HuaHen.HasValue ? bxQuoteResult.HuaHen.Value : 0
                };
                precisePrice.BuJiMianCheSun = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.BuJiMianCheSun.HasValue ? bxSaveQuote.BuJiMianCheSun.Value : 0,
                    BaoFei = bxQuoteResult.BuJiMianCheSun.HasValue ? bxQuoteResult.BuJiMianCheSun.Value : 0
                };
                precisePrice.BuJiMianSanZhe = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.BuJiMianSanZhe.HasValue ? bxSaveQuote.BuJiMianSanZhe.Value : 0,
                    BaoFei = bxQuoteResult.BuJiMianSanZhe.HasValue ? bxQuoteResult.BuJiMianSanZhe.Value : 0
                };
                precisePrice.BuJiMianDaoQiang = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.BuJiMianDaoQiang.HasValue ? bxSaveQuote.BuJiMianDaoQiang.Value : 0,
                    BaoFei = bxQuoteResult.BuJiMianDaoQiang.HasValue ? bxQuoteResult.BuJiMianDaoQiang.Value : 0
                };
                precisePrice.BuJiMianChengKe = new XianZhongUnit()
                {
                    BaoE   = bxSaveQuote.BuJiMianChengKe.HasValue ? bxSaveQuote.BuJiMianChengKe.Value : 0,
                    BaoFei = bxQuoteResult.BuJiMianChengKe.HasValue ? bxQuoteResult.BuJiMianChengKe.Value : 0
                };
                precisePrice.BuJiMianSiJi = new XianZhongUnit()
                {
                    BaoE   = bxSaveQuote.BuJiMianSiJi.HasValue ? bxSaveQuote.BuJiMianSiJi.Value : 0,
                    BaoFei = bxQuoteResult.BuJiMianSiJi.HasValue ? bxQuoteResult.BuJiMianSiJi.Value : 0
                };
                precisePrice.BuJiMianHuaHen = new XianZhongUnit()
                {
                    BaoE   = bxSaveQuote.BuJiMianHuaHen.HasValue ? bxSaveQuote.BuJiMianHuaHen.Value : 0,
                    BaoFei = bxQuoteResult.BuJiMianHuaHen.HasValue ? bxQuoteResult.BuJiMianHuaHen.Value : 0
                };
                precisePrice.BuJiMianSheShui = new XianZhongUnit()
                {
                    BaoE   = bxSaveQuote.BuJiMianSheShui.HasValue ? bxSaveQuote.BuJiMianSheShui.Value : 0,
                    BaoFei = bxQuoteResult.BuJiMianSheShui.HasValue ? bxQuoteResult.BuJiMianSheShui.Value : 0
                };
                precisePrice.BuJiMianZiRan = new XianZhongUnit()
                {
                    BaoE   = bxSaveQuote.BuJiMianZiRan.HasValue ? bxSaveQuote.BuJiMianZiRan.Value : 0,
                    BaoFei = bxQuoteResult.BuJiMianZiRan.HasValue ? bxQuoteResult.BuJiMianZiRan.Value : 0
                };
                precisePrice.BuJiMianJingShenSunShi = new XianZhongUnit()
                {
                    BaoE =
                        bxSaveQuote.BuJiMianJingShenSunShi.HasValue
                            ? bxSaveQuote.BuJiMianJingShenSunShi.Value
                            : 0,
                    BaoFei =
                        bxQuoteResult.BuJiMianJingShenSunShi.HasValue
                            ? bxQuoteResult.BuJiMianJingShenSunShi.Value
                            : 0
                };
                precisePrice.SheShui = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.SheShui.HasValue ? bxSaveQuote.SheShui.Value : 0,
                    BaoFei = bxQuoteResult.SheShui.HasValue ? bxQuoteResult.SheShui.Value : 0
                };
                precisePrice.ZiRan = new XianZhongUnit
                {
                    BaoE =
                        isquoteresult
                            ? (bxQuoteResult.ZiRanBE.HasValue ? bxQuoteResult.ZiRanBE.Value : 0)
                            : (bxSaveQuote.ZiRan.HasValue ? bxSaveQuote.ZiRan.Value : 0),
                    BaoFei = bxQuoteResult.ZiRan.HasValue ? bxQuoteResult.ZiRan.Value : 0
                };
                precisePrice.HcSheBeiSunshi = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.HcSheBeiSunshi.HasValue ? bxSaveQuote.HcSheBeiSunshi.Value : 0,
                    BaoFei = bxQuoteResult.HcSheBeiSunshi.HasValue ? bxQuoteResult.HcSheBeiSunshi.Value : 0
                };
                precisePrice.HcHuoWuZeRen = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.HcHuoWuZeRen.HasValue ? bxSaveQuote.HcHuoWuZeRen.Value : 0,
                    BaoFei = bxQuoteResult.HcHuoWuZeRen.HasValue ? bxQuoteResult.HcHuoWuZeRen.Value : 0
                };
                precisePrice.HcFeiYongBuChang = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.HcFeiYongBuChang.HasValue ? bxSaveQuote.HcFeiYongBuChang.Value : 0,
                    BaoFei = bxQuoteResult.HcFeiYongBuChang.HasValue ? bxQuoteResult.HcFeiYongBuChang.Value : 0
                };
                precisePrice.HcJingShenSunShi = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.HcJingShenSunShi.HasValue ? bxSaveQuote.HcJingShenSunShi.Value : 0,
                    BaoFei = bxQuoteResult.HcJingShenSunShi.HasValue ? bxQuoteResult.HcJingShenSunShi.Value : 0
                };
                precisePrice.HcSanFangTeYue = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.HcSanFangTeYue.HasValue ? bxSaveQuote.HcSanFangTeYue.Value : 0,
                    BaoFei = bxQuoteResult.HcSanFangTeYue.HasValue ? bxQuoteResult.HcSanFangTeYue.Value : 0
                };
                precisePrice.HcXiuLiChang = new XianZhongUnit
                {
                    BaoE   = bxSaveQuote.HcXiuLiChang.HasValue ? bxSaveQuote.HcXiuLiChang.Value : 0,
                    BaoFei = bxQuoteResult.HcXiuLiChang.HasValue ? bxQuoteResult.HcXiuLiChang.Value : 0
                };
                precisePrice.HcXiuLiChangType = bxSaveQuote.HcXiuLiChangType.HasValue
                    ? bxSaveQuote.HcXiuLiChangType.Value.ToString()
                    : "-1";
                precisePrice.RateFactor1 = bxQuoteResult.RateFactor1.HasValue
                    ? (double)bxQuoteResult.RateFactor1.Value
                    : 0;
                precisePrice.RateFactor2 = bxQuoteResult.RateFactor2.HasValue
                    ? (double)bxQuoteResult.RateFactor2.Value
                    : 0;
                precisePrice.RateFactor3 = bxQuoteResult.RateFactor3.HasValue
                    ? (double)bxQuoteResult.RateFactor3.Value
                    : 0;
                precisePrice.RateFactor4 = bxQuoteResult.RateFactor4.HasValue
                    ? (double)bxQuoteResult.RateFactor4.Value
                    : 0;
            }

            #endregion

            #region LastInfo转换

            if (bxLastInfo != null)
            {
                userInfo.LastEndDate          = bxLastInfo.last_end_date;
                userInfo.LastBusinessEndDdate = bxLastInfo.last_business_end_date;
            }

            #endregion

            #region 保险起始时间

            if (qrStartDate != null)
            {
                userInfo.ForceStartDate = qrStartDate.ForceStartDate.HasValue
                    ? qrStartDate.ForceStartDate.Value.ToString()
                    : string.Empty;
                userInfo.BizStartDate = qrStartDate.BizStartDate.HasValue
                    ? qrStartDate.BizStartDate.Value.ToString()
                    : string.Empty;
            }

            #endregion

            orderDetail.CarOrder     = carOrder;
            orderDetail.ClaimDetail  = claimDetails;
            orderDetail.PrecisePrice = precisePrice;
            orderDetail.UserInfo     = userInfo;

            return(orderDetail);
        }
        public long CreateOrder(bx_car_order order, bx_address address, bx_lastinfo lastinfo, bx_userinfo userinfo, bx_savequote savequote, bx_submit_info submitInfo, bx_quoteresult quoteresult, bx_quoteresult_carinfo carInfo, List <bx_claim_detail> claimDetails)
        {
            //如果此四张表数据为空,提示插入失败
            //if (userinfo == null || savequote == null || submitInfo == null || quoteresult == null)
            if (userinfo == null)
            {
                return(0);
            }
            long orderid = 0;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    //插入订单
                    var neworder = DataContextFactory.GetDataContext().bx_car_order.Add(order);
                    DataContextFactory.GetDataContext().SaveChanges();
                    orderid = neworder.id;

                    if (orderid > 0)
                    {
                        #region CarOrderUserInfoRepository

                        bx_order_userinfo orderUserinfo = new bx_order_userinfo()
                        {
                            Id               = userinfo.Id,
                            LicenseNo        = userinfo.LicenseNo,
                            OpenId           = userinfo.OpenId,
                            CityCode         = userinfo.CityCode,
                            EngineNo         = userinfo.EngineNo,
                            CarVIN           = userinfo.CarVIN,
                            MoldName         = userinfo.MoldName,
                            RegisterDate     = userinfo.RegisterDate,
                            Agent            = userinfo.Agent,
                            LicenseOwner     = userinfo.LicenseOwner,
                            CarType          = carInfo != null ? carInfo.car_type : null,
                            CarUsedType      = carInfo != null ? carInfo.car_used_type : null,
                            JiaoQiangEndDate =
                                lastinfo != null
                                    ? (!string.IsNullOrEmpty(lastinfo.last_end_date) ? lastinfo.last_end_date : "")
                                    : "",
                            ShangYeEndDate =
                                lastinfo != null
                                    ? (!string.IsNullOrEmpty(lastinfo.last_business_end_date)
                                        ? lastinfo.last_business_end_date
                                        : "")
                                    : "",
                            //2017.2.7新增
                            LastYearSource         = userinfo.LastYearSource,
                            InsuredName            = userinfo.InsuredName,
                            InsuredMobile          = userinfo.InsuredMobile,
                            InsuredIdCard          = userinfo.InsuredIdCard,
                            InsuredAddress         = userinfo.InsuredAddress,
                            RenewalType            = userinfo.RenewalType,
                            InsuredIdType          = userinfo.InsuredIdType,
                            OwnerIdCardType        = userinfo.OwnerIdCardType,
                            Email                  = userinfo.Email,
                            nonclaim_discount_rate = lastinfo != null ? lastinfo.nonclaim_discount_rate : null,
                            last_year_acctimes     = lastinfo != null ? lastinfo.last_year_acctimes : null,
                            last_year_claimamount  = lastinfo != null ? lastinfo.last_year_claimamount : null,
                            last_year_claimtimes   = lastinfo != null ? lastinfo.last_year_claimtimes : null,
                            //end新增
                            OrderId = orderid
                        };

                        #endregion

                        var re_ui = DataContextFactory.GetDataContext().bx_order_userinfo.Add(orderUserinfo);
                        DataContextFactory.GetDataContext().SaveChanges();

                        if (quoteresult != null)
                        {
                            #region CarOrderQuoteResultRepository

                            bx_order_quoteresult orderQuoteresult = new bx_order_quoteresult()
                            {
                                B_Uid            = quoteresult.B_Uid,
                                CreateTime       = quoteresult.CreateTime,
                                CheSun           = quoteresult.CheSun,
                                SanZhe           = quoteresult.SanZhe,
                                DaoQiang         = quoteresult.DaoQiang,
                                SiJi             = quoteresult.SiJi,
                                ChengKe          = quoteresult.ChengKe,
                                BoLi             = quoteresult.BoLi,
                                HuaHen           = quoteresult.HuaHen,
                                BuJiMianCheSun   = quoteresult.BuJiMianCheSun,
                                BuJiMianSanZhe   = quoteresult.BuJiMianSanZhe,
                                BuJiMianDaoQiang = quoteresult.BuJiMianDaoQiang,
                                BuJiMianRenYuan  = quoteresult.BuJiMianRenYuan,
                                BuJiMianFuJian   = quoteresult.BuJiMianFuJian,

                                //2.1.5版本修改 增加6个字段
                                BuJiMianChengKe        = quoteresult.BuJiMianChengKe,
                                BuJiMianSiJi           = quoteresult.BuJiMianSiJi,
                                BuJiMianHuaHen         = quoteresult.BuJiMianHuaHen,
                                BuJiMianSheShui        = quoteresult.BuJiMianSheShui,
                                BuJiMianZiRan          = quoteresult.BuJiMianZiRan,
                                BuJiMianJingShenSunShi = quoteresult.BuJiMianJingShenSunShi,

                                TeYue            = quoteresult.TeYue,
                                SheShui          = quoteresult.SheShui,
                                CheDeng          = quoteresult.CheDeng,
                                ZiRan            = quoteresult.ZiRan,
                                BizTotal         = quoteresult.BizTotal,
                                ForceTotal       = quoteresult.ForceTotal,
                                TaxTotal         = quoteresult.TaxTotal,
                                BizContent       = quoteresult.BizContent,
                                ForceContent     = quoteresult.ForceContent,
                                SavedAmount      = quoteresult.SavedAmount,
                                Source           = quoteresult.Source,
                                BizStartDate     = quoteresult.BizStartDate,
                                ForceStartDate   = quoteresult.ForceStartDate,
                                HcSheBeiSunshi   = quoteresult.HcSheBeiSunshi,
                                HcHuoWuZeRen     = quoteresult.HcHuoWuZeRen,
                                HcFeiYongBuChang = quoteresult.HcFeiYongBuChang,
                                HcJingShenSunShi = quoteresult.HcJingShenSunShi,
                                HcSanFangTeYue   = quoteresult.HcSanFangTeYue,
                                HcXiuLiChang     = quoteresult.HcXiuLiChang,
                                InsuredName      = quoteresult.InsuredName,
                                InsuredIdCard    = quoteresult.InsuredIdCard,
                                InsuredIdType    = quoteresult.InsuredIdType,
                                InsuredMobile    = quoteresult.InsuredMobile,
                                HolderName       = quoteresult.HolderName,
                                HolderIdCard     = quoteresult.HolderIdCard,
                                HolderIdType     = quoteresult.HolderIdType,
                                HolderMobile     = quoteresult.HolderMobile,
                                RateFactor1      = quoteresult.RateFactor1,
                                RateFactor2      = quoteresult.RateFactor2,
                                RateFactor3      = quoteresult.RateFactor3,
                                RateFactor4      = quoteresult.RateFactor4,
                                //2017.2.7新增
                                HcXiuLiChangType = quoteresult.HcXiuLiChangType,
                                CheSunBE         = quoteresult.CheSunBE,
                                ZiRanBE          = quoteresult.ZiRanBE,
                                DaoQiangBE       = quoteresult.DaoQiangBE,
                                //end新增
                                OrderId = orderid
                            };

                            #endregion

                            var re_qr = DataContextFactory.GetDataContext().bx_order_quoteresult.Add(orderQuoteresult);
                            DataContextFactory.GetDataContext().SaveChanges();
                        }

                        if (savequote != null)
                        {
                            #region CarOrderSaveQuoteRepository

                            bx_order_savequote orderSavequote = new bx_order_savequote()
                            {
                                B_Uid            = savequote.B_Uid,
                                CheSun           = savequote.CheSun,
                                SanZhe           = savequote.SanZhe,
                                DaoQiang         = savequote.DaoQiang,
                                SiJi             = savequote.SiJi,
                                ChengKe          = savequote.ChengKe,
                                BoLi             = savequote.BoLi,
                                HuaHen           = savequote.HuaHen,
                                BuJiMianCheSun   = savequote.BuJiMianCheSun,
                                BuJiMianSanZhe   = savequote.BuJiMianSanZhe,
                                BuJiMianDaoQiang = savequote.BuJiMianDaoQiang,
                                BuJiMianRenYuan  = savequote.BuJiMianRenYuan,
                                BuJiMianFuJian   = savequote.BuJiMianFuJian,

                                //2.1.5版本修改 增加6个字段
                                BuJiMianChengKe        = savequote.BuJiMianChengKe,
                                BuJiMianSiJi           = savequote.BuJiMianSiJi,
                                BuJiMianHuaHen         = savequote.BuJiMianHuaHen,
                                BuJiMianSheShui        = savequote.BuJiMianSheShui,
                                BuJiMianZiRan          = savequote.BuJiMianZiRan,
                                BuJiMianJingShenSunShi = savequote.BuJiMianJingShenSunShi,

                                TeYue            = savequote.TeYue,
                                SheShui          = savequote.SheShui,
                                CheDeng          = savequote.CheDeng,
                                ZiRan            = savequote.ZiRan,
                                IsRenewal        = savequote.IsRenewal,
                                CreateTime       = savequote.CreateTime,
                                JiaoQiang        = savequote.JiaoQiang,
                                BizStartDate     = savequote.BizStartDate,
                                HcSheBeiSunshi   = savequote.HcSheBeiSunshi,
                                HcHuoWuZeRen     = savequote.HcHuoWuZeRen,
                                HcFeiYongBuChang = savequote.HcFeiYongBuChang,
                                HcJingShenSunShi = savequote.HcJingShenSunShi,
                                HcSanFangTeYue   = savequote.HcSanFangTeYue,
                                HcXiuLiChang     = savequote.HcXiuLiChang,
                                //2017.2.7新增
                                SheBeiSunShiConfig   = savequote.SheBeiSunShiConfig,
                                FeiYongBuChangConfig = savequote.FeiYongBuChangConfig,
                                XiuLiChangConfig     = savequote.XiuLiChangConfig,
                                co_real_value        = savequote.co_real_value,
                                //end新增
                                OrderId = orderid
                            };

                            #endregion

                            var re_sqr = DataContextFactory.GetDataContext().bx_order_savequote.Add(orderSavequote);
                            DataContextFactory.GetDataContext().SaveChanges();
                        }

                        if (submitInfo != null)
                        {
                            #region CarOrderSubmitInfoRepository

                            bx_order_submit_info orderSubmitInfo = new bx_order_submit_info()
                            {
                                b_uid             = submitInfo.b_uid,
                                license_no        = submitInfo.license_no,
                                mobile            = submitInfo.mobile,
                                source            = submitInfo.source,
                                biz_tno           = submitInfo.biz_tno,
                                biz_pno           = submitInfo.biz_pno,
                                biz_start_time    = submitInfo.biz_start_time,
                                biz_end_time      = submitInfo.biz_end_time,
                                force_tno         = submitInfo.force_tno,
                                force_pno         = submitInfo.force_pno,
                                force_start_time  = submitInfo.force_start_time,
                                force_end_time    = submitInfo.force_end_time,
                                submit_status     = submitInfo.submit_status,
                                submit_result     = submitInfo.submit_result,
                                quote_status      = submitInfo.quote_status,
                                quote_result      = submitInfo.quote_result,
                                biz_rate          = submitInfo.biz_rate,
                                force_rate        = submitInfo.force_rate,
                                create_time       = submitInfo.create_time,
                                update_time       = submitInfo.update_time,
                                submit_result_toc = submitInfo.submit_result_toc,
                                quote_result_toc  = submitInfo.quote_result_toc,
                                channel_id        = submitInfo.channel_id,
                                //2017.2.7新增
                                err_code = submitInfo.err_code,
                                //end新增
                                OrderId = orderid
                            };

                            #endregion

                            var re_si = DataContextFactory.GetDataContext().bx_order_submit_info.Add(orderSubmitInfo);
                            DataContextFactory.GetDataContext().SaveChanges();
                        }
                        scope.Complete();
                    }
                }
                //catch (DbEntityValidationException dbEx)
                //{
                //    foreach (var validationErrors in dbEx.EntityValidationErrors)
                //    {
                //        foreach (var validationError in validationErrors.ValidationErrors)
                //        {
                //            logError.Info(string.Format("Property: {0} Error: {1}",
                //                                    validationError.PropertyName,
                //                                    validationError.ErrorMessage));
                //        }
                //    }
                //}
                catch (Exception ex)
                {
                    logError.Info("发生异常:事务订单号(" + orderid + ")\n" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" +
                                  ex.InnerException);
                }
                finally
                {
                    //orderid = 0;
                    scope.Dispose();
                }
            }


            return(orderid);
        }