public with sharing class buttonRepairQuotationCtl {
    public buttonRepairQuotationCtl() {

    }

    @AuraEnabled
    public static InitData init(String recordId){
        InitData res = new initData();
        try{
            Repair_Quotation__c report =  [SELECT Repair__c,Loaner_repair_sys__c,Rental_Apply_Discount_Status__c,Id,CutPriceStatus_Service__c FROM Repair_Quotation__c WHERE Id =: recordId LIMIT 1];
            System.debug(LoggingLevel.INFO, '*** opp: ' + report);
            res.RepairC = report.Repair__c;
            res.LoanerRepairSysC = report.Loaner_repair_sys__c;
            res.Id = report.Id;
            res.CutPriceStatusServiceC = report.CutPriceStatus_Service__c;
            res.RentalApplyDiscountStatusC = report.Rental_Apply_Discount_Status__c;
            res.profileId = UserInfo.getProfileId();

            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }   

     // 根据ID修理报价
     @AuraEnabled
     public static String updateRepairQuotation(String recordId){
        String res ='';
         try {
            Repair_Quotation__c repair = new Repair_Quotation__c();
             repair.Id = recordid;
             update repair;
         } catch (Exception e) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
             res = e.getMessage();
         }
         return res;
     }

    // 根据ID修理报价提交
    @AuraEnabled
    public static String updateRepairQuotation02(String recordId){
        String res ='';
        try {
            Repair_Quotation__c repair = new Repair_Quotation__c();
            repair.Id = recordId;
            repair.CutPriceStatus_Service__c = '已提交';
            update repair;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            res = e.getMessage();
        }
        return res;
    }

    // 根据ID修理报价提交
    @AuraEnabled
    public static String updateRepairQuotation03(String recordId){
        String res ='';
        try {
            Repair_Quotation__c repair = new Repair_Quotation__c();
            repair.Id = recordId;
            repair.Rental_Apply_Discount_Status__c = '已提交';
            update repair;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            res = e.getMessage();
        }
        return res;
    }

     // 根据ID修理报价提交
     @AuraEnabled
     public static String updateRepairQuotation04(String recordId){
         String res ='';
         try {
             Repair_Quotation__c repair = new Repair_Quotation__c();
             repair.Id = recordid;
             repair.Repair_quotation_status__c = '减价申请填写完毕';
             update repair;
         } catch (Exception e) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
             res = e.getMessage();
         }
         return res;
     }

    // 查找修理
    @AuraEnabled
    public static List<Repair__c> selectRepairC(String recordId){
        List<Repair__c> res = new List<Repair__c>();
        try{
            res = [SELECT Id, Return_Without_Repair__c, Return_Without_Repair_IF__c FROM Repair__c WHERE Id=: recordId ];
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }

     // 查找简档
     @AuraEnabled
     public static List<Profile> initSelectProfile(String profileId){
         List<Profile> res = new List<Profile>();
         try{
             res = [SELECT Id,name FROM Profile WHERE Id=: profileId ];
         }catch(Exception e){
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
         }
         return res;
     }

    public class InitData{
        @AuraEnabled
        public String Id;
        @AuraEnabled
        public String CutPriceStatusServiceC;
        @AuraEnabled
        public String profileId;
        @AuraEnabled
        public String RentalApplyDiscountStatusC;
        @AuraEnabled
        public Boolean LoanerRepairSysC;
        @AuraEnabled
        public String RepairC;
     }
}