import request from '@/utils/request';

// 账户相关
export function getMerchantAccount() {
  return request.get('/api/merchant/finance/account');
}

// 交易流水相关
export function getMerchantTransactions(params: any) {
  return request.get('/api/merchant/finance/transactions', { params });
}

export function getTransactionDetail(id: number) {
  return request.get(`/api/merchant/finance/transactions/${id}`);
}

// 提现相关
export function getMerchantWithdrawals(params: any) {
  return request.get('/api/merchant/finance/withdrawals', { params });
}

export function getWithdrawalDetail(id: number) {
  return request.get(`/api/merchant/finance/withdrawals/${id}`);
}

export function applyWithdrawal(data: { amount: number; bankAccount: string; bankName: string; accountName: string }) {
  return request.post('/api/merchant/finance/withdrawals', data);
}

export function cancelWithdrawal(id: number) {
  return request.put(`/api/merchant/finance/withdrawals/${id}/cancel`);
}

// 结算相关
export function getMerchantSettlements(params: any) {
  return request.get('/api/merchant/finance/settlements', { params });
}

export function getSettlementDetail(id: number) {
  return request.get(`/api/merchant/finance/settlements/${id}`);
}

export function getSettlementItems(id: number, params: any) {
  return request.get(`/api/merchant/finance/settlements/${id}/items`, { params });
}
