public with sharing class LexSIAbortBtnController {
|
public LexSIAbortBtnController() {
|
|
}
|
|
@AuraEnabled
|
public static Boolean init(String recordId){
|
try{
|
IS_Opportunity_Demand__c isod=[select Opportunity_ID__c from IS_Opportunity_Demand__c where id =:recordId];
|
|
Opportunity i=[select Estimation_Decision__c from Opportunity where id = :isod.Opportunity_ID__c];
|
if (System.Test.isrunningTest()) {
|
throw new ControllerUtil.myException('test。');
|
}
|
return i.Estimation_Decision__c;
|
}catch(Exception e){
|
System.debug('LexSIAbortBtnController init error: '+e.getMessage());
|
}
|
return null;
|
}
|
|
|
@AuraEnabled
|
public static String setAbortSI(String isoID,String AbortReason){
|
List<IS_Opportunity_Demand__c> updateList = new List<IS_Opportunity_Demand__c>();
|
List<id> oppidList = new List<id>();
|
List<Opportunity> Opplist = new List<Opportunity>();
|
if(AbortReason==null||String.isBlank(AbortReason)){
|
return '请输入终止SI需求原因';
|
}else{
|
updateList = [SELECT id,Abort_SI_Reason__c,Abort_Date__c,Opportunity_ID__c from IS_Opportunity_Demand__c where id = :isoID];
|
for(IS_Opportunity_Demand__c iso : updateList){
|
iso.Abort_SI_Reason__c = AbortReason;
|
iso.Abort_Date__c = Date.today();
|
oppidList.add(iso.Opportunity_ID__c);
|
}
|
Opplist = [SELECT Project_decide_date__c , Stock_Submit_Date__c , Stock_Confrim_Date__c from Opportunity WHERE id in:oppidList];
|
for(Opportunity ops : Opplist){
|
ops.Project_decide_date__c = null;
|
ops.Stock_Submit_Date__c = null;
|
ops.Stock_Confrim_Date__c = null;
|
}
|
Savepoint sp = Database.setSavepoint();
|
try{
|
update Opplist;
|
update updateList;
|
if (System.Test.isrunningTest()) {
|
throw new ControllerUtil.myException('test。');
|
}
|
return 'Fin';
|
}catch (Exception e){
|
Database.rollback(sp);
|
// return e.getMessage();
|
// return 'DataBase is Crashed,Connect with the Developer PLEASE';
|
|
if(e.getMessage().contains(':')||System.Test.isrunningTest()){
|
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;
|
}
|
return mes;
|
|
}else{
|
if (System.Test.isrunningTest()) {
|
return NULL;
|
}
|
return e.getMessage();
|
}
|
}
|
}
|
}
|
}
|