/**
 * 退款管理相关 API
 */

import { BaseService } from '../BaseService'
import type {
  Refund,
  RefundQueryParams,
  RefundListResponse,
  CreateRefundRequest,
  ResubmitRefundRequest,
  BaseResponse
} from '@/types/api'

export class RefundService extends BaseService {
  /**
   * 获取退款申请列表
   * @param params 查询参数
   */
  static getRefunds(params?: RefundQueryParams): Promise<BaseResponse<RefundListResponse>> {
    return this.get<BaseResponse<RefundListResponse>>('/api/admin/refunds', params)
  }

  /**
   * 获取退款申请详情
   * @param id 退款申请ID
   */
  static getRefundById(id: number): Promise<BaseResponse<Refund>> {
    return this.getOne<Refund>(`/api/admin/refunds/${id}`)
  }

  /**
   * 创建退款申请
   * @param data 创建退款申请请求参数
   */
  static createRefund(data: CreateRefundRequest): Promise<BaseResponse<Refund>> {
    return this.post<BaseResponse<Refund>>('/api/admin/refunds', data)
  }

  /**
   * 重新提交退款申请
   * @param id 退款申请ID
   * @param data 重新提交请求参数
   */
  static resubmitRefund(id: number, data: ResubmitRefundRequest): Promise<BaseResponse<void>> {
    return this.post<BaseResponse<void>>(`/api/admin/refunds/${id}/resubmit`, data)
  }
}
