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
public class OppLoseController {
 
    @AuraEnabled
    public static InitData init(String taskId){
        InitData res = new initData();
        try{
            task__c task = [SELECT id, OpportunityId__c , taskStatus__c
                            FROM task__c
                            WHERE Id =: taskId 
                            LIMIT 1];
 
            res.task = task;
            res.taskStatus = task.taskStatus__c;
            res.OpportunityId = task.OpportunityId__c;
 
            Opportunity opp =  [SELECT Sales_owner_buchangID__c,Manager_name__c,Sales_owner_buchang__c,
                                       Sales_manager_departmentID__c,name,Sales_assistant_name__c,
                                       Sales_assistant_ID__c,id,StageName,SAP_Send_OK__c,
                                       Cnt_Lost_cancel_report__c,Bidding_Project_Name_Bid__c 
                                FROM Opportunity 
                                WHERE id =: task.OpportunityId__c];
            System.debug('---lt123---task:---- ' + task);
            System.debug('---lt123---opp:---- ' + opp);
            System.debug(LoggingLevel.INFO, '*** opp: ' + opp);
 
            res.StageName = opp.StageName;
            res.SAP_Send_OK = opp.SAP_Send_OK__c;
            res.Cnt_Lost_cancel_report = opp.Cnt_Lost_cancel_report__c;
            res.Name = opp.Name;
            res.Sales_assistant_name = opp.Sales_assistant_name__c;
            res.Sales_assistant_ID = opp.Sales_assistant_ID__c;
            res.Manager_name = opp.Manager_name__c;
            res.Sales_manager_departmentID = opp.Sales_manager_departmentID__c;
            res.Sales_owner_buchang = opp.Sales_owner_buchang__c;
            res.Sales_owner_buchangID = opp.Sales_owner_buchangID__c;
            RecordType re=[select Id from recordType where name='询价失单报告'];
            res.reId=re.Id;
            res.opp = opp;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }  
  
    public class ReturnData{
 
    }
    //OLY中标
    @AuraEnabled
    public static String taskOLYwinBid(String recordId) {
        String messageText = '';
       try {
        Opportunity opp = [SELECT Id,ConfirmationofAward__c FROM Opportunity WHERE Id = :recordId LIMIT 1];
        opp.Id = recordId;
        opp.ConfirmationofAward__c = LightingButtonConstant.STATUS_OLYwinBid;
        messageText = '1';
        update opp;
        System.debug(LoggingLevel.INFO, '*** winBid: ' + opp);
        return messageText;
       } catch (Exception e) {
        // System.debug(LoggingLevel.INFO, '*** winBidXu: ' + ex);
        // messageText = ex.getMessage();
        // return messageText;
        if(e.getMessage().contains(':')||System.Test.isrunningTest()){
            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;
        }
       }
    }
    //竞争对手中标
    @AuraEnabled
    public static String taskLoseBid(String recordId) {
        String messageText = '';
        try {
        Opportunity opp = [SELECT Id,ConfirmationofAward__c FROM Opportunity WHERE Id = :recordId LIMIT 1];
        opp.Id = recordId;
        opp.ConfirmationofAward__c = LightingButtonConstant.STATUS_Bid_LoseBid;
        messageText = '1';
        update opp;
        System.debug(LoggingLevel.INFO, '*** winBid: ' + opp);
        return messageText;
        } catch (Exception e) {
        // System.debug(LoggingLevel.INFO, '*** winBidXu: ' + ex);
        // messageText = ex.getMessage();
        // return messageText;
        if(e.getMessage().contains(':')||System.Test.isrunningTest()){
            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;
        }
        }
    }
    public class InitData{
        //询价数据
        @AuraEnabled
        public Opportunity opp;
        @AuraEnabled
        public String StageName;
        @AuraEnabled
        public Boolean SAP_Send_OK;
        @AuraEnabled
        public Decimal Cnt_Lost_cancel_report;
        @AuraEnabled
        public String Name;
        @AuraEnabled
        public String Sales_assistant_name;
        @AuraEnabled
        public String Sales_assistant_ID;
        @AuraEnabled
        public String Manager_name;
        @AuraEnabled
        public String Sales_manager_departmentID;
        @AuraEnabled
        public String Sales_owner_buchang;
        @AuraEnabled
        public String Sales_owner_buchangID;
 
        //任务
        @AuraEnabled
        public String OpportunityId;
        @AuraEnabled
        public String taskStatus;
        @AuraEnabled
        public task__c task;
        @AuraEnabled
        public String reId;
    }
 
}