| | |
| | | syncToAgencyContact(); |
| | | updateDealerNum(); |
| | | sendToComPlat(); |
| | | //NFM702 |
| | | // NFM702_Handler(this.newList , this.newMap , this.oldList , this.oldMap); |
| | | } |
| | | |
| | | protected override void afterUpdate() { |
| | | syncToAgencyContact(); |
| | | updateDealerNum(); |
| | | sendToComPlat(); |
| | | //NFM702 |
| | | // NFM702_Handler(this.newList , this.newMap , this.oldList , this.oldMap); |
| | | |
| | | } |
| | | protected override void beforeUpdate() { |
| | |
| | | Pattern pattern = Pattern.compile('^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$'); |
| | | Map<String, Map<String,Contact>> accountContactMap = new Map<String, Map<String,Contact>>(); |
| | | Set<Id> accountIdSet = new Set<Id>(); |
| | | //用户对象上找对应的联系人 |
| | | List<User> userList=[select ID,ContactID from User where ContactID != null]; |
| | | Map<String,User> userMap= new Map<String,User>(); |
| | | if (userList.size()>0){ |
| | | for(User us1: userList){ |
| | | userMap.put(us1.ContactId, us1); |
| | | } |
| | | } |
| | | //查找联系人对象上对应的有效客户;医院直接使用有效/无效字段、经销商使用有效/无效公式字段 |
| | | List<String> accIdList = new List<String>(); |
| | | Map<String,String> accMap= new Map<String,String>(); |
| | | for (Contact contact1: newList) { |
| | | accIdList.add(contact1.AccountId); |
| | | } |
| | | if (accIdList.size()>0){ |
| | | List<Account> accList=[select ID,Is_Active__c,Is_Active_Formula__c from Account where ID in:accIdList]; |
| | | if(accList.size()>0){ |
| | | for(Account acc:accList){ |
| | | if (String.isNotBlank(acc.Is_Active__c)){ |
| | | accMap.put(acc.Id, acc.Is_Active__c); |
| | | continue; |
| | | } |
| | | if (String.isNotBlank(acc.Is_Active_Formula__c)){ |
| | | accMap.put(acc.Id, acc.Is_Active_Formula__c); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | for (Contact contactnew: newList) { |
| | | // 手机号 有值 并且 联系人有效 进行手机号码验证 |
| | | if (String.isNotBlank(contactnew.MobilePhone) && '有效'.equals(contactnew.Isactive__c)) { |
| | | // 手机号 有值 并且 联系人有效 联系人的客户有效 无外部关联用户 进行手机号码验证 |
| | | if (String.isNotBlank(contactnew.MobilePhone) && ('有效'.equals(contactnew.Isactive__c) ||'有効'.equals(contactnew.Isactive__c)) |
| | | && '有効'.equals(accMap.get(contactnew.AccountId)) |
| | | && !userMap.containsKey(contactnew.Id) |
| | | ) { |
| | | Matcher isMobilePhone = pattern.matcher(contactnew.MobilePhone); |
| | | if (isMobilePhone.matches()) { |
| | | // 将手机号 赋值给 手机号唯一字段 |
| | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public void NFM702_Handler(List<Contact> newList, Map<Id, Contact> newMap, List<Contact> oldList, Map<Id, Contact> oldMap){ |
| | | List<Contact> conIdList = new List<Contact>(); |
| | | List<String> idList = new List<String>(); |
| | | String LOG_TYPE = 'NFM702'; |
| | | // iflog.Log__c = '---------'; |
| | | String ConTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId(); |
| | | if (Trigger.isUpdate && Trigger.isAfter) { |
| | | if (newList.size() > 0) { |
| | | for (Contact con : newList) { |
| | | Contact oldCon = oldMap.get(con.Id); |
| | | if ((con.RecordTypeId.equals(ConTypeId)) && (con.FullName__c != oldCon.FullName__c || con.Phone != oldCon.Phone || con.Department__c != oldCon.Department__c || con.Isactive__c != oldCon.Isactive__c)) { |
| | | idList.add(con.Id); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(Trigger.isInsert && Trigger.isAfter){ |
| | | if (newList.size() > 0) { |
| | | for (Contact con : newList) { |
| | | if(con.RecordTypeId.equals(ConTypeId)){ |
| | | idList.add(con.Id); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (idList.size() > 0) { |
| | | BatchIF_Log__c iflog = new BatchIF_Log__c(); |
| | | iflog.Log__c = '触发成功'; |
| | | iflog.Type__c = LOG_TYPE; |
| | | insert iflog; |
| | | NFM702Controller.callout(iflog.Id, idList); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |