李金换
2023-04-21 cc7487a59bd4b0fa5bed1dd59f6d0565ace81b8b
force-app/main/default/classes/PCLLostReportController.cls
@@ -97,6 +97,7 @@
          Lost_reason_main__c,
          Lost_Reason_Sub__c,Lost_By_Company__c,
          LostTotalAmount__c,LostType__c,
          TotalAmountLost__c, //20230215 lt DB202302247719
          Report_Status__c,Sales_assistant__c,
          Opportunity__c, Opportunity__r.Sales_assistant_ID__c,
          Opportunity__r.Sales_manager_departmentID__c,
@@ -128,6 +129,7 @@
         list<PCLLostBrand__c> selectlostBrandList =
         [
            select id, LostPrice__c, Lost_By_Company__c,
            LostPrices_ThousandY__c,  //20230215 lt DB202302247719
            Lost_reason_main__c,Lost_Reason_Sub__c,Name,Agency__c, AgencyMannual__c,
            // ProductCategory__c,ProductClass__c,
            Lost_cancel_report__c,Lost_By_Company_Mannual__c,
@@ -335,6 +337,15 @@
            }
            // 当失单品牌名为其他时,报错字段为失单对手型号(手动) thh 2022-01-17 end
            // update tcm 20211123 end
            // 20230418 ljh DB202304320022 start
            String LostBrandNameS = tempLostBrand.lostBrand.Lost_By_Company__c != '其他'?tempLostBrand.lostBrand.Lost_By_Company__c:tempLostBrand.lostBrand.Lost_By_Company_Mannual__c;
            String LostBrandName = temlostProduct.LostProductss.LostBrandName__c;
            if(LostBrandNameS != LostBrandName){
               temlostProduct.LostProductss.LostBrandName__c.addError('失单品牌名不一致,请确认');
               dataCheck = false;
            }
            // 20230418 ljh DB202304320022 end
         }
         // 当失单品牌名为其他时,报错字段为失单对手型号(手动) thh 2022-01-17 start
         if (productCount == 0 && tempLostBrand.LostProducts != null && tempLostBrand.LostProducts.size() > 0) {
@@ -374,6 +385,7 @@
         // 设置记录类型
         LostReport.lostReport.recordTypeID  =  LostReport.lostReport.LostType__c== '失单'?Schema.SObjectType.Lost_cancel_report__c.getRecordTypeInfosByDeveloperName().get('PCL_Lost_report').getRecordTypeId() : Schema.SObjectType.Lost_cancel_report__c.getRecordTypeInfosByDeveloperName().get('PCL_PartLost_report').getRecordTypeId();
         LostReport.lostReport.LostTotalAmount__c    = 0;
         LostReport.lostReport.TotalAmountLost__c    = 0;  //20230215 lt DB202302247719
         LostReport.lostReport.of_lost_system_processor__c   = 0;
         LostReport.lostReport.Lost_reason_main__c = null;
         LostReport.lostReport.Lost_Reason_Sub__c  = null;
@@ -381,6 +393,16 @@
         for(LostBrand tempLostBrand : LostReport.LostBrands) {
            if(string.isNotBlank(tempLostBrand.lostBrand.Lost_By_Company__c)) {
               LostReport.lostReport.LostTotalAmount__c += tempLostBrand.lostBrand.LostPrice__c;
               //20230215 lt DB202302247719  start
               Decimal med = tempLostBrand.lostBrand.LostPrice__c/1.13/1000;
               Decimal med1 = med.setScale(2);
               System.debug('---lt123不含税数值(人工)Decimal---'+med);
               System.debug('---lt123不含税数值(人工)Decimal两位小数---'+med1);
               LostReport.lostReport.TotalAmountLost__c += med1;
               //LostReport.lostReport.TotalAmountLost__c += tempLostBrand.lostBrand.LostPrices_ThousandY__c;  //20230215 lt DB202302247719
               // LostReport.lostReport.TotalAmountLost__c += tempLostBrand.lostBrand.LostPrice__c/1.13/1000;  //20230215 lt DB202302247719
               //20230215 lt DB202302247719  en
               LostReport.lostReport.Lost_reason_main__c =
                  LostReport.lostReport.Lost_reason_main__c == null
                  ? tempLostBrand.lostBrand.Lost_reason_main__c
@@ -489,6 +511,7 @@
         LostReport.lostReport = templostReport;
         LostReport.LostBrands = tempBrands;
         // 这里需要写一些报错信息
         System.debug('---lt123---'+ex.getLineNumber());
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,ex.getMessage()));
         return false;
      }
@@ -561,7 +584,10 @@
      system.debug('brandNo:'+brandNo);
      LostBrand tempLostBrand = LostReport.LostBrands.get(brandNo);
      // PCLLostProduct__c plp = new PCLLostProduct__c(Competitor__c=CompetitionMap.get(LostReport.LostBrands[brandNo].lostBrand.Lost_By_Company__c));
      string brandName = tempLostBrand.lostBrand.Lost_By_Company__c;
      // 20230418 ljh DB202304320022 start
      // string brandName = tempLostBrand.lostBrand.Lost_By_Company__c;
      string brandName = tempLostBrand.lostBrand.Lost_By_Company__c != '其他'?tempLostBrand.lostBrand.Lost_By_Company__c:tempLostBrand.lostBrand.Lost_By_Company_Mannual__c;
      // 20230418 ljh DB202304320022 end
      PCLLostProduct__c plp = new PCLLostProduct__c();
      plp.LostBrandName__c = brandName;
      tempLostBrand.LostProducts.add(new PCLLostProducts(tempLostBrand.LostProducts.size(),plp));