import request from '@/utils/request'
import {param} from "@/utils";

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

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

// 删除订单
export function deleteOrder(id) {
  return request({
    url: '/ecw/order/delete?orderId=' + id,
    method: 'delete'
  })
}

// 获得订单
export function getOrder(orderId) {
  return request({
    url: '/ecw/order/info/' + orderId,
    method: 'get'
  })
}

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

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

// 导出订单 Excel
export function exportOrderExcel(query) {
  return request({
    url: '/ecw/order/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

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

//根据订单号获得订单费用申请列表
export function feeApplicationListByOrderId(query){
  return request({
    url:'/order/fee-application/listByOrderId',
    method: 'get',
    params: query,
  })
}
//费用申请提交
 export function feeApplicationCreate(data){
  return request({
    url:'order/fee-application/create',
    method:'post',
    data:data,
  })
 }
  //费用申请修改
 export function applicationUpdate(data){
  return request({
    url:'/order/fee-application/update',
    method:'put',
    data:data,
  })
 }
  export function ApplicationListByOrderId(params){
   return request({
     url:'order/fee-application/listByOrderId',
     method:'get',
     params:params

   })
  }
// 批量更新特需
export function specialNeedCreate(data){
  return request({
    url:'ecw/order-special-need/updateBatch',
    method:'put',
    data,
  })
}
// 创建特殊
export function getSpecialListByOrderId(orderId){
  return request({
    url: 'ecw/order-special-need/getListByOrderId',
    method: 'get',
    params: {orderId},
  })
}
// 删除特需
 export function orderSpecialNeed(params){
  return request({
    url:'/ecw/order-special-need/deleteByOrderId',
    method: 'delete',
    data:params
  })
 }

// 获得提单pdf
export function getLadingBill(query){
  return request({
    url:'ecw/order/billLading/template',
    method: 'get',
    responseType: 'arraybuffer',
    params: query,
  })
}
//调仓申请
export function orderWarehouseInAdjustApply(data){
  return request({
    url:'/order/order-warehouse-in/adjust-apply',
    method:'put',
    data:data,
  })
}

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

// 入仓
export function orderWarehouseIn(data){
  return request({
    url: '/order/order-warehouse-in/create',
    method: 'post',
    data
  })
}

// 入仓修改
export function orderWarehouseInUpdateApply(data){
  return request({
    url: '/order/order-warehouse-in/update-apply',
    method: 'put',
    data
  })
}

// 入仓修改箱号
export function orderWarehouseInUpdateLabel(data){
  return request({
    url: '/order/order-warehouse-in/update-label',
    method: 'post',
    data
  })
}

// 根据订单id获取标签箱号列表
export function getLabelByOrder(orderId){
  return request({
    url: '/order/order-warehouse-in/get-label-by-order',
    method: 'get',
    params: {
      orderId
    }
  })
}

// 根据订单id获取待入仓标签箱号
export function getLabelWaitInByOrder(orderId){
  return request({
    url: '/order/order-warehouse-in/get-label-wait-in-by-order',
    method: 'get',
    params: {
      orderId
    }
  })
}

// 入仓修改储位
export function saveOrUpdateOrderLocation(data){
  return request({
    url: '/order/order-warehouse-in/save-or-update-order-location',
    method: 'post',
    data
  })
}

// 入仓修改储位
export function updateWarehouseInLocation(data){
  return request({
    url: '/order/location/update-warehouse-in-location',
    method: 'put',
    data
  })
}

// 获取入仓修改审批单详情-审批使用
export function getWarehouseUpdateApprovalInfo(id) {
  return request({
    url: '/order/order-warehouse-in/get-update-approval-info?formId=' + id,
    method: 'get'
  })
}

// 获取最近的入仓修改审批单详情-修改页面使用
export function getWarehouseLastUpdateApprovalInfo(params) {
  return request({
    url: '/order/order-warehouse-in/get-last-update-approval-info',
    method: 'get',
    params
  })
}

// 入仓完成
export function orderWarehouseInFinish(data){
  return request({
    url: '/order/order-warehouse-in/finish',
    method: 'post',
    data
  })
}

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

// 退仓-订单项退仓（不审批）
export function rollbackDelete(data){
  return request({
    url: '/order/order-warehouse-in/rollback-order-item',
    method: 'put',
    data
  })
}

//取消订单
export function cancelOrder(orderId){
  return request({
    url: `/ecw/order/cancel/${orderId}`,
    method: 'put',
  })
}

// 恢复订单
export function recoveryOrder(orderId){
  return request({
    url: `/ecw/order/recovery/${orderId}`,
    method: 'put',
  })
}

// 获得我的订单分页
export function getMyOrderPage(query) {
  return request({
    url: '/ecw/order/my/page',
    method: 'get',
    params: query
  })
}


//根据流程ID获得订单信息
 export function applicationGetOrderByProcessId(params){
  return request({
    url:'/order/fee-application/getOrderByProcessId',
    method:'get',
    params
  })
 }
export function feeApplicationGet(params){
  return request({
    url:'/order/fee-application/get',
    method:'get',
    params
  })
}

//获得调仓明细
 export function orderWarehouseInGetAdjustInfo(params){
  return request({
    url:'order/order-warehouse-in/get-adjust-info',
    method:'get',
    params
  })
 }
 export function warehouseAdjustSendOut(data){
  return request({
    url:'/order/order-warehouse-in/warehouse-adjust-send-out',
    method:'put',
    data
  })
 }
 //获得订单仓库图片分页
 export function orderWarehousePicturePage(params){
  return request({
    url:'/order/warehouse-picture/page',
    method:'get',
    params
  })
 }
 export function warehouseAdjustPage(params){
  return request({
    url:'/order/warehouse-adjust/page',
    method:'get',
    params
  })
 }
export function getAdjustInfo(params){
  return request({
    url:'/order/order-warehouse-in/get-adjust-info',
    method:'get',
    params,
  })
}
  export function  warehouseAdjustArrived(data){
     return request({
       url:'/order/order-warehouse-in/warehouse-adjust-arrived',
       method:'put',
       data
     })
}
export function listByOrderId(params){
  return request({
    url:'/order/location/list-by-order-id',
    method:'get',
    params,
  })
}

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

// 获取审核
export function getApproval(id){
  return request({
    url:'/order/approval/get?id=' + id,
    method:'get'
  })
}

// 特价申请
export function createOrderSpecial(data) {
  return request({
    url: '/ecw/order/special/apply',
    method: 'put',
    data: data
  })
}

// 特价申请
export function cancelOrderSpecial(orderApprovalId,data) {
  return request({
    url: '/ecw/order/cancel/approval/'+orderApprovalId,
    method: 'get',
    params:data
  })
}

// 获得订单特价申请详情
export function getOrderSpecial(orderId, type, params) {
  console.log(orderId, type, params)
  return request({
    url: '/ecw/order/special/info/' + orderId + '/' + type,
    method: 'get',
    params
  })
}

// 根据订单项商品ID与审批类型获得订单商品的特价申请详情
export function getOrderSpecialByApproveId(approveId) {
  return request({
    url: '/ecw/order/special/info?approveId=' + approveId,
    method: 'get'
  })
}

// 订单号检索功能
export function getOrderNoSearch(params) {
  return request({
    url: '/ecw/order/orderNoSearch',
    method: 'get',
    params
  })
}

// 提单号检索功能
export function getBillNoSearch(params) {
  return request({
    url: '/ecw/order/billNoSearch',
    method: 'get',
    params
  })
}

// 根据合并订单编号获得已合单的订单动态
export function getMergeLogByMergedOrderNo(params){
  return request({
    url: '/order/merge/getMergeLogByMergedOrderNo',
    method: 'get',
    params
  })
}

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

// 下载装箱单模板
export function exportPackingList(){
  return request({
    url: '/ecw/order/export-packing-list',
    method: 'get',
    responseType: 'blob'
  })
}
//获得特需
export function orderSpecialNeedGet(params){
  return request({
    url:'/ecw/order-special-need/get',
    method:'get',
    params
  })
}
//取消调仓
  export function cancelAdjust(data){
  return request({
    url:'/order/order-warehouse-in/cancel-adjust',
    method:'post',
    data
  })
  }
//取消订单费用申请
 export function feeApplicationCancel(data){
   return request({
     url:'/order/fee-application/cancel',
     method:'delete',
     data
   })
 }


 // 获得订单修改申请详情
 export function getUpdateInfo(id){
  return request({
    url:'/ecw/order/update/info/' + id,
    method:'get'
  })
}

 // 根据审批ID获得订单修改申请详情
 export function getUpdateInfoByApproveId(approveId){
  return request({
    url:'/ecw/order/update/info',
    method:'get',
    params: {approveId}
  })
}

// (新修改订单)订单修改审批申请
export function updateApply(data){
  return request({
    url:'/ecw/order/update/apply',
    method:'put',
    data
  })
}
export function warehousePictureList(data){
  return request({
    url:'/order/warehouse-picture/list',
    method:'post',
    data
  })
}

// 获得部门订单分页
export function deptOrderPage(params){
  return request({
    url: '/ecw/order/dept-order-page',
    method: 'GET',
    params
  })
}

// 获得订单统计
export function orderStatistics(params){
  return request({
    url: '/ecw/order/statistics',
    method: 'GET',
    params
  })
}

// 获得我的订单统计
export function orderMyStatistics(params){
  return request({
    url: '/ecw/order/my/statistics',
    method: 'GET',
    params
  })
}

// 获得部门订单统计
export function orderDeptStatistics(params){
  return request({
    url: '/ecw/order/dept/statistics',
    method: 'GET',
    params
  })
}

// 参数搜索导出订单管理 Excel
export function orderExportSearch(params){
  return request({
    url: '/ecw/order/export/search',
    method: 'GET',
    responseType: 'arraybuffer',
    params
  })
}

// 参数搜索导出我的订单管理 Excel
export function orderExportMySearch(params){
  return request({
    url: '/ecw/order/export/my/search',
    responseType: 'arraybuffer',
    method: 'GET',
    params
  })
}

// 参数搜索导出部门订单管理 Excel
export function orderExportDeptSearch(params){
  return request({
    url: '/ecw/order/export/dept/search',
    method: 'GET',
    responseType: 'arraybuffer',
    params
  })
}

// 参数搜索导出异常订单统计 Excel
export function exportAbnormal(params){
  return request({
    url: '/ecw/order/export/export-exception',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}


// 参数搜索导出重货单统计 Excel
export function exportHeavyOrder(params){
  return request({
    url: '/ecw/order/export/export-heavyOrder',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}

// 参数搜索导出退仓单统计统计 Excel
export function exportReturnOrder(params){
  return request({
    url: '/ecw/order/export/export-returnOrder',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}

// 参数搜索导出售后赔偿金额统计 Excel
export function exportSaleRepay(params){
  return request({
    url: '/ecw/order/export/export-saleRepay',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}


// 参数搜索导出报关数统计 Excel
export function exportCustomsDatas(params){
  return request({
    url: '/ecw/order/export/export-customDatas',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}


// 参数搜索导出客户出货量统计 Excel
export function exportShippingDatas(params){
  return request({
    url: '/ecw/order/export/export-shipDatas',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}


// 参数搜索导出预付运费统计 Excel
export function exportShipFee(params){
  return request({
    url: '/ecw/order/export/export-shipFee',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}


// 参数搜索导出卸货费统计 Excel
export function exportUnload(params){
  return request({
    url: '/ecw/order/export/export-excel',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}

// 操作日志分页
export function operateLogPage(params){
  return request({
    url: '/ecw/order-operate-log/page',
    method: 'get',
    params: params
  })
}
