1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
public with sharing class LexSIAbortBtnController {
    public LexSIAbortBtnController() {
        
    }
 
    @AuraEnabled
    public static Boolean init(String recordId){
        try{
            Opportunity i=[select Estimation_Decision__c from Opportunity where id = :recordId];
            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;
                return 'Fin';
            }catch (Exception o){
                Database.rollback(sp);
                return 'DataBase is Crashed,Connect with the Developer PLEASE';
            }
        }
    }
    public class InitData{
        @AuraEnabled
        public String id;
        @AuraEnabled
        public Boolean delFlag;
    }
}