高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
public class OtherButtonOppCtl {
 
    @AuraEnabled
    public static InitData init(String recordId){
        InitData res = new initData();
        try{
            Opportunity opp =  [SELECT Id,CurrencyIsoCode,StageName,Estimation_Decision__c,SAP_Send_OK__c,If_Authorizing_Lock__c,
                                Agency1__c,Agency1_ID_18__c,Agency_Opportunity__c,Trade__c,Name,Close_Forecasted_Date__c,Opportunity_stage__c,
                                Bid_Planned_Date__c,Wholesale_Price__c,Opportunity_Category__c FROM Opportunity WHERE Id =: recordId LIMIT 1];
            System.debug(LoggingLevel.INFO, '*** opp: ' + opp);
            res.currencyIsoCode = opp.CurrencyIsoCode;
            res.stageName = opp.StageName;
            res.estimationDecision = opp.Estimation_Decision__c;
            res.SAPSendOK = opp.SAP_Send_OK__c;
            res.IfAuthorizingLock = opp.If_Authorizing_Lock__c;
            res.agency1Id = opp.Agency1_ID_18__c;
            res.agencyOpportunity = opp.Agency_Opportunity__c;
            res.trade = opp.Trade__c;
            res.oppName = opp.Name;
            res.opp = opp;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
 
    @AuraEnabled
    public static List<Agency_Hospital_Link__c> selectAgencyHospital(String recordId){
        List<Agency_Hospital_Link__c> res = new List<Agency_Hospital_Link__c>();
        try{
            Opportunity opp =  [SELECT Id,Agency1_ID_18__c,Hospital__c FROM Opportunity WHERE Id =: recordId LIMIT 1];
            res = [SELECT Id, Name FROM Agency_Hospital_Link__c WHERE Agency__c =:opp.Agency1_ID_18__c AND Hospital__c =:opp.Hospital__c];
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
 
    @AuraEnabled
    public static List<RecordType> selectRecordType(){
        List<RecordType> res = new List<RecordType>();
        try{
            res = [SELECT Id, Name FROM RecordType WHERE SobjectType='Agency_Opportunity__c' And developerName='Opportunity' And IsActive = TRUE];
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static List<FieldDefinition> selectFieldDefinition(){
        List<FieldDefinition> res = new List<FieldDefinition>();
        try{
            res = [Select QualifiedApiName, EntityDefinition.KeyPrefix, DurableId From FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Agency_Opportunity__c'];
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    
 
    public class ReturnData{
        @AuraEnabled
        public String status;
        @AuraEnabled
        public Object data;
 
        public void ReturnData(){
            status = 'Fail';
        }
    }
    public class InitData{
        @AuraEnabled
        public String currencyIsoCode;
        @AuraEnabled
        public String stageName;
        @AuraEnabled
        public Boolean estimationDecision;
        @AuraEnabled
        public Boolean SAPSendOK;
        @AuraEnabled
        public Boolean IfAuthorizingLock;
        @AuraEnabled
        public String agency1Id;
        //  Agency_Opportunity__c
        @AuraEnabled
        public String agencyOpportunity;
        @AuraEnabled
        public String trade;
        @AuraEnabled
        public String oppName;
        @AuraEnabled
        public Opportunity opp;
    }
 
}