package com.red.circle.other.app.service.room;

import com.red.circle.common.business.core.level.LevelUtils;
import com.red.circle.common.business.core.level.UserLevelExperience;
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
import com.red.circle.other.app.command.room.RoomRewardExtractCmdExe;
import com.red.circle.other.app.command.room.query.RoomContributionTodayTopQryExe;
import com.red.circle.other.app.command.room.query.RoomContributionTotalQuantityQryExe;
import com.red.circle.other.app.dto.clientobject.room.RoomContributionTopCO;
import com.red.circle.other.app.dto.clientobject.room.RoomContributionTotalCO;
import com.red.circle.other.app.dto.cmd.room.RoomContributionRankQryCmd;
import java.math.BigDecimal;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 房间贡献 实现.
 *
 * @author pengliang on 2023/9/22
 */
@Service
@RequiredArgsConstructor
public class RoomContributionServiceImpl implements RoomContributionService {

  private final RoomRewardExtractCmdExe roomRewardExtractCmdExe;
  private final RoomContributionTodayTopQryExe roomContributionTodayTopQryExe;
  private final RoomContributionTotalQuantityQryExe roomContributionTotalQuantityQryExe;

  @Override
  public RoomContributionTotalCO totalFormat(AppRoomIdCmd cmd) {
    return roomContributionTotalQuantityQryExe.execute(cmd);
  }

  @Override
  public UserLevelExperience getRoomLevel(AppRoomIdCmd cmd) {
    return LevelUtils.getRoomLevel(cmd.requireReqSysOriginEnum(),
        totalFormat(cmd).getTotal().longValue());
  }

  @Override
  public BigDecimal rewardExtract(AppRoomIdCmd cmd) {
    return roomRewardExtractCmdExe.execute(cmd);
  }

  @Override
  public List<RoomContributionTopCO> listRoomRank(RoomContributionRankQryCmd cmd) {
    return roomContributionTodayTopQryExe.execute(cmd);
  }

}
