import request from '@/utils/request'

// 查询【请填写功能名称】列表
export function listAgent(query) {
  return request({
    url: '/user/agent/list',
    method: 'get',
    params: query
  })
}


// 不分页
export function listAllAgent(query) {
  return request({
    url: '/user/agent/listAll',
    method: 'get',
    params: query
  })
}

// 查询【请填写功能名称】详细
export function getAgent(agentId) {
  return request({
    url: '/user/agent/' + agentId,
    method: 'get'
  })
}

// 新增【请填写功能名称】
export function addAgent(data) {
  return request({
    url: '/user/agent',
    method: 'post',
    data: data
  })
}

// 修改【请填写功能名称】
export function updateAgent(data) {
  return request({
    url: '/user/agent',
    method: 'put',
    data: data
  })
}

// 删除【请填写功能名称】
export function delAgent(agentId) {
  return request({
    url: '/user/agent/' + agentId,
    method: 'delete'
  })
}

// 查询地区
export function getArea() {
  return request({
    url: '/user/area/getAllAreaList',
    method: 'get'
  })
}
// 查询地区
export function getAreaTree() {
  return request({
    url: '/user/area/getAllAreaTree',
    method: 'get'
  })
}

// 根据地区id查询国家
export function getCountryByAreaId(areaId) {
  return request({
    url: '/user/country/getCountryByAreaId/' + areaId,
    method: 'get'
  })
}


// 根据区域id查询上级销售
export function getSalesByAreaId(areaId) {
  return request({
    url: '/user/agent/getSalesByAreaId/' + areaId,
    method: 'get'
  })
}

// 根据区域id查询上级代理
export function getAgentByAreaId(areaId, agentId) {
  return request({
    url: '/user/agent/getAgentByAreaId',
    method: 'get',
    params: {areaId, agentId}
  })
}

// 代理商状态修改
export function changeAgentStatus(agentId, status, updateTime) {
  const data = {
    agentId,
    status,
    updateTime
  }
  return request({
    url: '/user/agent/changeStatus/',
    method: 'put',
    data: data
  })
}

export function selectForAccount() {
  return request({
    url: '/user/agent/selectForAccount',
    method: 'get'
  })
}

export function selectForProject() {
  return request({
    url: '/user/agent/selectForProject',
    method: 'get'
  })
}

export function selectForYear(yearParam) {
  return request({
    url: '/user/agent/selectForYear',
    method: 'get',
    params: {yearParam}
  })
}

export function selectByOwner(ownerId) {
  return request({
    url: '/user/agent/selectByOwner/' + ownerId,
    method: 'get',
  })
}
