后台-每天播报昨天魅力榜榜一

This commit is contained in:
2023-02-21 18:15:20 +08:00
parent 2b0a81fde5
commit a4eb74aaef

View File

@@ -21,7 +21,7 @@ import java.util.Map;
import java.util.Set;
@Component
public class KryptonRankTask {
public class RankWechatTask {
@Autowired
private WebSecurityConfig webSecurityConfig;
@@ -41,6 +41,11 @@ public class KryptonRankTask {
}
String yesterDayStr = LocalDateTime.now().minusDays(1L).format(DateTimeFormatter.ofPattern(DateTimeUtil.DEFAULT_DATE_PATTERN));
pushKryptonDay2Wechat(yesterDayStr);
pushVigourDay2Wechat(yesterDayStr);
}
private void pushKryptonDay2Wechat(String yesterDayStr){
Set<Map<String, Object>> rankMap = jedisService.zrevrangeWithScore(getKryptonDayKey(yesterDayStr), 0L, 0L);
if (CollectionUtils.isEmpty(rankMap)){
return;
@@ -64,4 +69,28 @@ public class KryptonRankTask {
return RedisKey.krypton_rank.getKey(Constant.RankDatetype.day + ":" + date);
}
private void pushVigourDay2Wechat(String yesterDayStr){
Set<Map<String, Object>> rankMap = jedisService.zrevrangeWithScore(getVigourDayKey(yesterDayStr), 0L, 0L);
if (CollectionUtils.isEmpty(rankMap)){
return;
}
for (Map<String, Object> first: rankMap){
Long uid = Long.parseLong(first.get("member").toString());
Long score = Math.round((Double) first.get("score"));
Users u = usersService.getUsersByUid(uid);
MarkdownMessage msg = new MarkdownMessage();
msg.add(MarkdownMessage.getHeaderText(3, String.format("%s 魅力榜榜一大佬", yesterDayStr)));
msg.add(MarkdownMessage.getReferenceText(String.format("平台ID [%d]", u.getErbanNo())));
msg.add(MarkdownMessage.getReferenceText(String.format("昵称 [%s]", u.getNick())));
msg.add(MarkdownMessage.getReferenceText(String.format("当日累计收礼钻石价值 [%d]", score)));
enterpriseWechatPushService.pushMessageByKey(webSecurityConfig.getActivityEnterpriseWechatPushKey(), msg);
}
}
private String getVigourDayKey(String date){
return RedisKey.vigour_rank.getKey(Constant.RankDatetype.day + ":" + date);
}
}