package com.red.circle.other.app.service.user.invite;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.app.AppAccountCmd;
import com.red.circle.common.business.dto.cmd.app.AppFlowCmd;
import com.red.circle.other.app.command.user.InviteNewLotteryExe;
import com.red.circle.other.app.command.user.InviteNewOpenRedPacketExe;
import com.red.circle.other.app.command.user.InviteNewWithdrawExe;
import com.red.circle.other.app.command.user.query.InviteNewActivityStatusQryExe;
import com.red.circle.other.app.command.user.query.InviteNewCarouselConfigQryExe;
import com.red.circle.other.app.command.user.query.InviteNewHelpUserPageQryExe;
import com.red.circle.other.app.command.user.query.InviteNewInvitePeopleQryExe;
import com.red.circle.other.app.command.user.query.InviteNewLotteryDetailsPageQryExe;
import com.red.circle.other.app.command.user.query.InviteNewNextHelpTimeQryExe;
import com.red.circle.other.app.command.user.query.InviteNewRedPacketAuthCheckQryExe;
import com.red.circle.other.app.command.user.query.InviteNewRedPacketAuthorQryExe;
import com.red.circle.other.app.command.user.query.InviteNewRedPacketInfoQryExe;
import com.red.circle.other.app.command.user.query.InviteNewWithdrawQryExe;
import com.red.circle.other.app.command.user.query.InviteNewWithdrawRecordQryExe;
import com.red.circle.other.app.dto.clientobject.user.invite.*;
import com.red.circle.other.app.dto.cmd.user.user.InviteUserRedPacketCmd;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;

import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;

import com.red.circle.tool.core.date.LocalDateTimeUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 红包-邀请新用户.
 * </p>
 *
 * @author pengshigang
 * @since 2024-01-05
 */
@Service
@RequiredArgsConstructor
public class RedPacketInviteV2ServiceImpl implements RedPacketInviteV2Service {

  private final InviteNewLotteryExe inviteNewLotteryExe;
  private final InviteNewWithdrawExe inviteNewWithdrawExe;
  private final InviteNewWithdrawQryExe inviteNewWithdrawQryExe;
  private final InviteNewOpenRedPacketExe inviteNewOpenRedPacketExe;
  private final InviteNewHelpUserPageQryExe inviteNewHelpUserPageQryExe;
  private final InviteNewInvitePeopleQryExe inviteNewInvitePeopleQryExe;
  private final InviteNewNextHelpTimeQryExe inviteNewNextHelpTimeQryExe;
  private final InviteNewRedPacketInfoQryExe inviteNewRedPacketInfoQryExe;
  private final InviteNewActivityStatusQryExe inviteNewActivityStatusQryExe;
  private final InviteNewWithdrawRecordQryExe inviteNewWithdrawRecordQryExe;
  private final InviteNewCarouselConfigQryExe inviteNewCarouselConfigQryExe;
  private final InviteNewRedPacketAuthorQryExe inviteNewRedPacketAuthorQryExe;
  private final InviteNewRedPacketAuthCheckQryExe inviteNewRedPacketAuthCheckQryExe;
  private final InviteNewLotteryDetailsPageQryExe inviteNewLotteryDetailsPageQryExe;

  @Override
  public List<InviteRedPacketCarouselAwardsCO> listCarouselConfig(AppExtCommand cmd) {
    return inviteNewCarouselConfigQryExe.execute(cmd);
  }

  @Override
  public List<InviteRedPacketWithdrawRecordCO> listWithdrawRecord(AppExtCommand cmd) {
    return inviteNewWithdrawRecordQryExe.execute(cmd);
  }

  @Override
  public InviteRedPacketWithdrawalCO getWithdrawBalance(AppExtCommand cmd) {
    return inviteNewWithdrawQryExe.execute(cmd);
  }

  @Override
  public InviteRedPacketWithdrawalCO withdraw(AppExtCommand cmd) {
    return inviteNewWithdrawExe.execute(cmd);
  }

  @Override
  public InviteRedPacketUserInfoCO getUserRedPacketInfo(AppExtCommand cmd) {
    return inviteNewRedPacketInfoQryExe.execute(cmd);
  }

  @Override
  public InviteRedPacketUserCheckAuthCO checkUserRedPacketAuth(InviteUserRedPacketCmd cmd) {
    return inviteNewRedPacketAuthCheckQryExe.execute(cmd);
  }

  @Override
  public InviteRedPacketUserInfoCO openRedPacket(InviteUserRedPacketCmd cmd) {
    return inviteNewOpenRedPacketExe.execute(cmd);
  }

  @Override
  public InviteRedPacketCarouselAwardsCO lottery(AppExtCommand cmd) {
    return inviteNewLotteryExe.execute(cmd);
  }

  @Override
  public Boolean getActivityStatus(AppExtCommand cmd) {
    return inviteNewActivityStatusQryExe.execute(cmd);
  }

  @Override
  public List<InviteRedPacketHelpUserCO> pageHelpUsers(AppFlowCmd cmd) {
    return inviteNewHelpUserPageQryExe.execute(cmd);
  }

  @Override
  public List<InviteRedPacketUserLotteryDetailsCO> pageLotteryResults(AppFlowCmd cmd) {
    return inviteNewLotteryDetailsPageQryExe.execute(cmd);
  }

  @Override
  public InviteRedPacketUserAuthCO getUserRedPacketAuthor(AppExtCommand cmd) {
    return inviteNewRedPacketAuthorQryExe.execute(cmd);
  }

  @Override
  public  List<InviteUserSucceedCO>  getInviteUserSucceed (AppExtCommand cmd){
    return inviteNewRedPacketAuthorQryExe.getInviteUserSucceed(cmd);
  }
  @Override
  public UserProfileDTO getInvitePeople(AppAccountCmd cmd) {
    return inviteNewInvitePeopleQryExe.execute(cmd);
  }

  @Override
  public String getNextHelpTime(AppExtCommand cmd) {
    Timestamp time = inviteNewNextHelpTimeQryExe.execute(cmd);
    if (Objects.isNull(time)) {
      return null;
    }
    return LocalDateTimeUtils.format(LocalDateTimeUtils.convert(time),
            "dd-MM-yyyy HH:mm");
  }
}
