幸运24-我的排名
This commit is contained in:
@@ -5,13 +5,15 @@ import com.accompany.core.model.Users;
|
||||
import com.accompany.core.vo.UserLevelVo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
@ApiModel
|
||||
@Getter
|
||||
public class Lucky24WeekRankItemVo extends SimpleUserLevelVo {
|
||||
private int rank;
|
||||
private Double score;
|
||||
private double score;
|
||||
|
||||
public Lucky24WeekRankItemVo(Users targetUser, UserLevelVo userLevelVo, int rank, Double score) {
|
||||
public Lucky24WeekRankItemVo(Users targetUser, UserLevelVo userLevelVo, int rank, double score) {
|
||||
super(targetUser, userLevelVo);
|
||||
this.rank = rank;
|
||||
this.score = score;
|
||||
|
@@ -14,6 +14,8 @@ public class Lucky24WeekRankVo {
|
||||
private Long remainMillis;
|
||||
@ApiModelProperty("排行榜")
|
||||
private List<Lucky24WeekRankItemVo> rankList;
|
||||
@ApiModelProperty("我的排名")
|
||||
private Lucky24WeekRankItemVo meRank;
|
||||
@ApiModelProperty("飘屏列表")
|
||||
private List<Lucky24WeekFloatingItemVo> floatingList;
|
||||
|
||||
|
@@ -87,10 +87,27 @@ public class Lucky24SendWeekRankService extends AbstractRankService implements I
|
||||
List<Lucky24WeekRankItemVo> rankItemList = listRankItem(now, 30L, partitionEnum.getId());
|
||||
rankVo.setRankList(rankItemList);
|
||||
|
||||
Lucky24WeekRankItemVo meRank = getUserRankItem(now, me, rankItemList);
|
||||
rankVo.setMeRank(meRank);
|
||||
|
||||
rankVo.setFloatingList(getFloatingList(me.getPartitionId()));
|
||||
return rankVo;
|
||||
}
|
||||
|
||||
private Lucky24WeekRankItemVo getUserRankItem(Date now, Users me, List<Lucky24WeekRankItemVo> rankItemList) {
|
||||
if (CollectionUtil.isEmpty(rankItemList)){
|
||||
UserLevelVo meLevelVo = levelService.getUserLevelVo(me.getUid());
|
||||
return new Lucky24WeekRankItemVo(me, meLevelVo, 0, 0d);
|
||||
}
|
||||
Optional<Lucky24WeekRankItemVo> meRankOptional = rankItemList.stream().filter(item -> item.getUid().equals(me.getUid())).findFirst();
|
||||
if (meRankOptional.isPresent()){
|
||||
return meRankOptional.get();
|
||||
}
|
||||
UserLevelVo meLevelVo = levelService.getUserLevelVo(me.getUid());
|
||||
Double score = getUserRank(now, me.getUid(), me.getPartitionId());
|
||||
return new Lucky24WeekRankItemVo(me, meLevelVo, 0, score);
|
||||
}
|
||||
|
||||
private List<Lucky24WeekFloatingItemVo> getFloatingList(Integer partitionId) {
|
||||
List<Lucky24Record> recordList = getRecordList(partitionId).readAll();
|
||||
if (CollectionUtil.isEmpty(recordList)){
|
||||
@@ -155,7 +172,6 @@ public class Lucky24SendWeekRankService extends AbstractRankService implements I
|
||||
Map<Long, Users> usersMap = usersService.getUsersMapBatch(uidArray);
|
||||
Map<Long, UserLevelVo> userLevelVoMap = levelService.getUserLevelVoMap(uidArray);
|
||||
|
||||
|
||||
int rank = 0;
|
||||
for (Map<String, Object> ranking : rankSet) {
|
||||
Long uid = Long.parseLong((String) ranking.get(RedisZSetEnum.member.name()));
|
||||
@@ -170,4 +186,9 @@ public class Lucky24SendWeekRankService extends AbstractRankService implements I
|
||||
|
||||
return rankItemList;
|
||||
}
|
||||
|
||||
public void settlement(Integer id, ZonedDateTime hourAgo) {
|
||||
//Date lastWeek = hourAgo;
|
||||
//List<Lucky24WeekRankItemVo> list = listRankItem(lastWeek, 10L, partitionEnum.getId());
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.accompany.scheduler.task.luckyBag;
|
||||
|
||||
import com.accompany.business.message.GiftMessage;
|
||||
import com.accompany.business.message.Lucky24Message;
|
||||
import com.accompany.business.service.gift.Lucky24MessageService;
|
||||
import com.accompany.business.service.lucky.Lucky24RecordService;
|
||||
|
@@ -0,0 +1,47 @@
|
||||
package com.accompany.scheduler.task.luckyBag;
|
||||
|
||||
import com.accompany.business.service.lucky.rank.Lucky24SendWeekRankService;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.model.PartitionInfo;
|
||||
import com.accompany.core.service.partition.PartitionInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class Lucky24WeekRankTask {
|
||||
|
||||
@Autowired
|
||||
private PartitionInfoService partitionInfoService;
|
||||
@Resource(name = "bizExecutor")
|
||||
private ThreadPoolExecutor bizExecutor;
|
||||
@Autowired
|
||||
private Lucky24SendWeekRankService service;
|
||||
|
||||
@Scheduled(cron = "0 1 * * * ? ")
|
||||
public void lucky24WeekRankSettlement() {
|
||||
Date now = new Date();
|
||||
List<PartitionInfo> partitionInfoList = partitionInfoService.listAll();
|
||||
for (PartitionInfo partitionInfo : partitionInfoList) {
|
||||
ZonedDateTime zdt = DateTimeUtil.convertWithZoneId(now, partitionInfo.getZoneId());
|
||||
ZonedDateTime hourAgo = zdt.minusHours(1L);
|
||||
log.info("[lucky24WeekRankSettlement] zdt {} hourAgo {}, zdtDay {} hourAgoDay {}",
|
||||
zdt, hourAgo, zdt.getDayOfWeek(), hourAgo.getDayOfWeek());
|
||||
if (!zdt.getDayOfWeek().equals(DayOfWeek.MONDAY) || !hourAgo.getDayOfWeek().equals(DayOfWeek.SUNDAY)){
|
||||
continue;
|
||||
}
|
||||
bizExecutor.execute(() -> {
|
||||
service.settlement(partitionInfo.getId(), hourAgo);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user