Exemple #1
0
        public int Update(bx_address bxAddress)
        {
            int count = 0;

            try
            {
                var address =
                    DataContextFactory.GetDataContext().bx_address.FirstOrDefault(x => x.id == bxAddress.id && x.userid == bxAddress.userid);
                if (address != null)
                {
                    address.Name       = bxAddress.Name;
                    address.address    = bxAddress.address;
                    address.agentId    = bxAddress.agentId;
                    address.areaId     = bxAddress.areaId;
                    address.cityId     = bxAddress.cityId;
                    address.phone      = bxAddress.phone;
                    address.provinceId = bxAddress.provinceId;
                    address.updatetime = bxAddress.updatetime;
                    DataContextFactory.GetDataContext().bx_address.AddOrUpdate(address);
                    count = DataContextFactory.GetDataContext().SaveChanges();
                }
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(count);
        }
Exemple #2
0
        public bx_address Find(int addressId, int userid)
        {
            bx_address bxAddress = new bx_address();

            try
            {
                bxAddress = DataContextFactory.GetDataContext().bx_address.FirstOrDefault(x => x.id == addressId && x.userid == userid);
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(bxAddress);
        }
Exemple #3
0
        /// 20170228修改bx_address表userid为代理人id.
        /// 无需刷数据,该模块就预约单在用,目前预约单几乎未使用


        public int Add(bx_address bxAddress)
        {
            int addressId = 0;

            try
            {
                var t = DataContextFactory.GetDataContext().bx_address.Add(bxAddress);
                DataContextFactory.GetDataContext().SaveChanges();
                addressId = t.id;
            }
            catch (Exception ex)
            {
                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
                addressId = 0;
            }
            return(addressId);
        }
        public int Update(AddressRequest request)
        {
            //根据openid,mobile,获取userid
            //var user = _userService.FindUserByOpenId(request.openId);
            //if (user == null || user.UserId <= 0)
            //{
            //    return 0;
            //}
            var bxAddress = new bx_address()
            {
                id         = request.id,
                userid     = request.ChildAgent,//user.UserId,
                Name       = request.Name,
                phone      = request.phone,
                address    = request.address,
                provinceId = request.provinceId,
                cityId     = request.cityId,
                areaId     = request.areaId,
                agentId    = request.agentId,
                updatetime = DateTime.Now
            };

            return(_AddressRepository.Update(bxAddress));
        }
        public int Add(AddressRequest request)
        {
            //根据openid,mobile,获取userid
            //var user = _userService.AddUser(request.openId, request.phone);
            //if (user == null || user.UserId <= 0)
            //{
            //    return 0;
            //}
            var bxAddress = new bx_address()
            {
                userid     = request.ChildAgent,//user.UserId,
                Name       = request.Name,
                phone      = request.phone,
                address    = request.address,
                provinceId = request.provinceId,
                cityId     = request.cityId,
                areaId     = request.areaId,
                agentId    = request.agentId,
                Status     = 1,
                createtime = DateTime.Now
            };

            return(_AddressRepository.Add(bxAddress));
        }
        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);
        }