import request from '@/utils/request'

// 经销商订单
export function getOrderList(urlParams, data) {
    return request({
        url: '/api/v1/mp/admin/channel/order/list',
        method: 'post',
        data,
        urlParams
    })
}
// 经销商列表
export function listSite( data) {
  return request({
    url: '/api/v1/mp/admin/salesite/list',
    method: 'post',
    data,
  })
}

//批量发送短信
export function batchshortMessage( data) {
  return request({
    url: '/api/v1/mp/admin/deliver/order/sendSMS',
    method: 'post',
    data,
  })
}


// 快递下拉
export function companyList(data) {
  return request({
    url: '/api/v1/mp/delivery/company/list',
    method: 'post',
    data
  })
}

//快递单号自动识别
export function automaticRecognition(data) {
  return request({
    url:`/api/v1/mp/logistics/autonumber/auto/${ data }`,
    method:'post',
  })
}

// 经销商盲票组列表
export function boxList(data) {
  return request({
    url: '/api/v1/mp/admin/channel/order/item/list',
    method: 'post',
    data
  })
}

// 经销商订单发货查询筛选待售的盲票包列表
export function ticketPkgList(data) {
  return request({
    url: '/api/v1/mp/admin/channel/order/ticket/pkg/list',
    method: 'post',
    data
  })
}

// 经销商订单详情
export function orderDetail(data) {
  return request({
    url: '/api/v1/mp/admin/channel/order/detail',
    method: 'post',
    data
  })
}

// 经销商订单发货
export function channelOrderShip(data) {
  return request({
    url: '/api/v1/mp/admin/channel/order/ship',
    method: 'post',
    data
  })
}

// 修改经销商发货信息
export function channelOrderShipUpdate(data) {
  return request({
    url: '/api/v1/mp/admin/channel/order/ship/update',
    method: 'post',
    data
  })
}

// 用户订单
export function getDeliverList(urlParams, data) {
  return request({
      url: '/api/v1/mp/admin/deliver/order/list',
      method: 'post',
      data,
      urlParams
  })
}

// 用户订单详情
export function deliverDetail(data) {
  return request({
    url: '/api/v1/mp/admin/deliver/order/detail',
    method: 'post',
    data
  })
}

// 用户订单发货
export function deliverOrderShip(data) {
  return request({
    url: '/api/v1/mp/admin/deliver/order/ship',
    method: 'post',
    data
  })
}

// 用户订单发货
export function deliverOrderShipUpdate(data) {
  return request({
    url: '/api/v1/mp/admin/deliver/order/ship/update',
    method: 'post',
    data
  })
}

// 用户订单导出
export function deliverOrderExport(data) {
  return request({
    url: '/api/v1/mp/admin/deliver/order/export',
    method: 'post',
    data
  })
}
// 用户盲票订单导出
export function deliverOrderDrawExport(data) {
  return request({
    url: '/api/v1/mp/admin/ticket/order/ticket/export',
    method: 'post',
    data
  })
}


// 经销商订单导出
export function channelOrderExport(data) {
  return request({
    url: '/api/v1/mp/admin/channel/order/export',
    method: 'post',
    timeout: 15 * 60 * 1000,
    data
  })
}

// 经销商取消订单
export function removeChannelOrder(data) {
  return request({
    url: '/api/v1/mp/admin/channel/order/order/cancel',
    method: 'post',
    data
  })
}

// 盲票订单
export function ticketOrderList(urlParams, data) {
  return request({
      url: '/api/v1/mp/admin/ticket/order/list',
      method: 'post',
      data,
      urlParams
  })
}

// 盲票订单导出
export function ticketOrderExport(data) {
  return request({
    url: '/api/v1/mp/admin/ticket/order/export',
    method: 'post',
    timeout: 15 * 60 * 1000,
    data
  })
}

// 盲票订单详情
export function ticketOrderDetail(orderId) {
  return request({
    url: `/api/v1/mp/admin/ticket/order/detail/${ orderId }`,
    method: 'post',
  })
}

/**
 * Post 方式上传文件
 */
export function setBatchShip(data, config = {}) {
  var formData  = new FormData()
  Object.keys(data).forEach(key => {
    formData.append(key, data[key])
  })
  return request({
    url: '/api/v1/mp/admin/deliver/order/batchShip',
    method: 'post',
    data: formData ,
    ...config,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
