import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderVO, OrderForm, OrderQuery } from '@/api/system/physical/order/types';

/**
 * 查询商城订单主列表
 * @param query
 * @returns {*}
 */

export const listOrder = (query?: OrderQuery): AxiosPromise<OrderVO[]> => {
  return request({
    url: '/physical/order/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商城订单主详细
 * @param id
 */
export const getOrder = (id: string | number): AxiosPromise<OrderVO> => {
  return request({
    url: '/physical/order/' + id,
    method: 'get'
  });
};

/**
 * 新增商城订单主
 * @param data
 */
export const addOrder = (data: OrderForm) => {
  return request({
    url: '/physical/order',
    method: 'post',
    data: data
  });
};

/**
 * 修改商城订单主
 * @param data
 */
export const updateOrder = (data: OrderForm) => {
  return request({
    url: '/physical/order',
    method: 'put',
    data: data
  });
};

/**
 * 删除商城订单主
 * @param id
 */
export const delOrder = (id: string | number | Array<string | number>) => {
  return request({
    url: '/physical/order/' + id,
    method: 'delete'
  });
};

/**
 * 录入商城订单物流单号
 * @param data
 */
export const updateOrderSelective = (data: OrderForm) => {
  return request({
    url: '/physical/order/updateOrderSelective',
    method: 'put',
    data: data
  });
};
export const sendShipment = (data: OrderForm) => {
  return request({
    url: '/physical/order/sendShipment',
    method: 'put',
    data: data
  });
};
