admin
2021-06-30 a3304721c2e45e0f2ebd3139fdd623353f2ac72a
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
package com.ks.lijin.job;
 
import com.ks.lijin.pojo.DO.LiJinProviderTaoKeAccount;
import com.ks.lijin.service.LiJinProviderAccountService;
import com.ks.lijin.service.manager.LiJinProviderTaoKeAccountManager;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;
import org.yeshi.utils.DateUtil;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
@Component
public class LijinAccountJob {
 
 
    @Resource
    private LiJinProviderAccountService liJinProviderAccountService;
 
    @Resource
    private LiJinProviderTaoKeAccountManager liJinProviderTaoKeAccountManager;
 
    /**
     * 初始化淘客账号(每天凌晨过2分执行)
     *
     * @param param
     * @return
     * @throws Exception
     */
    @XxlJob("account-initTodayTaoKeAccount")
    public ReturnT<String> initTodayTaoKeAccount(String param) throws Exception {
        List<LiJinProviderTaoKeAccount> list = liJinProviderAccountService.listValidByProviderId(null, null);
        for (LiJinProviderTaoKeAccount account : list) {
            liJinProviderTaoKeAccountManager.initTodayData(account.getId());
        }
        return ReturnT.SUCCESS;
    }
 
 
    /**
     * 删除redis中过期的淘客账号信息
     *
     * @param param
     * @return
     * @throws Exception
     */
    @XxlJob("account-deleteOutDateAccountInRedis")
    public ReturnT<String> deleteOutDateAccountInRedis(String param) throws Exception {
        //删除1-5天前的
        Date now = new Date();
        for (int i = 1; i < 5; i++) {
            Date date = DateUtil.plusDayDate(0 - i, now);
            liJinProviderTaoKeAccountManager.deleteInfoInRedis(date);
        }
        return ReturnT.SUCCESS;
    }
}