|
|
@@ -508,15 +508,28 @@ public class Task {
|
|
|
LOG_PREFIX, openRewardLive.getLiveId(), config.getParticipateCondition());
|
|
|
continue;
|
|
|
}
|
|
|
+ if (openRewardLive.getStartTime() != null
|
|
|
+ && openRewardLive.getStartTime().isAfter(LocalDateTime.now())) {
|
|
|
+ log.info("{} autoUpdateWatchReward 直播未开始,跳过: liveId={}, startTime={}",
|
|
|
+ LOG_PREFIX, openRewardLive.getLiveId(), openRewardLive.getStartTime());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
List<LiveWatchUser> liveWatchUsers = liveWatchUserService.checkOnlineNoRewardUser(openRewardLive.getLiveId(), now);
|
|
|
if (liveWatchUsers == null || liveWatchUsers.isEmpty()) {
|
|
|
log.info("{} autoUpdateWatchReward 无待发放用户: liveId={}", LOG_PREFIX, openRewardLive.getLiveId());
|
|
|
continue;
|
|
|
}
|
|
|
- // 3.检查当前直播间的在线用户(可以传入一个时间,然后查出来当天没领取奖励的用户)
|
|
|
- List<LiveWatchUser> onlineUser = liveWatchUsers
|
|
|
- .stream().filter(user -> (now.getTime() - user.getUpdateTime().getTime() + (user.getOnlineSeconds() == null ? 0L : user.getOnlineSeconds())) > config.getWatchDuration() * 60 * 1000)
|
|
|
+ long requiredWatchSeconds = config.getWatchDuration() * 60;
|
|
|
+ List<LiveWatchUser> onlineUser = liveWatchUsers.stream()
|
|
|
+ .filter(user -> {
|
|
|
+ if (user.getUserId() == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Long watchSeconds = liveWatchUserService.getUserWatchDuration(
|
|
|
+ openRewardLive.getLiveId(), user.getUserId());
|
|
|
+ return watchSeconds != null && watchSeconds >= requiredWatchSeconds;
|
|
|
+ })
|
|
|
.collect(Collectors.toList());
|
|
|
if (onlineUser.isEmpty()) {
|
|
|
log.info("{} autoUpdateWatchReward 无达到观看时长用户: liveId={}", LOG_PREFIX, openRewardLive.getLiveId());
|