涂煌豪
2022-03-18 9bae0a550b450043f501483f89576fdae964b424
Revert "先款后修-修理增加先款标识"

This reverts commit 6dc46704e1dc3ffe0ddebc855933c6a40dac8fa9.
2个文件已修改
61 ■■■■■ 已修改文件
force-app/main/default/classes/RepairTrigger.cls 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/triggers/Repair.trigger 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/RepairTrigger.cls
@@ -696,63 +696,7 @@
        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');
force-app/main/default/triggers/Repair.trigger
@@ -273,9 +273,6 @@
                /****************************************************************************************************/
            }
        }
        //先款后修-修理增加先款标识 thh 20220318 start
        RepairTrigger.AdvancePaymentFlagUpsert(Trigger.new, Trigger.newMap, Trigger.old, Trigger.oldMap);
        //先款后修-修理增加先款标识 thh 20220318 end
    }
    // ----------------------------------------------------------------------
    // ここまで、サービスコントラクト項目を自動的に更新するロジック