Exemple #1
0
        public List <ContactInfoModel> SearchContacts(string args, int cid)
        {
            List <ContactInfoModel> contactInfoModels = new List <ContactInfoModel>();
            CustomerModel           customerModel     = _getCustomerBll.GetCustomerByCid(cid);

            if (!string.IsNullOrEmpty(customerModel.CorpID) && customerModel.Corporation != null)
            {
                if (customerModel.Corporation.IsAmplitudeCorp == "T")
                {
                    if (customerModel.IsMaster == "T")
                    {
                        //查询当前公司下所有的联系人信息
                        //List<CustomerModel> customerModels = _getCustomerBll.GetCustomerByCorpId(customerModel.CorpID);
                        //List<int> cidList = customerModels.Select(n => n.Cid).ToList();
                        //contactInfoModels = _getContactBll.GetContactByCid(cidList, args);

                        //查询当前客户名下的联系人信息
                        contactInfoModels = _getContactBll.GetContactByCid(customerModel.Cid, args);
                    }
                    else
                    {
                        //查询当前客户名下的联系人信息
                        contactInfoModels = _getContactBll.GetContactByCid(customerModel.Cid, args);
                    }
                }
                else
                {
                    //查询当前公司下所有的联系人信息
                    List <CustomerModel> customerModels = _getCustomerBll.GetCustomerByCorpId(customerModel.CorpID);
                    List <int>           cidList        = customerModels.Select(n => n.Cid).ToList();
                    contactInfoModels = _getContactBll.GetContactByCid(cidList, args);
                }
            }
            else
            {
                //查询当前客户名下的联系人信息
                contactInfoModels = _getContactBll.GetContactByCid(customerModel.Cid, args);
            }


            return(contactInfoModels);
        }
Exemple #2
0
 public List <CustomerModel> GetCustomerByCorpId(string corpId)
 {
     return(_customerBll.GetCustomerByCorpId(corpId));
 }
        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);
        }