涂煌豪
2022-05-27 c36f49d724cf5e680091a45f590fbd03673c82c4
只对医院客户人员进行姓名+手机重复校验
1个文件已修改
14 ■■■■ 已修改文件
force-app/main/default/classes/ContactTriggerHandler.cls 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/ContactTriggerHandler.cls
@@ -316,20 +316,23 @@
                }
            }
            // if (Trigger.isInsert) {
            if(DoctorRecordTypeId.equals(contactnew.RecordTypeId)){
            accountIdSet.add(contactnew.AccountId);  
            }
            // }   
        }
        //手机号唯一校验-医院下新建客户人员校验使用加密手机号,经销商使用普通手机号 thh 20220328 end
        // 新增联系人时
        // 新增医院联系人时
        if (accountIdSet.size() > 0) {
            List<Contact> contactList = new List<Contact>();
            if(Test.isRunningTest()){
            if(Trigger.isInsert){
                contactList = [SELECT Id,AccountId,FullName__c,LastName,FirstName,Account.Name,CManageCode__c,IsFromSPO__c,
                                                LastName_Encrypted__c// 20220314 PI改造 by Bright
                                                , MobilePhone_Encrypted__c // 通过姓名+手机号判断人员是否重复 thh 20220518
                                                FROM Contact 
                                                WHERE IsFromSPO__c = false AND AccountId IN:accountIdSet];
            }else{
            }
            if(Trigger.isUpdate){
                contactList = [SELECT Id,AccountId,FullName__c,LastName,FirstName,Account.Name,CManageCode__c,IsFromSPO__c,
                                             LastName_Encrypted__c// 20220314 PI改造 by Bright
                                             , MobilePhone_Encrypted__c // 通过姓名+手机号判断人员是否重复 thh 20220518
@@ -360,6 +363,11 @@
        }
        for (Contact contactnew: newList) { 
            if(AgencyRecordTypeId.equals(contactnew.RecordTypeId) || (Trigger.isUpdate && !oldMap.isEmpty() && oldMap.get(contactnew.Id) != null
                && String.isBlank(oldMap.get(contactnew.Id).MobilePhone_Encrypted__c)
                && String.isBlank(contactnew.MobilePhone_Encrypted__c))){
                continue;
            }
            String accountId = String.valueOf(contactnew.AccountId).substring(0, 15);
            if (accountContactMap.containsKey(accountId)) {
                Map<String,Contact> contactFullNameMap =  accountContactMap.get(accountId);