import { post } from "@/utils/request";

// 基础响应接口
export interface BaseResponse<T = any> {
  code: number;
  data: T;
  msg: string;
}

// 分页请求参数接口
export interface PageParams {
  page: {
    current: number;
    row: number;
  };
  [key: string]: any;
}

// 分页响应接口
export interface PageResponse<T> {
  data: T[];
  code: number;
  msg: string;
  page: {
    current: number;
    pageTotal: number;
    row: number;
    rowTotal: number;
  };
}

// 卡片类型相关接口
export interface CardType {
  id: string;
  name: string;
  [key: string]: any;
}

export interface CardTypeParams extends PageParams {
  name?: string;
  status?: number;
}

// 商户相关接口
export interface MerchantUser {
  id: string;
  username: string;
  [key: string]: any;
}

export interface MerchantAccount {
  balance: number;
  [key: string]: any;
}

export interface MerchantParams extends PageParams {
  username?: string;
  status?: number;
}

// KYC相关接口
export interface KycInfo {
  id: string;
  status: number;
  [key: string]: any;
}

export interface KycParams {
  merchantId: string;
  [key: string]: any;
}

// 卡片相关接口
export interface CardInfo {
  id: string;
  cardNo: string;
  [key: string]: any;
}

export interface CardApplyParams {
  cardTypeId: string;
  [key: string]: any;
}

// 交易相关接口
export interface TransactionInfo {
  id: string;
  amount: number;
  [key: string]: any;
}

export interface TransactionParams extends PageParams {
  cardId?: string;
  type?: number;
}

// 转账相关接口
export interface TransferInfo {
  id: string;
  amount: number;
  [key: string]: any;
}

export interface TransferParams {
  cardId: string;
  uniqueId: string;
  [key: string]: any;
}

// 国家城市相关接口
export interface CountryCityInfo {
  code: string;
  cnName: string;
  enName: string;
}

// 职业信息接口
export interface OccupationInfo {
  code: string;
  name: string;
  [key: string]: any;
}

// 激活码接口
export interface ActivationCode {
  code: string;
  [key: string]: any;
}

// 拒绝理由接口
export interface RefusalReason {
  id: string;
  reason: string;
  [key: string]: any;
}

export const ucardApi = {
  // 获取卡片类型列表
  cardTypesPage(
    params: CardTypeParams = { page: { current: 1, row: 10 } }
  ): Promise<BaseResponse<PageResponse<CardType>>> {
    return post("/wasabi/api/card/types/page", { ...params });
  },
  // 获取卡片类型列表
  cardTypesList(
    params: CardTypeParams = { page: { current: 1, row: 10 } }
  ): Promise<BaseResponse<PageResponse<CardType>>> {
    return post("/wasabi/api/card/types/list", { ...params });
  },
  // 更新卡片类型列表
  updateCardTypes(params: Partial<CardType> = {}): Promise<BaseResponse> {
    return post("/wasabi/api/card/update/basic/info", { ...params });
  },
  // 获取商户信息
  getSingle(params: { id: string }): Promise<BaseResponse<MerchantUser>> {
    return post("/wasabi/api/merchant/user/single", { ...params });
  },
  // 商户用户分页列表
  merchantList(
    params: MerchantParams = { page: { current: 1, row: 10 } }
  ): Promise<BaseResponse<PageResponse<MerchantUser>>> {
    return post("/wasabi/api/merchant/user/page", { ...params });
  },
  // 查询商户账户信息
  merchantAccount(params: {
    merchantId: string;
  }): Promise<BaseResponse<MerchantAccount>> {
    return post("/wasabi/api/merchant/account", { ...params });
  },
  // 商户注册选择用户列表
  merchantSearch(params: {
    keyword: string;
  }): Promise<BaseResponse<MerchantUser[]>> {
    return post("/custom/search/ucard", { ...params });
  },
  // 商户用户注册
  merchantRegister(params: Partial<MerchantUser>): Promise<BaseResponse> {
    return post("/wasabi/api/merchant/user/register", { ...params });
  },
  // 更新商户用户信息
  merchantUpdate(params: Partial<MerchantUser>): Promise<BaseResponse> {
    return post("/wasabi/api/merchant/user/update", { ...params });
  },
  // 国家城市
  ucardCountryCity(
    params: { code?: string } = {}
  ): Promise<BaseResponse<CountryCityInfo[]>> {
    return post("/wasabi/api/card/country", { ...params });
  },
  // 更新国家城市
  ucardUpdateCountryCity(
    params: Partial<CountryCityInfo> = {}
  ): Promise<BaseResponse> {
    return post("/wasabi/api/card/update/country", { ...params });
  },
  // 查询职业信息
  getOccupationList(
    params: { code?: string } = {}
  ): Promise<BaseResponse<OccupationInfo[]>> {
    return post("/wasabi/api/card/occupation/list", { ...params });
  },
  // 更新职业信息
  updateOccupationList(
    params: Partial<OccupationInfo> = {}
  ): Promise<BaseResponse> {
    return post("/wasabi/api/card/occupation/update", { ...params });
  },
  // 获取卡片申请列表
  applyList(
    params: PageParams = { page: { current: 1, row: 10 } }
  ): Promise<BaseResponse<PageResponse<CardApplyParams>>> {
    return post("/wasabi/api/card/apply/page", { ...params });
  },
  // 获取卡片列表
  cardList(
    params: PageParams = { page: { current: 1, row: 10 } }
  ): Promise<BaseResponse<PageResponse<CardInfo>>> {
    return post("/wasabi/api/card/list", { ...params });
  },
  // kyc列表
  kycList(
    params: PageParams = { page: { current: 1, row: 10 } }
  ): Promise<BaseResponse<PageResponse<KycInfo>>> {
    return post("/wasabi/api/merchant/kyc/page", { ...params });
  },
  // 查询KYC认证状态
  kycStatus(params: { merchantId: string }): Promise<BaseResponse<KycInfo>> {
    return post("/wasabi/api/merchant/kyc/status", { ...params });
  },
  // 查询开卡进度
  ucardApplyProgress(params: {
    applyId: string;
  }): Promise<BaseResponse<{ status: number; message: string }>> {
    return post("/wasabi/api/card/apply/progress", { ...params });
  },
  // 银行卡激活
  ucardActivate(params: {
    cardNo: string;
    uniqueId: string;
    password: string;
  }): Promise<BaseResponse> {
    return post("/wasabi/api/card/activate", { ...params });
  },
  // 银行卡详情
  getCardInfo(params: { id: string }): Promise<BaseResponse<CardInfo>> {
    return post("/wasabi/api/card/single", { ...params });
  },
  // 银行卡充值
  ucardRecharge(params: {
    cardNo: string;
    amount: number;
    currency: string;
    uniqueId: string;
  }): Promise<BaseResponse> {
    return post("/wasabi/api/card/recharge", { ...params });
  },
  // 查询卡片余额
  ucardBalance(params: {
    cardNo: string;
    uniqueId: string;
  }): Promise<BaseResponse<{ balance: number; currency: string }>> {
    return post("/wasabi/api/card/balance", { ...params });
  },
  // 找回密码
  ucardResetPassword(params: {
    cardNo: string;
    newPassword: string;
  }): Promise<BaseResponse> {
    return post("/wasabi/api/card/password/reset", { ...params });
  },
  // 冻结卡片
  ucardFreeze(params: {
    cardNo: string;
    uniqueId: string;
  }): Promise<BaseResponse> {
    return post("/wasabi/api/card/freeze", { ...params });
  },
  // 解冻卡片
  ucardUnfreeze(params: {
    cardNo: string;
    uniqueId: string;
  }): Promise<BaseResponse> {
    return post("/wasabi/api/card/unfreeze", { ...params });
  },
  // 查询充值订单
  ucardRechargeOrder(params: {
    orderNo: string;
  }): Promise<BaseResponse<TransactionInfo>> {
    return post("/wasabi/api/card/recharge/order", { ...params });
  },
  // 充值记录分页查询
  rechargeList(
    params: TransactionParams = { page: { current: 1, row: 10 } }
  ): Promise<BaseResponse<PageResponse<TransactionInfo>>> {
    return post("/wasabi/api/card/recharge/page", { ...params });
  },
  // 提交KYC认证
  kycSubmit(params: KycParams): Promise<BaseResponse> {
    return post("/wasabi/api/merchant/kyc/manual/submit", { ...params });
  },
  // 文件上传
  ucardUpload(params: FormData): Promise<BaseResponse<{ url: string }>> {
    return post("/wasabi/api/upload/file", { ...params });
  },
  // 获取WebSDK链接
  getWebsdkLink(params: {} = {}): Promise<BaseResponse<{ link: string }>> {
    return post("/wasabi/api/getWebsdkLink", { ...params });
  },
  // 上传KYC附件
  kycUpload(params: FormData): Promise<BaseResponse<{ url: string }>> {
    return post("/wasabi/api/merchant/kyc/upload", { ...params });
  },
  // 获取激活卡
  getActivationCode(params: {} = {}): Promise<BaseResponse<ActivationCode>> {
    return post("/wasabi/api/get/activation/code", { ...params });
  },
  // 查询交易记录分页列表
  transactionsList(
    params: TransactionParams = { page: { current: 1, row: 10 } }
  ): Promise<BaseResponse<PageResponse<TransactionInfo>>> {
    return post("/wasabi/api/card/transac/page", { ...params });
  },
  // 用户订单分页查询
  transferList(
    params: TransactionParams = { page: { current: 1, row: 10 } }
  ): Promise<BaseResponse<PageResponse<TransferInfo>>> {
    return post("/wasabi/api/transfer/page", { ...params });
  },
  // 申请开卡
  ucardApply(params: CardApplyParams): Promise<BaseResponse> {
    return post("/wasabi/api/card/apply", { ...params });
  },
  // 免费次数
  reductionNum(params: {} = {}): Promise<BaseResponse<{ count: number }>> {
    return post("/wasabi/api/apply/reduction/num", { ...params });
  },
  // 账户余额
  walletBalance(
    params: {} = {}
  ): Promise<BaseResponse<{ balance: number; currency: string }>> {
    return post("/wasabi/api/card/wallet/balance", { ...params });
  },
  // 开卡详情
  applyDetails(params: {
    applyId: string;
  }): Promise<BaseResponse<CardApplyParams>> {
    return post("/wasabi/api/card/apply/details", { ...params });
  },
  // 钱包记录分页列表
  getRecordPage(
    params: PageParams = { page: { current: 1, row: 10 } }
  ): Promise<BaseResponse<PageResponse<TransactionInfo>>> {
    return post("/wasabi/api/card/wallet/record/page", { ...params });
  },
  // 验证权限
  permissionVerify(params: {
    cardNo: string;
    uniqueId: string;
  }): Promise<BaseResponse<{ valid: boolean }>> {
    return post("/wasabi/api/card/permission/verify", { ...params });
  },
  // 人脸详情
  searchSingle(params: {
    id: string;
  }): Promise<BaseResponse<{ faceInfo: any }>> {
    return post("/wasabi/api/search/single", { ...params });
  },
  // 更新地址
  addressUpdate(params: {
    address: string;
    [key: string]: any;
  }): Promise<BaseResponse> {
    return post("/wasabi/api/merchant/user/address/update", { ...params });
  },
  // 查看cvv码校验密码
  getCvv(params: {
    cardNo: string;
    password: string;
  }): Promise<BaseResponse<{ cvv: string }>> {
    return post("/wasabi/api/card/password/verify", { ...params });
  },
  // 根据条件查看拒绝列表-用于下拉和选择展示理由
  reasonsRefusalList(
    params: { type?: string } = {}
  ): Promise<BaseResponse<RefusalReason[]>> {
    return post("/reasons/refusal/list", { ...params });
  },
  // 证件类型配置
  idTypesConfigList(
    params: { country?: string; type?: string } = {}
  ): Promise<BaseResponse<{ id: string; name: string }[]>> {
    return post("/wasabi/api/card/id/type/config/list", { ...params });
  },
  // 验证邮箱验证码查询
  getCvvCode(params: {
    cardNo: string;
    password: string;
  }): Promise<BaseResponse<{ code: string }>> {
    return post("/wasabi/api/query/cvv/verify/code", { ...params });
  },
  // 查询CVV 发送短信验证码
  sendEmailCode(params: {
    cardNo: string;
    password: string;
  }): Promise<BaseResponse<{ code: string }>> {
    return post("/wasabi/api/query/cvv/send/code", { ...params });
  },
  // 全球速汇
  globalCurrenciesSave(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/currencies/save", params);
  },

  globalCurrenciesList(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/currencies/list", params);
  },
  // 币种下拉列表
  globalCurrenciesDropdown(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/currencies/dropdown", params);
  },
  // 币种字段和可选值列表
  globalCurrenciesField(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/currencies/field/list", params);
  },


  // 查询 ucard 账户信息
  cardAccountDropdown(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/card/account/dropdown", params);
  },

  // 速汇订单分页列表
  globalOrdersList(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/order/page/list", params);
  },

  // 速汇订单审批
  globalOrderApprove(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/order/approve", params);
  },

  // 创建订单
  globalOrdersCreate(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/create/order", params);
  },

  // 订单详情
  globalOrdersDetail(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/order/details", params);
  },

  // 修改订单
  globalOrderUpdate(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/update/global/order", params);
  },

  // 查询已认证用户列表
  cardUserList(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/card/query/user/list", params);
  },

  // 更新手续费率
  updateGlobalFee(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/currencies/config", params);
  },

  // 查询手续费率和汇率
  globalExchangeRate(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/query/exchange/rate", params);
  },

  // 查询最新汇率
  globalLatestExchangeRate(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/query/latest/exchange/rate", params);
  },

  // 补充资料
  globalSupplementary(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/supplementary/data", params);
  },

  // 转账币种下拉框
  globalPayoutCurrencyDropdown(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/payout/currency/dropdown", params);
  },

  // 查询支持的城市列表
  globalQueryBankCities(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/query/bank/cities", params);
  },

  // 查询币种全局配置
  globalCurrenciesConfig(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/query/currencies/config", params);
  },

  // 取消交易订单
  globalCancelOrder(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/cancel/order", params);
  },

  // 配置用户汇率
  updateCardConfig(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/merchant/user/rate/config", params);
  },

  // 已认证用户信息详情
  globalUserDetails(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/user/details", params);
  },

  // 获取收款用户列表
  globalReceiverUserList(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/global/receiver/user/list", params);
  },

  // 上传文件
  scanFile(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/scan/upload/file", params);
  },

  // 区块链配置下拉列表
  getBlockchainDropdown(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/card/blockchain/config/dropdown", params);
  },

  // 生成钱包地址
  getVaultodyAddress(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/vaultody/generate/deposit/address", params);
  },

  // 加密货币交易记录列表
  getBlockchainTransactionPage(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/encrypted/wallet/transaction/page", params);
  },

  // 卡扣款分页列表
  getCardWithdrawPage(
    params: object = {}
  ): Promise<BaseResponse<any>> {
    return post("/wasabi/api/card/withdraw/page", params);
  }

};
