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

import com.red.circle.common.business.dto.cmd.app.AppTypeCmd;
import com.red.circle.other.app.command.activity.query.AgentActivityCountdownQueryExe;
import com.red.circle.other.app.command.activity.query.AgentActivityHistoryUserQueryExe;
import com.red.circle.other.app.command.activity.query.AgentActivityOwnQueryExe;
import com.red.circle.other.app.command.activity.query.AgentActivityUserQueryExe;
import com.red.circle.other.app.common.props.GroupRewardPoolCommon;
import com.red.circle.other.app.dto.clientobject.activity.AgentActivityHistoryCO;
import com.red.circle.other.app.dto.clientobject.activity.AgentActivityOwnCO;
import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum;
import com.red.circle.other.inner.model.dto.activity.props.ActivityRewardProps;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 代理活动.
 * </p>
 *
 * @author pengshigang
 * @since 2023-05-29
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class AgentActivityServiceImpl implements AgentActivityService {

  private final GroupRewardPoolCommon groupRewardPoolCommon;
  private final AgentActivityOwnQueryExe agentActivityOwnQueryExe;
  private final AgentActivityUserQueryExe agentActivityUserQueryExe;
  private final AgentActivityCountdownQueryExe agentActivityCountdownQueryExe;
  private final AgentActivityHistoryUserQueryExe agentActivityHistoryUserQueryExe;

  @Override
  public List<AgentActivityOwnCO> listNewUser(AppTypeCmd cmd) {
    return agentActivityUserQueryExe.execute(cmd);
  }

  @Override
  public List<AgentActivityHistoryCO> listHistoryUser(AppTypeCmd cmd) {
    return agentActivityHistoryUserQueryExe.execute(cmd);
  }

  @Override
  public AgentActivityOwnCO getOwnUser(AppTypeCmd cmd) {
    return agentActivityOwnQueryExe.execute(cmd);
  }

  @Override
  public List<List<ActivityRewardProps>> listRewardPool(AppTypeCmd cmd) {

    return groupRewardPoolCommon.listRewardProps(cmd.requireReqSysOriginEnum(),
        Objects.equals(cmd.getType(), "WEEK") ? PropsActivityTypeEnum.AGENT_ACTIVE_WEEK_REWARD
            : PropsActivityTypeEnum.AGENT_ACTIVE_MONTH_REWARD);

  }

  @Override
  public Map<String, Long> mapCountdown() {
    return agentActivityCountdownQueryExe.execute();
  }
}
