import request from '@/utils/request'

export function getList(query) {
  return request({
    url: '/order/organize/orderList',
    method: 'get',
    params: query
  })
}

export function getDetail(query) {
  return request({
    url: '/order/organize/detail',
    method: 'get',
    params: query
  })
}

export function getRemarks(id) {
  return request({
    url: '/order/cmOrderRemark/remarksView/' + id,
    method: 'get'
  })
}

export function saveRemarks(query) {
  return request({
    url: '/order/cmOrderRemark/addRemarks',
    method: 'post',
    data: query
  })
}
/**
 * 收退款记录
 */
export function getRefundRecord(query) {
  return request({
    url: '/order/organize/toRefundRecord',
    method: 'get',
    params: query
  })
}

export function getLogistics(query) {
  return request({
    url: '/order/organize/logisticsDetails',
    method: 'get',
    params: query
  })
}

/** 用户退款管理 */
export function getRefundList(query) {
  return request({
    url: '/order/cmReturnedPurchase/list',
    method: 'get',
    params: query
  })
}
/**
 * 用户退款详情
 */
export function getRefundDetail(id) {
  return request({
    url: '/order/cmReturnedPurchase/toReturnRecord/' + id,
    method: 'get'
  })
}
/**
 * 更改订单收款状态
 */
export function orderCheckReceipt(query) {
  return request({
    url: '/order/organize/check/receipt',
    method: 'get',
    params: query
  })
}
/**
 * 上传线下支付凭证
 */
export function orderSaveVoucher(data) {
  return request({
    url: '/order/organize/saveVoucher',
    method: 'post',
    data
  })
}
/**
 * 去发货
 */
export function orderTodeliver(id) {
  return request({
    url: '/order/deliver/to/deliver/' + id,
    method: 'get'
  })
}
/**
 * 确认发货
 */
export function confirmDeliver(data) {
  return request({
    url: '/order/deliver/confirm/deliver',
    method: 'post',
    data: data
  })
}
/**
 * 物流公司
 */
export function deliverShipCompany() {
  return request({
    url: '/order/deliver/ship/company',
    method: 'get'
  })
}
/**
 * 物流公司
 */
export function deliverDetails(id) {
  return request({
    url: `/order/deliver/deliver/details/${id.orderId}/${id.shopOrderId}`,
    method: 'get'
  })
}
/**
 * 订单备注列表
 * @param {number} orderId
 */
export function orderNotes(orderId) {
  return request({
    url: `/order/cmOrderRemark/remarksView/${orderId.orderId}/${orderId.shopOrderId}`,
    method: 'get'
  })
}
/**
 * 文件下载
 */
export function fileDownload(params) {
  return request({
    url: '/order/cmOrderRemark/download/remark',
    method: 'get',
    params,
    responseType: 'blob'
  })
}
/**
 * 新增订单备注
 */
export function orderAddNote(data) {
  return request({
    url: '/order/cmOrderRemark/add/remark',
    method: 'post',
    data
  })
}
