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

import com.red.circle.common.business.dto.cmd.PageUserIdCmd;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.wallet.inner.model.cmd.AddBeanIncomeExpenditureCmd;
import com.red.circle.wallet.inner.model.cmd.BeanReceiptCmd;
import com.red.circle.wallet.inner.model.cmd.UserBeanIncomeExpenditurePageQryCmd;
import com.red.circle.wallet.inner.model.dto.BeanBalanceDTO;
import com.red.circle.wallet.inner.model.dto.UserBeanIncomeExpenditureDTO;
import com.red.circle.wallet.inner.model.dto.WalletReceiptDTO;
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.concurrent.CompletableFuture;

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

  String API_PREFIX = "/wallet/bean";

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

  /**
   * 改变豆子余额.
   *
   * @param cmd 单据
   * @return 余额
   */
  @PostMapping("/balance/change")
  ResultResponse<WalletReceiptDTO> changeBalance(@RequestBody @Validated BeanReceiptCmd cmd);

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

  /**
   * 分页查询余额.
   */
  @PostMapping("/pageBeanBalance")
  ResultResponse<PageResult<BeanBalanceDTO>> pageBeanBalance(@RequestBody PageUserIdCmd cmd);

  /**
   * 流水分页列表.
   *
   * @param query 查询条件
   * @return page
   */
  @PostMapping("/pageRunningWater")
  ResultResponse<PageResult<UserBeanIncomeExpenditureDTO>> pageRunningWater(
      @RequestBody UserBeanIncomeExpenditurePageQryCmd query);

  /**
   * 保存豆子收支
   */
  @PostMapping("/saveBeanIncome")
  ResultResponse<Void> saveBeanIncome(@RequestBody AddBeanIncomeExpenditureCmd cmd);
}
