每日登录用户数(DAU)\(MAU)

    /**
     * 每日登录用户数(DAU)\(MAU)
     * 根据记录表
     */
    @GetMapping("/queryDailyAndMonthlyActiveUserCoinLog")
    public AjaxResult queryDailyAndMonthlyActiveUserCoinLog() {

        //每日
        // 获取当天的开始时间(最小值)
        LocalDateTime startOfDay = LocalDate.now().atStartOfDay();
        // 获取当天的结束时间(最大值)
        LocalDateTime endOfDay = LocalDate.now().atTime(23, 59, 59, 999999999);
        LambdaQueryWrapper<UserCoinLog> lqw = new LambdaQueryWrapper<>();
        lqw.eq(UserCoinLog::getAction,"LOGINLOG");
        lqw.le(UserCoinLog::getCreateTime, endOfDay);//小于等于
        lqw.ge(UserCoinLog::getCreateTime, startOfDay); //大于等于
        List<UserCoinLog> listDay = userCoinLogsService.list(lqw);
        int daySize = listDay.size();

        
        // 每月统计
        LocalDate today = LocalDate.now();
        LocalDate startOfMonth = today.withDayOfMonth(1);
        LocalDate lastDayOfMonth = today.withDayOfMonth(today.lengthOfMonth());
        LocalDateTime startOfMonthDateTime = startOfMonth.atStartOfDay();
        LocalDateTime endOfMonthDateTime = lastDayOfMonth.atTime(23, 59, 59, 999999999);
        LambdaQueryWrapper<UserCoinLog> monthlyWrapper = new LambdaQueryWrapper<>();
        monthlyWrapper.eq(UserCoinLog::getAction, "LOGINLOG");
        monthlyWrapper.ge(UserCoinLog::getCreateTime, startOfMonthDateTime);
        monthlyWrapper.le(UserCoinLog::getCreateTime, endOfMonthDateTime);
        List<UserCoinLog> listMonth = userCoinLogsService.list(monthlyWrapper);
        int monthSize = listMonth.size();
        
        HashMap<String, Integer> totalCount = new HashMap<>();
        totalCount.put("totalDau", daySize);
        totalCount.put("totalMau", monthSize);
        return AjaxResult.success(totalCount);
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值