import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderVO, OrderQuery } from './types';

/**
 * 查询订单列表
 * @param query
 */
export function listOrder(query: OrderQuery): AxiosPromise<OrderVO[]> {
  return request({
    url: '/main/order/list',
    method: 'get',
    params: query
  });
}

/**
 * 获取订单统计信息
 */
export function getOrderStatistics(): AxiosPromise<any> {
  return request({
    url: '/main/order/statistics',
    method: 'get'
  });
}

/**
 * 获取订单详细信息
 * @param id
 */
export function getOrder(id: string | number): AxiosPromise<OrderVO> {
  return request({
    url: '/main/order/' + id,
    method: 'get'
  });
}

/**
 * 新增订单
 * @param data
 */
export function addOrder(data: any) {
  return request({
    url: '/main/order',
    method: 'post',
    data: data
  });
}

/**
 * 修改订单
 * @param data
 */
export function updateOrder(data: any) {
  return request({
    url: '/main/order',
    method: 'put',
    data: data
  });
}

/**
 * 删除订单
 * @param ids
 */
export function delOrder(ids: string | number | (string | number)[]) {
  return request({
    url: '/main/order/' + ids,
    method: 'delete'
  });
}
