import { request } from '@/service/request';

/**
 * 统一上传文件
 * @param data
 * @returns
 */
export function fetchUpload(data: File, config?: any) {
  return request({
    url: '/admin/file/upload/img',
    method: 'post',
    data: {
      file: data
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    ...config
  });
}

/**
 * 企业ID查询运费模板
 * @param channelId
 * @returns
 */
export function fetchGetTransport(channelId: number) {
  return request<Api.delivery.Transport2>({
    url: `/platform/transport2/queryTransport2ByChannelId/${channelId}`,
    method: 'get'
  });
}

/**
 *新增或更新运费模板
 * @param data
 * @returns
 */
export function fetchGetAddOrEditTransport(data: any) {
  return request({
    url: '/platform/transport2/addOrEdit',
    method: 'post',
    data
  });
}

/**
 * 后管端-企业运费列表
 * @returns
 */

export function fetchChannelList(data: any) {
  return request<{ records: Api.delivery.Transport2[] }>({
    url: '/platform/transport2/transport2List',
    method: 'get',
    params: data
  });
}

/**
 * 后管端-分单管理列表
 * @returns
 */

export function fetchOrderSplitList(data: any) {
  return request<Api.config.orderSplit[]>({
    url: '/platform/channel/listAllSplitRule',
    method: 'get',
    params: data
  });
}

/**
 * 后管端-分单管理批量修改
 */

export function fetchBatchOrderSplit(splitRule: number, data: any) {
  return request({
    url: `/platform/channel/batch?splitRule=${splitRule}`,
    method: 'put',
    data
  });
}

/**
 * 获取当前登录用户的所属企业
 * @returns
 */
export function fetchGetLoginUserList() {
  return request<Api.goods.Channel[]>({
    url: '/platform/channel/list',
    method: 'get'
  });
}
