财富、魅力等榜单top3奖励定时任务
This commit is contained in:
@@ -17,6 +17,8 @@ public enum ActivityType {
|
||||
KRYPTON_MONTH(10, "COMMON ACTIVITY", ACTIVITY_FIRST_COMMON, true),
|
||||
|
||||
VIGOUR_MONTH(11, "COMMON ACTIVITY", ACTIVITY_FIRST_COMMON, true),
|
||||
|
||||
GUILD_MONTH(12, "GUILD MONTH", ACTIVITY_FIRST_COMMON, true),
|
||||
;
|
||||
|
||||
private Integer type;
|
||||
|
@@ -0,0 +1,72 @@
|
||||
package com.accompany.business.service.rank;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.accompany.business.constant.activity.ActivityType;
|
||||
import com.accompany.business.service.activity.h5.ActivityRankRuleService;
|
||||
import com.accompany.common.constant.RankConstant;
|
||||
import com.accompany.common.enums.RedisZSetEnum;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.alibaba.excel.util.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.accompany.business.constant.activity.ActivityType.KRYPTON_MONTH;
|
||||
import static com.accompany.business.constant.activity.ActivityType.VIGOUR_MONTH;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MonthRankTaskService {
|
||||
|
||||
@Autowired
|
||||
private ActivityRankRuleService activityRankRuleService;
|
||||
|
||||
/**
|
||||
* 东三区排行榜单奖励
|
||||
* @param lastMonthDate
|
||||
* @param partitionId
|
||||
*/
|
||||
public void sendLastMonthRankTop4GMT3(Byte rankType, Date lastMonthDate, Integer partitionId) {
|
||||
String rankTypeStr = null;
|
||||
ActivityType activityType = null;
|
||||
switch (rankType){
|
||||
case RankConstant.RankType.vigour:
|
||||
rankTypeStr = RedisKey.vigour_rank.name();
|
||||
activityType = KRYPTON_MONTH;
|
||||
break;
|
||||
case RankConstant.RankType.krypton:
|
||||
rankTypeStr = RedisKey.krypton_rank.name();
|
||||
activityType = VIGOUR_MONTH;
|
||||
break;
|
||||
}
|
||||
IRank iRank = RankServiceFactory.getServiceByType(rankTypeStr, RankConstant.RankDatetype.month);
|
||||
Set<Map<String, Object>> rankSet = iRank.getRank(lastMonthDate, 0L, 2L, partitionId);
|
||||
if (CollectionUtil.isEmpty(rankSet)) {
|
||||
log.info("sendLastMonthRankTop4GMT3.emptyList");
|
||||
return;
|
||||
}
|
||||
String dateTimeFormat = iRank.dateTimeFormat(lastMonthDate);
|
||||
int level = 1;
|
||||
for (Map<String, Object> map : rankSet) {
|
||||
Long memberUid = Long.valueOf(map.get(RedisZSetEnum.member.name()).toString());
|
||||
activityRankRuleService.sendLevelRankAward(activityType, memberUid, level++, dateTimeFormat, partitionId, null);
|
||||
if (level > 3) {//保证只发前3
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 东八区排行榜单奖励
|
||||
* @param lastMonthDate
|
||||
* @param partitionId
|
||||
*/
|
||||
public void sendLastMonthRankTop4GMT8(Date lastMonthDate, Integer partitionId) {
|
||||
|
||||
}
|
||||
}
|
@@ -1,5 +1,8 @@
|
||||
package com.accompany.business.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.accompany.business.service.rank.MonthRankTaskService;
|
||||
import com.accompany.business.service.rank.RankService;
|
||||
import com.accompany.business.vo.RankParentVo;
|
||||
import com.accompany.business.vo.RankVo;
|
||||
@@ -12,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -113,4 +117,14 @@ public class RankController {
|
||||
return new BusiResult(BusiStatus.BUSIERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private MonthRankTaskService monthRankTaskService;
|
||||
|
||||
@RequestMapping(value = "/taskRank", method = RequestMethod.GET)
|
||||
public BusiResult sendLastMonthRankTop4GMT3(Byte rankType, String lastMonthDate, Integer partitionId) {
|
||||
Date parseDateTime = DateUtil.parseDateTime(lastMonthDate);
|
||||
monthRankTaskService.sendLastMonthRankTop4GMT3(rankType, parseDateTime, partitionId);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,75 @@
|
||||
package com.accompany.scheduler.task.activity;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.accompany.business.service.rank.MonthRankTaskService;
|
||||
import com.accompany.common.constant.RankConstant;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.scheduler.base.BaseTask;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class MonthRankTask extends BaseTask {
|
||||
|
||||
@Autowired
|
||||
private MonthRankTaskService monthRankTaskService;
|
||||
|
||||
/**
|
||||
* 排行榜前三奖励
|
||||
* 每月1号凌晨0点10分执行
|
||||
*/
|
||||
@Scheduled(cron = "0 5 0 1 * ?", zone = "Etc/GMT-3")
|
||||
public void monthRankTaskGMT3() {
|
||||
Date date = new Date();
|
||||
Date lastMonthDate = DateUtil.offsetMonth(date, -1);
|
||||
List<PartitionEnum> partitionEnumList = List.of(PartitionEnum.ARAB, PartitionEnum.TURKEY);
|
||||
for (PartitionEnum partitionEnum : partitionEnumList) {
|
||||
try {
|
||||
log.info("=-=monthRankTaskGMT3.krypton_rank=-=:date:{},lastMonthDate:{}", DateUtil.formatDateTime(date), lastMonthDate);
|
||||
monthRankTaskService.sendLastMonthRankTop4GMT3(RankConstant.RankType.krypton, lastMonthDate, partitionEnum.getId());
|
||||
log.info("=-=monthRankTaskGMT3.krypton_rank=-= end");
|
||||
} catch (Exception e) {
|
||||
log.error("[monthRankTaskGMT3.krypton_rank] 异常", e);
|
||||
}
|
||||
try {
|
||||
log.info("=-=monthRankTaskGMT3.vigour_rank=-=:date:{},lastMonthDate:{}", DateUtil.formatDateTime(date), lastMonthDate);
|
||||
monthRankTaskService.sendLastMonthRankTop4GMT3(RankConstant.RankType.vigour, lastMonthDate, partitionEnum.getId());
|
||||
log.info("=-=monthRankTaskGMT3.vigour_rank=-= end");
|
||||
} catch (Exception e) {
|
||||
log.error("[monthRankTaskGMT3.vigour_rank] 异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 排行榜前三奖励
|
||||
* 每月1号凌晨0点10分执行
|
||||
*/
|
||||
@Scheduled(cron = "0 5 0 1 * ?")
|
||||
public void monthRankTaskGMT8() {
|
||||
Date date = new Date();
|
||||
Date lastMonthDate = DateUtil.offsetMonth(date, -1);
|
||||
List<PartitionEnum> partitionEnumList = List.of(PartitionEnum.ENGLISH);
|
||||
for (PartitionEnum partitionEnum : partitionEnumList) {
|
||||
try {
|
||||
log.info("=-=monthRankTaskGMT8.krypton_rank=-=:date:{},lastMonthDate:{}", DateUtil.formatDateTime(date), lastMonthDate);
|
||||
monthRankTaskService.sendLastMonthRankTop4GMT3(RankConstant.RankType.krypton, lastMonthDate, partitionEnum.getId());
|
||||
log.info("=-=monthRankTaskGMT8.krypton_rank=-= end");
|
||||
} catch (Exception e) {
|
||||
log.error("[monthRankTaskGMT8.krypton_rank] 异常", e);
|
||||
}
|
||||
try {
|
||||
log.info("=-=monthRankTaskGMT8.vigour_rank=-=:date:{},lastMonthDate:{}", DateUtil.formatDateTime(date), lastMonthDate);
|
||||
monthRankTaskService.sendLastMonthRankTop4GMT3(RankConstant.RankType.vigour, lastMonthDate, partitionEnum.getId());
|
||||
log.info("=-=monthRankTaskGMT8.vigour_rank=-= end");
|
||||
} catch (Exception e) {
|
||||
log.error("[monthRankTaskGMT8.vigour_rank] 异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user