From b54f1c796595671bd753a9161eccad074d444273 Mon Sep 17 00:00:00 2001
From: 李彤 <litong@prec-tech.com>
Date: 星期三, 16 三月 2022 17:45:36 +0800
Subject: [PATCH] 询价失单预留产品无效

---
 force-app/main/default/classes/OpportunityTrigger.cls |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/OpportunityTrigger.cls b/force-app/main/default/classes/OpportunityTrigger.cls
index c0dc0bc..15de464 100644
--- a/force-app/main/default/classes/OpportunityTrigger.cls
+++ b/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
+
 }
\ No newline at end of file

--
Gitblit v1.9.1