/**
 * 退款管理 API
 */

import { get, post } from '@/utils/request';

export interface RefundQueryParams {
  page?: number;
  pageSize?: number;
  orderNo?: string;
  status?: number;
  startDate?: string;
  endDate?: string;
}

export interface RefundListResponse {
  list: any[];
  total: number;
  pageSize: number;
  currentPage: number;
}

/** 获取退款申请列表 */
export function getRefundList(params: RefundQueryParams): Promise<RefundListResponse> {
  return get('/refund/list', params);
}

/** 获取退款申请详情 */
export function getRefundDetail(id: number): Promise<any> {
  return get(`/refund/${id}`);
}

/** 审核退款申请 */
export function reviewRefund(id: number, data: { approved: boolean; remark?: string }): Promise<any> {
  return post(`/refund/${id}/review`, data);
}

/** 直接退款（订单详情页操作） */
export function refundOrder(orderId: string, reason: string): Promise<void> {
  return post(`/order/${orderId}/refund`, { reason });
}
