public with sharing class LexTaskCloseController { public LexTaskCloseController() { } @AuraEnabled public static Task init(String recordId){ try{ Task res=[SELECT Status,QuoteIraiId__c from Task where id= :recordId]; return res; }catch(Exception e){ System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e); } return null; } @AuraEnabled public static QuoteIrai__c getQuoteIraic(String recordId) { try{ QuoteIrai__c res=[select id,Lead__c from QuoteIrai__c where id = :recordId]; return res; }catch(Exception e){ System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e); } return null; } @AuraEnabled public static UpdateResult updateLead( String recordId, String LatestQuotationEntrustmentc ) { UpdateResult result = new UpdateResult(); result.recordId = recordId; try{ // 更新记录并获取结果 if(recordId==null) return null; Lead rac = new Lead( id=recordId); if(String.isNotBlank(LatestQuotationEntrustmentc)){ rac.LatestQuotationEntrustment__c=LatestQuotationEntrustmentc; } if(rac.id==null)return null; update rac; result.success = true; result.errors = new List(); return result; }catch(Exception e){ result.success = false; result.errors = new List(); if(e.getMessage().contains(':')){ String eMessage =e.getMessage(); Integer left = eMessage.indexOf(',')+1; Integer right= eMessage.lastIndexOf('。 ')+1; if(right>eMessage.length()||right<=left){ right=eMessage.length(); } String mes=eMessage.substring(left,right); if (System.Test.isrunningTest()) { return null; } result.errors.add(mes); }else{ result.errors.add(e.getMessage()); } System.debug(LoggingLevel.INFO,'Rental_Apply__c update Error : ' + e); } return result; } @AuraEnabled public static UpdateResult updateQuoteIraic( String recordId, String QuoteIraiStatusc ) { UpdateResult result = new UpdateResult(); result.recordId = recordId; try{ // 更新记录并获取结果 if(recordId==null) return null; QuoteIrai__c rac = new QuoteIrai__c( id=recordId); if(String.isNotBlank(QuoteIraiStatusc)){ rac.QuoteIrai_Status__c=QuoteIraiStatusc; } if(rac.id==null)return null; update rac; result.success = true; result.errors = new List(); return result; }catch(Exception e){ result.success = false; result.errors = new List(); if(e.getMessage().contains(':')){ String eMessage =e.getMessage(); Integer left = eMessage.indexOf(',')+1; Integer right= eMessage.lastIndexOf('。 ')+1; if(right>eMessage.length()||right<=left){ right=eMessage.length(); } String mes=eMessage.substring(left,right); if (System.Test.isrunningTest()) { return null; } result.errors.add(mes); }else{ result.errors.add(e.getMessage()); } System.debug(LoggingLevel.INFO,'updateQuoteIraic update Error : ' + e); } return result; } @AuraEnabled public static UpdateResult updateTask( String recordId, String Status ) { UpdateResult result = new UpdateResult(); result.recordId = recordId; try{ // 更新记录并获取结果 if(recordId==null) return null; Task rac = new Task( id=recordId); if(String.isNotBlank(Status)){ rac.Status=Status; } rac.Quotation_request_completed_time__c =System.now(); if(rac.id==null)return null; update rac; result.success = true; result.errors = new List(); return result; }catch(Exception e){ result.success = false; result.errors = new List(); if(e.getMessage().contains(':')){ String eMessage =e.getMessage(); Integer left = eMessage.indexOf(',')+1; Integer right= eMessage.lastIndexOf('。 ')+1; if(right>eMessage.length()||right<=left){ right=eMessage.length(); } String mes=eMessage.substring(left,right); if (System.Test.isrunningTest()) { return null; } result.errors.add(mes); }else{ result.errors.add(e.getMessage()); } System.debug(LoggingLevel.INFO,'Rental_Apply__c update Error : ' + e); } return result; } @AuraEnabled public static String getProfileId(){ return UserInfo.getProfileId(); } public class UpdateResult { @AuraEnabled public String recordId {get;set;} @AuraEnabled public Boolean success {get;set;} @AuraEnabled public List errors {get;set;} } }