GWY
2022-04-27 12b7399736e90d33bfe0c2d29917d6f075246e00
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
global class OrdertoZhaoEmailBatch implements Database.Batchable<sObject> {
    //给赵新安总监发邮件,更改他的IS_8_Sendemail__c字段的真或假,联合'发送邮件给赵新安总监'的工作流。
    private List<String> idList = null;
 
    global OrdertoZhaoEmailBatch() {
    }
 
    global OrdertoZhaoEmailBatch(List<String> temp) {
       idList = temp;
    }
 
    global Database.QueryLocator start(Database.BatchableContext bc) {
        if(idList != null && idList.size()!=0){
            // return Database.getQueryLocator([select CreatedDate,Low_profit__c,LS_Big_amount__c,IENDTANI_Big_amount__c,RVI_Big_amount__c,
            //     Whether_the_mhbs__c,IS_8_Sendemail__c,Is_TAX__c
            //     from Order 
            //     where (Low_profit__c = true or  LS_Big_amount__c = true or IENDTANI_Big_amount__c = true or RVI_Big_amount__c = true) 
            //     and Whether_the_mhbs__c = false and ApproveStatus__c = 'OrderPass' 
            //     and CreatedDate >= 2021-04-01T00:00:00.000+0000
            //     and Id in :idList]);
             return Database.getQueryLocator([select CreatedDate,Low_profit__c,LS_Big_amount__c,IENDTANI_Big_amount__c,RVI_Big_amount__c,
                Whether_the_mhbs__c,IS_8_Sendemail__c,Is_TAX__c
                from Order 
                where Id in :idList]);
        }else{
            return Database.getQueryLocator([select CreatedDate,Low_profit__c,LS_Big_amount__c,IENDTANI_Big_amount__c,RVI_Big_amount__c,
                Whether_the_mhbs__c,IS_8_Sendemail__c,Is_TAX__c 
                from Order 
                where (Low_profit__c = true or  LS_Big_amount__c = true or IENDTANI_Big_amount__c = true or RVI_Big_amount__c = true) 
                and Whether_the_mhbs__c = false and ApproveStatus__c = 'OrderPass' 
                and CreatedDate >= 2021-04-01T00:00:00.000+0000]);    
                }
        }
 
    global void execute(Database.BatchableContext BC, list<Sobject> scope) {
        List<Order> updatetfList = new List<Order>();
        for(Sobject obj : scope){
            Order oer = (Order)obj;
            if(oer.IS_8_Sendemail__c == false){
                oer.IS_8_Sendemail__c = true;
            updatetfList.add(oer);
            }
        }
        if (updatetfList.size() > 0) update updatetfList;
    }
 
    global void finish(Database.BatchableContext BC) {
 
    }
}