import { request } from '@umijs/max';
import type { Order, OrderListParams, ShipForm, CancelForm } from '@/pages/Order/data';

// 查询订单列表
export async function queryOrderList(params?: OrderListParams) {
  return request('/api/orders', {
    method: 'GET',
    params,
  });
}

// 查询订单详情
export async function queryOrderDetail(id: string) {
  return request(`/api/orders/${id}`, {
    method: 'GET',
  });
}

// 订单发货
export async function shipOrder(id: string, params: ShipForm) {
  return request(`/api/orders/${id}/ship`, {
    method: 'POST',
    data: params,
  });
}

// 取消订单
export async function cancelOrder(id: string, params: CancelForm) {
  return request(`/api/orders/${id}/cancel`, {
    method: 'POST',
    data: params,
  });
}
