import request from '@/utils/request'

const api = {
  expressCommonList: '/mall/orders/{orderId}/deliver',
  expressList: '/store/expresses',
  createExpress: '/store/expresses',
  editExpress: '/store/expresses/{expressId}/edit',
  updateExpress: '/store/expresses/{expressId}',
  deleteExpress: '/store/expresses/{expressId}',
  getExpressDrow: '/staff/expresses',
  signInDrow: '/orders/{orderId}/outlineexpress'
}

/**
 * 保存物流信息时候用的接口
 * @returns {AxiosPromise}
 */
export function getExpressCommonList (orderId) {
  return request({
    url: api.expressCommonList.replace('{orderId}', orderId),
    method: 'get'
  })
}

/**
 * 物流列表
 * @param parameter
 * @returns {AxiosPromise}
 */
export function getExpressList (parameter) {
  return request({
    url: api.expressList,
    method: 'get',
    params: parameter
  })
}

/**
 * 新增
 * @param data
 * @returns {AxiosPromise}
 */
export function storeExpress (data) {
  return request({
    url: api.createExpress,
    method: 'post',
    data: data
  })
}

/**
 * 编辑
 * @param expressId
 * @returns {AxiosPromise}
 */
export function editExpress (expressId) {
  return request({
    url: api.editExpress.replace('{expressId}', expressId),
    method: 'get'
  })
}

/**
 * 更新
 * @param expressId
 * @param data
 * @returns {AxiosPromise}
 */
export function updateExpress (expressId, data) {
  return request({
    url: api.updateExpress.replace('{expressId}', expressId),
    method: 'put',
    data: data
  })
}

/**
 * 删除物流
 * @param expressId
 * @returns {AxiosPromise}
 */
export function deleteExpress (expressId) {
  return request({
    url: api.deleteExpress.replace('{expressId}', expressId),
    method: 'delete'
  })
}

/**
 * 线下签收信息前置
 * @param parameter
 * @returns {AxiosPromise}
 */
export function getExpressDrow (parameter) {
  return request({
    url: api.getExpressDrow,
    method: 'get'
  })
}

/**
 * 线下签收
 * @param parameter
 * @returns {AxiosPromise}
 */
export function signInDrow (orderId, parameter) {
  return request({
    url: api.signInDrow.replace('{orderId}', orderId),
    method: 'POST',
    data: parameter
  })
}
