/* eslint-disable */
import request from "@workspace/ui/lib/request";

/** Create order POST /v1/admin/order/ */
export async function createOrder(
  body: API.CreateOrderRequest,
  options?: { [key: string]: any }
) {
  return request<API.Response & { data?: any }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/order/`,
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      data: body,
      ...(options || {}),
    }
  );
}

/** Get order list GET /v1/admin/order/list */
export async function getOrderList(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.GetOrderListParams,
  options?: { [key: string]: any }
) {
  return request<API.Response & { data?: API.GetOrderListResponse }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/order/list`,
    {
      method: "GET",
      params: {
        ...params,
      },
      ...(options || {}),
    }
  );
}

/** Update order status PUT /v1/admin/order/status */
export async function updateOrderStatus(
  body: API.UpdateOrderStatusRequest,
  options?: { [key: string]: any }
) {
  return request<API.Response & { data?: any }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/order/status`,
    {
      method: "PUT",
      headers: {
        "Content-Type": "application/json",
      },
      data: body,
      ...(options || {}),
    }
  );
}

/**
 * 手动激活订单
 * POST /v1/admin/order/activate
 * @param body - 激活订单请求参数，包含 order_no
 * @param options - 可选的请求配置
 * @returns 激活结果
 */
export async function activateOrder(
  body: API.ActivateOrderRequest,
  options?: { [key: string]: any }
) {
  return request<API.Response & { data?: any }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/order/activate`,
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      data: body,
      ...(options || {}),
    }
  );
}

/** Refund order POST /v1/admin/order/refund */
export async function refundOrder(
  body: API.RefundOrderRequest,
  options?: { [key: string]: any }
) {
  return request<API.Response & { data?: any }>(
    `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/order/refund`,
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      data: body,
      ...(options || {}),
    }
  );
}
