import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/finance/order/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getGoodsOrder = (current, size, params) => {
  return request({
    url: '/api/finance/order/goodsOrder/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: '/api/finance/order/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/api/finance/order/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/finance/order/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/finance/order/submit',
    method: 'post',
    data: row
  })
}

export const deliver = (row) => {
  return request({
    url: '/api/finance/order/deliver',
    method: 'post',
    data: row
  })
}

export const exportData = (orderList, startTime, endTime) => {
  return request({
    url: '/api/finance/order/export',
    method: 'post',
    data: {
      orderStartTime: startTime,
      orderEndTime: endTime,
      orderList: orderList
    },
    responseType: "blob",
  })
}

export const bindLogisticsInfo = (orderNo, wlNo, wlCompany, wlCompanyNo) => {
  return request({
    url: '/api/finance/order/bindLogisticsInfo',
    method: 'post',
    params: {
      orderNo,
      wlNo,
      wlCompany,
      wlCompanyNo
    }
  })
}

export const refundCart = (orderNo, amount, deductIntegral) => {
  return request({
    url: '/api/finance/order/refund/cart',
    method: 'post',
    params: {
      orderNo,
      amount,
      deductIntegral
    }
  })
}

export const linkedOrderAdd = (phone, username, recommendPhone) => {
  return request({
    url: '/api/finance/order/linkedOrder/add',
    method: 'post',
    data: {
      phone: phone,
      username: username,
      recommendPhone: recommendPhone
    },
  })
}

export const dataReport = () => {
  return request({
    url: '/api/finance/order/dataReport',
    method: 'get'
  })
}

export const dataReportByDate = (queryType) => {
  return request({
    url: '/api/finance/order/dataReportByDate',
    method: 'get',
    params: {
      queryType
    }
  })
}

export const orderGoodsProportion = (queryType) => {
  return request({
    url: '/api/finance/order/orderGoodsProportion',
    method: 'get',
    params: {
      queryType
    }
  })
}

