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

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.wallet.inner.model.cmd.UserSalaryDiamondBalanceQryCmd;
import com.red.circle.wallet.inner.model.cmd.UserSalaryDiamondCmd;
import com.red.circle.wallet.inner.model.dto.SalaryDiamondBalanceDTO;
import com.red.circle.wallet.inner.model.dto.UserSalaryDiamondRunningWaterDTO;
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.Map;
import java.util.concurrent.CompletableFuture;

/**
 * 用户工资钻石
 *
 * @author zongpubin on 2024/3/14
 */
public interface SalaryDiamondBalanceClientApi {

  String API_PREFIX = "/salary/diamond/client";

  /**
   * 查看用户工资钻石账户.
   */
  @PostMapping("/listBalance")
  ResultResponse<PageResult<SalaryDiamondBalanceDTO>> listUserSalaryDiamondBalance(
      @RequestBody UserSalaryDiamondBalanceQryCmd query);

  /**
   * 是否存在账户.
   *
   * @return true 存在.
   */
  @GetMapping("/exists")
  ResultResponse<Boolean> exists(@RequestParam("userId") Long userId);

  @GetMapping("/mapBalance")
  ResultResponse<Map<Long, BigDecimal>> mapBalanceBySysOrigin(@RequestParam("sysOrigin") String sysOrigin);

  /**
   * 累计余额.
   *
   * @return 是否操作成功
   */
  @PostMapping("/incr")
  ResultResponse<Boolean> incr(@RequestBody @Validated UserSalaryDiamondCmd param);

  /**
   * 获取用户余额.
   */
  @GetMapping("/getBalance")
  ResultResponse<SalaryDiamondBalanceDTO> getBalance(@RequestParam("userId") Long userId);

  /**
   * 获取用户余额.
   */
  @PostMapping("/decr")
  ResultResponse<SalaryDiamondBalanceDTO> decr(@RequestBody @Validated UserSalaryDiamondCmd param);

  /**
   * 改变工资钻石余额(异步).
   *
   * @param cmd 单据
   * @return 余额
   */
  @PostMapping("/salary/balance/change/async")
  CompletableFuture<ResultResponse<SalaryDiamondBalanceDTO>> changeSalaryBalanceAsync(
          @RequestBody @Validated UserSalaryDiamondCmd cmd);
}
