From ea6a4eec81a6a74e214aefc5971d701242c3e7d3 Mon Sep 17 00:00:00 2001
From: Thhto <997058689@qq.com>
Date: 星期四, 17 十一月 2022 14:40:04 +0800
Subject: [PATCH]  SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy

---
 force-app/main/default/classes/NewQuoteEntryController.cls |  267 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 227 insertions(+), 40 deletions(-)

diff --git a/force-app/main/default/classes/NewQuoteEntryController.cls b/force-app/main/default/classes/NewQuoteEntryController.cls
index 0994ce1..0d9face 100644
--- a/force-app/main/default/classes/NewQuoteEntryController.cls
+++ b/force-app/main/default/classes/NewQuoteEntryController.cls
@@ -220,6 +220,12 @@
                //銆愭槸鍚﹂渶瑕佷环鏍肩敵璇枫�� thh start
                If_Need_PriceApply__c
                //銆愭槸鍚﹂渶瑕佷环鏍肩敵璇枫�� thh end
+               // Celon璇环淇敼 2022-04-24 ssm start
+               ,CelonOpportunity__c 
+               // Celon璇环淇敼 2022-04-24 ssm end
+               // lastbuy鍒ゆ柇鍙樻洿鐢ㄦ埛璇环 start
+               , If_Account_Change__c 
+               // lastbuy鍒ゆ柇鍙樻洿鐢ㄦ埛璇环 end
                FROM Opportunity Where Id = :oppId];
     // 澶氬勾淇濅慨 start
     trade = '澶栬部';
@@ -362,8 +368,8 @@
       }
     } else {
       //娣诲姞琛�
-      List<Quote> quoList =
-        [ SELECT Id, Name, Cancel_Decide__c, CreatedDate, PriceRefreshDate__c, Quote_Print_Date__c,
+      List<Quote> quoList =//SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy start QuotationChange__c,MainEngineWithoutMonitor__c,Interdepartmental__c,
+        [ SELECT Id, Name, Cancel_Decide__c, CreatedDate, PriceRefreshDate__c, Quote_Print_Date__c,QuotationChange__c,MainEngineWithoutMonitor__c,Interdepartmental__c,
           Dealer_Final_Price__c, TotalPrice__c, Estimation_List_Price__c, QuoteNumber,
           QuoteToName, Quote_Expiration_Date__c, Quote_Comment__c, Stocking_Price__c, Unit_Price__c,
           Offer_Amount__c, TOTAL__c, Discount__c, Pricing__c, Preferential_Trading_Price__c, Contract__c,
@@ -442,6 +448,7 @@
         }
         if (copyQuoId == null) {
           quo = quoList[0];
+          
           quo.QuoteName__c = quo.Name;
           // 澶氬勾淇濅慨 start
           quoteGurantee_Period = quo.Gurantee_Period__c;
@@ -813,10 +820,13 @@
     // CHAN-AVG3PW 璇环鎶ヤ环鐢婚潰瑙勫垯鍙樻洿
     Datetime cDate = quo.CreatedDate;
     over3month = cDate != null && cDate.date().addMonths(3) < Date.today();
-
+//SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy start
+quo.Offer_Amount__c = true;
+quo.TOTAL__c = true;
+quo.Preferential_Gurantee_Period__c = true;
+//SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy end
     return null;
   }
-
 
   //Search Events============================================================
   // TODO ManualEntry銇ㄥ悓妲樸�乯s銇仸瑙f焙銇с亶銈嬨�併亾銇撱仹webservice銇犮亼銈掑疅瑁呫�佷粖寰� by katsu
@@ -1254,6 +1264,8 @@
     for (QELine t : tmpactivities) {
       if (i == j) {
         Map<String, Product2> mpProduct2 = new Map<String, Product2>();                     // key銇孭roductCode銇с仚銆�
+        // Celon璇环淇敼 20220513 ssm start
+        String celon_type = String.isNotBlank(oppInfo.CelonOpportunity) ? oppInfo.CelonOpportunity : null;
         List<Product2> items = [select Id, Name, ProductCode,
                                 Foreign_Trade_Cost_US__c, Foreign_Trade_List_US__c, Intra_Trade_Cost_RMB__c, Intra_Trade_List_RMB__c,
                                 //CHAN-BKU3XH 妫�鏌ユ槸鍚﹀瓨鍦ㄤ笉鏄悓涓�涓緵閿�鍟嗗悕绉� 绮剧悽鎶�鏈� 2020/02/17 Start 澧炲姞瀛楁
@@ -1286,6 +1298,9 @@
                               //SFDC鍋滄棰勮 lt 20211009 end
 
                                 FROM Product2 Where ProductCode In :codelist
+                                // Celon璇环
+                                And Celon_Product__c = :celon_type 
+                                // Celon璇环
                                 And Manual_Entry__c = false];
         for (Product2 prd : items) {
           system.debug('prd.ProductCode:::::' + prd.ProductCode);
@@ -1542,6 +1557,22 @@
       errorMessagechack = null;
       Savepoint sp = Database.setSavepoint();
       try {
+        // 2022-04-19 钀ヤ笟閮ㄩ棬闇�姹� 娌℃湁琛岄」鐩笉鑳戒繚瀛� ssm start
+        if (activities != null && activities.size() > 0) {
+          QELine line1 = activities[0];
+          // System.debug('Save() line1: ' + line1);
+          // System.debug('line1 != null: ' + (line1 != null));
+          // System.debug('line1.pageObject.PricebookEntryId != null: ' + (line1.pageObject.PricebookEntryId != null));
+          // System.debug('isNotBlank(line1.pageObject.PricebookEntryId): ' + (String.isNotBlank(line1.pageObject.PricebookEntryId)));
+          // System.debug('Save() line1 flag: ' + (!(line1 != null && String.isNotBlank(line1.pageObject.PricebookEntryId))));
+          if (!(line1 != null && String.isNotBlank(line1.pageObject.PricebookEntryId))) {
+            errorflg = true;
+            errorMessage = '涓嶅厑璁镐繚瀛樼┖鐨勬姤浠峰崟锛岃閫夋嫨浜у搧';
+            return null;
+          }
+        }
+        // 2022-04-19 ssm end
+        
         // CHAN-AVG3PW 璇环鎶ヤ环鐢婚潰瑙勫垯鍙樻洿
         // 鎶ヤ环鍒涘缓鏃ヨ秴杩囦笁涓湀鏃讹紝鐐逛繚瀛樻椂寮哄埗鏇存柊
         // CHAN-AZG864 涓嶇鍦ㄤ笉鍦ㄦ姤浠锋湁鏁堟湡鍐咃紝CFDA涓嶅彲閿�鍞殑鏃跺�欙紝閮芥槸鎶ラ敊鐨勶紝鍏朵腑涓嶅彲閿�鍞骇鍝佹樉绀虹孩瀛楋紝涓嶅簲璇ヤ繚瀛樸��
@@ -1555,7 +1586,6 @@
           errormessage = '璇锋洿鏂颁笉鍙攢鍞殑浜у搧銆�';
           return null;
         }
-
         System.debug('checkSFDAStatus1 finished at: ' + System.currentTimeMillis());
 
         //銉囥兗銈裤儊銈с儍銈�
@@ -1737,6 +1767,22 @@
       // 鎶ヤ环鍒涘缓鏃ヨ秴杩囦笁涓湀鏃讹紝鐐逛繚瀛樻椂寮哄埗鏇存柊
       // CHAN-AZG864 涓嶇鍦ㄤ笉鍦ㄦ姤浠锋湁鏁堟湡鍐咃紝CFDA涓嶅彲閿�鍞殑鏃跺�欙紝閮芥槸鎶ラ敊鐨勶紝鍏朵腑涓嶅彲閿�鍞骇鍝佹樉绀虹孩瀛楋紝涓嶅簲璇ヤ繚瀛樸��
 
+      // 2022-04-19 XYOU-CDLCMM 娌℃湁琛岄」鐩笉鑳戒繚瀛� ssm start
+      if (activities != null && activities.size() > 0) {
+        QELine line1 = activities[0];
+        // System.debug('Save() line1: ' + line1);
+        // System.debug('line1 != null: ' + (line1 != null));
+        // System.debug('line1.pageObject.PricebookEntryId != null: ' + (line1.pageObject.PricebookEntryId != null));
+        // System.debug('isNotBlank(line1.pageObject.PricebookEntryId): ' + (String.isNotBlank(line1.pageObject.PricebookEntryId)));
+        // System.debug('Save() line1 flag: ' + (!(line1 != null && String.isNotBlank(line1.pageObject.PricebookEntryId))));
+        if (!(line1 != null && String.isNotBlank(line1.pageObject.PricebookEntryId))) {
+          errorflg = true;
+          errorMessage = '涓嶅厑璁镐繚瀛樼┖鐨勬姤浠峰崟锛岃閫夋嫨浜у搧';
+          return null;
+        }
+      }
+      // 2022-04-19 ssm end
+      
       if (WinOrDecideAlert && (!productStatusUpdated)) {
         errorflg = true;
         errorMessage = '浜у搧鐘舵�佸彂鐢熷彉鍖栵紝璇锋洿鏂�';
@@ -1794,20 +1840,22 @@
       errorflg = false;
       errormessage = null;
       //20220214 fy lastbuy start 
-      if(!ReservedProductVerification()){
-        system.debug('flglastbuy++++'+flglastbuy);
-        if(flglastbuy==1){
-          errorflg = true;
-          errormessage =  '棰勭暀浜у搧琛ㄤ腑娌℃湁璇ヨ浠凤紝璇烽�氳繃鏈儴绐楀彛鑱旂郴钀ヤ笟绠$悊璇�' ;
-          return null;
-        }else if(flglastbuy==2){
-          errorflg = true;
-          errormessage =  errorProductmodel+'浜у搧鏁伴噺涓嶅彲瓒呰繃浜у搧棰勭暀鏁伴噺' ;
-          return null;
-        }else if(flglastbuy==3){
-          errorflg = true;
-          errormessage =  '棰勭暀浜у搧'+errorProductmodel+'鏈綍鍏ラ鐣欎骇鍝佽〃';
-          return null;
+      if (!oppInfo.is_changed_opp) {
+        if(!ReservedProductVerification()){
+          system.debug('flglastbuy++++'+flglastbuy);
+          if(flglastbuy==1){
+            errorflg = true;
+            errormessage =  '棰勭暀浜у搧琛ㄤ腑娌℃湁璇ヨ浠凤紝璇烽�氳繃鏈儴绐楀彛鑱旂郴钀ヤ笟绠$悊璇�' ;
+            return null;
+          }else if(flglastbuy==2){
+            errorflg = true;
+            errormessage =  errorProductmodel+'浜у搧鏁伴噺涓嶅彲瓒呰繃浜у搧棰勭暀鏁伴噺' ;
+            return null;
+          }else if(flglastbuy==3){
+            errorflg = true;
+            errormessage =  '棰勭暀浜у搧'+errorProductmodel+'鏈綍鍏ラ鐣欎骇鍝佽〃';
+            return null;
+          }
         }
       }
       //20220214 fy lastbuy end
@@ -1843,12 +1891,14 @@
       if (dataEntry() == false) {
         return null;
       }
+      //SWAG-CC6AFQ銆愬鎵樸�戝張鏈夎浠疯烦杩囦簡鎶ヤ环璁$畻 fy start
       if(SkipQuotefilg){
         errorflg = true;
-        errormessage =  '鐢婚潰閰嶇疆鍙樻洿锛屽凡鐢熸垚鏂扮殑鎶ヤ环鍗曪紝璇烽噸鏂板仛鎶ヤ环璁$畻';
+        errormessage =  '浜у搧閰嶇疆鎴栬�呯粡閿�鍟嗕俊鎭彂鐢熷彉鍖栵紝宸茬粡鐢熸垚鏂扮殑鎶ヤ环鍗曪紝璇烽噸鏂版搷浣滄姤浠疯绠�';
         quo.IsQuoteTrial__c = false;
         return null;
       }
+      //SWAG-CC6AFQ銆愬鎵樸�戝張鏈夎浠疯烦杩囦簡鎶ヤ环璁$畻 fy end
       //寮曞悎銇绌嶆焙瀹氥倰銈兂
       if (oppId == null) {
         system.debug('Error is Opportunityid null!!!');
@@ -1859,7 +1909,12 @@
           /*鈫撯啌鈫撹绌嶅悓鏈熲啌鈫撯啌2012/11/28 鏈娇鐢�
           opps[0].SyncedQuoteId = quoId;
           鈫戔啈鈫戙��銆�銆�銆�鈫戔啈鈫�*/
-          ControllerUtil.updOpp(opps[0]);
+          // SWAG-CER5R4 浼樺寲淇濆瓨閫熷害 start
+          // ControllerUtil.updOpp(opps[0]);
+          StaticParameter.EscapeOppandStaTrigger = true;
+          update opps[0];
+          StaticParameter.EscapeOppandStaTrigger = false;
+          // SWAG-CER5R4 浼樺寲淇濆瓨閫熷害 end
         }
 
         errorflg = true;
@@ -1994,7 +2049,12 @@
               if (quos[0].Quote_Date__c == null) {
                 quos[0].Quote_Date__c = date.Today();
                 opps[0].Estimation_Proposal_Date__c = date.Today();
-                ControllerUtil.updOpp(opps[0]);
+                // SWAG-CER5R4 浼樺寲淇濆瓨閫熷害 start
+                // ControllerUtil.updOpp(opps[0]);
+                StaticParameter.EscapeOppandStaTrigger = true;
+                update opps[0];
+                StaticParameter.EscapeOppandStaTrigger = false;
+                // SWAG-CER5R4 浼樺寲淇濆瓨閫熷害 end
               }
               quos[0].Quote_Print_Date__c = date.Today();
               ControllerUtil.updQuote(quos[0]);
@@ -2143,7 +2203,11 @@
       }
 
     }
-
+    //SWAG-CER5R4 銆愬鎵樸�戞姤浠峰悎鍚岄噾棰濆鍔犻檺鍒� fy start
+    if(ContractAmountLimitJudge()){
+      return false;
+    }
+    //SWAG-CER5R4 銆愬鎵樸�戞姤浠峰悎鍚岄噾棰濆鍔犻檺鍒� fy end
     if (error == true && WinOrDecideAlert == false) {
       PageArrange();
       errorflg = true;
@@ -2211,7 +2275,13 @@
     Boolean error = false;
     errorflg = false;
     errormessage = null;
-
+    //obsap 鏈�缁堢敤鎴峰悎鍚岄噾棰濋獙璇� fy start
+    if (quo.Dealer_Final_Price_Page__c == null) {
+      quo.Dealer_Final_Price__c.addError(System.Label.Error_Message3);
+      error = true;
+      errormessage = System.Label.Error_Message3;
+    }
+    //obsap 鏈�缁堢敤鎴峰悎鍚岄噾棰濋獙璇� fy end
     if (checkAgentsDeleteFlag() == false) {
       return false;
     }
@@ -2574,7 +2644,55 @@
     return false;
   }
   //SWAG-C9JCS8 銆愬鎵樸�戙�愮揣鎬ャ�戣浠稧Z-SP-GD0757135鎶ヤ环鍗曢棶棰� fy end
-
+  //SWAG-CER5R4 銆愬鎵樸�戞姤浠峰悎鍚岄噾棰濆鍔犻檺鍒� fy start
+  private boolean ContractAmountLimitJudge(){
+    system.debug('oppInfo.Sales_Root+++='+oppInfo.Sales_Root);
+    if(oppInfo.Sales_Root =='OCM鐩存帴閿�鍞�'){
+      return false;
+    }
+    Boolean error = false;
+    // List<QuoteLineItem> act = new List<QuoteLineItem>();
+    // List<QuoteLineItem> act2 = new List<QuoteLineItem>();
+    Double AccrualTotal=0;
+    Double sumContractAmount =0;
+    for(QELine aaa :activities){
+      // 2022-06-14 绱ф�ヤ慨澶� ssm
+      if (String.isBlank(aaa.Asset_Model)) {
+        continue;
+      }
+      if(aaa.pageObject.PricebookEntry.Product2Id!=null){
+        if(aaa.GuranteePrice==null){
+          aaa.GuranteePrice=0;
+        }
+        AccrualTotal += aaa.pageObject.Quantity__c*aaa.GuranteePrice;
+        // act.add(aaa.pageObject);
+      }
+    }
+    // act2=act.deepClone();
+    // Double AccrualTotal=0;
+    // Double sumContractAmount =0;
+    // for(QuoteLineItem pspsc :act2){
+    //   AccrualTotal += pspsc.Quantity__c*pspsc.GuranteePrice__c;
+    // }
+    if(quo.MultiYearWarrantyTotalPrice__c==null){
+      quo.MultiYearWarrantyTotalPrice__c=0;
+    }
+    sumContractAmount = AccrualTotal+quo.MultiYearWarrantyTotalPrice__c;
+    if(quo.OCM_Agent1_Price_Page__c<=sumContractAmount){
+      error = true;
+      errorflg = true;
+      errormessage = '棰勬祴閲戦涓鸿礋鏁帮紝璇锋纭~鍐欏悎鍚岄噾棰濄��';
+    }
+    if(quo.multiYearWarranty__c){
+      if(quo.OCM_Agent1_Price_Page__c<=0){
+        error = true;
+        errorflg = true;
+        errormessage = '棰勬祴閲戦涓鸿礋鏁帮紝璇锋纭~鍐欏悎鍚岄噾棰濄��';
+      }
+    }
+    return error;
+  }
+  //SWAG-CER5R4 銆愬鎵樸�戞姤浠峰悎鍚岄噾棰濆鍔犻檺鍒� fy end
   public boolean dataEntry() {
     system.debug('activities++++----****3'+activities);
     //SWAG-C9JCS8 銆愬鎵樸�戙�愮揣鎬ャ�戣浠稧Z-SP-GD0757135鎶ヤ环鍗曢棶棰� fy start
@@ -2600,11 +2718,11 @@
         error = true;
         errormessage = System.Label.Error_Message3;
       }
-      if (quo.Dealer_Final_Price_Page__c == null) {
-        quo.Dealer_Final_Price__c.addError(System.Label.Error_Message3);
-        error = true;
-        errormessage = System.Label.Error_Message3;
-      }
+      // if (quo.Dealer_Final_Price_Page__c == null) {
+      //   quo.Dealer_Final_Price__c.addError(System.Label.Error_Message3);
+      //   error = true;
+      //   errormessage = System.Label.Error_Message3;
+      // }
       if (qb.Quote_Adjust_Calculate == null) {
         quo.Quote_Adjust_Calculate__c.addError(System.Label.Error_Message3);
         error = true;
@@ -2687,10 +2805,10 @@
 
       }
 
-      if (DisCalculation >= 1000 || DisCalculation <= -1000) {
-        error = true;
-        errormessage = System.Label.Error_Message38;
-      }
+      // if (DisCalculation >= 1000 || DisCalculation <= -1000) {
+      //   error = true;
+      //   errormessage = System.Label.Error_Message38;
+      // }
       if (qb.SalesCalculation1 >= 1000 || qb.SalesCalculation1 <= -1000) {
         error = true;
         errormessage = System.Label.Error_Message38;
@@ -2807,8 +2925,8 @@
         }
 
       } else {
-        List<Quote> qs = New List<Quote>();
-        qs = [select Id, OpportunityId, CreatedDate, Pricebook2Id, Name, Estimation_List_Price__c, Dealer_Final_Price__c,
+        List<Quote> qs = New List<Quote>();//SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy start QuotationChange__c,MainEngineWithoutMonitor__c,Interdepartmental__c,
+        qs = [select Id, OpportunityId, CreatedDate, Pricebook2Id, Name, Estimation_List_Price__c, Dealer_Final_Price__c,QuotationChange__c,MainEngineWithoutMonitor__c,Interdepartmental__c,
               Stocking_Price__c, Discount_Amount__c, Discount_Amount_Calculate__c, Quote_Adjust_Amount__c, Quote_Adjust_Calculate__c,
               Agency1__c, OCM_Agent1_Price__c, Agency1_Profit__c, Agency1_Profit_Rate__c, Quote_No__c,
               Agency2__c, Agent1_Agent2_Price__c, Agency2_Profit__c, Agency2_Profit_Rate__c,
@@ -2894,18 +3012,29 @@
       q.Quote_Comment__c = quo.Quote_Comment__c;
 
       q.Installation_location__c = quo.Installation_location__c;
+
+      //SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy start
+      q.QuotationChange__c = quo.QuotationChange__c;
+      q.MainEngineWithoutMonitor__c = quo.MainEngineWithoutMonitor__c;
+      q.Interdepartmental__c = quo.Interdepartmental__c;
+      //SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy end
       /*
       if (hasType3Machine) {
           q.Installation_location__c = '';
       }
       */
-      System.debug('start save quote at: ' + System.currentTimeMillis());
+      System.debug('q.QuotationChange__c+++'+q.QuotationChange__c);
+      System.debug('quo.QuotationChange__c++' + quo.QuotationChange__c);
+      System.debug('quo.MainEngineWithoutMonitor__c++' + quo.MainEngineWithoutMonitor__c);
       if (quoId == null) {
         insert q;
         quo.Quote_No__c = q.Quote_No__c;
       } else {
         update q;
       }
+      System.debug('q.QuotationChange__c2+++'+q.QuotationChange__c);
+      System.debug('quo.QuotationChange__c2++' + quo.QuotationChange__c);
+      System.debug('quo.MainEngineWithoutMonitor__c2++' + quo.MainEngineWithoutMonitor__c);
       System.debug('finished save quote at: ' + System.currentTimeMillis());
 
       system.debug('鈼嬧棆鈼嬧棆鈼婼ave1鈼嬧棆鈼嬧棆鈼�');
@@ -2989,6 +3118,9 @@
       os = [select Id, Estimation_List_Price__c, Dealer_Final_Price__c, Estimation_List_Price_Without_Tax__c,
             Agency1__c, OCM_Agent1_Price__c, Agency1_Profit__c, Agency1_Profit_Rate__c, Stocking_Price__c,
             Agency2__c, Agent1_Agent2_Price__c, Agency2_Profit__c, Agency2_Profit_Rate__c, Quote_Update_Sum__c , Hospital__c,Is_Corrosion__c 
+            // lt 20221008 SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 start
+            ,StageName ,OlyNumberHosts__c
+            // lt 20221008 SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 end
             From Opportunity Where Id = :oppid];
       if (os.size() > 0) {
         o = os[0];
@@ -3008,7 +3140,7 @@
 
         o.Stocking_Price__c = quo.Stocking_Price__c;
 
-        o.Estimation_No__c = quo.Quote_No__c;
+        o.Estimation_No__c = q.Quote_No__c; // quo.Quote_No__c;
         //o.Estimation_Name__c = quo.Name;
         o.Estimation_Name__c = q.Name;
         o.Estimation_Id__c = q.Id;
@@ -3024,6 +3156,40 @@
         o.quoteSavedDate__c = Date.today();
         // 澶氬勾淇濅慨 end
 
+        // lt 20221008 SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 start
+        System.debug('lt123璇环鐘舵��(闃舵): ' + o.StageName);
+        System.debug('lt123activities: ' + activities);
+        o.OlyNumberHosts__c = 0;
+        System.debug('lt123涓绘満鏁�: ' + o.OlyNumberHosts__c);
+        List<String> oppIds = New List<String>();
+        List<String> product2Ids = New List<String>();
+        Map<String,Decimal> product2IdsMap = new Map<String,Decimal>();
+        if (activities.size() > 0) {
+          for (QELine a : activities) {
+            if (String.isBlank(a.PageObject.Id__c) == false) {
+              product2Ids.add(a.PageObject.Id__c);
+              product2IdsMap.put(a.PageObject.Id__c,a.PageObject.Quantity__c);
+            }
+          }
+
+          for (Product2 prod : [Select Id,ProductClass__c
+                                From Product2 Where Id IN :product2Ids]) {
+            System.debug('lt123浜у搧甯傚満绫诲埆: ' + prod.ProductClass__c);
+
+                if(o.StageName == '寮曞悎' || o.StageName == '娉ㄦ畫' || o.StageName == '鍑鸿嵎' || o.StageName == '瀹屼簡'){
+                  if(prod.ProductClass__c == '涓绘満'){
+                    if(product2IdsMap.containsKey(prod.Id)){
+                      o.OlyNumberHosts__c += product2IdsMap.get(prod.Id);
+                      oppIds.add(o.Id);
+                      ControllerUtil.UpdateBiddingFlag(oppIds);
+                    }
+                  }else{
+                    o.OlyNumberHosts__c += 0;
+                  }
+                }
+          }
+        }
+        // lt 20221008 SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 end
 
         if (o.Quote_Update_Sum__c == null) {
           o.Quote_Update_Sum__c = 1;
@@ -3031,7 +3197,11 @@
           o.Quote_Update_Sum__c = o.Quote_Update_Sum__c + 1;
         }
         System.debug('start 1st save Opportunity at: ' + System.currentTimeMillis());
-        ControllerUtil.updOpp(o);
+        // SWAG-CER5R4 浼樺寲淇濆瓨閫熷害 start
+        // ControllerUtil.updOpp(o);
+        StaticParameter.EscapeOppandStaTrigger = true;
+        update o;
+        // SWAG-CER5R4 浼樺寲淇濆瓨閫熷害 end
         System.debug('finished 1st save Opportunity at: ' + System.currentTimeMillis());
 
         system.debug('鈼嬧棆鈼嬧棆鈼婼ave3鈼嬧棆鈼嬧棆鈼�');
@@ -3041,7 +3211,10 @@
         //渚℃牸銆佸崢浣嶃�佸皬瑷堛�丱CM澹蹭笂浜堟脯閲戦锛堢◣鎶滐級銆佷尽鏍艰〃
         List<OpportunityLineItem> ols = New List<OpportunityLineItem>();
         OpportunityLineItem ol = New OpportunityLineItem();
-        ols = [select Id from OpportunityLineItem Where OpportunityId = :oppid];
+        // lt 20221008 SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 end
+        ols = [select Id, Quantity from OpportunityLineItem Where OpportunityId = :oppid];  //update
+        System.debug('lt123璇环浜у搧: ' + ols);
+        // lt 20221008 SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 end
         if (ols.size() > 0) {
           //delete
           ControllerUtil.delOppLine(ols);
@@ -3055,6 +3228,7 @@
             if (s.Asset_Model != null && s.Asset_Model != '') {
               if (s.PageObject.PricebookEntryId != null) {
                 ol = New OpportunityLineItem();
+                System.debug('lt123璇环浜у搧鏁伴噺: ' + ol.Quantity);   //lt CHL5XA銆怓Y23璇环鏀瑰杽銆�
                 ol.OpportunityId = oppid;
                 ol.Id__c = s.PageObject.Id__c;
                 // CHAN-AVG3PW 璇环鎶ヤ环鐢婚潰瑙勫垯鍙樻洿
@@ -3287,6 +3461,13 @@
     public String Authorized_DB_No { get; set; }
     // LHJ End
 
+    // Celon璇环淇敼 2022-04-24 ssm start
+    public String CelonOpportunity { get; set; }
+    // Celon璇环淇敼 2022-04-24 ssm end
+    // lastbuy鍒ゆ柇鍙樻洿鐢ㄦ埛璇环 start
+    public Boolean is_changed_opp { get; set; }
+    // lastbuy鍒ゆ柇鍙樻洿鐢ㄦ埛璇环 end
+
     public OppInfo(Opportunity opp) {
       Account_RecordType_DeveloperName = opp.Account.RecordType.DeveloperName;
       Direct_Separate = opp.Direct_Separate__c;
@@ -3300,6 +3481,12 @@
       If_Need_Authorize = opp.If_Need_Authorize__c;
       Authorized_DB_No = opp.Authorized_DB_No__c;
       // LHJ End
+      // Celon璇环淇敼 2022-04-24 ssm start
+      CelonOpportunity = opp.CelonOpportunity__c;
+      // Celon璇环淇敼 2022-04-24 ssm end
+      // lastbuy鍒ゆ柇鍙樻洿鐢ㄦ埛璇环 start
+      is_changed_opp = opp.If_Account_Change__c != null ? opp.If_Account_Change__c : false;
+      // lastbuy鍒ゆ柇鍙樻洿鐢ㄦ埛璇环 end
     }
   }
   //TODO 1.Quote銈儢銈搞偋銈儓杩藉姞

--
Gitblit v1.9.1