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
//author : kkbes   forbutton  NewIntention  经销商询价对象 
public with sharing class LexNewIntentionController {
 
    @AuraEnabled
    public static Agency_Opportunity__c init(String recordId){
        Agency_Opportunity__c  res = new Agency_Opportunity__c();
        try{
            res = [Select Id,Is_Transformed__c,Department_Class_Opp_Name__c,
            Department_Name_Text__c,StageName__c,Close_Forecasted_Date__c,
            Name,Purchase_Reason__c,Fund_Basis__c,Purchase_Type__c,
            Sales_Method__c,Request__c,Request_Detail__c ,NewOpportunity_Agency_Apply_Status_F__c,Hospital_DC_Name__c,
            Account_Opp__c,Department_Class_Opp__c
                FROM Agency_Opportunity__c
                    WHERE  Id = : recordId];
            return res;
 
        }
        catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            return null;
        }
 
    }
 
 
    @AuraEnabled
    public static List<Account> getAccountByLongName(String Name){
        List<Account> res  = new List<Account>();
        res = [Select id, name 
                    From Account
                        WHERE Name = : Name];
        return res;
 
    }
 
    @AuraEnabled
    public static String updateAgencyOpportunity (String Id,String Status){
        try {
            Agency_Opportunity__c  res = new Agency_Opportunity__c();
            res.Id = Id;
            res.NewOpportunity_Agency_Apply_Status__c = Status;
            update res;            
            return 'success';
        }
        catch(Exception  e){
            String messageText='';
            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);
                messageText = mes;
                return messageText;
            }else{
                messageText=e.getMessage();
                return messageText;
            }          
        }
    }
 
}