沙世明
2022-09-13 bfca7a84bec815da594f1d12558535ed06d2490b
force-app/main/default/classes/ContactTriggerHandler.cls
@@ -6,6 +6,8 @@
    private Map < Id, Contact > oldMap;
    private List < Contact > newList;
    private List < Contact > oldList;
    private Id AgencyId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); // 20220830 ljh LLIU-CHR8FF add
    public ContactTriggerHandler() {
        this.newMap = (Map < Id, Contact > ) Trigger.newMap;
        this.oldMap = (Map < Id, Contact > ) Trigger.oldMap;
@@ -22,6 +24,7 @@
        syncToAgencyContact();
        updateDealerNum();
        sendToComPlat();
        updateChargeState();// 20220830 ljh LLIU-CHR8FF
    }
    protected override void afterUpdate() {
@@ -430,7 +433,7 @@
                        || old.ServicePlatformCode__c != local.ServicePlatformCode__c//服务平台编码
                        || old.UnifiedI_Contact_ID__c != local.UnifiedI_Contact_ID__c//智慧医疗编码
                        || old.ContactType__c != local.ContactType__c//人员类型
                        || (old.ChargeState__c != local.ChargeState__c && local.RecordTypeId == AgencyId)//负责省 // 20220830 ljh LLIU-CHR8FF add
                        ) {
                //获取客户人员的记录类型ID thh 20220330 start
                ID InternalStaffRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Internal_staff').getRecordTypeId();
@@ -439,7 +442,10 @@
                //获取客户人员的记录类型ID thh 20220330 end
                System.debug('local.UnifiedI_Contact_ID__c1:' + local.UnifiedI_Contact_ID__c);
                System.debug('local.MobilePhone1:' + local.MobilePhone);
                if (!local.IsFromSPO__c && !InternalStaffRecordTypeId.equals(local.RecordTypeId)) {
                // gzw 20220824 bugfix start
                // if (!local.IsFromSPO__c && !InternalStaffRecordTypeId.equals(local.RecordTypeId)) {
                if (!InternalStaffRecordTypeId.equals(local.RecordTypeId)) {
                // gzw 20220824 bugfix end
                    // 医院 客户人员 统一平台编码有值 发送 PO
                    if (DoctorRecordTypeId.equals(local.RecordTypeId) && String.isNotBlank(local.UnifiedI_Contact_ID__c)) {
                        if (!NFM606_IdMap.containsKey(local.Id)) {
@@ -490,5 +496,21 @@
        } 
    }
    // 606接口调用问题修复 thh 20220330 end
    // 20220830 ljh LLIU-CHR8FF add start
    private void updateChargeState(){
        List<Contact> contactL = new List<Contact>();
        for (Contact nObj : newList) {
            if(nObj.RecordTypeId == AgencyId && String.isBlank(nObj.ChargeState__c)){
                Contact cnew = new Contact();
                cnew.Id = nObj.Id;
                cnew.ChargeState__c =  nObj.ChargeState_F__c;
                contactL.add(cnew);
            }
        }
        if (!contactL.isEmpty()) {
            update contactL;
        }
    }
    // 20220830 ljh LLIU-CHR8FF add end
}