import request from '@/utils/request'
// 根据合并订单编号(或订单号)获得已合单列表和待合单列表
export function getMergeListByOrderNo(query){
  return request({
    url:'/order/merge/getMergeListByOrderNo',
    method: 'get',
    params: query,
  })
}
//创建订单合单申请
export function createMerge(data) {
  return request({
    url: '/order/merge/create',
    method: 'post',
    data: data
  })
}
// 取消订单拆单
export function cancelMerge(data) {
  return request({
    url: '/order/merge/cancel',
    method: 'delete',
    data:data
  })
}

//拆单申请提交
export function splitApply(data) {
  return request({
    url: '/order/split/apply',
    method: 'put',
    data: data
  })
}

// 创建订单拆单
export function createSplit(data) {
  return request({
    url: '/order/split/create',
    method: 'post',
    data: data
  })
}

// 更新订单拆单
export function updateSplit(data) {
  return request({
    url: '/order/split/update',
    method: 'put',
    data: data
  })
}

// 删除订单拆单
export function deleteSplit(id) {
  return request({
    url: '/order/split/delete?id=' + id,
    method: 'delete'
  })
}
//取消申请拆单
export function cancelApply(data) {
  return request({
    url: '/order/split/cancel-apply',
    method: 'put',
    data:data
  })
}

// 获得订单拆单
export function getSplit(id) {
  return request({
    url: '/order/split/get?id=' + id,
    method: 'get'
  })
}

// 获得订单拆单分页
export function getSplitPage(query) {
  return request({
    url: '/order/split/page',
    method: 'get',
    params: query
  })
}

// 导出订单拆单 Excel
export function exportSplitExcel(query) {
  return request({
    url: '/order/split/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}
//通过订单号获取拆单列表和拆单项明细
export function getSplitList(query) {
  return request({
    url: '/ecw/box-approval/list-by-order-id',
    method: 'get',
    params: query
  })
}

// 创建订单拆单项 - 放入
export function createSplitItem(data) {
  return request({
    url: '/order/split-item/create',
    method: 'post',
    data: data
  })
}

// 删除订单拆单项
export function deleteSplitItem(id, shipmentSplit = false) {
  return request({
    url: '/order/split-item/delete?id=' + id + '&shipmentSplit=' + shipmentSplit,
    method: 'delete'
  })
}

// 根据合并编号获得订单信息、已合单列表和待合单列表
export function getMergeListByMergeId(params){
  return request({
    url: '/order/merge/getMergeListByMergeId',
    method: 'get',
    params
  })
}

// 计价单位的数量参数是否必传
export function quantitycheck(query) {
  return request({
    url: '/order/split-item/quantity/check',
    method: 'get',
    params: query
  })
}

// 重置拆单
export function deleteAllSplit(orderId) {
  return request({
    url: '/order/split/delete/all',
    method: 'delete',
    params: {orderId}
  })
}

// 获取拆单订单的总货值与箱数拆分记录
export function splitItemWorthCheck(orderId, orderSplitItemId) {
  return request({
    url: '/order/split-item/worth/check',
    method: 'get',
    params: {orderId, orderSplitItemId}
  })
}
