package com.red.circle.other.app.inner.service.team.impl;

import com.red.circle.other.app.inner.convertor.team.TeamInnerConvertor;
import com.red.circle.other.app.inner.service.team.TeamMemberTargetClientService;
import com.red.circle.other.infra.common.team.TeamTargetCommon;
import com.red.circle.other.infra.common.team.decay.ListMemberWorkDecay;
import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberTargetService;
import com.red.circle.other.inner.model.cmd.team.TeamMemberWorkQryCmd;
import com.red.circle.other.inner.model.dto.agency.agency.TeamMemberTargetDTO;
import com.red.circle.other.inner.model.dto.agency.agency.TeamMemberWorkDTO;
import com.red.circle.other.inner.model.dto.agency.agency.TeamTargetBillRes;
import com.red.circle.other.inner.enums.team.TeamMemberTargetStatus;
import java.math.BigDecimal;
import java.util.List;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 团队成员目标.
 *
 * @author pengliang on 2023/8/19
 */
@Service
@RequiredArgsConstructor
public class TeamMemberTargetClientServiceImpl implements TeamMemberTargetClientService {

  private final TeamTargetCommon teamTargetCommon;
  private final TeamInnerConvertor teamInnerConvertor;
  private final ListMemberWorkDecay listMemberWorkDecay;
  private final TeamMemberTargetService teamMemberTargetService;

  @Override
  public void decrAcceptGiftValue(Long userId, Integer dateNumber, Long giftValue) {
    teamMemberTargetService.decrAcceptGiftValue(userId, dateNumber, giftValue);
  }

  @Override
  public TeamTargetBillRes incrementGiftValue(Long userId, BigDecimal quantity) {
    return teamTargetCommon.incrementGiftValue(userId, quantity);
  }

  @Override
  public void incrementRoomValue(Long userId, BigDecimal quantity) {
    teamTargetCommon.incrementRoomValue(userId, quantity);

  }

  @Override
  public void incrementSendGiftQuantity(Long userId, BigDecimal quantity) {
    teamTargetCommon.incrementSendGiftQuantity(userId, quantity);
  }

  @Override
  public List<TeamMemberTargetDTO> listByBillBelong(Long teamId,
      Integer billBelong) {
    return teamInnerConvertor.toListTeamMemberTargetDTO(
        teamMemberTargetService.listByBillBelong(teamId, billBelong));
  }

  @Override
  public List<TeamMemberWorkDTO> listMemberWork(TeamMemberWorkQryCmd query) {
    return listMemberWorkDecay.execute(query);
  }

  @Override
  public void updateStatusByTeamIds(Set<Long> teamIds, TeamMemberTargetStatus status) {
    teamMemberTargetService.updateStatusByTeamIds(teamIds, status);
  }

  @Override
  public Long getLatestInProgressTarget(Long userId) {
    return teamMemberTargetService.getLatestInProgressTarget(userId);
  }

  @Override
  public void removeUserTarget(Integer billBelong, Long userId) {
    teamMemberTargetService.removeUserTarget(billBelong, userId);
  }
}
