public without sharing class loanerChangeRecordTriggerHandler {

 public static void SetAssetStatus(List<LoanerChangeRecord__c> newList, Map<Id, LoanerChangeRecord__c> newMap, List<LoanerChangeRecord__c> oldList, Map<Id, LoanerChangeRecord__c> oldMap) {
        List<Asset> updList = new List<Asset>();
        Map<String, String> updMap = new Map<String, String>();       
        for (LoanerChangeRecord__c newLoachange : newList){
            LoanerChangeRecord__c oldLoachange = oldMap == null ? new LoanerChangeRecord__c() : oldMap.get(newLoachange.Id);
            if (newLoachange.ApproveIndex__c == true && newLoachange.ApproveIndex__c != oldLoachange.ApproveIndex__c){
                Asset as1 = new Asset();
                as1.Id = newLoachange.Loanerid__c;
                as1.Status = newLoachange.ChangeToStatus__c;
                updList.add(as1);
            }
            
            else if (newLoachange.RequestIndex__c == true && newLoachange.RequestIndex__c != oldLoachange.RequestIndex__c){
                Asset as1 = new Asset();
                as1.Id = newLoachange.Loanerid__c;
                as1.Status = '异动申请中';
                updList.add(as1);
            }  
            
            else if (newLoachange.RequestIndex__c == false && newLoachange.RequestIndex__c != oldLoachange.RequestIndex__c){
                Asset as1 = new Asset();
                as1.Id = newLoachange.Loanerid__c;
                as1.Status = newLoachange.LoanerStatus__c;
                updList.add(as1);
            }
             
        }
        if (updList.size() > 0) update updList;
    }
    
}