import request from '@/utils/request'

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

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

// 删除订单
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
  })
}

// 获得订单列表
export function getOrderList(query) {
  return request({
    url: '/ecw/order/list',
    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',
    timeout: 3 * 60000
  })
}

//根据订单号获得订单费用申请列表
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 feeApplicationCreateBatch(data){
  return request({
    url:'order/fee-application/create/batch',
    method:'post',
    data:data,
  })
}

// 根据订单ID获取是否有正在申请的费用申请
export function getFeeApplicationApproveByOrderId(orderId){
  return request({
    url:'/order/fee-application/get/isApprove',
    method:'get',
    params: {id: orderId}
  })
}

// 根据流程主键ID得到批量申请费用
export function getBatchFeeByBusinessId(businessId){
  return request({
    url:'/order/fee-application/getBatchFeeByBusinessId',
    method:'get',
    params: {businessId}
  })
}

// 查询批量申请费用
export function feeApplicationGetBatch(params){
  return request({
    url:'/order/fee-application/get/batch',
    method:'get',
    params
  })
}

  //费用申请修改
 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-or-updateApply',
    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 createOrderSpecialBatch(data) {
  return request({
    url: '/ecw/order/special/apply/batch',
    method: 'put',
    data: data
  })
}

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

// 根据订单项商品ID与审批类型获得订单商品的特价申请详情-批量
export function getOrderSpecialByApproveIdBatch(approveId) {
  return request({
    url: '/ecw/order/special/batch/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',
    timeout: 5 * 60000,
    params
  })
}

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

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

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


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

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

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


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


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


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


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

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

// 获取操作日志详情
export function getOperateLogDetail(id){
  return request({
    url: '/ecw/order-operate-log/get',
    params: {id},
    method: 'get',
  })
}

// 取消拆单申请
export function splitCancelApply(data){
  return request({
    url: '/order/split/cancel-apply',
    method: 'put',
    data
  })
}

// 撤销拆单
export  function orderSplitRevoke(data){
  return request({
    url: '/order/split/revoke',
    method: 'put',
    data
  })
}

/*根据订单ID获取撤销拆单详情*/
export  function splitRevoke(orderId){
  return request({
    url: '/order/split/revoke/' + orderId,
    method: 'get'
  })
}

/*根据审批ID获取撤销拆单详情*/
export  function splitRevokeApply(approvalId){
  return request({
    url: '/order/split/revoke/apply/' + approvalId,
    method: 'get'
  })
}

/*取消撤销拆单*/
export  function cancelSplitRevoke(data){
  return request({
    url: '/order/split/cancel/revoke',
    method: 'put',
    data
  })
}

/*修改拆单项*/
export function splitItemUpdate(data){
  return request({
    url: '/order/split-item/update',
    method: 'post',
    data
  })
}
// 待备货（可出）订单列表
export function canShipmentPage(params){
  return request({
    url: '/air/order/data/scope/can/shipment/page',
    method: 'get',
    params
  })
}
// 待出订单列表
export function waitingShipmentPage(params){
  return request({
    url: '/air/order/data/scope/waiting/shipment/page',
    method: 'get',
    params
  })
}

// 备货订单列表
export function canReadyStockShipmentPage(params){
  return request({
    url: '/air/order/can-ready-stock/shipment/page',
    method: 'get',
    params
  })
}

// 确认订单可出
export function setCanShipment(orderId){
  return request({
    url: '/air/order/can/shipment/' + orderId,
    method: 'put',
  })
}
// 批量可出
export function batchCanShipment(orderIdList){
  return request({
    url: '/air/order/can/shipment/',
    method: 'put',
    data: {orderIdList}
  })
}

// 导出备货订单
export function exportReadyStock(params){
  return request({
    url: '/ecw/order/export/ready-stock/search',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 导出可出订单
export function exportCanShipment(params){
  return request({
    url: '/ecw/order/export/can-shipment/search',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 导出待出订单
export function exportWaitingShipment(params){
    return request({
        url: '/ecw/order/export/waiting-shipment/search',
        method: 'get',
        params,
        responseType: 'blob'
    })
}

// 无需打包
export function noNeedPack(orderItemId){
  return request({
    url: '/order/order-warehouse-in/no-need-to-pack',
    method: 'get',
    params: {orderItemId}
  })
}

// 完成打包
export function finishPacked(data){
  return request({
    url: '/order/order-warehouse-in/finish-packed',
    method: 'post',
    data
  })
}
// 完成备货
export function finishStock(data){
  return request({
    url: '/order/order-warehouse-in/finish-stocked',
    method: 'put',
    data
  })
}
// 批量转异
export function batchException(data){
  return request({
    url: '/air/order/manual-exception/batch',
    method: 'put',
    data
  })
}
// 打包记录列表
export function orderItemPackLogPage(params){
  return request({
    url: '/order/item-pack-log/page',
    method: 'get',
    params
  })
}
// 上传报关资料
export function warehousePictureCreate(data) {
  return request({
    url: '/order/warehouse-picture/create',
    method: 'post',
    data
  })
}
// 删除报关资料
export function warehousePictureDelete(id) {
  return request({
    url: '/order/warehouse-picture/delete?id=' + id,
    method: 'delete'
  })
}
//上传
export function uploadFile(data) {
  return request({
    url: '/infra/file/up',
    method: 'post',
    data: data
  })
}
//上传
export function uploadOrgname(data) {
  return request({
    url: '/infra/file/org-name/up',
    method: 'post',
    data: data
  })
}
/*根据订单ID查询目的国*/
export  function getDestCountryByOrderId(params){
  return request({
    url: '/ecw/order/getDestCountryByOrderId',
    method: 'get',
    params:params
  })
}

// 订单费用汇总
export function orderSummary(orderId){
  return request({
    url: '/ecw/orderCount/orderSummary/' + orderId,
    method: 'get'
  })
}

// 订单明细汇总
export function orderDetailSummary(orderId){
  return request({
    url: '/ecw/orderCount/orderDetailSummary/' + orderId,
    method: 'get'
  })
}

// 自编号的订单费用汇总
export function orderSummaryByContainerNumber(params){
  return request({
    url: '/ecw/orderCount/containerNumber/orderSummary',
    method: 'get',
    params
  })
}

// 导出自编号订单汇总列表
export function exportOrderSummaryByContainerNumber(params){
  return request({
    url: '/ecw/order/export/export-order-summary',
    method: 'get',
    params,
    timeout: 5 * 60000,
    responseType: 'blob'
  })
}

// 查询权限范围内待出订单数量
export function getWaitingShipmentCount(){
  return request({
    url: '/air/order/data/scope/waiting/shipment/count',
    method: 'get'
  })
}

// 空运订单不可出
export function setCanNotShipment(orderId){
  return request({
    url: '/air/order/not/can/shipment/' + orderId,
    method: 'put',
  })
}

// 查看母订单
export function getParentOrder(orderId){
  return request({
    url: '/ecw/order/getParentOrder?orderId=' + orderId,
    method: 'get'
  })
}

// 获取订单入仓商品明细通用属性集合，用于备货选择订单商品到明细
export function getOrderItemCommonAttr(orderId, excludeOrderWarehouseInId){
  return request({
    url: '/order/order-warehouse-in/get-order-warehouse-in-common-attr-list',
    method: 'get',
    params: {orderId, excludeOrderWarehouseInId}
  })
}
//退仓品名列表
export function getOrderItemDeleted(orderId){
  return request({
    url: '/ecw/order/order-item-info-when-warehouse-in-deleted/' + orderId,
    method: 'get',
  })
}

// 打包页面订单数据统计
export function getPackStatistics(orderId){
  return request({
    url: '/ecw/order/order-packed-page-statistics/' + orderId,
    method: 'get'
  })
}
//获得订单品名对应的退仓入仓货物详情
export function getOrderWarehouseDeleted(orderId,orderItem){
  return request({
    url: '/order/order-warehouse-in/get-order-warehouse-in-deleted?orderId=' + orderId+'&orderItemId='+orderItem,

  })
}

export function getRegionList(type,regionId){
  return request({
    url:'/ecw/warehouse/getRegionList?type='+type+'&regionId='+regionId,
    method: 'get',
    
  })
}