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

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.model.cmd.user.InviteUserQryCmd;
import com.red.circle.other.inner.model.cmd.user.SysInviteUserConfigCmd;
import com.red.circle.other.inner.model.cmd.user.UserInviteRewardQryCmd;
import com.red.circle.other.inner.model.dto.user.InviteUserRechargeCommissionDTO;
import com.red.circle.other.inner.model.dto.user.InviteUserRegisterDTO;
import com.red.circle.other.inner.model.dto.user.InviteUserRewardRecordDTO;
import com.red.circle.other.inner.model.dto.user.InviteUserSummaryDTO;
import com.red.circle.other.inner.model.dto.user.PageInviteUserRegisterDTO;
import com.red.circle.other.inner.model.dto.user.SysInviteUserConfigDTO;
import java.math.BigDecimal;
import java.util.List;
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.RequestParam;

/**
 * 用户邀请.
 *
 * @author pengliang on 2023/8/18
 */
public interface InviteUserClientApi {

  String API_PREFIX = "/invite-user/client";

  /**
   * 被邀请人充值邀请人获得佣金.
   */
  @GetMapping("/processRechargeCommission")
  ResultResponse<Void> processRechargeCommission(
      @RequestParam("rechargeAmount") BigDecimal rechargeAmount,
      @RequestParam("sysOrigin") String sysOrigin,
      @RequestParam("inviteUserId") Long inviteUserId
  );

  /**
   * 获得用户邀请用户注册分页数据
   *
   * @param pageNumber 第几页
   * @param userId     邀请人用户id
   * @return 被邀请人信息
   */
  @GetMapping("/pageInviteUserRegister")
  ResultResponse<List<InviteUserRegisterDTO>> pageInviteUserRegister(
      @RequestParam("pageNumber") Integer pageNumber, @RequestParam("userId") Long userId);

  /**
   * 获取邀请用户充值佣金与数量累计
   *
   * @param userId 用户id
   * @return 邀请用户充值佣金与数量累计
   */
  @GetMapping("/getInviteUserSummary")
  ResultResponse<InviteUserSummaryDTO> getInviteUserSummary(@RequestParam("userId") Long userId);

  /**
   * 获得已领取的奖励规则id集合
   */
  @GetMapping("/getRewardsReceivedRuleIds")
  ResultResponse<String> getRewardsReceivedRuleIds(@RequestParam("userId") Long userId);

  /**
   * 保存已领取的奖励规则id集合
   */
  @GetMapping("/setRewardsReceivedRuleIds")
  ResultResponse<Void> setRewardsReceivedRuleIds(@RequestParam("userId") Long userId,
      @RequestParam("list") String list);

  /**
   * 获得邀请用户充值佣金分页数据
   */
  @GetMapping("/pageInviteUserRechargeCommission")
  ResultResponse<List<InviteUserRechargeCommissionDTO>> pageInviteUserRechargeCommission(
      @RequestParam("pageNumber") Integer pageNumber,
      @RequestParam("inviteUserId") Long inviteUserId);


  /**
   * 获取被邀请人用户id
   *
   * @param inviteUserId 被邀请用户
   * @return 用户id
   */
  @GetMapping("/getUserIdByInviteUserId")
  ResultResponse<Long> getUserIdByInviteUserId(@RequestParam("inviteUserId") Long inviteUserId);

  /**
   * 添加邀请,奖励记录.
   */
  @PostMapping("/addRewardRecord")
  ResultResponse<Void> addRewardRecord(@RequestBody @Validated InviteUserRewardRecordDTO dto);

  /**
   * 邀请用户奖励分页列表.
   */
  @PostMapping("/getUserInviteRewardRecord")
  ResultResponse<PageResult<InviteUserRewardRecordDTO>> getUserInviteRewardRecord(
      @RequestBody UserInviteRewardQryCmd query);

  /**
   * 分页查询用户邀请用户注册信息
   */
  @PostMapping("/pageInviteUserRegisterAll")
  ResultResponse<PageResult<PageInviteUserRegisterDTO>> pageInviteUserRegisterAll(
      @RequestBody InviteUserQryCmd query);

  /**
   * 修改邀请用户规则
   */
  @PostMapping("/updateConfig")
  ResultResponse<Void> updateConfig(@RequestBody SysInviteUserConfigCmd config);

  /**
   * 邀请用户规则
   */
  @GetMapping("/getConfig")
  ResultResponse<SysInviteUserConfigDTO> getConfig(@RequestParam("sysOrigin") String sysOrigin);
}
