liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
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<String>();
            return result;
        }catch(Exception e){
            result.success = false;
            result.errors = new List<String>();
            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<String>();
            return result;
        }catch(Exception e){
            result.success = false;
            result.errors = new List<String>();
            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<String>();
            return result;
        }catch(Exception e){
            result.success = false;
            result.errors = new List<String>();
            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<String> errors {get;set;}
    }
}