import request from '@/utils/request'

export function getOrder(query) {
  return request({
    url: '/app-api/my/order/info/' + query,
    method: 'get'
  })
}

// 获得订单编辑详情
export function getOrderDetail(orderId) {
  return request({
    url: '/app-api/my/order/get',
    method: 'get',
    params: { orderId }
  })
}

// 获得所有订单分页
export function getAllOrder(query) {
  return request({
    url: '/app-api/my/order/all/order',
    method: 'get',
    params: query
  })
}

export function getControl(query) {
  return request({
    url: '/app-api/my/order/cargo/control/page',
    method: 'get',
    params: query
  })
}

export function getIssued(query) {
  return request({
    url: '/app-api/my/order/issued/page',
    method: 'get',
    params: query
  })
}

export function getReceived(query) {
  return request({
    url: '/app-api/my/order/received/page',
    method: 'get',
    params: query
  })
}

export function createOrder(data) {
  return request({
    url: '/app-api/my/order/create',
    method: 'post',
    data
  })
}

export function updateOrder(data) {
  return request({
    url: '/app-api/my/order/update',
    method: 'put',
    data
  })
}

export function cancelOrder(data) {
  return request({
    url: '/app-api/my/order/cancel/' + data,
    method: 'put'
  })
}

// 获得入仓货物详情
export function getOrderWarehouseIn(id) {
  return request({
    url: '/app-api/order/order-warehouse-in/get-order-warehouse-in?orderId=' + id,
    method: 'get'
  })
}

// 获得提单pdf
export function getLadingBill(orderId) {
  return request({
    url: '/app-api/shipment/make-bill-of-lading/downloadByOrderId',
    method: 'get',
    // responseType: 'arraybuffer',
    params: { orderId }
  })
}

// 退仓
export function refundWarehouseApply(data) {
  return request({
    url: '/app-api/order/order-warehouse-in/rollback-apply',
    method: 'put',
    data
  })
}

// 创建订单控货人放货记录
export function createPick(data) {
  return request({
    url: '/app-api/order/order-cargo-control-pick/create',
    method: 'post',
    data
  })
}

// 获得控货订单放货编辑详情
export function getRleaseInfo(orderId) {
  return request({
    url: '/app-api/order/order-cargo-control-pick/release/info/' + orderId,
    method: 'get'
  })
}

// 发送控货手机验证码
export function sendSmsCode(data) {
  return request({
    url: '/app-api/order/order-cargo-control/send-sms-code',
    method: 'post',
    data
  })
}

// 创建订单控货人信息
export function create(data) {
  return request({
    url: '/app-api/order/order-cargo-control/create',
    method: 'post',
    data
  })
}

// 根据订单ID获取所有的订单异常列表
export function getExceptionListByOrderId(id) {
  return request({
    url: '/app-api/ecw/order-exception/getExceptionListByOrderId?orderId=' + id,
    method: 'get'
  })
}

// 获得订单异常
export function getExceptionById(id) {
  return request({
    url: '/app-api/ecw/order-exception/getExceptionById?id=' + id,
    method: 'get'
  })
}

// 根据异常ID进行异常处理
export function handlerExceptionByExceptionId(data) {
  return request({
    url: '/app-api/ecw/order-exception/handlerExceptionByExceptionId',
    method: 'post',
    data: data
  })
}

// 获取快递单号
export function getOrderCourierNumber(params) {
  return request({
    url: '/app-api/my/order/courier/number',
    method: 'get',
    params
  })
}

// 导入装箱单
export function orderImport(data) {
  return request({
    url: '/app-api/my/order/import',
    method: 'post',
    data
  })
}

// 下载装箱单模板
export function exportPackingList() {
  return request({
    url: '/app-api/my/order/export-packing-list',
    method: 'get',
    responseType: 'blob'
  })
}

// 获得订单物流信息列表
export function getLogistics(params) {
  return request({
    url: '/app-api/order/order-time/list',
    method: 'get',
    params
  })
}

// 获得控货订单放货详情
export function getPickRleaseInfo(orderId) {
  return request({
    url: '/app-api/order/order-cargo-control-pick/release/info/' + orderId,
    method: 'get'
  })
}

// 打印标签
export function printTag(id) {
  return request({
    url: '/app-api/order/print/orderTagPrint?orderId=' + id,
    method: 'get'
  })
}

// 删除订单
export function deleteOrder(id) {
  return request({
    url: '/app-api/my/order/delete?orderId=' + id,
    method: 'delete'
  })
}
// 跟据订单id获取报关资料
export function warehousePictureList(data) {
  return request({
    url: '/admin-api/order/warehouse-picture/list',
    method: 'post',
    data
  })
}
// 上传报关资料
export function warehousePictureCreate(data) {
  return request({
    url: '/admin-api/order/warehouse-picture/create',
    method: 'post',
    data
  })
}
// 删除报关资料
export function warehousePictureDelete(id) {
  return request({
    url: '/admin-api/order/warehouse-picture/delete?id=' + id,
    method: 'delete'
  })
}

// 控货日志
export function controlLog(id) {
  return request({
    url: '/app-api/order/order-control-log/list/' + id,
    method: 'get'
  })
}
// 报价单
export function getOfferSelect(params) {
  return request({
    url: '/app-api/offer/select',
    method: 'get',
    params
  })
}
// 报价单
export function getOfferCheck(params) {
  return request({
    url: '/app-api/offer/check',
    method: 'get',
    params
  })
}

// 复制订单/my/order/copy/{copyOrderId}
export function copyOrder(copyOrderId) {
  return request({
    url: '/app-api/my/order/copy/' + copyOrderId,
    method: 'post'
  })
}
