李彤
2022-03-16 b54f1c796595671bd753a9161eccad074d444273
force-app/main/default/classes/OpportunityTrigger.cls
@@ -260,4 +260,38 @@
        }
    } 
    // SWAG-C7P4XB end
    //LastBuy 预留产品 lt 20220315 start
    //询价失单或取消时,预留产品的"是否有效"设置为否
    public static void ReservedProFlg(List<Opportunity> newList, Map<Id, Opportunity> newMap, List<Opportunity> oldList, Map<Id, Opportunity> oldMap){
        List<Id> oppList = new List<Id>();
        List<LastbuyProduct__c> lbpflgList = new List<LastbuyProduct__c>();
        for (Opportunity lbOpp : newList){
            Opportunity OldLbOpp = oldMap.get(lbOpp.Id);
            if(OldLbOpp.StageName != lbOpp.StageName){
                if(lbOpp.StageName == '敗戦' || lbOpp.StageName == '削除'){
                    oppList.add(lbOpp.Id);
                }
            }
        }
        if(oppList.size() > 0){
            List<LastbuyProduct__c> lbpList = [select id, effectiveFLG__c,InquiryCode__c from LastbuyProduct__c where InquiryCode__c in :oppList];
            if(lbpList.size() > 0){
                for(LastbuyProduct__c lbp : lbpList){
                    if(lbp.effectiveFLG__c == true){
                        lbp.effectiveFLG__c = false;
                        lbpflgList.add(lbp);
                    }
                }
            }
        }
        if(lbpflgList.size() > 0){
            update lbpflgList;
        }
    }
    //LastBuy 预留产品 lt 20220315 end
}