123333
This commit is contained in:
34
ruoyi-cai/src/main/java/com/ruoyi/cai/cache/AnchorCountTotalCache.java
vendored
Normal file
34
ruoyi-cai/src/main/java/com/ruoyi/cai/cache/AnchorCountTotalCache.java
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.cai.cache;
|
||||
|
||||
import com.ruoyi.cai.constant.RedisHttpConstant;
|
||||
import org.redisson.api.RBucket;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Component
|
||||
public class AnchorCountTotalCache {
|
||||
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
private String getKey(LocalDate date){
|
||||
String day = date.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
return String.format(RedisHttpConstant.ANCHOR_COUNT_REDIS,day);
|
||||
}
|
||||
|
||||
public void set(LocalDate date, Long total){
|
||||
RBucket<Long> bucket = redissonClient.getBucket(getKey(date));
|
||||
bucket.set(total);
|
||||
}
|
||||
|
||||
public Long get(LocalDate date){
|
||||
RBucket<Long> bucket = redissonClient.getBucket(getKey(date));
|
||||
Long count = bucket.get();
|
||||
return count == null ? 0L : count;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class RedisHttpConstant {
|
||||
public static final String INVITE_RANK_REDIS = REDIS_P + "inviteRank:%s:%s";
|
||||
public static final String WITHDRAW_RANK_REDIS = REDIS_P + "withdrawRank:%s:%s";
|
||||
public static final String RECHARGE_RANK_REDIS = REDIS_P + "rechargeRank:%s:%s";
|
||||
public static final String ANCHOR_COUNT_REDIS = REDIS_P + "anchorCount:%s";
|
||||
public static final String HOME_RECOMMEND_REDIS = REDIS_P + "homeRecommendAnchor";
|
||||
public static final String HOME_NEW_REDIS = REDIS_P + "homeNewAnchor";
|
||||
public static final String HOME_ACTIVE_REDIS = REDIS_P + "homeActiveAnchor";
|
||||
|
||||
@@ -13,6 +13,8 @@ public class HomeStaticIndexVo {
|
||||
private BigDecimal todayLoginDiffLast;
|
||||
@Schema(description = "主播人数")
|
||||
private Long anchorNum;
|
||||
@Schema(description = "主播人数与昨日相比")
|
||||
private BigDecimal anchorNumDiffLast;
|
||||
@Schema(description = "今日充值金额")
|
||||
private BigDecimal todayRechargeAmountNum;
|
||||
@Schema(description = "今日充值订单数")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.ruoyi.cai.manager;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.cai.cache.AnchorCountTotalCache;
|
||||
import com.ruoyi.cai.cache.RechargeTotalCache;
|
||||
import com.ruoyi.cai.cache.WithdrawTotalCache;
|
||||
import com.ruoyi.cai.cache.bean.RechargeTotalCacheBean;
|
||||
@@ -53,6 +53,8 @@ public class AdminHomeManager {
|
||||
private RankManager rankManager;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private AnchorCountTotalCache anchorCountTotalCache;
|
||||
|
||||
/**
|
||||
* @param rankType 1-魅力榜 2-邀请榜 3-充值榜 4-提现榜
|
||||
@@ -140,7 +142,10 @@ public class AdminHomeManager {
|
||||
HomeStaticIndexVo vo = new HomeStaticIndexVo();
|
||||
vo.setTodayLoginNum(onlineTodayNum);
|
||||
vo.setTodayLoginDiffLast(CaiNumUtil.diffRate(onlineTodayNum,onlineLastNum));
|
||||
vo.setAnchorNum(anchorService.count(Wrappers.emptyWrapper()));
|
||||
long anchorNum = anchorService.count(Wrappers.emptyWrapper());
|
||||
Long lastAnchorNum = anchorCountTotalCache.get(LocalDate.now().plusDays(-1));
|
||||
vo.setAnchorNum(anchorNum);
|
||||
vo.setAnchorNumDiffLast(CaiNumUtil.diffRate(anchorNum,lastAnchorNum));
|
||||
RechargeTotalCacheBean todayRecharge = rechargeTotalCache.getToday();
|
||||
RechargeTotalCacheBean lastTodayRecharge = rechargeTotalCache.getLastToday();
|
||||
vo.setTodayRechargeAmountNum(todayRecharge.getAmount());
|
||||
|
||||
Reference in New Issue
Block a user