package com.red.circle.wallet.inner.endpoint.wallet.api;

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.wallet.inner.model.cmd.DiamondReceiptCmd;
import com.red.circle.wallet.inner.model.cmd.UserDiamondBalanceQryCmd;
import com.red.circle.wallet.inner.model.cmd.UserDiamondOriginQryCmd;
import com.red.circle.wallet.inner.model.cmd.UserDiamondRunWaterQryCmd;
import com.red.circle.wallet.inner.model.dto.*;
import jakarta.validation.Valid;
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;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
 * @author pengliang on 2023/5/26
 */
public interface WalletDiamondClientApi {

  String API_PREFIX = "/wallet/diamond";

  /**
   * 用户钱包钻石余额.
   *
   * @param userId 用户id
   * @return 钱包
   */
  @GetMapping("/balance")
  ResultResponse<BigDecimal> getBalance(@RequestParam("userId") Long userId);

  /**
   * 钻石余额.
   */
  @PostMapping("/mapBalance")
  ResultResponse<Map<Long, BigDecimal>> mapBalance(@RequestBody Collection<Long> userIds);

  /**
   * 公司钻石余额.
   */
  @PostMapping("/salaryMapBalance")
  ResultResponse<Map<Long, BigDecimal>> salaryMapBalance(@RequestBody Collection<Long> userIds);

  /**
   * 钻石自动兑换金币
   * @param userId
   * @param amount
   * @return
   */
  @GetMapping("/auto/exchange/gold")
  ResultResponse<Void> autoExchangeGold(@RequestParam("userId") Long userId,
                                        @RequestParam("amount") BigDecimal amount);

  /**
   * 改变钻石余额.
   *
   * @param cmd 单据
   * @return 余额
   */
  @PostMapping("/balance/change")
  ResultResponse<WalletReceiptDTO> changeBalance(@RequestBody @Valid DiamondReceiptCmd cmd);

  /**
   * 改变钻石余额(异步).
   *
   * @param cmd 单据
   * @return 余额
   */
  @PostMapping("/balance/change/async")
  CompletableFuture<ResultResponse<WalletReceiptDTO>> changeBalanceAsync(
      @RequestBody @Validated DiamondReceiptCmd cmd);

  /**
   * 钻石余额列表
   */
  @PostMapping("/pageUserDiamondBalance")
  ResultResponse<PageResult<DiamondBalanceDTO>> pageUserDiamondBalance(
      @RequestBody @Validated UserDiamondBalanceQryCmd query);

  /**
   * 钻石余额列表
   */
  @PostMapping("/pageUserDiamondRunWater")
  ResultResponse<PageResult<UserDiamondRunWaterDTO>> pageUserDiamondRunWater(
      @RequestBody @Validated UserDiamondRunWaterQryCmd query);


  /**
   * 获取钻石流水分页列表
   *
   * @param query 查询条件
   * @return page
   */
  @PostMapping("/pageUserDiamondOriginDetails")
  ResultResponse<PageResult<UserDiamondOriginDTO>> pageUserDiamondOriginDetails(
      @RequestBody UserDiamondOriginQryCmd query);
}

