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 }); }
public List <ContactInfoModel> GetContactByContactId(List <int> contactIdList) { List <ContactInfoEntity> contactInfoEntities = _contactDal.Query <ContactInfoEntity>(n => contactIdList.Contains(n.Contactid)).ToList(); return(Mapper.Map <List <ContactInfoEntity>, List <ContactInfoModel> >(contactInfoEntities)); }
/// <summary> /// 非差旅客户获取乘客信息 /// </summary> /// <param name="customerBll"></param> /// <returns></returns> public List <PassengerInfoModel> GetPassenger(CommonCustomerBll customerBll) { var customer = customerBll.Customer; IQueryable <ContactInfoEntity> contactInfoEntitieses = _contactDal.Query <ContactInfoEntity>( n => n.Cid == customer.Cid && n.IsPassenger == "T" && (n.IsDel ?? "F") == "F" && !n.PCid.HasValue, true); contactInfoEntitieses = SearchContact(contactInfoEntitieses); if (_isOnline == 1)//如果是线上查询临客,则只显示线上新增的临客;线下查询不做限制 { contactInfoEntitieses = contactInfoEntitieses.Where(n => n.IsOnline == 1); } List <ContactInfoEntity> contactList = contactInfoEntitieses.ToList(); return(ConvertContactToPassenger(contactList, null)); }
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); }
public bool UpdateCustomerInfo(UpdateCustomerInfoModel up) { CustomerInfoEntity customerInfoEntity = _customerDal.Find <CustomerInfoEntity>(up.Cid); if (customerInfoEntity == null) { throw new Exception("当前客户信息异常"); } ContactInfoEntity contactInfoEntity = null; if (!string.IsNullOrEmpty(customerInfoEntity.CorpID)) { contactInfoEntity = _contactDal.Query <ContactInfoEntity>(n => n.PCid == customerInfoEntity.Cid).FirstOrDefault(); if (contactInfoEntity == null) { throw new Exception("当前客户信息异常,不能修改"); } } List <string> upArgsList = new List <string>(); List <string> upArgsList2 = new List <string>(); if (!string.IsNullOrEmpty(up.Email)) { int emailCount = _customerDal.Query <CustomerInfoEntity>( n => n.Email == up.Email && n.Cid != up.Cid && n.CorpID == customerInfoEntity.CorpID, true) .Count(); if (emailCount > 0) { throw new Exception("当前邮箱已经存在,不能修改"); } customerInfoEntity.Email = up.Email; upArgsList.Add("Email"); if (contactInfoEntity != null) { contactInfoEntity.Email = up.Email; upArgsList2.Add("Email"); } } if (!string.IsNullOrEmpty(up.Gender)) { List <string> genderList = new List <string>() { "M", "F" }; if (!genderList.Contains(up.Gender)) { throw new Exception("性别参数异常,请使用M/F"); } customerInfoEntity.Gender = up.Gender; upArgsList.Add("Gender"); if (contactInfoEntity != null) { contactInfoEntity.Gender = up.Gender; upArgsList2.Add("Gender"); } } if (!string.IsNullOrEmpty(up.RealName)) { customerInfoEntity.RealName = up.RealName; upArgsList.Add("RealName"); if (contactInfoEntity != null) { if (up.RealName.Contains("/")) { contactInfoEntity.Ename = up.RealName; upArgsList2.Add("Ename"); } else { contactInfoEntity.Cname = up.RealName; upArgsList2.Add("Cname"); } } } if (!string.IsNullOrEmpty(up.Mobile)) { //这里要判断手机号,userid是否唯一 int mobileCount = _customerDal.Query <CustomerInfoEntity>( n => n.Mobile == up.Mobile && n.Cid != up.Cid && n.CorpID == customerInfoEntity.CorpID, true) .Count(); if (mobileCount > 0) { throw new Exception("当前手机号存在,不能修改"); } int userIdCount = _customerDal.Query <CustomerInfoEntity>( n => n.UserID == up.Mobile && n.Cid != up.Cid && n.CorpID == customerInfoEntity.CorpID, true) .Count(); if (userIdCount > 0) { throw new Exception("当前UserId存在,不能修改"); } customerInfoEntity.Mobile = up.Mobile; customerInfoEntity.UserID = up.Mobile; upArgsList.Add("Mobile"); upArgsList.Add("UserID"); upArgsList2.Add("Mobile"); if (contactInfoEntity != null) { contactInfoEntity.Mobile = up.Mobile; upArgsList2.Add("Mobile"); } } _customerDal.Update(customerInfoEntity, upArgsList.ToArray()); if (contactInfoEntity != null) { _contactDal.Update(contactInfoEntity, upArgsList2.ToArray()); } return(true); }