import type { Recordable } from '@vben/types';

import { requestClient } from '#/api/request';

export namespace OrderQueryApi {
  export interface QueryItem {
    feature: Recordable<any>;
    data: Recordable<any>;
  }

  export interface QueryDetail {
    id: number;
    order_id: number;
    user_id: number;
    product_name: string;
    query_params: Recordable<any>;
    query_data: QueryItem[];
    create_time: string;
    update_time: string;
    query_state: string;
  }

  export interface GetQueryDetailRequest {
    order_id: number;
  }

  export interface GetQueryDetailResponse {
    id: number;
    order_id: number;
    user_id: number;
    product_name: string;
    query_params: Recordable<any>;
    query_data: QueryItem[];
    create_time: string;
    update_time: string;
    query_state: string;
  }
}

/**
 * 获取订单查询详情
 * @param orderId 订单ID
 */
async function getOrderQueryDetail(orderId: number) {
  return requestClient.get<OrderQueryApi.GetQueryDetailResponse>(
    `/query/detail/${orderId}`,
  );
}

export { getOrderQueryDetail };
