| | |
| | | // Author ljh 测试类 MaintenanceProductDataControllerTest |
| | | public without sharing class MaintenanceUpdateProductHandler extends Oly_TriggerHandler { |
| | | private Map<Id, Maintenance_Product_Data__c> newMap; |
| | | private Map<Id, Maintenance_Product_Data__c> oldMap; |
| | |
| | | } |
| | | //Tier1_Category__c, |
| | | query = 'select Id, Name ,ProductsID__c,Maintenance_Product_Data__c,RecordType.DeveloperName '; |
| | | query += ' ,ENG_DeaerProFlag__c,Dealer_special_Object__c,Key_product_147P__c,Key_product_147P_Old__c,Important_Endopartner_product__c '; |
| | | query += ' ,ENG_DeaerProFlag__c,Dealer_special_Object__c,Key_product_147P__c,Key_product_147P_Old__c,Important_Endopartner_product__c'; |
| | | // FY23修改 WLIG-CFV4AV 重点产品维护(新)start |
| | | query += ' ,Key_product_155P__c,Key_product_155P_Old__c,Celon_Product__c,Celon_Product_Old__c '; |
| | | // FY23修改 WLIG-CFV4AV 重点产品维护(新)end |
| | |
| | | //LJPH-C6A3DF 【委托】 【重要】产品主数据中增加服务用产品分类 liuyan 20210831 Star |
| | | query += ' ,Can_Repair__c , Service_Category1__c ,Service_Category2__c,Service_Category3__c,Service_Category4__c, Service_Category5__c,Service_Category6__c,Service_Category7__c '; |
| | | //LJPH-C6A3DF 【委托】 【重要】产品主数据中增加服务用产品分类 liuyan 20210831 End |
| | | query += ' ,LastbuyProductFLG__c'; //kk lastbuy add 20240319 |
| | | query += ' from Maintenance_Product_Data_Details__c where Maintenance_Product_Data__r.Status__c =\'完成\' '; |
| | | query += ' and Maintenance_Product_Data__c in '+sqlTail; |
| | | List<Maintenance_Product_Data_Details__c> mpdList = Database.query(query); |
| | | List<Product2> product2Update = new List<Product2>(); |
| | | //Map<String,String> mpdId = new Map<String,String>(); |
| | | // chenjingwu 3+2多年保修 20240226 start |
| | | List<MultiYearWarranty__c> muUPdate = new List<MultiYearWarranty__c>(); |
| | | List<String> muIdList = new List<String>(); |
| | | // chenjingwu 3+2多年保修 20240226 end |
| | | List<Maintenance_Product_Data_Details__c> mpdDetailsStatus = new List<Maintenance_Product_Data_Details__c>(); |
| | | for(Maintenance_Product_Data_Details__c mpdDetails : mpdList){ |
| | | Maintenance_Product_Data_Details__c pdd = new Maintenance_Product_Data_Details__c(); |
| | | Product2 product2 = new Product2(); |
| | | // chenjingwu 3+2多年保修 20240226 start |
| | | MultiYearWarranty__c mu = new MultiYearWarranty__c(); |
| | | if(mpdDetails.MultiYearWarranty__c != '' && mpdDetails.MultiYearWarranty__c != ''){ |
| | | muIdList.add(mpdDetails.MultiYearWarranty__c); |
| | | } |
| | | // chenjingwu 3+2多年保修 20240226 end |
| | | //mpdId.put(mpdDetails.Maintenance_Product_Data__c,mpdDetails.Maintenance_Product_Data__c); |
| | | pdd.Id = mpdDetails.Id; |
| | | if(mpdDetails.RecordType.DeveloperName.equals('GuranteeMain')||mpdDetails.RecordType.DeveloperName.equals('GuranteeMain')){ |
| | |
| | | product2.ENG_DeaerProFlag__c = mpdDetails.ENG_DeaerProFlag__c; |
| | | product2.Dealer_special_Object__c = mpdDetails.Dealer_special_Object__c; |
| | | product2.Important_Endopartner_product__c = mpdDetails.Important_Endopartner_product__c; |
| | | product2.LastbuyProductFLG__c = mpdDetails.LastbuyProductFLG__c;//kk lastbuy 20240329 add |
| | | //需要做处理 |
| | | //MaintenanceProductDataDetails |
| | | SS_Batch_Column_Mapping__c mpdMapping = SS_Batch_Column_Mapping__c.getValues('MaintenanceProductDataDetails'); |
| | |
| | | product2.Default_Fixture_Arrival_Process__c = mpdDetails.Default_Fixture_Arrival_Process__c; |
| | | product2.Default_Fixture_Arrival_Product__c = mpdDetails.Default_Fixture_Arrival_Product__c; |
| | | } |
| | | // chenjingwu 3+2多年保修 20240226 start |
| | | if(mpdDetails.RecordType.DeveloperName.equals('GuranteeExtend')){ |
| | | mu.AgeLimit__c = mpdDetails.AgeLimit__c; |
| | | mu.MultiOneYearWarrantyPrice__c = mpdDetails.MultiOneYearWarrantyPrice__c; |
| | | mu.AmountWithheld__c = mpdDetails.AmountWithheld__c; |
| | | mu.ProductName__c = mpdDetails.ProductsID__c; |
| | | muUPdate.add(mu); |
| | | } |
| | | // chenjingwu 3+2多年保修 20240226 end |
| | | //跟新标识 |
| | | product2.IsFromSAP__c = true; |
| | | product2Update.add(product2); |
| | | } |
| | | // chenjingwu 3+2多年保修 20240226 start |
| | | if(muUPdate.size()>0 && muUPdate !=null ){ |
| | | if(muIdList.size()>0 && muIdList !=null ){ |
| | | List<MultiYearWarranty__c> muList = [select Id from MultiYearWarranty__c where ProductName__c in:muIdList]; |
| | | delete muList; |
| | | } |
| | | Database.SaveResult[] lsr = Database.insert(muUPdate, false); |
| | | } |
| | | // chenjingwu 3+2多年保修 20240226 end |
| | | |
| | | if(product2Update.size()>0 && product2Update !=null ){ |
| | | Database.SaveResult[] lsr = Database.update(product2Update, false); |
| | | String errStr = '';// 20231219 ljh DB202312020423 add |
| | | Boolean flag = true; |
| | | for (Integer tIdx = 0; tIdx < lsr.size(); tIdx++) { |
| | | Database.SaveResult sr = lsr[tIdx]; |
| | |
| | | if (!sr.isSuccess()) { |
| | | Database.Error emsg = sr.getErrors()[0]; |
| | | flag = false; |
| | | errStr += emsg.getMessage()+';';// 20231219 ljh DB202312020423 add |
| | | } |
| | | } |
| | | if(flag){ |
| | | update mpdDetailsStatus; |
| | | } |
| | | } |
| | | // 20231219 ljh DB202312020423 start |
| | | else{ |
| | | for (Maintenance_Product_Data__c newMpd : nList) { |
| | | newMpd.addError(errStr); break; |
| | | } |
| | | } |
| | | // 20231219 ljh DB202312020423 end |
| | | } |
| | | //------------------------- |
| | | //发送邮件 |