From 928399eceec50e3d37ea08669a12789a9410a9d2 Mon Sep 17 00:00:00 2001
From: 沙世明 <shashiming@prec-tech.com>
Date: 星期二, 22 十一月 2022 16:51:16 +0800
Subject: [PATCH] 111

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

diff --git a/force-app/main/default/classes/OpportunityTrigger.cls b/force-app/main/default/classes/OpportunityTrigger.cls
index 0685657..e9ab71d 100644
--- a/force-app/main/default/classes/OpportunityTrigger.cls
+++ b/force-app/main/default/classes/OpportunityTrigger.cls
@@ -184,6 +184,24 @@
                     }
                 }
 
+                //20221017  lt SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 start
+                System.debug('lt123 oly涓绘満'+op.OlyNumberHosts__c);
+                System.debug('lt123 鑰乷ly涓绘満'+oldopp.OlyNumberHosts__c);
+                System.debug('lt123 瀵规墜涓绘満'+op.RivalHostsNumber__c);
+                System.debug('lt123 鑰佸鎵嬩富鏈�'+oldopp.RivalHostsNumber__c);
+
+                if(op.OlyNumberHosts__c != oldopp.OlyNumberHosts__c || op.RivalHostsNumber__c != oldopp.RivalHostsNumber__c || op.InquireNumberHosts__c != oldopp.InquireNumberHosts__c){
+                    for (Tender_Opportunity_Link__c link : links){
+                        if (link.Opportunity__c == op.Id){
+                            Tender_information__c temptender = new Tender_information__c();
+                            temptender.Id = link.Tender_information__c;
+                            temptender.IsReactionOpp__c = true;
+                            tenderMap.put(temptender.id ,temptender); 
+                        }
+                    }
+                }
+                //20221017  lt SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 end
+
             // }else {
             //     //鏂板缓鏃跺垽鏂浠风殑鎷涙爣椤圭洰鏄笉鏄粠鏃犲埌鏈�
             //     if(String.isNotBlank(op.Bidding_Project_Name_Bid__c) ){
@@ -366,13 +384,39 @@
         }
 
         Set<Id> oppoIds = new Set<Id>();
+        Map<Id,String> mapoppid = new Map<Id,String>();
+        list<task__c> taskUpdateList = new list<task__c>();
         for(Opportunity op : newList){
             Opportunity oldopp =  oldMap.get(op.Id);
             //璇环涓爣缁撴灉纭绔炰簤瀵规墜涓爣鏃跺疄鏃跺垱寤哄け鍗曚换鍔� 涓� 璇环鐘舵��1绛変簬璇环
-            if (oldopp.ConfirmationofAward__c != '绔炰簤瀵规墜涓爣' && op.ConfirmationofAward__c == '绔炰簤瀵规墜涓爣' && op.StageName__c == '璇环'){
+            if (oldopp.ConfirmationofAward__c != '绔炰簤瀵规墜涓爣' && op.ConfirmationofAward__c == '绔炰簤瀵规墜涓爣' && op.StageName__c == '璇环' && op.LeakageNumber__c !=1){
                 oppoIds.add(op.Id);
             }
+            //20220929 you  SWAG-CJP7TL 鎵嬪姩鏇存敼璇环鎵�鏈変汉锛屽悓姝ヤ慨鏀逛换鍔℃墍鏈変汉
+            if(String.isNotBlank(op.OwnerId) && op.OwnerId !=oldopp.OwnerId){
+                 mapoppid.put(op.id,op.OwnerId);
+            }
         }
+        if(mapoppid.size() > 0){
+            List<Task__c> taskList = [
+                    SELECT Id,OpportunityId__c,taskStatus__c 
+                    FROM task__c 
+                    WHERE OpportunityId__c in :mapoppid.keySet()
+                    AND (RecordType.Name = '涓爣缁撴灉纭' OR RecordType.Name = '澶卞崟鎶ュ憡浠诲姟')
+                    AND taskStatus__c = '02 鎺ュ彈'];
+            system.debug(mapoppid.keySet()+'test1-----'+taskList);
+            for(Task__c t: taskList){
+                if(mapoppid.containsKey(t.OpportunityId__c)){
+                   t.Ownerid = mapoppid.get(t.OpportunityId__c);
+                   t.assignee__c = mapoppid.get(t.OpportunityId__c);
+                   taskUpdateList.add(t);
+                }
+                           
+            }
+             if (taskUpdateList != null && taskUpdateList.size() > 0) {
+                update taskUpdateList;
+            }
+        }    
 
         if (!oppoIds.isEmpty()) {
             // 鏈夋晥澶卞崟鐘舵�佷竴瑙�
@@ -472,20 +516,23 @@
 
         if(!oppoIds.isEmpty()){
 
-            list<Tender_Opportunity_Link__c> toppLinkList = [Select Id, Opportunity__c, Tender_information__c,Tender_information__r.ResultDate__c FROM Tender_Opportunity_Link__c WHERE Opportunity__c in :oppoIds];
+            list<Tender_Opportunity_Link__c> toppLinkList = [Select Id, Opportunity__c, Tender_information__c,Tender_information__r.ResultDate__c,Tender_information__r.InfoType__c FROM Tender_Opportunity_Link__c WHERE Opportunity__c in :oppoIds and Tender_information__r.InfoType__c = '3锛氱粨鏋�'];
             Map<String, Tender_Opportunity_Link__c> toopLinkMap = new Map<String, Tender_Opportunity_Link__c>();
             
             for(Tender_Opportunity_Link__c tol : toppLinkList){
-                toopLinkMap.put(tol.Opportunity__c, tol);
+                Opportunity oppoTemp = newMap.get(tol.Opportunity__c);
+                //璇环鍏宠仈鍒版嫑鏍囬」鐩墠杩涜鎿嶄綔
+                if(oppoTemp.Bidding_Project_Name_Bid__c == tol.Tender_information__c){
+                    toopLinkMap.put(tol.Opportunity__c, tol);
+                }
+                
             }
             
             for (String key : toopLinkMap.keySet()) {
                 Opportunity oppoTemp = newMap.get(key);
-
                 //20220628浼氳鏂伴渶姹�  OLY涓爣 7.涓爣鏃ワ紙缁撴灉璁板綍鏃ワ級= 鎷涙爣椤圭洰.缁撴灉璁板綍鏃�
                 oppoTemp.Closing_Bid_Date__c = toopLinkMap.get(key).Tender_information__r.ResultDate__c;
                 System.debug('============'+toopLinkMap.get(key).Tender_information__r.ResultDate__c);
-
                 
                 //鏄惁鎸夋椂纭锛�3涓伐浣滄棩鍐呮寜鏃�1锛屼笉鎸夋椂0
                 //String inttemp = CalendarUtil.getWorkDayNum(String.valueOf(oppoTemp.Task_createTime__c), String.valueOf(oppoTemp.ConfirmationofAward_createTime__c));
@@ -633,6 +680,68 @@
         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++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
 
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1