import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderStatusLogVO, OrderStatusLogForm, OrderStatusLogQuery } from '@/api/order/orderStatusLog/types';

/**
 * 查询订单状态流转记录列表
 * @param query
 * @returns {*}
 */

export const listOrderStatusLog = (query?: OrderStatusLogQuery): AxiosPromise<OrderStatusLogVO[]> => {
  return request({
    url: '/order/orderStatusLog/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询订单状态流转记录详细
 * @param id
 */
export const getOrderStatusLog = (id: string | number): AxiosPromise<OrderStatusLogVO> => {
  return request({
    url: '/order/orderStatusLog/' + id,
    method: 'get'
  });
};

/**
 * 新增订单状态流转记录
 * @param data
 */
export const addOrderStatusLog = (data: OrderStatusLogForm) => {
  return request({
    url: '/order/orderStatusLog',
    method: 'post',
    data: data
  });
};

/**
 * 修改订单状态流转记录
 * @param data
 */
export const updateOrderStatusLog = (data: OrderStatusLogForm) => {
  return request({
    url: '/order/orderStatusLog',
    method: 'put',
    data: data
  });
};

/**
 * 删除订单状态流转记录
 * @param id
 */
export const delOrderStatusLog = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/orderStatusLog/' + id,
    method: 'delete'
  });
};

/**
 * 查询最新状态流转记录
 * @param data
 */
export const selectNewOneLog = (data: OrderStatusLogForm) => {
  return request({
    url: '/order/orderStatusLog/selectNewOne',
    method: 'post',
    data: data
  });
};
