/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许，不可做商业用途！
*
* 版权所有，侵权必究！
*/

// 采购订单Api接口
import request from '@/utils/request'
import excelRequest from '@/utils/excelRequest'

/**
 * 获取采购订单列表
 * @param {Object} pageParam 分页请求配置
 */
export function page (pageParam) {
  return request({
    url: '/mall4cloud_search/s/purchase_order_search/page',
    method: 'get',
    params: pageParam
  })
}

/**
 * 获取采购订单详情
 * @param { String, Number } purchaseOrderNumber 采购单号
 */
export function orderInfo (purchaseOrderNumber) {
  return request({
    url: '/mall4cloud_order/s/purchase/order/info/' + purchaseOrderNumber,
    method: 'get'
  })
}

/**
 * 获取订单待发货信息
 * @param {*} purchaseOrderNumber 采购单号
 */
export function getOrderItemAndAddress (purchaseOrderNumber) {
  return request({
    url: '/mall4cloud_order/s/purchase/order/order_item_and_address/' + purchaseOrderNumber,
    method: 'get'
  })
}

/**
 * 发货
 * @param {*} data 执行发货操作的商品项数据
 */
export function delivery (data) {
  return request({
    url: '/mall4cloud_order/s/purchase/order/delivery',
    method: 'post',
    data
  })
}

/**
 * 导出筛选的采购订单
 * @param {*} param 当前筛选条件
 */
export function soldExcel (param) {
  return excelRequest({
    url: '/mall4cloud_order/s/purchase/order/sold_excel',
    method: 'GET',
    params: param
  })
}

/**
 * 导出待发货采购订单
 * @param {*} param 当前筛选条件
 */
export function deliverySoldExcel (param) {
  return excelRequest({
    url: '/mall4cloud_order/s/purchase/order/un_delivery_sold_excel',
    method: 'GET',
    params: param
  })
}

/**
 * 查询订单物流包裹信息
 * @param {*} param 当前筛选条件
 */
export function deliveryExpressInfo (param) {
  return request({
    url: '/mall4cloud_order/mp/order_delivery/info',
    method: 'GET',
    params: param
  })
}

/**
 * 审核付款凭证
 * @param {*} param 当前筛选条件
 */
export function auditVoucher (data) {
  return request({
    url: '/mall4cloud_order/s/purchase/order/auditVoucher',
    method: 'PUT',
    data
  })
}
