liwentao
2023-05-17 0a759be7943c0352c540dd5aee70ffbf946bbe9e
force-app/main/default/classes/LexContractAuthorizeController.cls
@@ -4,7 +4,7 @@
    @AuraEnabled
    public static Opportunity init(String recordId){
       try{
          Opportunity item=[select
          Opportunity item=[select
           id,Estimation_Decision__c,Contract_DB_complite_day__c,Contract_Authorize__c,Contract_Authorize_Lock__c,If_Need_Authorize__c,
           Authorized_DB_No__c,SPO_URL__c,Estimation_No__c,Closing_Bid_Date__c,Bid_Date__c,
           Cnt_Lost_cancel_Draft__c,Cnt_Lost_cancel_report__c,IF_Submit__c,Agency1__c,Trade__c,Sales_Root__c,Is_Corrosion__c
@@ -19,7 +19,7 @@
    }
    @AuraEnabled
    public static UpdateResult updateOppotunity(
    public static UpdateResult updateOppotunity(
        String recordId
    ) {
        UpdateResult result = new UpdateResult();
@@ -29,7 +29,7 @@
            opp.Contract_Authorize__c = true;
         opp.If_Interface_Lock__c=true;
         opp.IF_Submit__c = true;
            update opp;
            result.success = true;
@@ -61,6 +61,18 @@
   public static String getProfileId(){
      return UserInfo.getProfileId();
   }
    @AuraEnabled
    public static boolean queryProfileId(){
        List<Profile> res=[select id,name from profile where name in
        ('2J3_特约店窗口','2M4_市场产品本部担当(询价)','系统管理员','2S6-2_营业助理','2S7_销售本部合同管理窗口','2S6-1_销售本部窗口')
        ];
        for(Profile p:res){
            if (UserInfo.getProfileId()==p.id) {
                return true;
            }
        }
        return false;
    }
   @AuraEnabled
   public static Boolean judgeIsAssistantAppliedOutTime(String  Quoteid) {
        List<PromotionSales__c> PromotionSalesList = [select id,IsAssistantAppliedOutTime__c from PromotionSales__c where Quote__r.Quote_No__c =:Quoteid];
@@ -95,7 +107,7 @@
                                                     WHERE LicenseAndAccount__c = :agency1
                                                       AND LicenseType__c = '危险化学品经营许可证'
                                                       AND Is_Active_Formula__c = true
                                                    ];
        //检查是否有阿西赛多协议
        List<Account> accountList = [SELECT Id
@@ -131,7 +143,7 @@
        Map<Id, String> proMap= new Map<Id, String>();
        List<OpportunityLineItem> OppItemList = [select PricebookEntry.Product2Id, PricebookEntry.Product2.Name
                                                   From OpportunityLineItem
                                                   From OpportunityLineItem
                                                  Where OpportunityId = :oppid];
        if (OppItemList.size() > 0) {
@@ -152,7 +164,7 @@
        return strRet;
    }
    public static String checkProRegisterDecide(Map<Id, String> proMap, String agency1, String OppId) {
        String errormessage = '';
        Boolean error = false;
@@ -170,8 +182,8 @@
        List<OpportunityLineItem> updList = new List<OpportunityLineItem>();
        List<OpportunityLineItem> OppItemList = [select id, Id__c, Register_alleffective__c,
                                                        PricebookEntry.Product2.RegisterNo_ALL__c
                                                           From OpportunityLineItem
                                                        PricebookEntry.Product2.RegisterNo_ALL__c
                                                           From OpportunityLineItem
                                                          Where OpportunityId = :oppid];
        for (OpportunityLineItem ol : OppItemList) {
            ol.Register_alleffective__c = ol.PricebookEntry.Product2.RegisterNo_ALL__c;
@@ -217,11 +229,11 @@
        //         midStr.add(rr.Register_old__c);
        //         new_oldMap.put(rr.Register_new__c, midStr.clone());
        //     }
        // }
        // 取得经销商 医疗器械经营许可证
        List<License_Information__c> licenseList = [SELECT Id,
                                                           ScopeKey__c,
                                                           ScopeKey__c,
                                                           LicenseType__c
                                                      FROM License_Information__c
                                                     WHERE LicenseAndAccount__c = :agency1
@@ -253,23 +265,23 @@
                    agList.add(a.substring(0, a.length() - 1));
                } else {
                    agList.add(a.trim());
                }
                }
            }
            //产品注册证
            Map<String,Map<String,String>> proBSMap = new Map<String,Map<String,String>>();
            Map<String,String> proMidMap = null;
            //产品所有有效注册证(可以和经销商匹配)
            proAllBSstrMap = new Map<String,List<String>>();
            set<Id> proIdList = new set<Id>();
            for (String qli : proMap.keySet()) {
            for (String qli : proMap.keySet()) {
                    proIdList.add(qli);
                    proBSMap.put(qli, proMidMap);
                    List<String> empList = new List<String>();
                    proAllBSstrMap.put(qli, empList);
            }
            List<Product_Register_Link__c> prls = [
@@ -278,9 +290,9 @@
                                                        Product2__r.SFDA_Approbated_Status__c,
                                                        Product2__r.SFDA_Status_New__c, // 产品的CFDA最终状态 20181225
                                                        Product_Register__r.Name,
                                                        Product_Register__r.BusinessScopeKey__c,
                                                        Product_Register__r.BusinessScopeKey__c,
                                                        Product_Register__r.RegisterNoStatus__c,
                                                        Product_Register__r.MedPrdClass__c
                                                        Product_Register__r.MedPrdClass__c
                                                   From Product_Register_Link__c
                                                  where Product2__c in :proIdList
                                                  ];
@@ -295,13 +307,13 @@
            // LHJ 20190102 增加跳过逻辑 End
            for (Product_Register_Link__c prl : prls) {
                // 设置产品类别MAP
                if (String.isNotBlank(prl.Product_Register__r.BusinessScopeKey__c)) {
                    system.debug('Product2 +++++++' + prl.Product2__c);
                    if (proBSMap.get(prl.Product2__c) != null) {
                        proBSMap.get(prl.Product2__c).put(prl.Product_Register__r.Name, prl.Product_Register__r.BusinessScopeKey__c);
                    } else {
                        Map<String,String> toooMap = new Map<String,String>();
                        toooMap.put(prl.Product_Register__r.Name, prl.Product_Register__r.BusinessScopeKey__c);
@@ -310,8 +322,8 @@
                }
                // 产品的产品注册证是"不要"状态 不需要匹配注册证 20181225
                if (prl.Product2__r.SFDA_Approbated_Status__c == '不要'
                if (prl.Product2__r.SFDA_Approbated_Status__c == '不要'
                        || prl.Product_Register__r.MedPrdClass__c == '1') {
                     proNotNeedList.add(prl.Product2__c);
                }
@@ -353,7 +365,7 @@
                            for(String strReg:proRegList){
                                // 被定义为"6815A"的产品类别,经营范围中必须有6815或者6815A外才可以匹配。
                                if (strReg.length() == 6) {
                                    for(String strAg:agListA){
                                        if(strAg.length() >= 5 && midMap.get(str.substring(0, str.length() - 1)) == strAg.substring(0,5)){
                                            proAllBSstrMap.get(proId).add(str.substring(0, str.length() - 1));
@@ -377,10 +389,10 @@
                                        haveBS = true;
                                        break;
                                    }
                                }
                                }
                            }
                        }
                    }
@@ -395,7 +407,7 @@
        if (retMap.isEmpty() == false) {
            //return errormessage;
        } else {
            if (OppId != '') {
                // 更新所有注册证信息
@@ -404,7 +416,7 @@
                Map<String, Product2> pro2Map = new Map<String, Product2>();
                List<OpportunityLineItem> updList = new List<OpportunityLineItem>();
                List<OpportunityLineItem> OppItemList = [select id, Id__c, Register_alleffective__c,PricebookEntry.Product2Id
                                                           From OpportunityLineItem
                                                           From OpportunityLineItem
                                                          Where OpportunityId = :OppId];
                // 非医疗或1类产品,取得
                if (proNotNeedList != null && proNotNeedList.size() > 0) {
@@ -439,7 +451,7 @@
                if (updList.size() > 0)  update updList;
            }
        }
        //如果不满足阿西赛多的条件,进入这个变量 20200821 ljh
        //如果不满足阿西赛多的条件,进入这个变量 20200821 ljh
        return retMap;
    }
    public class UpdateResult {
@@ -449,6 +461,6 @@
    }
   public class InitData{
    }
}
}