import {
  IdParam,
  CoinQueryParam,
  CoinPageResult,
  FormData,
  CoinItem,
  CoinExtFormData,
  ColdWalletForm,
  CoinTransferQueryParam,
  CoinTransferPageResult,
  CoinTransferItem
} from '@/types/api/system/coin';
import request from '@/utils/request';
import { AxiosPromise } from 'axios';

/**
 * "系统管理"=>"查询币种"
 * @param data
 */
export function querySysCoin(data: CoinQueryParam): AxiosPromise<CoinPageResult> {
  return request({
    url: 'admin/system/coin/page-query',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理" => "添加币种"
 * @param data
 */
export function addSysCoin(data: FormData): any {
  return request({
    url: 'admin/system/coin/create',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理" => "更新币种"
 * @param data
 */
export function updateSysCoin(data: FormData): any {
  return request({
    url: 'admin/system/coin/update',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理" => "币种详情"
 * @param data
 */
export function sysCoinDetail(data: IdParam): AxiosPromise<CoinItem> {
  return request({
    url: 'admin/system/coin/detail',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理"=>"币种管理"=>"转账是否超时"
 * @param data
 */
export function tansTimeout(data: CoinQueryParam): AxiosPromise<CoinPageResult> {
  return request({
    url: 'admin/system/coin/get-no-check-key',
    method: 'fetch',
    params: data
  });
}

/**
 * "系统管理"=>"币种管理"=>"转入冷钱包"
 * @param data
 */
export function transferColdWallet(data: ColdWalletForm): any {
  return request({
    url: 'admin/system/coin/transfer',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理"=>"币种管理"=>"转入冷钱包获取验证码"
 * @param data
 */
export function getColdWalletCode(data: FormData): any {
  return request({
    url: 'admin/code/sms-provider/transfer-cold-wallet',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理"=>"币种管理"=>"是否为平台币"
 * @param data
 */
export function setPlatformCoin(data: FormData): any {
  return request({
    url: 'admin/system/coin/set/platform',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理"=>"币种管理"=>"修改币种时发送验证码"
 * @param data
 */
export function coinReviseSys(data: FormData): any {
  return request({
    url: 'admin/code/sms-provider/system/coin-revise',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理"=>"币种管理"=>"添加钱包"
 * @param data
 */
export function createMemberWallet(data: any): AxiosPromise<any> {
  return request({
    url: 'admin/system/coin/create-member-wallet',
    method: 'post',
    params: data
  });
}


/**
 * "系统管理"=>"币种管理"=>"获取扩展信息"
 * @param symbol
 */
export function getCoinExt(symbol: string): any {
  return request({
    url: 'admin/system/coin/ext/detail',
    method: 'post',
    params: { symbol }
  });
}

/**
 * "系统管理"=>"币种管理"=>"获取所有币种名称"
 */
export function getAllCoinNames(): AxiosPromise<string[]> {
  return request({
    url: 'admin/system/coin/all-name',
    method: 'post'
  });
}

/** 获取所有币种 name + unit，用于下拉选择 */
export function getAllCoinNameAndUnit(): AxiosPromise<{ name: string; unit: string }[]> {
  return request({
    url: 'admin/system/coin/all-name-and-unit',
    method: 'post'
  });
}

/** 获取所有启用中的币种 name + unit */
export function getEnabledCoinNameAndUnit(): AxiosPromise<{ name: string; unit: string }[]> {
  return request({
    url: 'admin/system/coin/enabled-name-and-unit',
    method: 'post'
  });
}

/**
 * "系统管理"=>"币种管理"=>"获取所有顶级币种名称（parentCoinName 为空）"
 */
export function getTopCoinNames(): AxiosPromise<{ name: string; unit: string }[]> {
  return request({
    url: 'admin/system/coin/top-coin-names',
    method: 'post'
  });
}

/**
 * "系统管理"=>"币种管理"=>"转入明细"
 * @param data
 */
export function coinTransferDetail(data: CoinTransferQueryParam): AxiosPromise<CoinTransferPageResult> {
  return request({
    url: 'admin/system/coin/hot-transfer-record/page-query',
    method: 'post',
    params: data
  });
}