19626
2023-10-31 fd9df05c48c09b4d7f39a3b401882bda226dedea
force-app/main/default/classes/OpportunityLightingButtonController.cls
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-12 11:16:07
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-10-08 18:09:35
 * @LastEditTime: 2023-10-26 20:30:06
 */
public with sharing class OpportunityLightingButtonController {
    @AuraEnabled
@@ -19,6 +19,12 @@
                from Lost_cancel_report__c where RecordTypeId != '01210000000R4hHAAS' and Opportunity__c =: recordId];
            rep.lostReport = re;
            objs.put('report',rep);
            Schema.DescribeSObjectResult s = Lost_cancel_report__c.sObjectType.getDescribe();
         if( !s.isCreateable()) {
            objs.put('error',true);
         }else{
                objs.put('error',false);
            }
        } catch (Exception e) {
            objs.put('error',e.getMessage());
            return objs;
@@ -294,6 +300,12 @@
            res.salesOwnerBuchang = opportunity.Sales_owner_buchang__c;
            res.salesOwnerBuchangID = opportunity.Sales_owner_buchangID__c;
            res.cntLostCancelDraft = opportunity.Cnt_Lost_cancel_Draft__c;
            Schema.DescribeSObjectResult s = Lost_cancel_report__c.sObjectType.getDescribe();
         if( !s.isCreateable()) {
            res.isHavePower = false;
         }else{
                res.isHavePower = true;
            }
        } catch (Exception e) {
            
        }
@@ -450,7 +462,8 @@
                SI_Decide_ID__c,
                Name,
                Opportunity_No__c,
                IsAuthorized__c
                IsAuthorized__c,
                recordTypeId
                from Opportunity where Id =: recordId
            ];
            res.authorizedDBNo = oppo.Authorized_DB_No__c;
@@ -459,6 +472,7 @@
            res.name = oppo.Name;
            res.opportunityNo = oppo.Opportunity_No__c;
            res.isAuthorized = oppo.IsAuthorized__c;
            res.recordTypeId = oppo.recordTypeId;
        } catch (Exception e) {
            
        }
@@ -772,7 +786,18 @@
            ];
            return user.Id;
        } catch (Exception e) {
            return errorMessage(e);
            if (e.getMessage().contains(',')) {
                System.debug(LoggingLevel.INFO, '*** e: ' + e);
                String exc = '' + e.getMessage();
                Integer left = exc.indexOf(':') + 1;
                Integer right = exc.lastIndexOf(':');
                String str = exc.substring(left,right);
                left = str.indexOf(',') +  1;
                String newStr = str.substring(left);
                return newStr;
            }else {
                return e.getMessage();
            }
        }
    }
    @AuraEnabled
@@ -786,7 +811,18 @@
            ];
            return pro.Id;
        } catch (Exception e) {
            return errorMessage(e);
            if (e.getMessage().contains(',')) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            String exc = '' + e.getMessage();
            Integer left = exc.indexOf(':') + 1;
            Integer right = exc.lastIndexOf(':');
            String str = exc.substring(left,right);
            left = str.indexOf(',') +  1;
            String newStr = str.substring(left);
            return newStr;
         }else {
            return e.getMessage();
         }
        }
    }
    @AuraEnabled
@@ -934,7 +970,26 @@
            return errorMessage(ex);
        }
    }
    @AuraEnabled
    public static Boolean queryLostReport (String recordId){
        RecordType recordType1 = [select Id from RecordType where Name = '询价取消报告'];
        List<Lost_cancel_report__c> repList = [select Id from Lost_cancel_report__c where Opportunity__c =: recordId and RecordTypeId !=: recordType1.Id];
        if(repList.size() > 0){
            return true;
        }
        return false;
    }
    @AuraEnabled
    public static Boolean queryCancelReport (String recordId){
        RecordType recordType1 = [select Id from RecordType where Name = '询价取消报告'];
        List<Lost_cancel_report__c> repList = [select Id from Lost_cancel_report__c where Opportunity__c =: recordId and RecordTypeId =: recordType1.Id];
        if(repList.size() > 0){
            return true;
        }
        return false;
    }
    public static string errorMessage(Exception e){
        if (e.getMessage().contains(',')) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -947,9 +1002,9 @@
            return newStr;
        }else {
            return e.getMessage();   
        }
        }
    }
    public class InitData{
        @AuraEnabled
        public Boolean directLossFLG;
@@ -1101,5 +1156,7 @@
        public String reportStatus;
        @AuraEnabled
        public String reportId;
        @AuraEnabled
        public Boolean isHavePower;
    }
}