123333
This commit is contained in:
@@ -13,6 +13,8 @@ import java.time.LocalDate;
|
|||||||
public class IncomeStatisticsJob {
|
public class IncomeStatisticsJob {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DayIncomeStatisticsService dayIncomeStatisticsService;
|
private DayIncomeStatisticsService dayIncomeStatisticsService;
|
||||||
|
|
||||||
|
// 每6分钟执行一次
|
||||||
@Scheduled(cron = "0 0/6 * * * ?")
|
@Scheduled(cron = "0 0/6 * * * ?")
|
||||||
public void persistentDb() {
|
public void persistentDb() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.ruoyi.job;
|
package com.ruoyi.job;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.ruoyi.cai.cache.AnchorCountTotalCache;
|
||||||
|
import com.ruoyi.cai.service.AnchorService;
|
||||||
import com.ruoyi.cai.service.DayIncomeStatisticsService;
|
import com.ruoyi.cai.service.DayIncomeStatisticsService;
|
||||||
import com.ruoyi.cai.service.RankService;
|
import com.ruoyi.cai.service.RankService;
|
||||||
import com.ruoyi.cai.service.UserService;
|
import com.ruoyi.cai.service.UserService;
|
||||||
@@ -10,7 +13,6 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.time.DayOfWeek;
|
import java.time.DayOfWeek;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -20,10 +22,17 @@ public class RankJob {
|
|||||||
private RankService rankService;
|
private RankService rankService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DayIncomeStatisticsService dayIncomeStatisticsService;
|
private DayIncomeStatisticsService dayIncomeStatisticsService;
|
||||||
|
@Autowired
|
||||||
|
private AnchorCountTotalCache anchorCountTotalCache;
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@Autowired
|
||||||
|
private AnchorService anchorService;
|
||||||
|
|
||||||
|
// 凌晨0点1分执行一次
|
||||||
@Scheduled(cron = "0 1 0 * * ? ")
|
@Scheduled(cron = "0 1 0 * * ? ")
|
||||||
public void persistentDb() {
|
public void persistentDb() {
|
||||||
LocalDate date = LocalDateTime.now().plusDays(-1).toLocalDate();
|
LocalDate date = LocalDate.now().plusDays(-1);
|
||||||
try {
|
try {
|
||||||
rankService.saveDayRank(date,1);
|
rankService.saveDayRank(date,1);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -72,9 +81,13 @@ public class RankJob {
|
|||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("刷新用户年龄失败!",e);
|
log.error("刷新用户年龄失败!",e);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
long anchorNum = anchorService.count(Wrappers.emptyWrapper());
|
||||||
|
anchorCountTotalCache.set(date,anchorNum);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("报错昨日主播统计失败!",e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
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 INVITE_RANK_REDIS = REDIS_P + "inviteRank:%s:%s";
|
||||||
public static final String WITHDRAW_RANK_REDIS = REDIS_P + "withdrawRank:%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 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_RECOMMEND_REDIS = REDIS_P + "homeRecommendAnchor";
|
||||||
public static final String HOME_NEW_REDIS = REDIS_P + "homeNewAnchor";
|
public static final String HOME_NEW_REDIS = REDIS_P + "homeNewAnchor";
|
||||||
public static final String HOME_ACTIVE_REDIS = REDIS_P + "homeActiveAnchor";
|
public static final String HOME_ACTIVE_REDIS = REDIS_P + "homeActiveAnchor";
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ public class HomeStaticIndexVo {
|
|||||||
private BigDecimal todayLoginDiffLast;
|
private BigDecimal todayLoginDiffLast;
|
||||||
@Schema(description = "主播人数")
|
@Schema(description = "主播人数")
|
||||||
private Long anchorNum;
|
private Long anchorNum;
|
||||||
|
@Schema(description = "主播人数与昨日相比")
|
||||||
|
private BigDecimal anchorNumDiffLast;
|
||||||
@Schema(description = "今日充值金额")
|
@Schema(description = "今日充值金额")
|
||||||
private BigDecimal todayRechargeAmountNum;
|
private BigDecimal todayRechargeAmountNum;
|
||||||
@Schema(description = "今日充值订单数")
|
@Schema(description = "今日充值订单数")
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.ruoyi.cai.manager;
|
package com.ruoyi.cai.manager;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.ruoyi.cai.cache.AnchorCountTotalCache;
|
||||||
import com.ruoyi.cai.cache.RechargeTotalCache;
|
import com.ruoyi.cai.cache.RechargeTotalCache;
|
||||||
import com.ruoyi.cai.cache.WithdrawTotalCache;
|
import com.ruoyi.cai.cache.WithdrawTotalCache;
|
||||||
import com.ruoyi.cai.cache.bean.RechargeTotalCacheBean;
|
import com.ruoyi.cai.cache.bean.RechargeTotalCacheBean;
|
||||||
@@ -53,6 +53,8 @@ public class AdminHomeManager {
|
|||||||
private RankManager rankManager;
|
private RankManager rankManager;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
@Autowired
|
||||||
|
private AnchorCountTotalCache anchorCountTotalCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rankType 1-魅力榜 2-邀请榜 3-充值榜 4-提现榜
|
* @param rankType 1-魅力榜 2-邀请榜 3-充值榜 4-提现榜
|
||||||
@@ -140,7 +142,10 @@ public class AdminHomeManager {
|
|||||||
HomeStaticIndexVo vo = new HomeStaticIndexVo();
|
HomeStaticIndexVo vo = new HomeStaticIndexVo();
|
||||||
vo.setTodayLoginNum(onlineTodayNum);
|
vo.setTodayLoginNum(onlineTodayNum);
|
||||||
vo.setTodayLoginDiffLast(CaiNumUtil.diffRate(onlineTodayNum,onlineLastNum));
|
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 todayRecharge = rechargeTotalCache.getToday();
|
||||||
RechargeTotalCacheBean lastTodayRecharge = rechargeTotalCache.getLastToday();
|
RechargeTotalCacheBean lastTodayRecharge = rechargeTotalCache.getLastToday();
|
||||||
vo.setTodayRechargeAmountNum(todayRecharge.getAmount());
|
vo.setTodayRechargeAmountNum(todayRecharge.getAmount());
|
||||||
|
|||||||
Reference in New Issue
Block a user