Example #1
0
        public CustomerModel GetCustomerByCid(int cid)
        {
            CustomerInfoEntity      customerInfoEntity      = _customerDal.Find <CustomerInfoEntity>(cid);
            CustomerUnionInfoEntity customerUnionInfoEntity = _customerUnionDal.Find <CustomerUnionInfoEntity>(cid);

            List <CustomerInfoEntity>      customerList      = null;
            List <CustomerUnionInfoEntity> customerUnionList = null;

            if (customerInfoEntity != null)
            {
                customerList = new List <CustomerInfoEntity> {
                    customerInfoEntity
                };
            }

            if (customerUnionInfoEntity != null)
            {
                customerUnionList = new List <CustomerUnionInfoEntity> {
                    customerUnionInfoEntity
                };
            }

            List <CustomerModel> customerModels = Convert(customerList, customerUnionList);

            return(customerModels.FirstOrDefault());
        }
Example #2
0
 public int Update(CustomerUnionInfoEntity t, string[] properties = null)
 {
     using (BrightourDbContext db = new BrightourDbContext())
     {
         return(db.Update(t, properties));
     }
 }
Example #3
0
        public CustomerUnionInfoModel GetCustomerUnionByCid(int cid)
        {
            CustomerUnionInfoEntity customerUnionInfoEntity = _unionDal.Query(cid);

            if (customerUnionInfoEntity == null)
            {
                return(null);
            }

            return(Mapper.Map <CustomerUnionInfoEntity, CustomerUnionInfoModel>(customerUnionInfoEntity));
        }
        public bool UpdateCustomerCorpDepartIdList(int cid, List <int> corpDepartIdList, bool isAll)
        {
            CustomerUnionInfoEntity customerUnionInfoEntity =
                _customerUnionDal.Query <CustomerUnionInfoEntity>(n => n.Cid == cid).FirstOrDefault();

            string d = string.Empty;

            corpDepartIdList.ForEach(n =>
            {
                d += "," + n;
            });

            if (string.IsNullOrEmpty(d) && !isAll)
            {
                return(true);
            }

            if (!string.IsNullOrEmpty(d))
            {
                d = d.Substring(1);
            }


            if (customerUnionInfoEntity != null)
            {
                customerUnionInfoEntity.CorpDepartIDList = d;
                if (isAll)
                {
                    customerUnionInfoEntity.CorpDepartIDList = "0";
                }

                _customerUnionDal.Update(customerUnionInfoEntity, new string[] { "CorpDepartIDList" });
            }
            else
            {
                customerUnionInfoEntity = new CustomerUnionInfoEntity()
                {
                    Cid = cid,
                    CorpDepartIDList = d
                };

                if (isAll)
                {
                    customerUnionInfoEntity.CorpDepartIDList = "0";
                }

                _customerUnionDal.Insert(customerUnionInfoEntity);
            }

            return(true);
        }
        public List <PassengerInfoModel> GetPassenger(int cid, bool isTemporary, string searchArgs = "", int isOnline = 0)
        {
            CustomerInfoEntity customer    = _customerDal.Find <CustomerInfoEntity>(cid);
            BaseCustomerBll    customerBll = null;

            if (!string.IsNullOrEmpty(customer.CorpID))
            {
                CorporationEntity corporationEntity = _corporationDal.Find <CorporationEntity>(customer.CorpID);
                if (corporationEntity.IsAmplitudeCorp == "T" && !isTemporary) //是差旅公司,并且不是查询临客
                {
                    if (customer.IsMaster == "T")                             //预订员
                    {
                        CustomerUnionInfoEntity customerUnionInfoEntity =
                            _customerUnionDal.Query <CustomerUnionInfoEntity>(n => n.Cid == cid, true).FirstOrDefault();
                        string corpDepartIdList = customerUnionInfoEntity?.CorpDepartIDList;
                        if (!customer.CorpDepartID.HasValue)
                        {
                            throw new Exception("当前预定员部门信息异常");
                        }

                        if (string.IsNullOrEmpty(corpDepartIdList))
                        {
                            corpDepartIdList = customer.CorpDepartID.Value.ToString();
                        }

                        customerBll = new TripDepartBookingCustomerBll(customer, corporationEntity.CorpId,
                                                                       corpDepartIdList);
                    }
                    else
                    {
                        customerBll = new TripNotBookingCustomerBll(customer); //非预订员,普通差旅客户
                    }
                }
                else
                {
                    customerBll = new CommonCustomerBll(customer); //临客
                }
            }
            else
            {
                customerBll = new CommonCustomerBll(customer); //临客
            }

            ICustomerVisitor customerVisitor = new CustomerVisitor(_contactDal, _contactIdentificationDal, _customerDal,
                                                                   _corpDepartmentDal, searchArgs, base.Context, isOnline);
            List <PassengerInfoModel> passengerInfoModels = customerBll.GetPassenger(customerVisitor);

            return(passengerInfoModels);
        }
Example #6
0
        private List <CustomerModel> Convert(List <CustomerInfoEntity> customerInfoEntities, List <CustomerUnionInfoEntity> customerUnionInfoEntities)
        {
            List <string>           corpIdList        = new List <string>();
            List <CorporationModel> corporationModels = new List <CorporationModel>();

            #region 获取部门信息
            List <int> departIdList = new List <int>();
            List <CorpDepartmentModel> corpDepartmentModels = new List <CorpDepartmentModel>();
            customerInfoEntities.ForEach(n =>
            {
                if (n.CorpDepartID.HasValue)
                {
                    departIdList.Add(n.CorpDepartID.Value);
                }
                if (!string.IsNullOrEmpty(n.CorpID))
                {
                    corpIdList.Add(n.CorpID);
                }
            });
            if (departIdList.Count > 0)
            {
                departIdList = departIdList.Distinct().ToList();
                List <CorpDepartmentEntity> corpDepartmentEntities =
                    _corpDepartmentDal.Query <CorpDepartmentEntity>(n => departIdList.Contains(n.Id)).ToList();
                corpDepartmentModels =
                    Mapper.Map <List <CorpDepartmentEntity>, List <CorpDepartmentModel> >(corpDepartmentEntities);
            }
            #endregion

            #region 部门信息
            if (corpIdList.Count > 0)
            {
                corpIdList = corpIdList.Distinct().ToList();
                List <CorporationEntity> corporationEntities =
                    _corporationDal.Query <CorporationEntity>(n => corpIdList.Contains(n.CorpId)).ToList();
                corporationModels =
                    Mapper.Map <List <CorporationEntity>, List <CorporationModel> >(corporationEntities);
            }
            #endregion

            List <CustomerModel> customerModels = new List <CustomerModel>();
            foreach (var customerInfoEntity in customerInfoEntities)
            {
                CustomerModel customerModel = Mapper.Map <CustomerInfoEntity, CustomerModel>(customerInfoEntity);
                if (!string.IsNullOrEmpty(customerModel.CorpID))
                {
                    if (customerModel.CorpDepartID.HasValue)
                    {
                        customerModel.CorpDepartment =
                            corpDepartmentModels.Find(n => n.Id == customerModel.CorpDepartID.Value);
                    }
                    customerModel.Corporation = corporationModels.Find(n => n.CorpId.ToLower() == customerModel.CorpID.ToLower());
                }

                CustomerUnionInfoEntity customerUnionInfoEntity = customerUnionInfoEntities?.Find(n => n.Cid == customerInfoEntity.Cid);
                if (customerUnionInfoEntity != null)
                {
                    customerModel.Cid              = customerUnionInfoEntity.Cid;
                    customerModel.CPCID            = customerUnionInfoEntity.CPCID;
                    customerModel.CheckType        = customerUnionInfoEntity.CheckType;
                    customerModel.CorpDepartIDList = customerUnionInfoEntity.CorpDepartIDList;
                    customerModel.CustomerFrom     = customerUnionInfoEntity.CustomerFrom;
                    customerModel.GrantCPCID       = customerUnionInfoEntity.GrantCPCID;
                    customerModel.GrantEndDate     = customerUnionInfoEntity.GrantEndDate;
                    customerModel.GrantStartDate   = customerUnionInfoEntity.GrantStartDate;
                    customerModel.IsCheckU8        = customerUnionInfoEntity.IsCheckU8;
                    customerModel.IsSupplier       = customerUnionInfoEntity.IsSupplier;
                    customerModel.TelTime          = customerUnionInfoEntity.TelTime;
                }

                customerModels.Add(customerModel);
            }
            return(customerModels);
        }
Example #7
0
        public List <CorpBookingDepartModel> GetCorpBookingDepartList(int cid, string corpId)
        {
            if (cid == 0)
            {
                throw new Exception("该客户信息异常");
            }

            CustomerInfoEntity customerInfoEntity =
                _customerDal.Find <CustomerInfoEntity>(cid);

            if (string.IsNullOrEmpty(customerInfoEntity?.CorpID))
            {
                throw new Exception("该客户信息异常");
            }
            if (!customerInfoEntity.CorpDepartID.HasValue)
            {
                throw new Exception("该客户部门信息异常");
            }

            List <CorpBookingDepartModel> list = new List <CorpBookingDepartModel>();
            List <CorpDepartmentModel>    corpDepartmentModels =
                _getCorpDepartmentBll.GetCorpDepartmentByCorpId(corpId);

            CustomerUnionInfoEntity customerUnionInfoEntity =
                _customerUnionDal.Query <CustomerUnionInfoEntity>(n => n.Cid == cid, true).FirstOrDefault();

            string corpDepartStr = string.Empty;

            List <int> departIdList = new List <int>();

            if (customerUnionInfoEntity != null)
            {
                corpDepartStr = customerUnionInfoEntity.CorpDepartIDList;
            }

            if (string.IsNullOrEmpty(corpDepartStr))//如果当前值为NULL,则默认当前客户的部门Id
            {
                departIdList.Add(customerInfoEntity.CorpDepartID.Value);
            }
            else
            {
                if (corpDepartStr == "0")//如果为0值,则认为全部部门
                {
                    IsAll = true;
                }
                else
                {
                    List <string> c = corpDepartStr.Split(',').ToList();
                    if (c != null && c.Count > 0)
                    {
                        c.ForEach(n => departIdList.Add(Convert.ToInt32(n)));
                    }
                    else
                    {
                        throw new Exception("配置信息异常");
                    }
                }
            }



            if (IsAll)
            {
                foreach (var corpDepartmentModel in corpDepartmentModels)
                {
                    CorpBookingDepartModel departModel = new CorpBookingDepartModel()
                    {
                        DepartId    = corpDepartmentModel.Id,
                        DepartName  = corpDepartmentModel.DepartName,
                        IsBookinged = true
                    };
                    list.Add(departModel);
                }
            }
            else
            {
                foreach (var corpDepartmentModel in corpDepartmentModels)
                {
                    CorpBookingDepartModel departModel = new CorpBookingDepartModel()
                    {
                        DepartId    = corpDepartmentModel.Id,
                        DepartName  = corpDepartmentModel.DepartName,
                        IsBookinged = departIdList.Contains(corpDepartmentModel.Id)
                    };
                    list.Add(departModel);
                }
            }

            return(list);
        }
Example #8
0
 public int Insert(CustomerUnionInfoEntity t)
 {
     throw new NotImplementedException();
 }