import request from '@/utils/request'

// 查询订单列表
// 查询订单列表
export function listOrder(query) {
  return request({
    url: '/store/storeOrder/list',
    method: 'get',
    params: query
  })
}
// 下载导入模板
export function importTemplate() {
  return request({
    url: '/store/storeOrder/importTemplate',
    method: 'get'
  })
}
// 查询订单详细
export function getStoreOrder(orderId) {
  return request({
    url: '/store/storeOrder/' + orderId,
    method: 'get'
  })
}
export function getPrescribe(orderId) {
  return request({
    url: '/store/storeOrder/Prescribe/' + orderId,
    method: 'get'
  })
}

export function payment(orderId) {
  return request({
    url: '/store/storeOrder/payment/' + orderId,
    method: 'get'
  })
}
export function importExpressTemplate() {
  return request({
    url: '/store/storeOrder/importExpressTemplate',
    method: 'get'
  })
}
export function logList(orderId) {
  return request({
    url: '/store/storeOrder/logList/' + orderId,
    method: 'get'
  })
}


export function listOrderitem(orderId) {
  return request({
    url: '/store/storeOrder/ltemlist/' + orderId,
    method: 'get'
  })
}
export function createErpOrder(orderId) {
  return request({
    url: '/store/storeOrder/createErpOrder/' + orderId,
    method: 'get'
  })
}
export function getEroOrder(orderId) {
  return request({
    url: '/store/storeOrder/getEroOrder/' + orderId,
    method: 'get'
  })
}
export function getExpress(orderId) {
  return request({
    url: '/store/storeOrder/getExpress/' + orderId,
    method: 'get'
  })
}
export function editTuiMoney(orderId) {
  return request({
    url: '/store/storeOrder/editTuiMoney/' + orderId,
    method: 'get'
  })
}

export function syncExpress(orderId) {
  return request({
    url: '/store/storeOrder/syncExpress/' + orderId,
    method: 'get'
  })
}
export function updateExpress(orderId) {
  return request({
    url: '/store/storeOrder/updateExpress/' + orderId,
    method: 'get'
  })
}
// 新增订单
export function addOrder(data) {
  return request({
    url: '/store/storeOrder',
    method: 'post',
    data: data
  })
}

// 修改订单
export function updateStoreOrder(data) {
  return request({
    url: '/store/storeOrder',
    method: 'put',
    data: data
  })
}

// 修改物流编号
export function updateDeliveryId(data) {
  return request({
    url: '/store/storeOrder/editDeliveryId',
    method: 'put',
    data: data
  })
}

export function updateDelivery(data) {
  return request({
    url: '/store/storeOrder/updateDelivery',
    method: 'put',
    data: data
  })
}


// 修改订单
export function sendgoods(data) {
  return request({
    url: '/store/storeOrder/sendGoods',
    method: 'put',
    data: data
  })
}
export function afterSales(data) {
  return request({
    url: '/store/storeOrder/afterSales',
    method: 'put',
    data: data
  })
}


export function tuiOrder(data) {
  return request({
    url: '/store/storeOrder/tuiOrder',
    method: 'put',
    data: data
  })
}


// 修改订单
export function getGoods(data) {
  return request({
    url: '/store/storeOrder/getGoods',
    method: 'put',
    data: data
  })
}
// 修改订单
export function updateMoney(data) {
  return request({
    url: '/store/storeOrder/updateMoney',
    method: 'put',
    data: data
  })
}

// 删除订单
export function delOrder(orderId) {
  return request({
    url: '/store/storeOrder/' + orderId,
    method: 'delete'
  })
}

// 导出订单
export function exportOrder(query) {
  return request({
    url: '/store/storeOrder/export',
    method: 'get',
    params: query
  })
}
export function getCustomerOrderList(query) {
  return request({
    url: '/store/storeOrder/getCustomerOrderList',
    method: 'get',
    params: query
  })
}
//修改评论
export function updateCommentInfo(data) {
  return request({
    url: '/store/storeOrder/comment',
    method: 'put',
    data: data
  })
}

export function getCommentInfo(id) {
  return request({
    url: '/store/storeOrder/comment/' + id,
    method: 'get'
  })
}

export function downloadOrderExcel(id) {
  return request({
    url: `/store/storeOrder/downloadExcel/${id}`,
    method: 'get',
    responseType: 'blob', // 重要：告诉axios返回Blob类型
    headers: {
      'Accept': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }
  });
}
