19626
2023-06-26 666b1cff3d705a53d07cd3ee6d146a7ef7ac7754
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-05-31 17:32:51
 * @LastEditTime: 2023-06-25 13:10:39
 */
public with sharing class OpportunityLightingButtonController {
    @AuraEnabled
@@ -184,6 +184,7 @@
            res.systemProfileId = getProfileIdByName(lexLightingButtonConstant.SYSTEM_PROFILE_NAME);
            res.s1ProfileId = getProfileIdByName(lexLightingButtonConstant.S1_PROFILE_NAME);
            res.s4ProfileId = getProfileIdByName(lexLightingButtonConstant.S4_PROFILE_NAME);
            res.recordTypeId = Schema.SObjectType.Request_tedner_doc__c.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_AUTHORIZATION_REQUEST).getRecordTypeId();
        } catch (Exception e) {
            System.debug('e:****' + e);
        }
@@ -305,7 +306,11 @@
                CurrencyIsoCode
                from Opportunity where Id =: recordId
            ];
            Report cnyReport = [SELECT Id FROM Report WHERE Name = :lexLightingButtonConstant.REPORT_NAME_FOR_CNY limit 1];
            Report usdReport = [SELECT Id FROM Report WHERE Name = :lexLightingButtonConstant.REPORT_NAME_FOR_USD limit 1];
            res.currencyIsoCode = opportunity.CurrencyIsoCode;
            res.reportForCNYId = cnyReport.Id;
            res.reportForUSDId = usdReport.Id;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
@@ -426,6 +431,7 @@
            res.accountId = opp.AccountId;
            res.accountName = acc.Name;
            res.name = opp.Name;
            res.recordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_INQUIRY_FOLLOW_UP).getRecordTypeId();
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
@@ -447,6 +453,42 @@
            res.estimationDecision = opp.Estimation_Decision__c;
            res.sapSendOK = opp.SAP_Send_OK__c;
            res.ifAuthorizingLock = opp.If_Authorizing_Lock__c;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForSpecilaApplyCreateButton(String recordId){
        InitData res = new InitData();
        try {
            Opportunity opp = [
                select
                Forecast_this_month__c
                from Opportunity where Id =: recordId
            ];
            res.oppForecastStatus = opp.Forecast_this_month__c;
            res.recordTypeId = Schema.SObjectType.OpportunitySpecialApply__c.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_SPECIL_APPLY_CREATE).getRecordTypeId();
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
        return res;
    }
    @AuraEnabled
    public static InitData initForSpecilaApplyCreateAchButton(String recordId){
        InitData res = new InitData();
        try {
            Statu_Achievements__c ach = [
                select
                Id,
                Monthly_forecast_shipping__c,
                Opportunity__c
                from Statu_Achievements__c where Id =: recordId
            ];
            res.oppId = ach.Opportunity__c;
            res.oppForecastStatus = ach.Monthly_forecast_shipping__c;
            res.recordTypeId = Schema.SObjectType.OpportunitySpecialApply__c.getRecordTypeInfosByName().get(lexLightingButtonConstant.RECORD_TYPE_NAME_BY_SPECIL_APPLY_CREATE_ACH).getRecordTypeId();
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
@@ -836,5 +878,13 @@
        public String accountName;
        @AuraEnabled
        public String recordTypeId;
        @AuraEnabled
        public String reportForCNYId;
        @AuraEnabled
        public String reportForUSDId;
        @AuraEnabled
        public String oppForecastStatus;
        @AuraEnabled
        public String oppId;
    }
}