import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LogisticsQuoteVO, LogisticsQuoteForm, LogisticsQuoteQuery } from '@/api/amz/logisticsQuote/types';
import { InquiryQuoteStatusVO } from '@/api/amz/logisticsOrder/types';
import { UnwrapRef } from 'vue';

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

export const listLogisticsQuote = (query?: LogisticsQuoteQuery): AxiosPromise<LogisticsQuoteVO[]> => {
  return request({
    url: '/amz/logisticsQuote/list',
    method: 'get',
    params: query
  });
};

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

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

export const queryLogisticsQuoteWithDes = (destination: string | number, date: string,shipmentId: string | number): AxiosPromise<LogisticsQuoteVO[]> => {
  return request({
    url: '/amz/logisticsQuote/queryWithDes/' + destination + '/' + date + '/' + shipmentId,
    method: 'get'
  });
};

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

/**
 * 查询 今天的报价情况
 * @param id
 */
export const getTodayQuoteStatus = (): AxiosPromise<InquiryQuoteStatusVO[]> => {
  return request({
    url: '/amz/logisticsQuote/today-quote-status',
    method: 'get'
  });
};

/**
 * 新增物流报价
 * @param data
 */
export const addLogisticsQuote = (data: LogisticsQuoteForm) => {
  return request({
    url: '/amz/logisticsQuote',
    method: 'post',
    data: data
  });
};

/**
 * 新增物流报价
 * @param data
 */
export const addMostLogisticsQuote = (data: LogisticsQuoteForm) => {
  return request({
    url: '/amz/logisticsQuote/most',
    method: 'post',
    data: data
  });
};

/**
 *  获取物流报价建议
 * @param data
 */
export const checkPriceQuoteByBo = (data: LogisticsQuoteForm) => {
  return request({
    url: '/amz/logisticsQuote/check-quote-price',
    method: 'post',
    data: data
  });
};

/**
 * 修改物流报价
 * @param data
 */
export const updateLogisticsQuote = (data: LogisticsQuoteForm) => {
  return request({
    url: '/amz/logisticsQuote',
    method: 'put',
    data: data
  });
};

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

/**
 * 报表
 * @param data
 */
export const queryLogisticsQuoteReport = (queryData: any) => {
  return request({
    url: '/amz/logisticsQuote/report',
    method: 'post',
    data: queryData
  });
};
