From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/NewAndEditContactController.cls |   85 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 77 insertions(+), 8 deletions(-)

diff --git a/force-app/main/default/classes/NewAndEditContactController.cls b/force-app/main/default/classes/NewAndEditContactController.cls
index 51152d2..a3c6101 100644
--- a/force-app/main/default/classes/NewAndEditContactController.cls
+++ b/force-app/main/default/classes/NewAndEditContactController.cls
@@ -1,9 +1,10 @@
 global class NewAndEditContactController extends NewAndEditBaseController 
 {
     public String unifiedIContactID{set;get;}
+    public String staticResourceContactV2 {get; set;}
+    
 	
     public NewAndEditContactController(ApexPages.StandardController controller) {
-        
         List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Contact').getDescribe().fields.getMap().keyset());  
         // Add fields to controller. This is to avoid the SOQL error in visualforce page
         if (!Test.isRunningTest()) {
@@ -12,19 +13,22 @@
         Init(controller.getRecord());
         String contactId = controller.getRecord().Id;
         if(contactId != null){
-            Contact c = [select UnifiedI_Contact_ID__c from Contact where Id =:contactId ];
+            Contact c = [select id,UnifiedI_Contact_ID__c from Contact where Id =:contactId ];
             system.debug('Contact c = '+c);
             unifiedIContactID = c.UnifiedI_Contact_ID__c;
         }else{
             Map<string,string> mso = ApexPages.currentPage().getParameters();
             system.debug('mso='+mso);
-            system.debug('url='+ApexPages.currentPage().getUrl());
             if(mso.containsKey('con4_lkid')){
                 controller.getRecord().put('AccountId',mso.get('con4_lkid'));
             }
         }
         system.debug('controller.getRecord()='+controller.getRecord());
-
+        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24 start
+        PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo('contactV2');
+        staticResourceContactV2 = JSON.serialize(piIntegration);
+        System.debug('staticResourceContactV2 = ' + staticResourceContactV2);
+        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24 end
     }
     
     PageReference RedirectStandardPage(){
@@ -32,16 +36,15 @@
         system.debug(mso);
         PageReference pg = null;
         mso.remove('sfdc.override');
-        mso.remove('save_new');
         system.debug('recordId='+recordId);
         if(string.isBlank(recordId)){
             pg = new PageReference('/003/e');
         }else{
             pg = new PageReference('/'+recordId+'/e');
         }
-        pg.getParameters().putAll(mso);
-        //pg.getParameters().put('RecordType',mso.get('RecordType'));
-        //pg.getParameters().put('accid',mso.get('accid'));
+        //pg.getParameters().putAll(mso);
+        pg.getParameters().put('RecordType',mso.get('RecordType'));
+        pg.getParameters().put('accid',mso.get('accid'));
         pg.getParameters().put('nooverride','1');
         pg.setRedirect(true);
         return pg;
@@ -76,4 +79,70 @@
     global static Response saveContact(String leadJson,String transId,Boolean isNew) {
         return save(new Contact(),leadJson,transId,isNew);
     }
+
+    //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24 start
+    @RemoteAction
+    global static ResponseV2 searchContactByAccountId(String accountId,String RecordTypeId,String Isactive) {
+        System.debug('accountId = ' + accountId);
+        ResponseV2 res = new ResponseV2();
+        try{
+            Account account = [select Id,Name from Account where Id = :accountId];
+            List<Contact> contactList = [select id,AWS_Data_Id__c, CManageCode__c,Name from Contact where AccountId = :account.Id];
+            Map<String,String> dataIdManageCodeMap = new Map<String,String>();
+            for(Contact contact : contactList){
+                dataIdManageCodeMap.put(contact.AWS_Data_Id__c,contact.CManageCode__c);
+            }
+            res.dataIdManageCodeMap = dataIdManageCodeMap;
+            res.accountName = account.Name;
+            res.contactList = contactList;
+
+            ID DoctorRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId();
+            Map<String,String> accMap= new Map<String,String>();
+            List<Account> accList=[select ID,Is_Active__c,Is_Active_Formula__c from Account where ID =:accountId];
+            if(accList.size()>0){
+                for(Account acc:accList){
+                    if (String.isNotBlank(acc.Is_Active__c)){
+                        String subId = acc.Id;
+                        accMap.put(subId.substring(0,15), acc.Is_Active__c);
+                        continue;
+                    }
+                    if (String.isNotBlank(acc.Is_Active_Formula__c)){
+                        String subId = acc.Id;
+                        accMap.put(subId.substring(0,15), acc.Is_Active_Formula__c);
+                    }
+                }
+            }
+            System.debug('accMap= ' + accMap);
+            //濡傛灉鏄疍octor璁板綍绫诲瀷鐨勯渶瑕佽繘琛屽鍚�+鎵嬫満鍙峰垽鏂�
+            if(DoctorRecordTypeId.equals(RecordTypeId)){
+                res.isNameMobileVerif = true;
+            }
+            System.debug('Isactive= ' + Isactive);
+            System.debug('DoctorRecordTypeId.equals(RecordTypeId) = ' + DoctorRecordTypeId.equals(RecordTypeId));
+            System.debug('accMap.get(accountId) = ' + accMap.get(accountId));
+            if (('鏈夋晥'.equals(Isactive) || '鏈夊姽'.equals(Isactive))
+                && ('鏈夊姽'.equals(accMap.get(accountId)) || '鏈夋晥'.equals(accMap.get(accountId))) && (DoctorRecordTypeId.equals(RecordTypeId))) {
+                res.isMobileVerif = true;
+            }else {
+                res.isMobileVerif = false;
+            }
+            res.status = 'success';
+            return res;
+        }catch(Exception e){
+            res.message = e.getMessage() + '';
+            res.status = 'fail';
+            return res;
+        }
+    }
+
+    global class ResponseV2{
+        public List<Contact> contactList{set;get;}
+        public String accountName{set;get;}
+        public Map<String,String> dataIdManageCodeMap{set;get;}
+        public Boolean isMobileVerif;
+        public Boolean isNameMobileVerif;
+        public String message{set;get;}
+        public String status{set;get;}
+    }
+    //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24 end
 }
\ No newline at end of file

--
Gitblit v1.9.1