package com.ruoyi.system.service.impl;

import java.time.LocalDate;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.dto.DailyUserDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DailyUserMapper;
import com.ruoyi.system.domain.DailyUser;
import com.ruoyi.system.service.IDailyUserService;

/**
 * userDailyService业务层处理
 * 
 * @author 昊天
 * @date 2024-11-04
 */
@Service
public class DailyUserServiceImpl implements IDailyUserService 
{
    @Autowired
    private DailyUserMapper dailyUserMapper;

    /**
     * 查询userDaily
     * 
     * @param dailyUserId userDaily主键
     * @return userDaily
     */
    @Override
    public DailyUser selectDailyUserByDailyUserId(Long dailyUserId)
    {
        return dailyUserMapper.selectDailyUserByDailyUserId(dailyUserId);
    }

    //根据用户id和date来获取用户数据
    @Override
    public DailyUser selectDailyUserByUserIdAndDate(Long userId, LocalDate date) {
        return dailyUserMapper.selectByUserIdAndDate(userId, date);
    }

    /**
     * 查询userDaily列表
     * 
     * @param dailyUser userDaily
     * @return userDaily
     */
    @Override
    public List<DailyUser> selectDailyUserList(DailyUser dailyUser)
    {
        return dailyUserMapper.selectDailyUserList(dailyUser);
    }

    /**
     * 新增userDaily
     * 
     * @param dailyUser userDaily
     * @return 结果
     */
    @Override
    public int insertDailyUser(DailyUser dailyUser)
    {
        dailyUser.setCreateTime(DateUtils.getNowDate());
        return dailyUserMapper.insertDailyUser(dailyUser);
    }

    /**
     * 修改userDaily
     * 
     * @param dailyUser userDaily
     * @return 结果
     */
    @Override
    public int updateDailyUser(DailyUser dailyUser)
    {
        dailyUser.setUpdateTime(DateUtils.getNowDate());
        return dailyUserMapper.updateDailyUser(dailyUser);
    }

    /**
     * 批量删除userDaily
     * 
     * @param dailyUserIds 需要删除的userDaily主键
     * @return 结果
     */
    @Override
    public int deleteDailyUserByDailyUserIds(Long[] dailyUserIds)
    {
        return dailyUserMapper.deleteDailyUserByDailyUserIds(dailyUserIds);
    }

    /**
     * 删除userDaily信息
     * 
     * @param dailyUserId userDaily主键
     * @return 结果
     */
    @Override
    public int deleteDailyUserByDailyUserId(Long dailyUserId)
    {
        return dailyUserMapper.deleteDailyUserByDailyUserId(dailyUserId);
    }

    @Override
    public Long getTotalOnlineTime(LocalDate date){
        return dailyUserMapper.getTotalOnlineTime(date);
    }

    @Override
    public Long getTotalMRTime(LocalDate date){
        return dailyUserMapper.getTotalMRTime(date);
    }

    /*
     * 返回每天资源位总的被购买次数
     * */
    @Override
    public Long getTotalBought(LocalDate date){
        return dailyUserMapper.getTotalBought(date);
    }

    /*
     * 系统每天统计用户相关信息
     * */
    @Override
    public DailyUserDto getStDailyUser(LocalDate date){
        return dailyUserMapper.getStDailyUser(date);
    }
}
