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

import com.red.circle.common.business.dto.cmd.UserIdCmd;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.tool.core.tuple.PennyAmount;
import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient;
import com.red.circle.wallet.inner.model.tmp.AssetRecordRunningWaterCO;
import com.red.circle.wallet.inner.model.tmp.UserGoldRunningWaterClsTmpCO;
import com.red.circle.wallet.inner.model.tmp.UserGoldRunningWaterTmpCO;
import com.red.circle.wallet.inner.model.dto.WalletGoldCountDTO;
import com.red.circle.wallet.inner.model.cmd.RecoveryGoldReceiptCmd;
import com.red.circle.wallet.inner.model.cmd.RefundBackReceiptCmd;
import com.red.circle.wallet.inner.model.cmd.SyncGoldReceiptCmd;
import com.red.circle.wallet.inner.model.cmd.TestWalletReceiptCmd;
import com.red.circle.wallet.inner.model.cmd.UserGoldRunningWaterBackQryCmd;
import com.red.circle.wallet.inner.model.cmd.WalletReceiptCmd;
import com.red.circle.wallet.inner.model.dto.WalletReceiptResDTO;
import com.red.circle.wallet.inner.service.wallet.TmpGoldWalletService;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
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;

/**
 * 过渡服务.
 *
 * @author pengliang on 2023/6/29
 */
@Deprecated
@RestController
@RequiredArgsConstructor
@RequestMapping("/wallet-gold")
public class TmpWalletGoldClientEndpoint {

  private final WalletGoldClient walletGoldClient;
  private final TmpGoldWalletService tmpGoldWalletService;

  @GetMapping("/list-wallet-gold-count/export")
  public List<WalletGoldCountDTO> listWalletGoldCountExport(String sysOrigin, Integer monthNumber) {
    return tmpGoldWalletService.listWalletGoldCountExport(sysOrigin, monthNumber);
  }

  @GetMapping("/list-wallet-gold-count")
  public List<WalletGoldCountDTO> listWalletGoldCount(String sysOrigin, Integer groupNum) {
    return tmpGoldWalletService.listWalletGoldCount(sysOrigin, groupNum);
  }

  @GetMapping("/exists/id")
  public Boolean existsEventId(Long id) {
    return tmpGoldWalletService.existsId(id);
  }

  @GetMapping("/exists/event-id")
  public Boolean existsEventId(String eventId) {
    return tmpGoldWalletService.existsEventId(eventId);
  }

  @PostMapping("/maps")
  public Map<Long, Long> mapBalance(@RequestBody Collection<Long> userIds) {
    return tmpGoldWalletService.mapBalance(userIds);
  }

  @PostMapping("/list-water")
  public List<UserGoldRunningWaterTmpCO> listWater(
      @RequestBody @Validated UserGoldRunningWaterBackQryCmd cmd) {
    return tmpGoldWalletService.listWater(cmd);
  }

  @PostMapping("/cls-search-water")
  public UserGoldRunningWaterClsTmpCO getClsSearchWater(
      @RequestBody @Validated UserGoldRunningWaterBackQryCmd cmd) {
    return tmpGoldWalletService.getClsSearchWater(cmd);
  }

  @GetMapping("/latest-water")
  public List<AssetRecordRunningWaterCO> latestWater(String sysOrigin, Long userId, Long lastId) {
    return tmpGoldWalletService.latestWater(sysOrigin, userId, lastId);
  }

  @PostMapping("/sync")
  public void sync(@RequestBody @Validated SyncGoldReceiptCmd cmd) {
    tmpGoldWalletService.sync(cmd);
  }

  @PostMapping("/recovery")
  public void recovery(@RequestBody @Validated RecoveryGoldReceiptCmd cmd) {
    tmpGoldWalletService.recovery(cmd);
  }

  @PostMapping("/refund-back")
  public void refundBack(@RequestBody @Validated RefundBackReceiptCmd cmd) {
    tmpGoldWalletService.refundBack(cmd);
  }

  @GetMapping("/balance")
  public PennyAmount balance(UserIdCmd cmd) {
    return tmpGoldWalletService.getBalance(cmd);
  }

  @PostMapping("/change")
  public WalletReceiptResDTO change(@RequestBody @Validated WalletReceiptCmd cmd) {
    return tmpGoldWalletService.changeBalance(cmd);
  }

  @PostMapping("/change/open-feign")
  public ResultResponse<WalletReceiptResDTO> changeOpenFeign(
      @RequestBody @Validated TestWalletReceiptCmd cmd) {
    return walletGoldClient.changeBalanceTest(cmd);
  }

  @GetMapping("/sync-cache-db-check")
  public ResultResponse<Void> syncCacheDbCheck(Long userId) {
    tmpGoldWalletService.syncCacheDbCheck(userId);
    return ResultResponse.success();
  }

}
