package com.red.circle.other.infra.database.cache.service.other;


import com.red.circle.other.infra.database.cache.entity.game.luckgift.GameLuckyBoxAwardDetailsConfigCache;
import com.red.circle.other.infra.database.cache.entity.game.luckgift.GameLuckyBoxFortuneValueConfigCache;
import com.red.circle.other.infra.database.cache.entity.game.luckgift.GameLuckyBoxGiftConfigDetailsCache;
import com.red.circle.other.infra.database.cache.entity.game.luckgift.GameLuckyBoxInventoryCache;
import com.red.circle.other.infra.database.cache.entity.game.luckgift.GameLuckyBoxTimeConfigCache;
import com.red.circle.tool.core.func.VoidCallable;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 新 LuckyBox 缓存.
 *
 * @author zongpubin on 2023/8/26
 */
public interface GameNewLuckyBoxCacheService {

  /**
   * 记录每日抽中目标礼物次数.
   *
   * @param userId 用户id
   * @param count  抽中次数
   */
  void recordLuckyBoxAwardDay(Long userId, Integer count);


  /**
   * 获取每日抽中目标礼物次数.
   *
   * @param userId 用户id
   * @return 抽中次数
   */
  Integer getLuckyBoxAwardDay(Long userId);


  /**
   * 记录每周抽中目标礼物次数.
   *
   * @param userId 用户id
   * @param count  抽中次数
   */
  void recordLuckyBoxAwardWeek(Long userId, Integer count);

  /**
   * 获取每周抽中目标礼物次数.
   *
   * @param userId 用户id
   * @return 抽中次数
   */
  Integer getLuckyBoxAwardWeek(Long userId);

  /**
   * 创建每天的领取记录.
   *
   * @param userId 用户id
   * @param number 目标次数
   */
  void receiveLuckyBoxAwardDay(Long userId, Integer number);

  /**
   * 获取每天的领取记录.
   *
   * @param userId 用户id
   * @return 已领取的目标
   */
  List<Integer> getReceiveLuckyBoxAwardDay(Long userId);

  /**
   * 创建每周的领取记录.
   *
   * @param userId 用户id
   * @param number 目标次数
   */
  void receiveLuckyBoxAwardWeek(Long userId, Integer number);

  /**
   * 获取每周的领取记录.
   *
   * @param userId 用户id
   * @return 已领取的目标
   */
  List<Integer> getReceiveLuckyBoxAwardWeek(Long userId);

  /**
   * 获取抽奖频数配置信息.
   *
   * @param standardId 抽奖规格id
   * @param orElsePut  否则put
   * @return banner
   */
  List<GameLuckyBoxTimeConfigCache> getTimeConfigCache(Long standardId, String sysOrigin,
      VoidCallable<List<GameLuckyBoxTimeConfigCache>> orElsePut);


  /**
   * 移除抽奖频数配置信息.
   */
  void removeTimeConfigCache(Long standardId, String sysOrigin);

  /**
   * 获取抽奖礼物配置信息.
   *
   * @param standardId 抽奖规格id
   * @param orElsePut  否则put
   * @return banner
   */
  List<GameLuckyBoxGiftConfigDetailsCache> getGiftInfoCache(Long standardId, String sysOrigin,
      VoidCallable<List<GameLuckyBoxGiftConfigDetailsCache>> orElsePut);

  /**
   * 移除抽奖频礼物置信息.
   */
  void removeGiftInfoCache(Long standardId, String sysOrigin);


  /**
   * 获取抽奖奖励配置信息.
   *
   * @param awardId   奖励规格id
   * @param orElsePut 否则put
   * @return banner
   */
  List<GameLuckyBoxAwardDetailsConfigCache> getAwardDetailsCache(Long awardId, String lotteryType,
      VoidCallable<List<GameLuckyBoxAwardDetailsConfigCache>> orElsePut);

  /**
   * 移除抽奖奖励配置信息.
   */
  void removeAwardDetailsConfigCache(Long awardId, String lotteryType);


  /**
   * 获取luckyBox幸运值配置信息.
   *
   * @param orElsePut 否则put
   * @return banner
   */
  GameLuckyBoxFortuneValueConfigCache getFortuneValueConfigCache(
      VoidCallable<GameLuckyBoxFortuneValueConfigCache> orElsePut);

  /**
   * 移除luckyBox幸运值配置信息.
   */
  void removeFortuneValueConfigCache();


  /**
   * 获取luckyBox库存配置信息.
   */
  List<GameLuckyBoxInventoryCache> getInventoryTemplate(Long standardId, Integer sort);


  /**
   * 缓存luckyBox库存配置信息.
   */
  void cacheInventoryTemplate(Long standardId, Integer sort,
      List<GameLuckyBoxInventoryCache> gameLuckyBoxInventoryCaches);

  /**
   * 移除倍数库存基础配置模版.
   *
   * @param standardId 规格ID
   * @param sort       排序
   */
  void removeInventoryTemplate(Long standardId, Integer sort);

  /**
   * 初始化礼物库存倍数签
   *
   * @param sort     序号
   * @param template 完整的库存数据
   */
  List<GameLuckyBoxInventoryCache> initRemainInventory(Long standardId, Integer sort,
      List<GameLuckyBoxInventoryCache> template);

  /**
   * 获得剩余库存倍数签集合
   *
   * @param sort          序号
   * @param giftConfigIds 抽奖规格礼物配置id
   * @return 剩余库存礼物签集合
   */
  Map<Long, Integer> mapRemainInventory(Long standardId, Integer sort, Set<Long> giftConfigIds);


  /**
   * 移除签库存.
   *
   * @param sort       排序
   * @param standardId 规格ID
   */
  void removeRemainingInventory(Long standardId, Integer sort);

  /**
   * 递减礼物库存数量.
   *
   * @param sort         排序
   * @param giftConfigId 抽奖规格礼物配置id
   */
  Long decrInventoryQuantity(Long standardId, Integer sort, Long giftConfigId);
}
