import { http } from "@/utils/http";

type Result = {
  code: number;
  message: string;
  data?: any;
};

type ResultTable = {
  code: number;
  message: string;
  data?: {
    list: Array<any>;
    total: number;
    pageSize: number;
    currentPage: number;
  };
};

export const getOrderList = (params: {
  page?: number;
  pageSize?: number;
  orderNo?: string;
  deviceId?: string;
  payStatus?: string;
  status?: number;
  startDate?: string;
  endDate?: string;
}) => {
  return http.request<ResultTable>("get", "/order/list", { params });
};

export const getOrderById = (id: number) => {
  return http.request<Result>("get", `/order/${id}`);
};

export const getOrderStatistics = () => {
  return http.request<Result>("get", "/order/statistics");
};

export const refundOrder = (id: number, data: { reason: string }) => {
  return http.request<Result>("post", `/order/${id}/refund`, { data });
};
