import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InquiryRequestVO, InquiryRequestForm, InquiryRequestQuery, InquiryRequestItemVO } from '@/api/amz/inquiryRequest/types';
import { LogisticsChannelVO } from '@/api/amz/logisticsChannel/types';
import { LogisticsQuoteVO } from '@/api/amz/logisticsQuote/types';

/**
 * 查询物流询价列表
 * @param query
 * @returns {*}
 */

export const listInquiryRequest = (query?: InquiryRequestQuery): AxiosPromise<InquiryRequestVO[]> => {
  return request({
    url: '/amz/inquiryRequest/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物流询价详细
 * @param id
 */
export const getInquiryRequest = (id: string | number): AxiosPromise<InquiryRequestVO> => {
  return request({
    url: '/amz/inquiryRequest/' + id,
    method: 'get'
  });
};

export const createWithDesAndChannel = (destination: string | number, channelId: string | number, date: string): AxiosPromise<void> => {
  return request({
    url: '/amz/inquiryRequest/create/' + destination + '/' + channelId + '/' + date,
    method: 'get'
  });
};

export const createBatch = (items: InquiryRequestItemVO[]): AxiosPromise<void> => {
  return request({
    url: '/amz/inquiryRequest/create/batch',
    method: 'post',
    data: items
  });
};

export const insertList = (items: (string | number)[]): AxiosPromise<void> => {
  return request({
    url: '/amz/inquiryBlacklist/insert',
    method: 'post',
    data: items
  });
};

/**
 * 根据目的地仓库和渠道查询物流询价列表
 * @returns {*}
 * @param destination
 * @param channelId
 * @param date
 */

export const queryWithDesAndChannel = (destination: string | number, channelId: string | number, date: string): AxiosPromise<LogisticsQuoteVO[]> => {
  return request({
    url: '/amz/inquiryRequest/query/' + destination + '/' + channelId + '/' + date,
    method: 'get'
  });
};

/**
 * 新增物流询价
 * @param data
 */
export const addInquiryRequest = (data: InquiryRequestForm) => {
  return request({
    url: '/amz/inquiryRequest',
    method: 'post',
    data: data
  });
};

/**
 * 修改物流询价
 * @param data
 */
export const updateInquiryRequest = (data: InquiryRequestForm) => {
  return request({
    url: '/amz/inquiryRequest',
    method: 'put',
    data: data
  });
};

/**
 * 删除物流询价
 * @param id
 */
export const delInquiryRequest = (id: string | number | Array<string | number>) => {
  return request({
    url: '/amz/inquiryRequest/' + id,
    method: 'delete'
  });
};
