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 +++++++++++++++++
force-app/main/default/classes/OpportunityTriggerTest.cls | 47 +++++++++++++++++++----
force-app/main/default/triggers/OpportunityTrigger.trigger | 4 ++
3 files changed, 77 insertions(+), 8 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
diff --git a/force-app/main/default/classes/OpportunityTriggerTest.cls b/force-app/main/default/classes/OpportunityTriggerTest.cls
index 71058a8..0131d31 100644
--- a/force-app/main/default/classes/OpportunityTriggerTest.cls
+++ b/force-app/main/default/classes/OpportunityTriggerTest.cls
@@ -324,13 +324,15 @@
opp1.NotesApprovedNo__c = '123';
update opp1;
- //鎷涙爣椤圭洰
- Tender_information__c te1 = new Tender_information__c();
- te1.Name = 'TestZhaoBiao';
- insert te1;
- opp1.Bidding_Project_Name_Bid__c = te1.Id;
- update opp1;
+ //lt 娉ㄩ噴鎺� te1
+ // //鎷涙爣椤圭洰
+ // Tender_information__c te1 = new Tender_information__c();
+ // te1.Name = 'TestZhaoBiao';
+ // insert te1;
+
+ // opp1.Bidding_Project_Name_Bid__c = te1.Id;
+ // update opp1;
//澶卞崟
opp1.StageName = '鏁楁垿';
@@ -347,8 +349,8 @@
AccountId = depart.Id,
Closing_Bid_Date__c = Date.today().addDays(-5),
Hospital__c = company.Id,
- Competitor__c = 'A',
- Bidding_Project_Name_Bid__c = te1.Id
+ Competitor__c = 'A'
+ //,Bidding_Project_Name_Bid__c = te1.Id //lt 20220316
);
insert opp2;
@@ -358,4 +360,33 @@
}
//2021-05-13 mzy QLM
+ //LastBuy 棰勭暀浜у搧 lt 20220315 start
+ @isTest
+ static void TestMethod1() {
+
+ Opportunity opp = new Opportunity();
+ opp.Name = 'GZ-SP-NFM007_1';
+ opp.StageName = '寮曞悎';
+ opp.CloseDate = date.newinstance(2022, 11, 30);
+ insert opp;
+
+
+ Product2 pro = new Product2();
+ pro.Name = 'Testname0316';
+ pro.LastbuyProductFLG__c = false;
+ insert pro;
+
+ LastbuyProduct__c lbp = new LastbuyProduct__c();
+ lbp.Name = 'Test0215';
+ lbp.ProductName__c = pro.Id;
+ lbp.InquiryCode__c = opp.Id;
+ lbp.effectiveFLG__c = true;
+ insert lbp;
+
+ opp.StageName = '鏁楁垿';
+ update opp;
+
+ }
+ //LastBuy 棰勭暀浜у搧 lt 20220315 end
+
}
\ No newline at end of file
diff --git a/force-app/main/default/triggers/OpportunityTrigger.trigger b/force-app/main/default/triggers/OpportunityTrigger.trigger
index ebe4fda..b9400d4 100644
--- a/force-app/main/default/triggers/OpportunityTrigger.trigger
+++ b/force-app/main/default/triggers/OpportunityTrigger.trigger
@@ -4,6 +4,10 @@
// CHAN-AYTCE6 璇环椤甸潰涓殑缁忛攢鍟�1鍙樻洿鍚庢洿鏂版姤浠蜂腑缁忛攢鍟�1 2018/5/25 start
OpportunityTrigger.changeQuoteAgency1(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
// CHAN-AYTCE6 璇环椤甸潰涓殑缁忛攢鍟�1鍙樻洿鍚庢洿鏂版姤浠蜂腑缁忛攢鍟�1 2018/5/25 end
+
+ //LastBuy 棰勭暀浜у搧 lt 20220315 start
+ OpportunityTrigger.ReservedProFlg(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
+ //LastBuy 棰勭暀浜у搧 lt 20220315 end
}
if (Trigger.isBefore && Trigger.isUpdate) {
OpportunityTrigger.changeConsumableOrderStatus(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
--
Gitblit v1.9.1