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;
|
}
|
|
}
|