高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public with sharing class updateTenDeleteBackHandler extends Oly_TriggerHandler {
    private Map<Id, Tender_information__c> newMap;
    private Map<Id, Tender_information__c> oldMap;
    private List<Tender_information__c> newList;
    private List<Tender_information__c> oldList;
    public updateTenDeleteBackHandler() {
        this.newMap = (Map<Id, Tender_information__c>) Trigger.newMap;
        this.oldMap = (Map<Id, Tender_information__c>) Trigger.oldMap;
        this.newList = (List<Tender_information__c>) Trigger.new;
        this.oldList = (List<Tender_information__c>) Trigger.old;
    }
    protected override void beforeUpdate() {
        updateTenDel();
    }
 
    private void updateTenDel() {
        List<Tender_information__c> updateTenList = new List<Tender_information__c>();
        for (Tender_information__c TenoldInfo : newList) {
            if(TenoldInfo.Logical_delete__c == false && (TenoldInfo.Logical_delete__c != oldMap.get(TenoldInfo.Id).Logical_delete__c)){
                TenoldInfo.Retain_Tender__c = null;
            }
            if(TenoldInfo.Retain_Tender__c == null && (TenoldInfo.Retain_Tender__c != oldMap.get(TenoldInfo.Id).Retain_Tender__c)){
                TenoldInfo.Logical_delete__c = false;
            }
            // updateTenList.add(TenoldInfo);
        }
        // if(updateTenList.size()>0){
        //     update updateTenList;
        // }
    }
}