沙世明
2022-09-13 bfca7a84bec815da594f1d12558535ed06d2490b
force-app/main/default/triggers/AccountTrigger.trigger
@@ -2,10 +2,7 @@
 * 客户同步 在SP、GI主担当变化时更新询价权限
 */
trigger AccountTrigger on Account (after insert, after update, before delete, before insert, before update, after delete ) {
    if (StaticParameter.EscapeAccountTrigger) {
System.debug('Escape、EscapeAccountTrigger:::::' + StaticParameter.EscapeAccountTrigger);
        return;
    }
    if ((Trigger.isAfter && Trigger.isInsert) || (Trigger.isAfter && Trigger.isUpdate) || (Trigger.isBefore && Trigger.isDelete)) {
        // 同步到 Account2__c
        AccountTrigger.syncAccount2(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
@@ -130,27 +127,32 @@
            }
        }
        //HWAG-B4PCZ5 2018-09-19 end 
        if (StaticParameter.EscapeAccountTrigger) {
            System.debug('Escape、EscapeAccountTrigger:::::' + StaticParameter.EscapeAccountTrigger);
            return;
        }
        //NFM112 2021/11/10 start
        String Idbox;
        List<String> IdList = new List<String>();
        for(Account account : Trigger.new){
           Account old = Trigger.oldMap.get(account.Id);
           if(old.FirstParagraph__c != account.FirstParagraph__c  || old.MonthlyPayment__c != account.MonthlyPayment__c){
                    Idbox = account.Id;
                IdList.add(account.Id);
            }
        }
        if(Idbox != null){
            BatchIF_Log__c iflog = new BatchIF_Log__c();
            iflog.Type__c = 'NFM112';
            iflog.Log__c  = 'callout start\n';
            insert iflog;
            iflog = [Select Id, Name from BatchIF_Log__c where Id = :iflog.Id];
            System.debug(Logginglevel.DEBUG, 'NFM112_' + iflog.Name + ' start');
            NFM112Controller.executeNotFuture(iflog.Id, Idbox);
        if(IdList.size()>0){
            for(String Id : IdList){
                BatchIF_Log__c iflog = new BatchIF_Log__c();
                iflog.Type__c = 'NFM112';
                iflog.Log__c  = 'callout start\n';
                insert iflog;
                //iflog = [Select Id, Name from BatchIF_Log__c where Id = :iflog.Id];
                //System.debug(Logginglevel.DEBUG, 'NFM112_' + iflog.Name + ' start');
                NFM112Controller.executeNotFuture(iflog.Id, Id);
            }
        }
        //NFM112 2021/11/10 end
    }
    //add            wangweipeng              2022/02/10                            start
 //add            wangweipeng              2022/02/10                            start
    //经销商的性质发生变化,那么需要发邮件,其中一个收件人为大区助理
    //大区助理:根据此经销商所在的那个大区,来判断到底发给谁,每个大区助理都有一个人,目前是存到自定义源数据里面了
    if(Trigger.isBefore){