From e17750829bfb841dcb4e55a93bd0860df6efbb55 Mon Sep 17 00:00:00 2001
From: 李彤 <litong@prec-tech.com>
Date: 星期五, 24 三月 2023 10:22:56 +0800
Subject: [PATCH] 失单退询价

---
 force-app/main/default/classes/LostCancelReportHandler.cls |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/force-app/main/default/classes/LostCancelReportHandler.cls b/force-app/main/default/classes/LostCancelReportHandler.cls
index a864cd5..ebce451 100644
--- a/force-app/main/default/classes/LostCancelReportHandler.cls
+++ b/force-app/main/default/classes/LostCancelReportHandler.cls
@@ -239,7 +239,6 @@
             // for浜у搧
             for (PCLLostProduct__c lcr : lcrList) {
                 if (opp.Id==lcr.Opportunity__c) {
-
                     //20220930  lt SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 start
                     if(lcr.ProductClass__c == '涓绘満'){
                         opp.RivalHostsNumber__c += lcr.Quantity__c;
@@ -326,12 +325,13 @@
                     opp.of_lost_system_processor__c=lcr.PCLLostBrand__r.Lost_cancel_report__r.of_lost_system_processor__c;
                 }
             }
-            //20230215 lt DB202302247719 start
+            //20230215 lt DB202302247719 start 
             if(arrMap.get(lcro).TotalAmountLost__c != null){
                 if(opp.LostPrices__c == null){
                     opp.LostPrices__c = 0;
                 }
                 opp.LostPrices__c+=arrMap.get(lcro).TotalAmountLost__c;
+                // System.debug('lt123---opp.LostPrices__c---澶卞崟閲戦2锛� '+opp.LostPrices__c);
             }
             //20230215 lt DB202302247719 end
 
@@ -345,7 +345,6 @@
             oppList.add(opp);
         }
         update oppList;
-
     }
     // tcm 20211126 鏇存柊璇环淇℃伅 end
 
@@ -404,13 +403,31 @@
         }
         System.debug('oppIds: ' + oppIds);
         if (oppIds.size() > 0) {
-            List<Opportunity> opps = [select Id, StageName, Final_Contract_Proceeded_Date__c, Lost_Opportunity_Date__c from Opportunity where Id in :oppIds and StageName in ('鏁楁垿', '鍓婇櫎')];
-            System.debug('opps: ' + opps);
+            //DB202303237846 lt 20230316 add   , Lost_Cancel_Report__c,Lost_Cancel_Report__r.Report_Status__c,Lost_Cancel_Report__r.LostType__c
+            List<Opportunity> opps = [select Id, StageName, Final_Contract_Proceeded_Date__c, Lost_Opportunity_Date__c, Lost_Cancel_Report__c,Lost_Cancel_Report__r.Report_Status__c,Lost_Cancel_Report__r.LostType__c from Opportunity where Id in :oppIds and StageName in ('鏁楁垿', '鍓婇櫎')];
+            System.debug('opps: ' + opps); 
+            //DB202303237846 lt 20230316 start 
+            Set<String> oppSet = new Set<String>();
+            List<Lost_Cancel_Report__c> oppreps = [select Id, Report_Status__c, LostType__c, Opportunity__c from Lost_Cancel_Report__c where Opportunity__c in :opps and Report_Status__c='鎵瑰噯' and LostType__c = '澶卞崟'];
+            if(oppreps.Size() > 0){
+                for(Lost_Cancel_Report__c lcp : oppreps){
+                    oppSet.add(lcp.Opportunity__c);
+                }
+            }
             if (opps.size() > 0) {
                 for (Opportunity opp : opps) {
-                    opp.StageName = '寮曞悎';
-                    opp.Final_Contract_Proceeded_Date__c = null;
-                    opp.Lost_Opportunity_Date__c = null;
+                    if(oppSet.size() > 0 && oppSet.contains(opp.Id)){
+                        continue;
+                   }else{
+                        opp.StageName = '寮曞悎';
+                        opp.Final_Contract_Proceeded_Date__c = null;
+                        opp.Lost_Opportunity_Date__c = null;
+                   }
+                   
+                    // if(opp.Lost_Cancel_Report__c == null || (opp.Lost_Cancel_Report__c != null && (opp.Lost_Cancel_Report__r.Report_Status__c != '鎵瑰噯' || opp.Lost_Cancel_Report__r.LostType__c != '澶卞崟'))){
+                        
+                    // }
+            //DB202303237846 lt 20230316 end
                 }
                 update opps;
             }

--
Gitblit v1.9.1