unknown
2023-04-13 78076c7895366ce4da3781c4dd7c21c5ecaccd32
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
/*
 * @Description: 
 * @version: 
 * @Author: chen jing wu
 * @Date: 2023-04-12 11:16:07
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-13 17:02:46
 */
public with sharing class OpportunityLightingButtonController {
    @AuraEnabled
    public static InitData initForPredictedDateChangeButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
            select 
            DirectLossFLG__c,
            Created_Day__c
            from Opportunity where Id =: recordId];
            res.createdDay = opportunity.Created_Day__c;
            res.directLossFLG = opportunity.DirectLossFLG__c;
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForAgencyAuthorizeButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select 
                Agency1_ID_18__c,
                StageName,
                SAP_Send_OK__c,
                Opp_order_Type__c,
                If_Have_170__c,
                If_Have_AH__c,
                Cnt_Lost_cancel_Draft__c,
                Cnt_Lost_cancel_report__c,
                Estimation_Id__c,
                DetailNum__c,
                Estimation_Decision__c,
                Sales_Root__c,
                AcecideCntCheck__c,
                IF_Submit__c ,
                Trade__c,
                Is_Corrosion__c,
                If_Authorizing_Lock__c 
                from Opportunity where Id =: recordId 
            ];
            res.agency1Id = opportunity.Agency1_ID_18__c;
            res.stageName = opportunity.StageName;
            res.sapSendOK = opportunity.SAP_Send_OK__c;
            res.oppOrderType = opportunity.Opp_order_Type__c;
            res.ifHave170 = opportunity.If_Have_170__c;
            res.ifHaveAH = opportunity.If_Have_AH__c;
            res.cntLostCancelDraft = opportunity.Cnt_Lost_cancel_Draft__c;
            res.cntLostCancelReport = opportunity.Cnt_Lost_cancel_report__c;
            res.estimationId = opportunity.Estimation_Id__c;
            res.detailNum = opportunity.DetailNum__c;
            res.estimationDecision = opportunity.Estimation_Decision__c;
            res.salesRoot = opportunity.Sales_Root__c;
            res.acecideCntCheck = opportunity.AcecideCntCheck__c;
            res.ifSubmit = opportunity.IF_Submit__c;
            res.trade = opportunity.Trade__c;
            res.isCorrosion = opportunity.Is_Corrosion__c;
            res.ifAuthorizingLock = opportunity.If_Authorizing_Lock__c;
            String profile18 = UserInfo.getProfileId();
            res.profileId = profile18.substring(0,profile18.length() - 3);
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForLoseBidButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                ifOpenBid__c
                from Opportunity where Id =: recordId
            ];
            res.ifOpenBid = opportunity.ifOpenBid__c;
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForOLYwinBidButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                ifOpenBid__c
                from Opportunity where Id =: recordId
            ];
            res.ifOpenBid = opportunity.ifOpenBid__c;
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForCreateEventButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select 
                AccountId 
                from Opportunity where Id =: recordId];
            res.accountId = opportunity.AccountId;
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initFoBeforeOPDPDFBtnButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                AccountId
                from Opportunity where Id =: recordId
            ];
            res.accountId = opportunity.AccountId;
            res.userId = UserInfo.getUserId();
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initFoBeforeOPDPDFBtnSISButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                AccountId
                from Opportunity where Id =: recordId
            ];
            res.accountId = opportunity.AccountId;
            res.userId = UserInfo.getUserId();
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForRequestDBButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opportunity = [
                select
                StageName,
                SAP_Send_OK__c,
                Cnt_Lost_cancel_report__c,
                Cnt_Lost_cancel_Draft__c,
                Agency1__c,
                Agency1_ID_18__c,
                Name,
                Bid_Planned_Date__c,
                Sales_assistant_name__c,
                Sales_assistant_ID__c
                from Opportunity where Id =: recordId
            ];
            res.stageName = opportunity.StageName;
            res.sapSendOK = opportunity.SAP_Send_OK__c;
            res.cntLostCancelReport = opportunity.Cnt_Lost_cancel_report__c;
            res.cntLostCancelDraft = opportunity.Cnt_Lost_cancel_Draft__c;
            res.agency1 = opportunity.Agency1__c;
            res.agency1Id = opportunity.Agency1_ID_18__c;
            res.name = opportunity.Name;
            res.bidPlannedDate = opportunity.Bid_Planned_Date__c;
            res.salesAssistantName = opportunity.Sales_assistant_name__c;
            res.salesAssistantID = opportunity.Sales_assistant_ID__c;
            String profileId18 = UserInfo.getProfileId();
            res.profileId = profileId18.substring(0, profileId18.length() - 3);
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return res;
    }
    @AuraEnabled
    public static string updateForAgencyAuthorizeButton(String recordId){
        try {
            Opportunity opp = new Opportunity();
            opp.Id = recordId;
            opp.If_Authorizing__c = true;
            opp.if_Interface_Lock__c = true;
            opp.IF_Submit__c = true;
            update opp;
            return null;
        } catch (Exception e) {
            String eMessage = e.getMessage();
            Integer left  = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    @AuraEnabled
    public static string updateForLoseBidButton(String recordId){
        try {
            Opportunity opp = new Opportunity();
            opp.Id = recordId;
            opp.ConfirmationofAward__c = '竞争对手中标';
            update opp;
            return null;
        } catch (Exception e) {
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    @AuraEnabled
    public static string updateForOLYwinBidButton(String recordId){
        try {
            Opportunity opp = [select ConfirmationofAward__c,Closing_Bid_Date__c from Opportunity where Id =: recordId];
            opp.ConfirmationofAward__c = 'OLY中标';
            if (opp.Closing_Bid_Date__c == null) {
                opp.Closing_Bid_Date__c = Date.today();
            }
            update opp;
            return null;
        } catch (Exception e) {
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
        }
    }
    @AuraEnabled
    public static List<InquiryPredictsDateChange__c> queryForPredictedDateChangeButton(String recordId){
        List<InquiryPredictsDateChange__c> rac = null;
        try {
            rac = [
                select 
                id 
                from InquiryPredictsDateChange__c where Predicted_Date_Status__c = '审批中' and Opportunity__c =:recordId];
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return rac;
    }
    @AuraEnabled
    public static List<task__c> queryForLoseBidButton(String recordId){
        List<task__c> tasks = null;
        try {
            tasks = [
                select
                taskStatus__c
                from task__c where OpportunityId__c =: recordId and name like '%中标结果确认%'];
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return tasks;
    }
    @AuraEnabled
    public static List<task__c> queryForOLYwinBidButton(String recordId){
        List<task__c> tasks = null;
        try {
            tasks = [
                select
                taskStatus__c
                from task__c where OpportunityId__c =: recordId and name like '%中标结果确认%'];
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
        return tasks;
    }
    public class InitData{
        @AuraEnabled
        public Boolean directLossFLG;
        @AuraEnabled
        public Date createdDay;
        @AuraEnabled
        public String agency1Id;
        @AuraEnabled
        public String agency1;
        @AuraEnabled
        public String stageName;
        @AuraEnabled
        public Boolean sapSendOK;
        @AuraEnabled
        public String oppOrderType;
        @AuraEnabled
        public Boolean ifHave170;
        @AuraEnabled
        public Boolean ifHaveAH;
        @AuraEnabled
        public Decimal cntLostCancelDraft;
        @AuraEnabled
        public Decimal cntLostCancelReport;
        @AuraEnabled
        public String estimationId;
        @AuraEnabled
        public Decimal detailNum;
        @AuraEnabled
        public Boolean estimationDecision;
        @AuraEnabled
        public String salesRoot;
        @AuraEnabled
        public Boolean acecideCntCheck;
        @AuraEnabled
        public Boolean ifSubmit;
        @AuraEnabled
        public String trade;
        @AuraEnabled
        public Boolean isCorrosion;
        @AuraEnabled
        public Boolean ifAuthorizingLock;
        @AuraEnabled
        public String profileId;
        @AuraEnabled
        public String ifOpenBid;
        @AuraEnabled
        public String accountId;
        @AuraEnabled
        public String userId;
        @AuraEnabled
        public String name;
        @AuraEnabled
        public Date bidPlannedDate;
        @AuraEnabled
        public String salesAssistantName;
        @AuraEnabled
        public String salesAssistantID;
    }
}