涂煌豪
2022-03-25 c2f105094a6ee6bae21b16130023eabbb55914df
624调用606问题修复,联系人手机号排重
1个文件已修改
62 ■■■■ 已修改文件
force-app/main/default/classes/ContactTriggerHandler.cls 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/ContactTriggerHandler.cls
@@ -223,19 +223,19 @@
    //更新经销商用户人数字段 精琢技术 pk 2021-08-26 end
    
    // 手机号去重及规则验证 及新增客户人员重名验证
    public  void mobileNumberVerification(){
    public void mobileNumberVerification(){
        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<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>();
@@ -257,11 +257,9 @@
            }
        }
        for (Contact contactnew: newList) {
            // 手机号 有值 并且 联系人有效 联系人的客户有效 无外部关联用户 进行手机号码验证
            // 手机号 有值 并且 联系人有效 联系人的客户有效 进行手机号码验证
            if (String.isNotBlank(contactnew.MobilePhone) && ('有效'.equals(contactnew.Isactive__c) ||'有効'.equals(contactnew.Isactive__c))
                && '有効'.equals(accMap.get(contactnew.AccountId))
                && !userMap.containsKey(contactnew.Id)
                ) {
                && '有効'.equals(accMap.get(contactnew.AccountId))) {
                Matcher isMobilePhone = pattern.matcher(contactnew.MobilePhone);
                if (isMobilePhone.matches()) {
                    // 将手机号 赋值给 手机号唯一字段
@@ -376,22 +374,26 @@
                    // 医院 客户人员 统一平台编码有值 发送 PO
                    if ('01210000000QfWdAAK'.equals(local.RecordTypeId) && String.isNotBlank(local.UnifiedI_Contact_ID__c)) {
                        if (!NFM606_IdMap.containsKey(local.Id)) {
                            if(UserInfo.getProfileId().equals(System.Label.ProfileId_SystemAdmin)){
                                interfaceUserUpsertContact.add(local.Id);
                            } else {
                            //624调用606问题修复 thh 20220325 start
                            // if(UserInfo.getProfileId().equals(System.Label.ProfileId_SystemAdmin)){
                            //     interfaceUserUpsertContact.add(local.Id);
                            // } else {
                                contactIdList.add(local.Id);
                            }
                            // }
                            //624调用606问题修复 thh 20220325 end
                            NFM606_IdMap.put(local.Id, local.Id);
                        }
                    }
                    // 经销商 客户人员 手机号码有值 发送 PO
                    if ('01210000000QfWiAAK'.equals(local.RecordTypeId) && String.isNotBlank(local.MobilePhone)) {
                        if (!NFM606_IdMap.containsKey(local.Id)) {
                            if(UserInfo.getProfileId().equals(System.Label.ProfileId_SystemAdmin)){
                                interfaceUserUpsertContact.add(local.Id);
                            } else {
                            //624调用606问题修复 thh 20220325 start
                            // if(UserInfo.getProfileId().equals(System.Label.ProfileId_SystemAdmin)){
                            //     interfaceUserUpsertContact.add(local.Id);
                            // } else {
                                contactIdList.add(local.Id);
                            }
                            // }
                            //624调用606问题修复 thh 20220325 end
                            NFM606_IdMap.put(local.Id, local.Id);
                        }
                    }
@@ -402,23 +404,27 @@
        
        if(!System.Test.isRunningTest()){
            // NFM606Controller.executeNotFuture('', contactIdList);
            //624调用606问题修复 thh 20220325 start
            if (contactIdList.size() > 0) {
                // NFM606Controller.callout('', contactIdList);
                 //添加future 判断 add for pipl  sushanhu 20220317 start
                 if (!(System.isFuture()||System.isBatch())) {
                //添加future 判断 add for pipl  sushanhu 20220317 start
                if (!(System.isFuture()||System.isBatch())) {
                    NFM606Controller.callout('', contactIdList);
                } else{
                    NFM606Controller.executeNotFuture('', contactIdList);
                }
               //添加future 判断 add for pipl  sushanhu 20220317 end
                //添加future 判断 add for pipl  sushanhu 20220317 end
            }
            if (interfaceUserUpsertContact.size() > 0) {
            // if (interfaceUserUpsertContact.size() > 0) {
                // NFM606Controller.executeNotFuture('', interfaceUserUpsertContact);
                //添加future 判断 add for pipl  sushanhu 20220316 start
                if (!(System.isFuture()||System.isBatch())) {
                    NFM606Controller.executeNotFuture('', interfaceUserUpsertContact);
                }
                // if (!(System.isFuture()||System.isBatch())) {
                //     NFM606Controller.executeNotFuture('', interfaceUserUpsertContact);
                // }
               //添加future 判断 add for pipl  sushanhu 20220316 end 
               
            }
            // }
            //624调用606问题修复 thh 20220325 end
        } 
        
    }