buli
2023-05-22 71b93327e8f3fb3bffffc7c033c1f782e7b6ab32
force-app/main/default/classes/LexSummonsCreatController.cls
@@ -2521,32 +2521,53 @@
        nameCondition += '%' + String.escapeSingleQuotes(''.replaceAll('%', '\\%')) + '%';
        List<Account> accs;
        System.debug('nameCondition = ' + nameCondition);
        accs = [
            SELECT id, Parentid
            FROM Account
            WHERE
                Parent.Name LIKE :nameCondition
                AND Contract_Decide_Start_Date__c <= :Date.Today()
                AND Contract_Decide_End_Date__c >= :Date.Today()
        ];
        // 用于保存特约经销商匹配到的其父类的id
        Set<String> pids = new Set<String>();
        for (Account acc : accs) {
            pids.add(acc.Parentid);
        }
        //查询条件修改
        //筛选判断条件:当前财年的4/1 ~ 第二年的6/30  & ET or ENG类型 & 当前用户类型
        //1 and 2
        //1. Integer year 2022/4/1 ~ 2023/6/30
        //开始日期 + 结束日期
        //Contract_Decide_Start_Date__c>=开始日期  and Contract_Decide_End_Date__c<结束日期
        //2. 添加经销商允销类型:ET经销商协议;ENG耗材经销商协议
        //取当前用户的类型,如果用户类型是ET,ET经销商协议 = true
        accs = [
            SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
            FROM Account
            WHERE
                (Id IN :pids
                OR (Name = '奥林巴斯(北京)销售服务有限公司'
                AND Name LIKE :nameCondition))
                 Name = '奥林巴斯(北京)销售服务有限公司'
                AND Name LIKE :nameCondition
                AND RecordType.DeveloperName = 'Agency'
                AND Is_Active__c != '無効'
                //And 1 And 2
                //AND Is_Active__c != '無効'
            ORDER BY Name
            LIMIT 5
            LIMIT 49
        ];
        // accs = [
        //     SELECT id, Parentid
        //     FROM Account
        //     WHERE
        //         Parent.Name LIKE :nameCondition
        //         AND Contract_Decide_Start_Date__c <= :Date.Today()
        //         AND Contract_Decide_End_Date__c >= :Date.Today()
        // ];
        // 用于保存特约经销商匹配到的其父类的id
        // Set<String> pids = new Set<String>();
        // for (Account acc : accs) {
        //     pids.add(acc.Parentid);
        // }
        // accs = [
        //     SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
        //     FROM Account
        //     WHERE
        //         (Id IN :pids
        //         OR (Name = '奥林巴斯(北京)销售服务有限公司'
        //         AND Name LIKE :nameCondition))
        //         AND RecordType.DeveloperName = 'Agency'
        //         AND Is_Active__c != '無効'
        //     ORDER BY Name
        //     LIMIT 5
        // ];
        List<LookupSearchResult> results = new List<LookupSearchResult>();
        String accountIcon = 'standard:account';
@@ -2581,7 +2602,7 @@
        Map<String, object> data = new Map<String, object>();
        res.entity = data;
        List<ContentVersion> cvList = [
            SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate
            SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate,ContentDocumentId
            FROM ContentVersion
            WHERE FirstPublishLocationId = :recordId
        ];