liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 * 2021-11-09  mzy  SWAG-C8KCZZ
 * 【委托】营业担当SFDC系统首页增加“未接受任务”(未转化询价)提醒功能申请 
 */
public with sharing class AgencyOpportunityManageCotroller {
    public AgencyOpportunityManageCotroller() {
 
    }
 
    //获取当前用户可以查看到的未转换成询价的经销商询价
    public static AgencyOpportunityView getCurrentAgencyOpportunity(){
        AgencyOpportunityView tempView = new AgencyOpportunityView();
        // 提醒权限:2S1_销售医院担当
        String myUserID = UserInfo.getUserId();
        User currentUser = [SELECT Id,ProfileId FROM user Where Id = :myUserID];
        //String currentUserProfileId = String.valueOf(currentUser.ProfileId).substring(0,15);
        String currentUserProfileId = currentUser.ProfileId;
        if(currentUserProfileId.equals(System.Label.ProfileId2S1HP) || currentUserProfileId.equals(System.Label.ProfileId_2S4)
        || currentUserProfileId.equals(System.Label.ProfileId_2S4_Chief) ){
            //当前登录用户简档为2S1_销售医院担当
            tempView.isShow = true;
            //查找未转换成询价的经销商询价
            tempView.AgencyOpportunityList = goSelectByCurrentUser();
        }
        return tempView;
    }
 
    //查找未转换成询价的经销商询价
    public static List<Agency_Opportunity__c> goSelectByCurrentUser(){
        //定义变量保存查询结果
        List<Agency_Opportunity__c> AgencyOpportunityList= new List<Agency_Opportunity__c>();
        //查询
        String sql = 'SELECT Id FROM Agency_Opportunity__c ';
        //条件拼接
            //记录类型
            sql += 'WHERE RecordType_Name__c = \'Opportunity\' ';
            //询价阶段
            sql += 'AND StageName__c NOT IN (\'中标签约\',\'失单\',\'取消\') ';
            //已转换
            sql += 'AND Is_Transformed__c = false ';
            //是否OCSM共享询价
            sql += 'AND OCM_Change_To_Opportunity_Flg__c = false ';
            //营业担当确认
            sql += 'AND No_Convert_Reason__c IN (\'\',\'2.询价尚未成熟\',null) ';
        AgencyOpportunityList  = Database.query(sql);
 
        return AgencyOpportunityList;
    }
 
    
    public class AgencyOpportunityView {
        //是否显示
        @AuraEnabled
        public Boolean isShow;
        //查询结果
        @AuraEnabled
        public List<Agency_Opportunity__c> AgencyOpportunityList;
 
        public AgencyOpportunityView(){
            this.isShow = false;
            this.AgencyOpportunityList = new List<Agency_Opportunity__c>();
        }
    }
}