buli
2022-04-26 5835379ec30b1667c4e522db9d294c9b7bb8633a
force-app/main/default/classes/ContactTriggerHandler.cls
@@ -5,7 +5,7 @@
            // String new_profileId = UserInfo.getProfileId().subString(0,15);
            //calendarUtil.getMemberProfileID  这里用到的人员ID 和获取到的简档ID都是15位的
            String new_profileId = calendarUtil.getMemberProfileID(UserInfo.getUserId().subString(0,15));
            if (new_profileId.subString(0,15) == System.label.Market_Department || new_profileId.subString(0,15) == System.label.Market_Department1 || new_profileId.subString(0,15) == System.label.Service_Owner ||
                UserInfo.getUserType() == 'PowerPartner') {
                newCon.IsNew__c = true;
@@ -25,8 +25,22 @@
                if(new_profileId.subString(0,15) == '00e28000000YKLo'){
                    newCon.IsNew__c = true;
                }
                // PIPL Update 20220420 By Chen Yanan Start
                newCon.MobilePhoneD_Encrypted__c = newCon.MobilePhone_Encrypted__c;
                newCon.OtherPhoneD_Encrypted__c = newCon.OtherPhone_Encrypted__c;
                newCon.FaxD_Encrypted__c = newCon.Fax_Encrypted__c;
                newCon.EmailD_Encrypted__c = newCon.Email_Encrypted__c;
                newCon.PhoneD_Encrypted__c = newCon.Phone_Encrypted__c;
                newCon.TitleD_Encrypted__c = newCon.Title_Encrypted__c;
                newCon.Address1D_Encrypted__c = newCon.Address1_Encrypted__c;
                newCon.Address2D_Encrypted__c = newCon.Address2_Encrypted__c;
                newCon.Address3D_Encrypted__c = newCon.Address3_Encrypted__c;
                newCon.PostcodeD_Encrypted__c = newCon.Postcode_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
            System.debug('setIsNew newCon: ' + newCon);
        }
    }
    
    public static void updateForDealer(List<Contact> newList, Map<Id, Contact> newMap, List<Contact> oldList, Map<Id, Contact> oldMap) {
@@ -65,33 +79,73 @@
            
            if (newCon.MobilePhone != oldCon.MobilePhone) {
                newCon.MobilePhoneD__c = newCon.MobilePhone;
                // PIPL Update 20220420 By Chen Yanan Start
                System.debug('MobilePhoneD_Encrypted__c');
                newCon.MobilePhoneD_Encrypted__c = newCon.MobilePhone_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
            if (newCon.OtherPhone != oldCon.OtherPhone) {
                newCon.OtherPhoneD__c = newCon.OtherPhone;
                // PIPL Update 20220420 By Chen Yanan Start
                System.debug('OtherPhoneD_Encrypted__c');
                newCon.OtherPhoneD_Encrypted__c = newCon.OtherPhone_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
            if (newCon.Fax != oldCon.Fax) {
                newCon.FaxD__c = newCon.Fax;
                // PIPL Update 20220420 By Chen Yanan Start
                System.debug('FaxD_Encrypted__c');
                newCon.FaxD_Encrypted__c = newCon.Fax_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
            if (newCon.Email != oldCon.Email) {
                newCon.EmailD__c = newCon.Email;
                // PIPL Update 20220420 By Chen Yanan Start
                System.debug('EmailD_Encrypted__c');
                newCon.EmailD_Encrypted__c = newCon.Email_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
            if (newCon.Phone != oldCon.Phone) {
                newCon.PhoneD__c = newCon.Phone;
                // PIPL Update 20220420 By Chen Yanan Start
                System.debug('PhoneD_Encrypted__c');
                newCon.PhoneD_Encrypted__c = newCon.Phone_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
            if (newCon.Title != oldCon.Title) {
                newCon.TitleD__c = newCon.Title;
                // PIPL Update 20220420 By Chen Yanan Start
                System.debug('TitleD_Encrypted__c');
                newCon.TitleD_Encrypted__c = newCon.Title_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
            if (newCon.Address1__c != oldCon.Address1__c) {
                newCon.Address1D__c = newCon.Address1__c;
                System.debug('Address1D_Encrypted__c');
                // PIPL Update 20220420 By Chen Yanan Start
                newCon.Address1D_Encrypted__c = newCon.Address1_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
            if (newCon.Address2__c != oldCon.Address2__c) {
                newCon.Address2D__c = newCon.Address2__c;
                System.debug('Address2D_Encrypted__c');
                // PIPL Update 20220420 By Chen Yanan Start
                newCon.Address2D_Encrypted__c = newCon.Address2_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
            if (newCon.Address3__c != oldCon.Address3__c) {
                newCon.Address3D__c = newCon.Address3__c;
                System.debug('Address3D_Encrypted__c');
                // PIPL Update 20220420 By Chen Yanan Start
                newCon.Address3D_Encrypted__c = newCon.Address3_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
            if (newCon.Postcode__c != oldCon.Postcode__c) {
                newCon.PostcodeD__c = newCon.Postcode__c;
                System.debug('PostcodeD_Encrypted__c');
                // PIPL Update 20220420 By Chen Yanan Start
                newCon.PostcodeD_Encrypted__c = newCon.Postcode_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            }
                
            if (newCon.ContactStatus__c != oldCon.ContactStatus__c) {
@@ -100,7 +154,10 @@
            if (newCon.CancelReason__c != oldCon.CancelReason__c) {
                newCon.CancelReasonD__c = newCon.CancelReason__c;
            }
            System.debug('updateForDealer newCon: ' + newCon);
        }
    }
    
    public static void dealerContactApproval(List<Contact> newList, Map<Id, Contact> newMap, List<Contact> oldList, Map<Id, Contact> oldMap) {
@@ -139,6 +196,18 @@
                
                newCon.ContactStatus__c = newCon.ContactStatusD__c;
                newCon.CancelReason__c = newCon.CancelReasonD__c;
                // PIPL Update 20220420 By Chen Yanan Start
                newCon.MobilePhone_Encrypted__c = newCon.MobilePhoneD_Encrypted__c;
                newCon.OtherPhone_Encrypted__c = newCon.OtherPhoneD_Encrypted__c;
                newCon.Fax_Encrypted__c = newCon.FaxD_Encrypted__c;
                newCon.Email_Encrypted__c = newCon.EmailD_Encrypted__c;
                newCon.Phone_Encrypted__c = newCon.PhoneD_Encrypted__c;
                newCon.Title_Encrypted__c = newCon.TitleD_Encrypted__c;
                newCon.Address1_Encrypted__c = newCon.Address1D_Encrypted__c;
                newCon.Address2_Encrypted__c = newCon.Address2D_Encrypted__c;
                newCon.Address3_Encrypted__c = newCon.Address3D_Encrypted__c;
                newCon.Postcode_Encrypted__c = newCon.PostcodeD_Encrypted__c;
                // PIPL Update 20220420 By Chen Yanan End
            } else if (newCon.StatusD__c != oldCon.StatusD__c) {
                if (newCon.StatusD__c == 'Submit') {
                    //newCon.DealerSelectOwner__c = newCon.Account.DealerSelectOwner__c;
@@ -167,6 +236,19 @@
                    
                    newCon.ContactStatus__c = newCon.ContactStatusD__c;
                    newCon.CancelReason__c = newCon.CancelReasonD__c;
                    // PIPL Update 20220420 By Chen Yanan Start
                    System.debug('Pass');
                    newCon.MobilePhone_Encrypted__c = newCon.MobilePhoneD_Encrypted__c;
                    newCon.OtherPhone_Encrypted__c = newCon.OtherPhoneD_Encrypted__c;
                    newCon.Fax_Encrypted__c = newCon.FaxD_Encrypted__c;
                    newCon.Email_Encrypted__c = newCon.EmailD_Encrypted__c;
                    newCon.Phone_Encrypted__c = newCon.PhoneD_Encrypted__c;
                    newCon.Title_Encrypted__c = newCon.TitleD_Encrypted__c;
                    newCon.Address1_Encrypted__c = newCon.Address1D_Encrypted__c;
                    newCon.Address2_Encrypted__c = newCon.Address2D_Encrypted__c;
                    newCon.Address3_Encrypted__c = newCon.Address3D_Encrypted__c;
                    newCon.Postcode_Encrypted__c = newCon.PostcodeD_Encrypted__c;
                    // PIPL Update 20220420 By Chen Yanan End
                    
//                  if (accsMap.containsKey(newCon.AccountId + '' + newCon.OwnerId) == true && newCon.IsNew__c == true) {
//                      AccountShare upd = new AccountShare(
@@ -194,7 +276,21 @@
                    
                    newCon.ContactStatusD__c = newCon.ContactStatus__c;
                    newCon.CancelReasonD__c = newCon.CancelReason__c;
                    // PIPL Update 20220420 By Chen Yanan Start
                    System.debug('Reject');
                    newCon.MobilePhoneD_Encrypted__c = newCon.MobilePhone_Encrypted__c;
                    newCon.OtherPhoneD_Encrypted__c = newCon.OtherPhone_Encrypted__c;
                    newCon.FaxD_Encrypted__c = newCon.Fax_Encrypted__c;
                    newCon.EmailD_Encrypted__c = newCon.Email_Encrypted__c;
                    newCon.PhoneD_Encrypted__c = newCon.Phone_Encrypted__c;
                    newCon.TitleD_Encrypted__c = newCon.Title_Encrypted__c;
                    newCon.Address1D_Encrypted__c = newCon.Address1_Encrypted__c;
                    newCon.Address2D_Encrypted__c = newCon.Address2_Encrypted__c;
                    newCon.Address3D_Encrypted__c = newCon.Address3_Encrypted__c;
                    newCon.PostcodeD_Encrypted__c = newCon.Postcode_Encrypted__c;
                    // PIPL Update 20220420 By Chen Yanan End
                }
            System.debug('dealerContactApproval newCon: ' + newCon);
            }
        }
        // 更新客户小组