import { http } from '@/utils/http'
import type { OrderType } from '@/types/order'
import type { ListType, ListResponseType } from '@/types/list'
import { parseQueryValues } from '@/utils'

/** 订单列表 */
export const getOrderListApi = (params: Partial<OrderType>, page: Partial<ListType>) => {
  return http.get<ListResponseType<OrderType>>('/api/query/list?pagevalue=51', {
    ...page,
    ...parseQueryValues(params),
  })
}

/** 获取订单详情 */
export const getOrderDetailApi = (id: string) => {
  return http.get<OrderType>(
    '/api/query/view?pagevalue=61',
    {
      ...parseQueryValues({ ordersid: id }),
    },
    {
      formatData: true,
    },
  )
}

/** 使用优惠劵提交订单 */
export const submitOrderApi = (params: { ordersproductid: string; orderscouponid: string }) => {
  return http.get<any>('/api/nlua/call?pagevalue=44', params)
}
