package com.red.circle.console.adapter.app.user;

import com.red.circle.console.app.service.app.user.UserRedPacketInviteNewService;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
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 java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 红包邀新用户 前端控制器.
 * </p>
 *
 * @author pengshigang on 2023-12-20 17:13
 * @eo.api-type http
 * @eo.groupName 红包邀新用户
 * @eo.path /user/red/packet/invite/new
 */
@RestController
@RequestMapping("/user/invite-new")
@RequiredArgsConstructor
public class UserRedPacketInviteNewRestController extends BaseController {

  private final UserRedPacketInviteNewService userRedPacketInviteNewService;

  /**
   * 邀请新用户-目标中转账户-分页.
   */
  @GetMapping("/target/transit/balance/page")
  public PageResult<InviteBalanceDTO> pageTargetTransitBalance(InviteBalancePageQryCmd cmd) {
    return userRedPacketInviteNewService.pageTargetTransitBalance(cmd);
  }

  /**
   * 邀请新用户-扣除目标.
   */
  @PostMapping("/target/transit/reduce")
  public void reduceTarget(@RequestBody @Validated InviteTargetTransitBalanceCmd cmd) {
    userRedPacketInviteNewService.reduceTarget(cmd);
  }

  /**
   * 邀请新用户-美元中转账户-分页.
   */
  @GetMapping("/withdraw/transit/balance/page")
  public PageResult<InviteBalanceDTO> pageWithdrawTransitBalance(
      InviteBalancePageQryCmd cmd) {
    return userRedPacketInviteNewService.pageWithdrawTransitBalance(cmd);
  }

  /**
   * 邀请新用户-红包抽奖记录-分页.
   */
  @GetMapping("/red/packet/draw/log/page")
  public PageResult<InviteRedPacketDrawLogDTO> pageRedPacketDrawLog(
      InviteRedPacketDrawLogPageQryCmd cmd) {
    return userRedPacketInviteNewService.pageRedPacketDrawLog(cmd);
  }

  /**
   * 邀请新用户-助力记录-分页.
   */
  @GetMapping("/red/packet/help/log/page")
  public PageResult<InviteRedPacketHelpLogDTO> pageRedPacketHelpLog(
      InviteRedPacketHelpLogPageQryCmd cmd) {
    return userRedPacketInviteNewService.pageRedPacketHelpLog(cmd);
  }

  /**
   * 邀请新用户-红包记录-分页.
   */
  @GetMapping("/red/packet/log/page")
  public PageResult<InviteRedPacketDTO> pageRedPacket(InviteRedPacketPageQryCmd cmd) {
    return userRedPacketInviteNewService.pageRedPacket(cmd);
  }

  /**
   * 邀请新用户-转盘奖项列表.
   */
  @GetMapping("/red/packet/carousel/awards/list")
  public List<InviteCarouselAwardsBackDTO> listCarouselAwards(String sysOrigin) {
    return userRedPacketInviteNewService.listCarouselAwards(sysOrigin);
  }

  /**
   * 邀请新用户-转盘奖项-保存.
   */
  @PostMapping("/red/packet/carousel/awards/save")
  public void saveCarouselAwards(@RequestBody @Validated InviteCarouselAwardsCmd cmd) {
    userRedPacketInviteNewService.saveCarouselAwards(cmd);
  }

  /**
   * 邀请新用户-删除转盘奖项.
   */
  @GetMapping("/red/packet/carousel/awards/delete")
  public void deleteCarouselAwards(Long id) {
    userRedPacketInviteNewService.deleteCarouselAwards(id);
  }

  /**
   * 邀请新用户-配置.
   */
  @GetMapping("/red/packet/config")
  public InviteConfigDTO getConfigBySysOrigin(String sysOrigin) {
    return userRedPacketInviteNewService.getConfigBySysOrigin(sysOrigin);
  }

  /**
   * 邀请新用户-配置-保存.
   */
  @PostMapping("/red/packet/config/save")
  public void saveConfig(@RequestBody @Validated InviteConfigCmd cmd) {
    userRedPacketInviteNewService.saveConfig(cmd);
  }

}
