package com.red.circle.other.app.inner.endpoint.user.user;

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.endpoint.user.user.api.UserRedPacketInviteNewClientApi;
import com.red.circle.other.inner.model.cmd.user.invite.InviteBalancePageQryCmd;
import com.red.circle.other.inner.model.cmd.user.invite.InviteCarouselAwardsCmd;
import com.red.circle.other.inner.model.cmd.user.invite.InviteConfigCmd;
import com.red.circle.other.inner.model.cmd.user.invite.InviteRedPacketDrawLogPageQryCmd;
import com.red.circle.other.inner.model.cmd.user.invite.InviteRedPacketHelpLogPageQryCmd;
import com.red.circle.other.inner.model.cmd.user.invite.InviteRedPacketPageQryCmd;
import com.red.circle.other.inner.model.cmd.user.invite.InviteTargetTransitBalanceCmd;
import com.red.circle.other.inner.model.dto.user.invite.InviteBalanceDTO;
import com.red.circle.other.inner.model.dto.user.invite.InviteCarouselAwardsBackDTO;
import com.red.circle.other.inner.model.dto.user.invite.InviteConfigDTO;
import com.red.circle.other.inner.model.dto.user.invite.InviteRedPacketDTO;
import com.red.circle.other.inner.model.dto.user.invite.InviteRedPacketDrawLogDTO;
import com.red.circle.other.inner.model.dto.user.invite.InviteRedPacketHelpLogDTO;
import com.red.circle.other.app.inner.service.user.user.UserRedPacketInviteNewClientService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户svip.
 *
 * @author pengliang on 2023/6/6
 */
@Validated
@RestController
@RequestMapping(value = UserRedPacketInviteNewClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserRedPacketInviteNewClientEndpoint implements UserRedPacketInviteNewClientApi {

  private final UserRedPacketInviteNewClientService userRedPacketInviteNewClientService;

  @Override
  public ResultResponse<PageResult<InviteBalanceDTO>> pageTargetTransitBalance(
      InviteBalancePageQryCmd cmd) {
    return ResultResponse.success(
        userRedPacketInviteNewClientService.pageTargetTransitBalance(cmd));
  }

  @Override
  public ResultResponse<Void> reduceTarget(InviteTargetTransitBalanceCmd cmd) {
    userRedPacketInviteNewClientService.reduceTarget(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<PageResult<InviteBalanceDTO>> pageWithdrawTransitBalance(
      InviteBalancePageQryCmd cmd) {

    return ResultResponse.success(
        userRedPacketInviteNewClientService.pageWithdrawTransitBalance(cmd));
  }

  @Override
  public ResultResponse<PageResult<InviteRedPacketDrawLogDTO>> pageRedPacketDrawLog(
      InviteRedPacketDrawLogPageQryCmd cmd) {

    return ResultResponse.success(userRedPacketInviteNewClientService.pageRedPacketDrawLog(cmd));
  }

  @Override
  public ResultResponse<PageResult<InviteRedPacketHelpLogDTO>> pageRedPacketHelpLog(
      InviteRedPacketHelpLogPageQryCmd cmd) {

    return ResultResponse.success(userRedPacketInviteNewClientService.pageRedPacketHelpLog(cmd));
  }

  @Override
  public ResultResponse<PageResult<InviteRedPacketDTO>> pageRedPacket(
      InviteRedPacketPageQryCmd cmd) {

    return ResultResponse.success(userRedPacketInviteNewClientService.pageRedPacket(cmd));
  }

  @Override
  public ResultResponse<List<InviteCarouselAwardsBackDTO>> listCarouselAwards(String sysOrigin) {

    return ResultResponse.success(
        userRedPacketInviteNewClientService.listCarouselAwards(sysOrigin));
  }

  @Override
  public ResultResponse<Void> saveCarouselAwards(InviteCarouselAwardsCmd cmd) {

    userRedPacketInviteNewClientService.saveCarouselAwards(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> deleteCarouselAwards(Long id) {

    userRedPacketInviteNewClientService.deleteCarouselAwards(id);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<InviteConfigDTO> getConfigBySysOrigin(String sysOrigin) {

    return ResultResponse.success(
        userRedPacketInviteNewClientService.getConfigBySysOrigin(sysOrigin));
  }

  @Override
  public ResultResponse<Void> saveConfig(InviteConfigCmd cmd) {

    userRedPacketInviteNewClientService.saveConfig(cmd);
    return ResultResponse.success();
  }
}
