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

import com.google.common.collect.Lists;
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.framework.web.controller.BaseController;
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.app.service.user.invite.RedPacketInviteV2Service;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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/invite/new/user
 */
@RestController
@RequestMapping("/user/invite/new/user")
@RequiredArgsConstructor
@Slf4j
public class RedPacketInviteRestController extends BaseController {

  private final RedPacketInviteV2Service redPacketInviteService;

  /**
   * 转盘配置.
   *
   * @eo.name 转盘配置.
   * @eo.url /carousel/config
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/carousel/config")
  public List<InviteRedPacketCarouselAwardsCO> listCarouselConfig(AppExtCommand cmd) {
    return redPacketInviteService.listCarouselConfig(cmd);
  }

  /**
   * 提现记录.
   *
   * @eo.name 提现记录.
   * @eo.url /withdraw/record
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/withdraw/record")
  public List<InviteRedPacketWithdrawRecordCO> listWithdrawRecord(AppExtCommand cmd) {
    return redPacketInviteService.listWithdrawRecord(cmd);
  }

  /**
   * 获得用户提现账户.
   *
   * @eo.name 获得用户提现账户.
   * @eo.url /withdraw/balance
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/withdraw/balance")
  public InviteRedPacketWithdrawalCO getWithdrawBalance(AppExtCommand cmd) {
    return redPacketInviteService.getWithdrawBalance(cmd);
  }

  /**
   * 提现.
   *
   * @eo.name 提现.
   * @eo.url /withdraw
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/withdraw")
  public InviteRedPacketWithdrawalCO withdraw(AppExtCommand cmd) {
    return redPacketInviteService.withdraw(cmd);
  }

  /**
   * 获得用户红包信息.
   *
   * @eo.name 获得用户红包信息.
   * @eo.url /red-packet/info
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/red-packet/info")
  public InviteRedPacketUserInfoCO getUserRedPacketInfo(AppExtCommand cmd) {
    return redPacketInviteService.getUserRedPacketInfo(cmd);
  }

  /**
   * 帮砍一刀与邀新红包活动权限校验.
   *
   * @eo.name 帮砍一刀与邀新红包活动权限校验.
   * @eo.url /check/red-packet/auth
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/check/red-packet/auth")
  public InviteRedPacketUserCheckAuthCO checkUserRedPacketAuth(
      @Validated InviteUserRedPacketCmd cmd) {

    InviteRedPacketUserCheckAuthCO checkAuthCO = redPacketInviteService.checkUserRedPacketAuth(cmd);
    checkAuthCO.setImei(null);
    checkAuthCO.setIp(null);
    return checkAuthCO;
  }

  /**
   * 开红包.
   *
   * @eo.name 开红包.
   * @eo.url /open/red-packet
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/open/red-packet")
  public InviteRedPacketUserInfoCO openRedPacket(
      @RequestBody @Validated InviteUserRedPacketCmd cmd) {
    return redPacketInviteService.openRedPacket(cmd);
  }

  /**
   * 抽奖.
   *
   * @eo.name 抽奖.
   * @eo.url /lottery
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/lottery")
  public InviteRedPacketCarouselAwardsCO lottery(AppExtCommand cmd) {
    return redPacketInviteService.lottery(cmd);
  }

  /**
   * 红包邀请活动状态(true 已关闭, false 运行中).
   *
   * @eo.name 红包邀请活动状态(true 已关闭, false 运行中).
   * @eo.url /activity/status
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/activity/status")
  public Boolean getActivityStatus(AppExtCommand cmd) {
    return redPacketInviteService.getActivityStatus(cmd);
  }

  /**
   * 助力列表.
   *
   * @eo.name 助力列表.
   * @eo.url /help/page
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/help/page")
  public List<InviteRedPacketHelpUserCO> pageHelpUsers(AppFlowCmd cmd) {
    return redPacketInviteService.pageHelpUsers(cmd);
  }

  /**
   * 抽奖结果列表.
   *
   * @eo.name 抽奖结果列表.
   * @eo.url /lottery/results/page
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/lottery/results/page")
  public List<InviteRedPacketUserLotteryDetailsCO> pageLotteryResults(AppFlowCmd cmd) {
    return redPacketInviteService.pageLotteryResults(cmd);
  }

  /**
   * 红包权限(App使用).
   *
   * @eo.name 红包权限(App使用).
   * @eo.url /author
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/author")
  public InviteRedPacketUserAuthCO getUserRedPacketAuthor(AppExtCommand cmd) {
    return redPacketInviteService.getUserRedPacketAuthor(cmd);
  }

  @GetMapping("/user/succeed")
  public List<InviteUserSucceedCO> getInviteUserSucceed(AppExtCommand cmd){
    return redPacketInviteService.getInviteUserSucceed(cmd);
  }

  /**
   * 根据邀请码获得用户信息(App使用).
   *
   * @eo.name 根据邀请码获得用户信息(App使用).
   * @eo.url /invite/people
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/invite/people")
  public UserProfileDTO getInvitePeople(AppAccountCmd cmd) {
    return redPacketInviteService.getInvitePeople(cmd);
  }

  /**
   * 新用户下次可助力时间.
   *
   * @eo.name 新用户下次可助力时间.
   * @eo.url /next/help/time
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/next/help/time")
  public String getNextHelpTime(AppExtCommand cmd) {
    return redPacketInviteService.getNextHelpTime(cmd);
  }

  /**
   * 分享落地页假数据.
   *
   * @eo.name 分享落地页假数据.
   * @eo.url /withdrawn/users/log
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/withdrawn/users/log")
  public List<InviteRedPacketFakeDataCO> listWithdrawnUsers() {

    List<InviteRedPacketFakeDataCO> users = Lists.newArrayList();
    InviteRedPacketFakeDataCO user1 = new InviteRedPacketFakeDataCO();
    user1.setUserNickname("Zickhaii Khaii");
    user1.setUserAvatar(
        "https://img.sugartimeapp.com/avatar/43bdc428-1e48-4822-8ab8-faf69686072c.png");
    user1.setMoney(888);
    users.add(user1);

    InviteRedPacketFakeDataCO user2 = new InviteRedPacketFakeDataCO();
    user2.setUserNickname("ZMX YO");
    user2.setUserAvatar(
        "https://img.sugartimeapp.com/avatar/945a40c1-fdd7-4cab-9fb2-66ca3c7cfba7.jpg");
    user2.setMoney(588);
    users.add(user2);

    InviteRedPacketFakeDataCO user3 = new InviteRedPacketFakeDataCO();
    user3.setUserNickname("সোনালাী");
    user3.setUserAvatar(
        "https://img.sugartimeapp.com/avatar/39a20d78-6cee-4802-bed1-93ef19801713.jpg");
    user3.setMoney(888);
    users.add(user3);

    InviteRedPacketFakeDataCO user4 = new InviteRedPacketFakeDataCO();
    user4.setUserNickname("Medi cen cen");
    user4.setUserAvatar(
        "https://img.sugartimeapp.com/avatar/c7f7fd75-733c-4a1b-9f7d-c46deec7c0ab.jpg");
    user4.setMoney(300);
    users.add(user4);

    InviteRedPacketFakeDataCO user5 = new InviteRedPacketFakeDataCO();
    user5.setUserNickname("Mehaki");
    user5.setUserAvatar(
        "https://img.sugartimeapp.com/avatar/3e2c185b-aba2-46ab-a0f6-bd92fdaaa236.jpg");
    user5.setMoney(288);
    users.add(user5);

    InviteRedPacketFakeDataCO user6 = new InviteRedPacketFakeDataCO();
    user6.setUserNickname("youcef");
    user6.setUserAvatar(
        "https://img.sugartimeapp.com/avatar/3a458922-ce68-4c11-a6bb-efe5fed7e690.jpg");
    user6.setMoney(388);
    users.add(user6);

    InviteRedPacketFakeDataCO user7 = new InviteRedPacketFakeDataCO();
    user7.setUserNickname("Khan");
    user7.setUserAvatar(
        "https://img.sugartimeapp.com/avatar/65193479-9c53-4146-9075-52558eed4d5d.jpeg");
    user7.setMoney(600);
    users.add(user7);

    InviteRedPacketFakeDataCO user8 = new InviteRedPacketFakeDataCO();
    user8.setUserNickname("°ㇱᴛᴏxɪᴄ ɢɪʀʟㇱ°");
    user8.setUserAvatar(
        "https://img.sugartimeapp.com/avatar/844fcd2b-55d1-4bcf-9f47-b2a5bbfc9218.jpg");
    user8.setMoney(688);
    users.add(user8);

    InviteRedPacketFakeDataCO user9 = new InviteRedPacketFakeDataCO();
    user9.setUserNickname("বোকা");
    user9.setUserAvatar(
        "https://img.sugartimeapp.com/avatar/da2d62b7-b495-4362-a1aa-4d5e81a2c8a2.jpg");
    user9.setMoney(500);
    users.add(user9);

    InviteRedPacketFakeDataCO user10 = new InviteRedPacketFakeDataCO();
    user10.setUserNickname("aseem");
    user10.setUserAvatar(
        "https://img.sugartimeapp.com/avatar/566ba0c6-a5de-4a00-a9c8-3221c0f20d49.jpg");
    user10.setMoney(800);
    users.add(user10);

    return users;
  }

}
