付煜
2022-03-25 8ea597d3c67631cd702415d43bc3d2961f6bc94d
force-app/main/default/classes/OpportunityTrigger.cls
@@ -38,6 +38,20 @@
            if (newOpp.SAP_Send_OK__c != oldOpp.SAP_Send_OK__c && newOpp.SAP_Send_OK__c == false ) {
                if (String.isNotBlank(newOpp.Estimation_Id__c) && newOpp.Estimation_Id__c.StartsWith('a2K'))newOpp.StageName = '削除';
                if (String.isNotBlank(newOpp.Opportunity_No__c)) orderIds.add(newOpp.Opportunity_No__c);
                //lastbuy  2022/2/9 fy start
                List<LastbuyProduct__c> upLastbuyObjList = new List<LastbuyProduct__c>();
                List<LastbuyProduct__c> LastbuyObjList=[select id,LastbuyQuantity__c,InquiryCode__c,ProductName__c,effectiveFLG__c from LastbuyProduct__c where InquiryCode__c= : newOpp.Id];
                if(LastbuyObjList!=null){
                    for(LastbuyProduct__c lastbuypr :LastbuyObjList){
                        lastbuypr.ActualQuantity__c=0;
                        lastbuypr.effectiveFLG__c=true;
                        upLastbuyObjList.add(lastbuypr);
                    }
                }
                if(upLastbuyObjList!=null){
                    upsert upLastbuyObjList;
                }
                //lastbuy  2022/2/9 fy end
            }
        }
@@ -246,4 +260,89 @@
        }
    } 
    // 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;
        }
    }
    public static void intI(){
        Integer i=0;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
    }
        //LastBuy 预留产品 lt 20220315 end
}