From c2f105094a6ee6bae21b16130023eabbb55914df Mon Sep 17 00:00:00 2001
From: 涂煌豪 <tuhuanghao@prec-tech.com>
Date: 星期五, 25 三月 2022 17:59:45 +0800
Subject: [PATCH] 624调用606问题修复,联系人手机号排重

---
 force-app/main/default/classes/ContactTriggerHandler.cls |   62 +++++++++++++++++--------------
 1 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/force-app/main/default/classes/ContactTriggerHandler.cls b/force-app/main/default/classes/ContactTriggerHandler.cls
index f5f46f9..55901b1 100644
--- a/force-app/main/default/classes/ContactTriggerHandler.cls
+++ b/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 
         } 
         
     }

--
Gitblit v1.9.1