import request from '@/utils/request'

const api = {
  list: '/orders',
  info: '/orders/{orderId}',
  base: '/orders/{orderId}/base',
  items: '/orders/{orderId}/items',
  services: '/orders/{orderId}/services',
  check: '/orders/{orderId}/check',
  updateOrderInfo: '/orders/{orderId}/update',
  pass: '/orders/{orderId}/check/pass',
  repass: '/orders/{orderId}/repass',
  diffp: '/orders/{orderId}/diffprice',
  diffs: '/orders/{orderId}/diffs',
  diffBack: '/orders/{orderId}/diffprice/{diff}',
  firstpass: 'orders/{orderId}/firstpass',
  teachermakesure: 'orders/{orderId}/teachermakesure',
  getExpressesList: 'orders/{orderId}/expresses',
  logistic: 'orders/{express}/logistic',
  signInLogistic: 'orders/{orderId}/sign/{express}',
  doLogs: 'orders/{orderId}/dologs',
  doLogsList: 'orders/{orderId}/dologs',
  delLog: 'orders/{orderId}/dologs/{logId}',
  getSchemes: 'orders/{orderId}/schemes/{itemId}',
  institutionEdit: 'institutions/{itemId}/institution', //  修改机构名称 主要做备注用换了机构
  getOrdersCount: 'orders/count',
  changeBankCount: 'orders/{orderId}/items/{itemId}/price',
  getChangeBankCountLog: 'orders/{orderId}/items/{itemId}/price_log',
  getAllBanks: 'orders/{orderId}/all_items' // 获得所有机构信息
}
// 订单列表
export function getOrderList (parameter) {
  return request({
    url: api.list,
    method: 'get',
    params: parameter
  })
}
// 根据订单id获取订单详情
export function orderInfo (orderId) {
  return request({
    url: api.info.replace('{orderId}', orderId),
    method: 'get'
  })
}
// 根据订单id获取下单用户的真实信息
export function realName (orderId) {
  return request({
    url: api.base.replace('{orderId}', orderId),
    method: 'get'
  })
}

// 根据订单 id 获取下单申请机构列表
export function getBankItem (orderId, parameter) {
  return request({
    url: api.items.replace('{orderId}', orderId),
    method: 'get',
    params: parameter
  })
}

// 根据id 展示服务包
export function getServices (orderId, parameter) {
  return request({
    url: api.services.replace('{orderId}', orderId),
    method: 'get',
    params: parameter
  })
}
// 订单信息修改
export function updateOrderInfo (orderId, parameter) {
  return request({
    url: api.updateOrderInfo.replace('{orderId}', orderId),
    method: 'post',
    params: parameter
  })
}

// 驳回用户基本信息和机构信息   type 1. 用户信息 2. 机构信息
export function checkInfo (orderId, parameter) {
  return request({
    url: api.check.replace('{orderId}', orderId),
    method: 'post',
    params: parameter
  })
}

// 用户信息驳回通过/orders/1/check/pass
export function passInfo (orderId, parameter) {
  return request({
    url: api.pass.replace('{orderId}', orderId),
    method: 'post',
    params: parameter
  })
}

// 用户服务包补差价
export function diffPrice (orderId, parameter) {
  return request({
    url: api.diffp.replace('{orderId}', orderId),
    method: 'post',
    params: parameter
  })
}
// 用户服务包补差价记录
export function diffPayList (orderId) {
  return request({
    url: api.diffs.replace('{orderId}', orderId),
    method: 'get'
  })
}

// 撤回补差价
export function diffBack (orderId, diff) {
  return request({
    url: api.diffBack.replace('{orderId}', orderId).replace('{diff}', diff),
    method: 'DELETE'
  })
}

// 初审通过orders/{order}/firstpass
export function firstPass (orderId) {
  return request({
    url: api.firstpass.replace('{orderId}', orderId),
    method: 'post'
  })
}

// 复审
export function secondPass (orderId) {
  return request({
    url: api.repass.replace('{orderId}', orderId),
    method: 'post'
  })
}

// 待老师确认通过审核按钮
export function teachermakesure (orderId) {
  return request({
    url: api.teachermakesure.replace('{orderId}', orderId),
    method: 'post'
  })
}

// 查看邮寄材料列表
export function getExpressesList (orderId, parameter) {
  return request({
    url: api.getExpressesList.replace('{orderId}', orderId),
    params: parameter
  })
}
// 查看邮寄材料物流信息
export function getLogistic (express) {
  return request({
    url: api.logistic.replace('{express}', express)
  })
}

// 确认签收
export function signInLogistic (orderId, express) {
  return request({
    url: api.signInLogistic.replace('{orderId}', orderId).replace('{express}', express),
    method: 'post'
  })
}

// 添加记录  itemid  有就是给机构添加的记录 没有就是给订单加的记录信息
export function doLogs (orderId, parameter) {
  return request({
    url: api.doLogs.replace('{orderId}', orderId),
    method: 'post',
    params: parameter
  })
}

// 记录列表  itemid  代表查机构的记录列表 不带itemid 就是查全部的记录列表
export function doLogsList (orderId, parameter) {
  return request({
    url: api.doLogsList.replace('{orderId}', orderId),
    method: 'get',
    params: parameter
  })
}

// 删除记录delLog
export function delLog (orderId, logId) {
  return request({
    url: api.delLog.replace('{orderId}', orderId).replace('{logId}', logId),
    method: 'DELETE'
  })
}

// 获取确认方案信息
export function getSchemes (orderId, itemId) {
  return request({
    url: api.getSchemes.replace('{orderId}', orderId).replace('{itemId}', itemId),
    method: 'get'
  })
}
// 修改机构名称（备注使用换了机构）
export function institutionEdit (itemId, parameter) {
  return request({
    url: api.institutionEdit.replace('{itemId}', itemId),
    method: 'POST',
    params: parameter
  })
}
// 提交确认方案
export function addSchemes (orderId, itemId, parameter) {
  return request({
    url: api.getSchemes.replace('{orderId}', orderId).replace('{itemId}', itemId),
    method: 'post',
    params: parameter
  })
}
// 修改机构金额
export function changeBankCount (orderId, itemId, parameter) {
  return request({
    url: api.changeBankCount.replace('{orderId}', orderId).replace('{itemId}', itemId),
    method: 'PUT',
    params: parameter
  })
}

// 机构修改金额记录getChangeBankCount
export function getChangeBankCountLog (orderId, itemId) {
  return request({
    url: api.getChangeBankCountLog.replace('{orderId}', orderId).replace('{itemId}', itemId),
    method: 'get'
  })
}
// 获取订单数量
export function getOrdersCount (parameter) {
  return request({
    url: api.getOrdersCount,
    method: 'get',
    params: parameter
  })
}
// 获得所有机构信息
export function getAllBanks (orderId) {
  return request({
    url: api.getAllBanks.replace('{orderId}', orderId),
    method: 'get'
  })
}
