admin
2022-10-28 0e9b6603d4ae9d11c1fbc90257ce816c5807b8ff
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
65
66
67
68
package com.yeshi.makemoney.app.job;
 
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yeshi.makemoney.app.entity.SystemEnum;
import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetRecordService;
import com.yeshi.makemoney.app.service.manager.PushManager;
import com.yeshi.makemoney.app.utils.goldcorn.GoldCornUtil;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.*;
 
/**
 * @author hxh
 * @title: PushJob
 * @description: 推送任务
 * @date 2022/5/7 17:44
 */
@Component
public class PushJob {
 
    @Resource
    private PushManager pushManager;
 
    @Resource
    private GoldCornGetRecordService goldCornGetRecordService;
 
 
    /**
     * @return com.xxl.job.core.biz.model.ReturnT<java.lang.String>
     * @author hxh
     * @description 推送签到
     * @date 18:18 2022/5/7
     * @param: param
     **/
    @XxlJob("pushSignIn")
    public ReturnT<String> pushSignIn(String param) throws Exception {
        SystemEnum system = SystemEnum.valueOf(param);
        //从近30日活跃用户中寻找今日还未签到的活跃用户
        Date now = new Date();
        int page = 1;
        int PAGE_SIZE = 500;
        List<Long> uidList;
 
        do {
            uidList = goldCornGetRecordService.listUids(new Date(now.getTime() - 1000 * 60 * 60 * 24L * 30), now, page, PAGE_SIZE);
            page++;
            if (uidList != null && uidList.size() > 0) {
                //查询是否签到
                Map<Long, Boolean> map = goldCornGetRecordService.isSignIned(uidList, GoldCornUtil.getFormatDay(now));
                List<Long> pushUids = new ArrayList<>();
                for (Long uid : map.keySet()) {
                    if (!map.get(uid)) {
                        pushUids.add(uid);
                    }
                }
                try {
                    pushManager.pushSignIn(system, pushUids);
                } catch (Exception e) {
 
                }
            }
        } while (uidList != null && uidList.size() > 0);
        return ReturnT.SUCCESS;
    }
 
}