import http from '../../util/http';

/**
 * 订单详情
 *
 * @param {*} id
 * @return {*}
 */
export const getOrderDetail = (id) => {
  return http(
    `app-api/my/order/info/${id}`,
    {},
    {
      method: 'GET',
      loading: true,
    }
  );
};

/**
 * 订单详情1
 *
 * @param {*} id
 * @return {*}
 */
 export const getOrderDetailAdmin = (id) => {
  return http(
    `/ecw/order/info/${id}`,
    {},
    {
      method: 'GET',
      loading: true,
    }
  );
};

/**
 * 订单装箱编号列表
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function orderTagList(data) {
  return http(`/ecw/box-load-info/orderTagList`, data, {
    method: 'POST',
    loading: true,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  });
}

/**
 * 订单详情
 *
 * @param {*} params
 * @returns
 */
export const getOrderDetailByBoxNo = (params) => {
  return http('/my/shipment/searchLoadOrderByBoxNo', params, {
    method: 'POST',
    loading: true,
  });
};

/**
 * 待装柜列表
 *
 * @param {*} params
 * @return {*}
 */
export const getLoadingList = (params) => {
  return http(`/my/shipment/loadPage`, params, {
    method: 'POST',
  });
};

/**
 * 待装柜详情
 *
 * @param {*} params
 * @returns
 */
export const getLoadingDetail = (params) => {
  return http(`/my/shipment/cabinetDetail`, params, {
    method: 'GET',
    loading: true,
  });
};

/**
 * 批量装柜
 *
 * @param {*} params
 * @returns
 */
export const batchLoadGoods = (params) => {
  return http('/ecw/box-load-info/externalLoad', params, {
    method: 'POST',
    loading: true,
  });
};

/**
 * 批量纠错
 *
 * @param {*} params
 * @returns
 */
export const unloadGoods = (params) => {
  return http('/my/shipment/batchRemove', params, {
    method: 'POST',
    loading: true,
  });
};

/**
 * 移出订单
 *
 * @param {*} params
 * @returns
 */
export const moveOutLoadGoods = (params) => {
  return http('/ecw/box-load-info/remove', params, {
    method: 'POST',
    loading: true,
  });
};

/**
 * 装柜
 *
 * @param {*} params
 * @returns
 */
export const loadGoods = (params) => {
  return http('/ecw/box-load-info/singleCreate', params, {
    method: 'POST',
    loading: true,
    errorHandle: false,
  });
};

/**
 * 可拆订单详情获取接口
 *
 * @param {*} params
 * @returns
 */
export const getSplitGoods = (params) => {
  return http('/order/split/list-by-order-id', params, {
    method: 'GET',
    loading: true,
  });
};

/**
 * 创建拆单
 *
 * @param {*} params
 * @returns
 */
export const createSplit = (params) => {
  return http('/order/split/create', params, {
    method: 'POST',
    loading: true,
  });
};

/**
 * 创建订单拆单项 - 放入
 *
 * @param {*} params
 * @returns
 */
export const createSplitItem = (params) => {
  return http('/order/split-item/batchCreate', params, {
    method: 'POST',
    loading: true,
  });
};

/**
 * 拆单审核
 *
 * @param {*} params
 * @returns
 */
export const createApproval = (params) => {
  return http('/ecw/box-approval/create', params, {
    method: 'POST',
    loading: true,
  });
};

/**
 * 获得预装分页
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function preloadPage(params) {
  return http('/ecw/box-preload-goods/preloadPage', params, {
    method: 'POST',
    loading: true,
  });
}
/**
 * 密码校验
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function validatePwd(params) {
  return http('/ecw/busi-pwd/validate-pwd', params, {
    method: 'POST',
    loading: true,
  });
}
/**
 * 预装
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function createGoods(params) {
  return http('/ecw/box-preload-goods/v2/create', params, {
    method: 'POST',
    loading: true,
  });
}

/**
 * 申请封柜
 *
 * @param {*} params
 * @returns
 */
export const closureApply = (params) => {
  return http('/my/shipment/closureApply', params, {
    method: 'post',
    loading: true,
    errorHandle: false,
  });
};

/**
 * 更新装柜
 *
 * @param {*} params
 * @returns
 */
export const boxCabinetUpdate = (params) => {
  return http('/ecw/box-cabinet/update', params, {
    method: 'put',
    loading: true,
    errorHandle: false,
  });
};

/**
 * 获取
 *
 * @param {*} id
 * @returns
 */
export const getCabinet = (id) => {
  return http('/shipment/box/get', {id}, {
    method: 'GET',
    loading: true,
  });
}

/**
 * 确认封柜
 *
 * @param {*} params
 * @returns
 */
export const createCabinet = (params) => {
  return http('/ecw/box-cabinet/create', params, {
    method: 'post',
    loading: true,
    errorHandle: false,
  });
};

/**
 * 获取拆单列表
 *
 * @param {*} params
 * @returns
 */
export function splitList(data) {
  return http(`/shipment/box/splitList`, data, {
    method: 'POST',
    loading: true,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  });
}

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

export const listByOrderId = (params) => {
  return http('/order/location/list-by-order-id', params, {
    method: 'GET',
  });
};

/**
 * 订单仓库图片上传
 * @param {{bizId: number, type: number, url: string}} data 类型 1订单完成入仓 2 调拨出仓 3调拨到仓 4 订单转异 5订单项入仓 6报关资料
 * @returns {*}
 */
export const warehousePictureCreate = (data) => {
  return http('/order/warehouse-picture/create', data, {
    method: 'POST'
  })
}

/**
 * 获取订单仓库图片
 * @param data
 * @returns {*}
 */
export const warehousePictureList = (data) => {
  return http('/order/warehouse-picture/list', data, {
    method: 'POST'
  })
}

/**
 * 删除订单仓库图片
 * @param id
 * @returns {*}
 */
export const warehousePictureDelete = (id) => {
  return http('/order/warehouse-picture/delete?id=' + id, {}, {
    method: 'DELETE'
  })
}
