From 4a05201d126ade3192225d25345ec78d2882affb Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期二, 18 四月 2023 16:40:11 +0800
Subject: [PATCH] Merge branch 'LEX_dev' of http://47.92.229.245:8089/r/lightningupdate into LEX_dev

---
 force-app/main/default/classes/OpportunityLightingButtonController.cls |  204 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 198 insertions(+), 6 deletions(-)

diff --git a/force-app/main/default/classes/OpportunityLightingButtonController.cls b/force-app/main/default/classes/OpportunityLightingButtonController.cls
index 45124f4..5c0b778 100644
--- a/force-app/main/default/classes/OpportunityLightingButtonController.cls
+++ b/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-04-13 17:02:46
+ * @LastEditTime: 2023-04-14 17:24:54
  */
 public with sharing class OpportunityLightingButtonController {
     @AuraEnabled
@@ -184,6 +184,127 @@
         return res;
     }
     @AuraEnabled
+    public static InitData initForCancelReportButton(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,
+            Job_category__c,
+            Bidding_Project_Name_Bid__c,
+            Name,
+            Sales_assistant_name__c,
+            Sales_assistant_ID__c,
+            Manager_name__c,
+            Sales_manager_departmentID__c,
+            Sales_owner_buchang__c,
+            Sales_owner_buchangID__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.jobCategory = opportunity.Job_category__c;
+        res.biddingProjectNameBid = opportunity.Bidding_Project_Name_Bid__c;
+        res.name = opportunity.Name;
+        res.salesAssistantName = opportunity.Sales_assistant_name__c;
+        res.salesAssistantID = opportunity.Sales_assistant_ID__c;
+        res.managerName = opportunity.Manager_name__c;
+        res.salesManagerDepartmentID = opportunity.Sales_manager_departmentID__c;
+        res.salesOwnerBuchang = opportunity.Sales_owner_buchang__c;
+        res.salesOwnerBuchangID = opportunity.Sales_owner_buchangID__c;
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return res;
+    }
+    @AuraEnabled
+    public static InitData initForLostReportButton(String recordId){
+        InitData res = new InitData();
+        try {
+            Opportunity opportunity = [
+                select
+                StageName,
+                SAP_Send_OK__c,
+                Cnt_Lost_cancel_report__c,
+                Name,
+                Sales_assistant_name__c,
+                Sales_assistant_ID__c,
+                Manager_name__c,
+                Sales_manager_departmentID__c,
+                Sales_owner_buchang__c,
+                Sales_owner_buchangID__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.name = opportunity.Name;
+            res.salesAssistantName = opportunity.Sales_assistant_name__c;
+            res.salesAssistantID = opportunity.Sales_assistant_ID__c;
+            res.managerName = opportunity.Manager_name__c;
+            res.salesManagerDepartmentID = opportunity.Sales_manager_departmentID__c;
+            res.salesOwnerBuchang = opportunity.Sales_owner_buchang__c;
+            res.salesOwnerBuchangID = opportunity.Sales_owner_buchangID__c;
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return res;
+    }
+    @AuraEnabled
+    public static InitData initForQuotationRequestButton(String recordId){
+        InitData res = new InitData();
+        try {
+            Opportunity opportunity = [
+                select
+                Bidding_Project_Name_Bid__r.Id,
+                Estimation_Id__c
+                from Opportunity where Id =: recordId
+            ];
+            res.biddingProjectNameBidId = opportunity.Bidding_Project_Name_Bid__r.Id;
+            res.estimationId = opportunity.Estimation_Id__c;
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return res;
+    }
+    @AuraEnabled
+    public static InitData initForStockApplyButton(String recordId){
+        InitData res = new InitData();
+        try {
+            Opportunity opportunity = [
+                select
+                Stock_apply_status__c,
+                Last_opportunity_file__r.Id
+                from Opportunity where Id =: recordId
+            ];
+            res.stockApplyStatus = opportunity.Stock_apply_status__c;
+            res.lastOpportunityFileId = opportunity.Last_opportunity_file__r.Id;
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return res;
+    }
+    @AuraEnabled
+    public static InitData initForQuotationProductNewButton(String recordId){
+        InitData res = new InitData();
+        try {
+            Opportunity opportunity = [
+                select
+                CurrencyIsoCode
+                from Opportunity where Id =: recordId
+            ];
+            res.currencyIsoCode = opportunity.CurrencyIsoCode;
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return res;
+    }
+    @AuraEnabled
     public static string updateForAgencyAuthorizeButton(String recordId){
         try {
             Opportunity opp = new Opportunity();
@@ -205,7 +326,7 @@
         try {
             Opportunity opp = new Opportunity();
             opp.Id = recordId;
-            opp.ConfirmationofAward__c = '绔炰簤瀵规墜涓爣';
+            opp.ConfirmationofAward__c = LightingButtonConstant.OPPORTUNITY_CONFIRMATION_OF_AWARD_LOSE_BID;
             update opp;
             return null;
         } catch (Exception e) {
@@ -219,9 +340,28 @@
     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涓爣';
+            opp.ConfirmationofAward__c = LightingButtonConstant.OPPORTUNITY_CONFIRMATION_OF_AWARD_OLY_WIN_BID;
             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 string updateForStockApplyButton(String recordId,Boolean flag){
+        try {
+            Opportunity opp = new Opportunity();
+            opp.Id = recordId;
+            if(flag){
+                opp.Stock_apply_status__c  = '濉啓瀹屾瘯';
+            }else {
+                opp.Stock_apply_status__c = '鑽夋涓�';
             }
             update opp;
             return null;
@@ -239,7 +379,7 @@
             rac = [
                 select 
                 id 
-                from InquiryPredictsDateChange__c where Predicted_Date_Status__c = '瀹℃壒涓�' and Opportunity__c =:recordId];
+                from InquiryPredictsDateChange__c where Predicted_Date_Status__c = :LightingButtonConstant.PREDICTED_DATE_STATUS and Opportunity__c =:recordId];
         } catch (Exception e) {
             System.debug('e:****' + e);
         }
@@ -249,10 +389,11 @@
     public static List<task__c> queryForLoseBidButton(String recordId){
         List<task__c> tasks = null;
         try {
+            String obscureName = '%' + LightingButtonConstant.TASK_NAME_BY_CONFIRMATION_OF_WINNING_BID + '%';
             tasks = [
                 select
                 taskStatus__c
-                from task__c where OpportunityId__c =: recordId and name like '%涓爣缁撴灉纭%'];
+                from task__c where OpportunityId__c =: recordId and name like :obscureName];
         } catch (Exception e) {
             System.debug('e:****' + e);
         }
@@ -262,14 +403,45 @@
     public static List<task__c> queryForOLYwinBidButton(String recordId){
         List<task__c> tasks = null;
         try {
+            String obscureName = '%' + LightingButtonConstant.TASK_NAME_BY_CONFIRMATION_OF_WINNING_BID + '%';
             tasks = [
                 select
                 taskStatus__c
-                from task__c where OpportunityId__c =: recordId and name like '%涓爣缁撴灉纭%'];
+                from task__c where OpportunityId__c =: recordId and name like :obscureName];
         } catch (Exception e) {
             System.debug('e:****' + e);
         }
         return tasks;
+    }
+    @AuraEnabled
+    public static List<Tender_Opportunity_Link__c> queryForCancelReportButton(String recordId){
+        List<Tender_Opportunity_Link__c> links = null;
+        try {
+            links = [
+                select id,
+                Tender_information__r.subInfoType__c
+                from Tender_Opportunity_Link__c 
+                where (Tender_information__r.subInfoType__c = '3-1锛氬簾鏍囧叕鍛�' OR Tender_information__r.subInfoType__c ='3-2锛氭祦鏍囧叕鍛�') and Opportunity__c =: recordId
+            ];
+        } catch (Exception e) {
+            System.debug('e:****' + e);
+        }
+        return links;
+    }
+    @AuraEnabled
+    public static List<QuoteIrai__c > queryForQuotationRequestButton(String recordId){
+        List<QuoteIrai__c> quotes = null;
+        try {
+            String opportunityId = '%' + recordId + '%';
+            quotes = [
+                select 
+                id 
+                from QuoteIrai__c where Note__c like :opportunityId and QuoteIrai_Status__c = '鑽夋涓�'
+            ];
+        } catch (Exception e) {
+            System.debug('e:****' + e);
+        }
+        return quotes;
     }
     public class InitData{
         @AuraEnabled
@@ -328,5 +500,25 @@
         public String salesAssistantName;
         @AuraEnabled
         public String salesAssistantID;
+        @AuraEnabled
+        public String jobCategory;
+        @AuraEnabled
+        public String biddingProjectNameBid;
+        @AuraEnabled
+        public String managerName;
+        @AuraEnabled
+        public String salesManagerDepartmentID;
+        @AuraEnabled
+        public String salesOwnerBuchang;
+        @AuraEnabled
+        public String salesOwnerBuchangID;
+        @AuraEnabled
+        public String biddingProjectNameBidId;
+        @AuraEnabled
+        public String stockApplyStatus;
+        @AuraEnabled
+        public String lastOpportunityFileId;
+        @AuraEnabled
+        public String currencyIsoCode;
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1