Пример #1
0
        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);
        }
Пример #2
0
        /// <summary>
        /// 差旅预订员客户获取所有公司的乘客信息
        /// </summary>
        /// <param name="customerBll"></param>
        /// <returns></returns>
        public List <PassengerInfoModel> GetPassenger(TripDepartBookingCustomerBll customerBll)
        {
            if (string.IsNullOrEmpty(customerBll.CorpId))
            {
                throw new Exception("请传入CorpId参数");
            }
            _context.Configuration.LazyLoadingEnabled = false;

            //int corpDepartId = (customerBll.Customer?.CorpDepartID ?? 0);
            List <string> corpDepartIdStrList = customerBll.CorpDepartIdList.Split(',').ToList();
            List <int>    corpDepartIdList    = new List <int>();

            foreach (var s in corpDepartIdStrList)
            {
                corpDepartIdList.Add(Convert.ToInt32(s));
            }


            IQueryable <PassengerInfoModel> select = from contact in
                                                     _context.Set <ContactInfoEntity>().AsNoTracking()
                                                     join customer in _context.Set <CustomerInfoEntity>().AsNoTracking() on contact.PCid equals
                                                     customer.Cid into c
                                                     from customer in c.DefaultIfEmpty()
                                                     where
                                                     customer.CorpID == customerBll.CorpId && (customer.IsDel ?? "F") == "F" && customer.IsLock == "F" &&
                                                     !string.IsNullOrEmpty(customer.DepartmentName) && customer.CorpDepartID.HasValue

                                                     select new PassengerInfoModel()
            {
                ContactId               = contact.Contactid,
                PassengerName           = customer.RealName,
                Mobile                  = customer.Mobile,
                Phone                   = customer.Phone,
                Fax                     = customer.Fax,
                Email                   = customer.Email,
                DepartmentName          = customer.DepartmentName,
                Cid                     = customer.Cid,
                DefaultIdentificationId = contact.DefaultIdentificationId,
                CorpDepartId            = customer.CorpDepartID
            };

            if (!corpDepartIdList.Contains(0))
            {
                select = select.Where(n => corpDepartIdList.Contains(n.CorpDepartId ?? 0));
            }

            //if (customerBll.Customer?.CorpID.ToUpper() == "TTL" || customerBll.Customer?.CorpID.ToUpper() == "MZL")
            //{
            //    int cid = (customerBll.Customer?.Cid ?? 0);
            //    if (cid != 5718)
            //    {
            //        select = select.Where(n => n.CorpDepartId == corpDepartId);
            //    }
            //}


            if (!string.IsNullOrEmpty(_searchArgs))
            {
                select =
                    select.Where(n => n.PassengerName.Contains(_searchArgs) ||
                                 n.Mobile == _searchArgs);
            }

            select = select.Take(50).OrderBy(n => n.PassengerName);


            List <PassengerInfoModel> passengerInfoModels = select.ToList();

            List <int> contactIdList = passengerInfoModels.Select(n => n.ContactId).ToList();
            List <ContactIdentificationInfoEntity> identificationList =
                _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(
                    n => contactIdList.Contains(n.Contactid)).ToList();

            if (identificationList == null || identificationList.Count == 0)
            {
                identificationList = new List <ContactIdentificationInfoEntity>();
            }

            foreach (PassengerInfoModel passengerInfoModel in passengerInfoModels)
            {
                var tempCardList =
                    identificationList.FindAll(n => n.Contactid == passengerInfoModel.ContactId);

                #region 将默认证件放在首位

                int defaultCardType = passengerInfoModel.DefaultIdentificationId ?? 0;
                var tempCard        = tempCardList.Find(n => n.Iid == defaultCardType);
                if (tempCard != null)
                {
                    tempCardList.RemoveAll(n => n.Iid == defaultCardType);
                    tempCardList = tempCardList.OrderBy(n => n.Iid).ToList();
                    tempCardList.Add(tempCard);
                    tempCardList.Reverse();
                }

                #endregion

                passengerInfoModel.IdentificationList = Mapper
                                                        .Map <List <ContactIdentificationInfoEntity>, List <IdentificationModel> >(tempCardList);
            }


            return(passengerInfoModels);
        }