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
global class OPDPlanWarningSchedule implements Schedulable {
     global void execute(SchedulableContext sc) {
 
        Date today = Date.today();
        Date mon1stDate = Date.newInstance(today.year(), today.month(), 1);
        Date monLastDate = mon1stDate.addMonths(1).addDays(-1);
        // 本月最后一天的周日
        Date weekStart = monLastDate.toStartofWeek();
        system.debug('wwwwwwwww' + weekStart);
 
        Date lastSecondFriday;
        if (weekStart.addDays(5).month() == today.month()) {
            lastSecondFriday = weekStart.addDays(-2);
        } else {
            lastSecondFriday = weekStart.addDays(-9);
        }
        if(today == lastSecondFriday){
            // 设置一回最多只发40个邮件
            Id execBTId = Database.executeBatch(new OPDPlanWarningBatch(), 40);
            
        }
        // chenjingwu Batch整理合并 20240306 start
        Database.executeBatch(new updateCampaignMailflg7BeTrueBatch(),1);
        // chenjingwu Batch整理合并 20240306 end
    }
}