Пример #1
0
        public AddResultBaseModel <int> Add(AddContactModel model)
        {
            string cName = model.Cname;
            string eName = string.Empty;

            if (model.Cname.Contains("/"))
            {
                eName = model.Cname;
                cName = string.Empty;
            }
            List <ContactInfoEntity> contactInfoEntities = _contactDal.Query <ContactInfoEntity>(
                n => n.Cid == model.Cid && n.IsDel == "F" && (n.Cname == model.Cname || n.Ename == model.Cname), true)
                                                           .ToList();

            if (contactInfoEntities != null && contactInfoEntities.Count > 0)
            {
                List <int> contactId = new List <int>();
                contactInfoEntities.ForEach(n => contactId.Add(n.Contactid));
                int count = _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(
                    n => contactId.Contains(n.Contactid) && n.CardNo == model.CardNo, true).Count();
                if (count > 0)
                {
                    throw new Exception("当前已经存在该信息");
                }
            }


            ContactInfoEntity contactInfo = new ContactInfoEntity()
            {
                Cname          = cName,
                Ename          = eName,
                Mobile         = model.Mobile,
                Cid            = model.Cid,
                LastUpdateTime = DateTime.Now,
                IsDel          = "F",
                IsPassenger    = model.IsPassenger,
                UpdateOid      = "sys",
                DelTime        = DateTime.Now,
                Email          = model.Email,
                IsOnline       = (model.OrderSource == "O" ? 0 : 1)
            };

            contactInfo = _contactDal.Insert <ContactInfoEntity>(contactInfo);

            _contactIdentificationDal.Insert <ContactIdentificationInfoEntity>(new ContactIdentificationInfoEntity()
            {
                Contactid      = contactInfo.Contactid,
                CardNo         = model.CardNo,
                Iid            = model.Iid,
                LastUpdateTime = DateTime.Now
            });

            return(new AddResultBaseModel <int>()
            {
                IsSuccessed = true,
                Id = contactInfo.Contactid
            });
        }
Пример #2
0
        public AddResultBaseModel <int> Edit(EditContactModel model)
        {
            ContactInfoEntity contactInfoEntity = _contactDal.Find <ContactInfoEntity>(model.ContactId);

            if (model.Cname.Contains("/"))
            {
                contactInfoEntity.Ename = model.Cname;
                contactInfoEntity.Cname = string.Empty;
            }
            else
            {
                contactInfoEntity.Cname = model.Cname;
                contactInfoEntity.Ename = string.Empty;
            }

            contactInfoEntity.Mobile         = model.Mobile;
            contactInfoEntity.LastUpdateTime = DateTime.Now;
            contactInfoEntity.UpdateOid      = "sys";
            contactInfoEntity.DelTime        = DateTime.Now;
            contactInfoEntity.Email          = model.Email;
            if (!string.IsNullOrEmpty(model.IsDel))
            {
                contactInfoEntity.IsDel = model.IsDel;
            }

            _contactDal.Update(contactInfoEntity);

            ContactIdentificationInfoEntity contactIdentificationInfoEntity =
                _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(
                    n => n.Contactid == model.ContactId && n.Iid == model.Iid, true).FirstOrDefault();

            if (contactIdentificationInfoEntity != null)
            {
                contactIdentificationInfoEntity.Iid            = model.Iid;
                contactIdentificationInfoEntity.CardNo         = model.CardNo;
                contactIdentificationInfoEntity.LastUpdateTime = DateTime.Now;
                _contactIdentificationDal.Update(contactIdentificationInfoEntity);
            }
            else
            {
                _contactIdentificationDal.Insert <ContactIdentificationInfoEntity>(new ContactIdentificationInfoEntity()
                {
                    Contactid      = model.ContactId,
                    CardNo         = model.CardNo,
                    Iid            = model.Iid,
                    LastUpdateTime = DateTime.Now
                });
            }

            return(new AddResultBaseModel <int>()
            {
                IsSuccessed = true, Id = model.ContactId
            });
        }
Пример #3
0
        public GetContactInfoModel GetCorpContactByCid(int cid)
        {
            ContactInfoModel contactInfoModel = _getContactBll.GetCorpContactByCid(cid);

            if (contactInfoModel == null)
            {
                return(null);
            }
            GetContactInfoModel getContactInfoModel = new GetContactInfoModel().ConvertEntity(contactInfoModel);

            List <ContactIdentificationInfoEntity> contactIdentificationInfoEntities = _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(
                n => n.Contactid == getContactInfoModel.ContactId, true).ToList();

            getContactInfoModel.IdentificationList = Mapper
                                                     .Map <List <ContactIdentificationInfoEntity>, List <IdentificationModel> >(contactIdentificationInfoEntities);

            return(getContactInfoModel);
        }
Пример #4
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);
        }
        public bool PostIdentification(IdentificationModel model, int cid)
        {
            var contact = _contactDal.Query <ContactInfoEntity>(a => a.PCid == cid).FirstOrDefault();

            if (contact == null)
            {
                throw new Exception("当前客户信息异常,不能修改");
            }

            if (model.IsDefault == 1)
            {
                contact.DefaultIdentificationId = model.Iid;
                _contactDal.Update <ContactInfoEntity>(contact, new string[] { "DefaultIdentificationId" });
            }
            else
            {
                if (contact.DefaultIdentificationId.HasValue && contact.DefaultIdentificationId.Value == model.Iid)
                {
                    contact.DefaultIdentificationId = 0;
                    _contactDal.Update <ContactInfoEntity>(contact, new string[] { "DefaultIdentificationId" });
                }
            }

            model.ContactId = contact.Contactid;
            //判断当前公司下,是否存在相同证件,如果存在,则不许修改
            CustomerModel customerModel = _getCustomerBll.GetCustomerByCid(cid);

            if (!string.IsNullOrEmpty(customerModel.CorpID))
            {
                List <CustomerModel> customerModels = _getCustomerBll.GetCustomerByCorpId(customerModel.CorpID);
                List <int>           cidList        = new List <int>();
                customerModels.ForEach(n =>
                {
                    if (n.Cid != cid)
                    {
                        cidList.Add(n.Cid);
                    }
                });

                List <ContactInfoEntity> contactInfoEntities =
                    _contactDal.Query <ContactInfoEntity>(a => cidList.Contains(a.PCid ?? 0)).ToList();

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

                contactInfoEntities.ForEach(n => contactIdList.Add(n.Contactid));

                List <ContactIdentificationInfoEntity> infoList =
                    _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(
                        n =>
                        contactIdList.Contains(n.Contactid) && !string.IsNullOrEmpty(n.CardNo) &&
                        n.CardNo.ToUpper() == model.CardNo.ToUpper() && n.Iid == model.Iid)
                    .ToList();

                if (infoList != null && infoList.Count > 0)
                {
                    throw new Exception("当前公司存在相同证件号,不能修改");
                }
            }


            var identifications = _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(a => a.Contactid == model.ContactId && a.Iid == model.Iid);
            var entity          = Mapper.Map <IdentificationModel, ContactIdentificationInfoEntity>(model);

            entity.LastUpdateTime = DateTime.Now;
            entity.CardNo         = entity.CardNo ?? "";
            if (identifications != null && identifications.Any())
            {
                _contactIdentificationDal.Update <ContactIdentificationInfoEntity>(entity);
            }
            else
            {
                _contactIdentificationDal.Insert <ContactIdentificationInfoEntity>(entity);
            }
            return(true);
        }