From 5c31207724abdf323a9c0c37ecc3eb0b72d1ac4b Mon Sep 17 00:00:00 2001
From: yangjieke <yangjieke@prec-tech.com>
Date: 星期六, 02 四月 2022 14:28:50 +0800
Subject: [PATCH] SWAG-CCL6R7

---
 force-app/main/default/classes/NFM206Rest.cls               |    2 +-
 force-app/main/default/triggers/OpportunityBefUpd.trigger   |   11 +++++++++++
 force-app/main/default/classes/TenderInformationHandler.cls |   21 +++++++++++++++++++++
 force-app/main/default/classes/NFM202Controller.cls         |   12 ++++++++++++
 4 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/force-app/main/default/classes/NFM202Controller.cls b/force-app/main/default/classes/NFM202Controller.cls
index 0bf1180..8e4e6d0 100644
--- a/force-app/main/default/classes/NFM202Controller.cls
+++ b/force-app/main/default/classes/NFM202Controller.cls
@@ -69,6 +69,10 @@
         // CHAN-C9P5WM 20211216 ssm 澧炲姞绉戝鍚� start
         public String DepartmentName;
         // CHAN-C9P5WM 20211216 ssm 澧炲姞绉戝鍚� end
+
+        
+        public String winBiddingDate;//SWAG-CCL6R7 2022-3-22 yjk 澧炲姞涓爣鏃�
+
     }
 
     public class Detail_element {
@@ -221,6 +225,11 @@
                                           // CHAN-C9P5WM 20211216 ssm 澧炲姞绉戝鍚� start
                                           Department_Name__c,
                                           // CHAN-C9P5WM 20211216 ssm 澧炲姞绉戝鍚� end
+
+                                          //SWAG-CCL6R7 2022-3-22 yjk 澧炲姞涓爣鏃� start
+                                          Closing_Bid_Date_Bid__c,
+                                          Closing_Bid_Date__c,
+                                          //SWAG-CCL6R7 2022-3-22 yjk 澧炲姞涓爣鏃� end
                                           Account.RecordType.DeveloperName
 
                                     from  Opportunity
@@ -475,6 +484,9 @@
                     quotation.DepartmentName = opp.Department_Name__c;
                     // CHAN-C9P5WM 20211216 ssm 澧炲姞绉戝鍚� end
 
+                    //SWAG-CCL6R7 2022-3-22 yjk 澧炲姞涓爣鏃� start
+                    quotation.winBiddingDate = opp.Closing_Bid_Date_Bid__c ==null? NFMUtil.formatDate2Str(opp.Closing_Bid_Date__c) : NFMUtil.formatDate2Str(opp.Closing_Bid_Date_Bid__c);
+                    //SWAG-CCL6R7 2022-3-22 yjk 澧炲姞涓爣鏃� end
                     // 浜у搧
                     List<OpportunityLineItem> oppLineList = oppIDMap.get(opp.id);
                     quotation.Items = new List<Detail_element>();
diff --git a/force-app/main/default/classes/NFM206Rest.cls b/force-app/main/default/classes/NFM206Rest.cls
index 6cba549..2845e21 100644
--- a/force-app/main/default/classes/NFM206Rest.cls
+++ b/force-app/main/default/classes/NFM206Rest.cls
@@ -165,7 +165,7 @@
                     opportunityInfo.Contract_DB_request_reason__c = gda.Contract_DB_request_reason;
                     opportunityInfo.Contract_DB_complite_day__c = NFMUtil.parseStr2Date(gda.Contract_DB_complite_day);
                     opportunityInfo.Assistant_Applied_Date__c = NFMUtil.parseStr2Date(gda.Assistant_Applied_Date);
-                    opportunityInfo.Closing_Bid_Date__c  = NFMUtil.parseStr2Date(gda.Closing_Bid_Date);
+                    //opportunityInfo.Closing_Bid_Date__c  = NFMUtil.parseStr2Date(gda.Closing_Bid_Date); //SWAG-CCL6R7 2022-3-22 yjk 娉ㄩ噴鎺変腑鏍囨棩閫昏緫
                     opportunityInfo.Contract_DB_SalesDept_complite_day__c = NFMUtil.parseStr2Date(gda.Contract_DB_SalesDept_complite_day);
                     opportunityInfo.Contract_Invalid_Date__c = null;
                     opportunityInfo.Contract_Authorize_Lock__c = true;
diff --git a/force-app/main/default/classes/TenderInformationHandler.cls b/force-app/main/default/classes/TenderInformationHandler.cls
index 4f8fe52..17de6fe 100644
--- a/force-app/main/default/classes/TenderInformationHandler.cls
+++ b/force-app/main/default/classes/TenderInformationHandler.cls
@@ -46,6 +46,7 @@
         if (!StaticParameter.EscapeOtherUpdateTenOwner) {
             updateTenOwner();
         }
+                
     }
 
     protected override void afterInsert() {
@@ -58,6 +59,26 @@
         addShare();
         sednMessage();
         updateWin();
+
+        //2022-3-29 yjk SWAG-CCL6R7
+        updateOpportunity();
+    }
+
+
+    //2022-3-29 yjk SWAG-CCL6R7
+    private void updateOpportunity(){
+        for(Tender_information__c newOne : newList){
+            Tender_information__c oldOne = oldMap.get(newOne.id);
+            if(oldOne.ResultDate__c == null && newOne.ResultDate__c != null){
+                List<Opportunity> oppList = [select id,Closing_Bid_Date__c  from Opportunity where Bidding_Project_Name_Bid__c = :newOne.id];
+                if(oppList.size() > 0){
+                    for(Opportunity opp : oppList){
+                        opp.Closing_Bid_Date__c = newOne.ResultDate__c;
+                    }
+                    update oppList;
+                }
+            }
+        }
     }
 
     public void sednMessage() {
diff --git a/force-app/main/default/triggers/OpportunityBefUpd.trigger b/force-app/main/default/triggers/OpportunityBefUpd.trigger
index 51c22ea..61b4720 100644
--- a/force-app/main/default/triggers/OpportunityBefUpd.trigger
+++ b/force-app/main/default/triggers/OpportunityBefUpd.trigger
@@ -2,8 +2,10 @@
  * Opportunity浣滄垚寰�(銈炽償銉�)銆乼rigger銇仸闆嗚▓闋呯洰銈抧ull銇仚銈�
  * 鍟嗚珖銇�屽璨�/鍐呰部銆嶃仺銆岄�氳波銆嶃伄鍊ゃ亴涓�鑷淬仌銇涖倠銉堛儶銈兗銇с仚銆�
  * 鍟嗚珖銇墍鏈夎�呫�愩偡銈广儐銉犮�戙伀鎵�鏈夎�呫伄Id銈掑叆銈屻倠
+ * OpportunityBefInsUpdTriggerTest
  */
 trigger OpportunityBefUpd on Opportunity (before insert, before update) {
+
     List<String> idlist = new List<String>();
     if(Trigger.isInsert){
         //璇环鎷呭綋浜哄拰鎴樼暐绉戝鎷呭綋浜轰笉涓�鑷�,鍦ㄨ繖閲屽悓姝� 20170512 XFUU-ALB9JK
@@ -50,6 +52,15 @@
             //if(ops.State_Owner__c == '鑳介噺') ops.STMS_Package_Sale__c = true;
             // opIds.add(ops.Id);
             // acs.add(ops.)
+
+            //2022-3-29 yjk SWAG-CCL6R7
+            Opportunity oldOne = Trigger.oldMap.get(ops.id);
+            if(oldOne.Bidding_Project_Name_Bid__c==null  && ops.Bidding_Project_Name_Bid__c !=null ){
+                List<Tender_information__c> ticList = [select id,ResultDate__c from Tender_information__c where id = :ops.Bidding_Project_Name_Bid__c];
+                
+                ops.Closing_Bid_Date__c = ticList.size() == 1? ticList.get(0).ResultDate__c : null ;
+
+            }
         }
         // System.debug('====================='+opIds);
         // //鍦ㄨ浠疯Е鍙戝櫒閲屾敼杩欎釜楠岃瘉锛屾帓闄ゅ鍝佺姸鎬佹槸鍙栨秷鐨勶紝鍙鏄湁澶囧搧锛屽氨涓嶅厑璁告洿鏀规渶缁堢敤鎴枫��

--
Gitblit v1.9.1