|  |  | 
 |  |  |         return repair; | 
 |  |  |     } | 
 |  |  |     //add        wangweipeng                 2021/12/09                     end | 
 |  |  |     //先款后修-修理增加先款标识 thh 20220318 start | 
 |  |  |     public static void AdvancePaymentFlagUpsert(List<Repair__c> newList, Map<Id, Repair__c> newMap, List<Repair__c> oldList, Map<Id, Repair__c> oldMap) { | 
 |  |  |         List<String> RepairQuotationIdList = new List<String>(); | 
 |  |  |         List<Repair__c> NoRepairQuotationList = new List<Repair__c>(); | 
 |  |  |         List<Repair_Quotation__c> RepairQuotationList = new List<Repair_Quotation__c>(); | 
 |  |  |         List<String> DealerIdList = new List<String>(); | 
 |  |  |         List<Account> DealerList = new List<Account>(); | 
 |  |  |         List<Repair__c> updateRepairList = new List<Repair__c>(); | 
 |  |  |         System.debug('newList1:' + newList); | 
 |  |  |         for(Repair__c rep : newList){ | 
 |  |  |             Repair__c oldRep = oldMap.get(rep.Id); | 
 |  |  |             if(rep.Repair_Quotation_Id__c != null){ | 
 |  |  |                 RepairQuotationIdList.add(rep.Repair_Quotation_Id__c); | 
 |  |  |             }else{ | 
 |  |  |                 NoRepairQuotationList.add(rep); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         //同期中的修理修理报价有值时,看报价上的先款标识进行赋值 | 
 |  |  |         if(RepairQuotationIdList.size() > 0){ | 
 |  |  |             RepairQuotationList = [select Id, Is_RecognitionModel__c from Repair_Quotation__c where Id IN :RepairQuotationIdList]; | 
 |  |  |         } | 
 |  |  |         for(Repair_Quotation__c rq : RepairQuotationList){ | 
 |  |  |             for(Repair__c rep : newList){ | 
 |  |  |                 if(rq.Id == rep.Repair_Quotation_Id__c){ | 
 |  |  |                     rep.Advance_Payment_Flag__c = rq.Is_RecognitionModel__c; | 
 |  |  |                     updateRepairList.add(rep); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         //同期中的修理报价没值时,看修理单上的经销商是不是先款对象进行赋值 | 
 |  |  |         if(NoRepairQuotationList.size() > 0){ | 
 |  |  |             for(Repair__c rep : NoRepairQuotationList){ | 
 |  |  |                 DealerIdList.add(rep.Dealer__c); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if(DealerIdList.size() > 0 ){ | 
 |  |  |             DealerList = [select Id, FirstParagraphEnd__c from Account where Id IN : DealerIdList]; | 
 |  |  |         } | 
 |  |  |         for(Account dealer : DealerList){ | 
 |  |  |             for(Repair__c rep : newList){ | 
 |  |  |                 if(rep.Dealer__c == dealer.Id){ | 
 |  |  |                     rep.Advance_Payment_Flag__c = dealer.FirstParagraphEnd__c; | 
 |  |  |                     updateRepairList.add(rep); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         Savepoint sp = Database.setSavepoint(); | 
 |  |  |         try { | 
 |  |  |             if(updateRepairList.size() > 0){ | 
 |  |  |                 update updateRepairList; | 
 |  |  |             } | 
 |  |  |         } catch (System.Exception e) { | 
 |  |  |             Database.rollback(sp); | 
 |  |  |             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage())); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     //先款后修-修理增加先款标识 thh 20220318 end | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public static void CheckUpdate(List<Repair__c> oldList, Map<Id, Repair__c> newMap) { | 
 |  |  |         System.debug('===========> start'); |