package com.red.circle.game.fruit.infrastructure.database.dao;

import com.red.circle.framework.mybatis.dao.BaseDAO;
import com.red.circle.game.fruit.application.dto.clientobject.GameFruitAwardRecordCO;
import com.red.circle.game.fruit.infrastructure.database.entity.GameFruitUserDaysRanking;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 用户每日盈利排名 DAO 接口.
 * </p>
 *
 * @author lisizhe on  2023-11-30 19:17
 */
public interface DaysRankingDAO extends BaseDAO<GameFruitUserDaysRanking> {

  void addDaysRankingEarning(@Param("list") List<GameFruitAwardRecordCO> gameFruitAwardRecords);

  List<GameFruitUserDaysRanking> listByUserIds(@Param("userIds") Set<Long> userIds,
      @Param("lossRatioLottery") BigDecimal lossRatioLottery,
      @Param("toDayLossLottery") BigDecimal toDayLossLottery);

  Long countWeekEarning(@Param("userId") Long userId, @Param("startDate") Date startDate,
      @Param("endDate") Date endDate);

  Long countWeekPlayDays(@Param("userId") Long userId, @Param("startDate") Date startDate,
      @Param("endDate") Date endDate);

  @Select("SELECT * FROM game_fruit_user_days_ranking WHERE user_id = #{uid} AND `date` = #{date}")
  GameFruitUserDaysRanking getByUidForUpdate(@Param("uid") Long uid, @Param("date") String date);
}
