import request from '@/utils/request'

// 查询客户公海信息列表
export function listPool(query) {
  return request({
    url: '/customer/customerPool/customerList',
    method: 'get',
    params: {
      ...query,
      isHighSeas: 'true'
    }
  })
}

// 查询我负责的客户列表
export function listMineCustomer(query) {
  return request({
    url: '/customer/customerPool/mineList',
    method: 'get',
    params: query
  })
}

// 查询我参与的客户列表
export function listInvolvedCustomer(query) {
  return request({
    url: '/customer/customerPool/involvedList',
    method: 'get',
    params: query
  })
}

// 查询全部有效客户列表
export function listAllCustomer(query) {
  return request({
    url: '/customer/customerPool/allList',
    method: 'get',
    params: query
  })
}

// 公海客户认领
export function claimPool(data) {
  return request({
    url: '/customer/customerPool/claimPool',
    method: 'put',
    data: data
  })
}

// 退回到公海池（支持批量）
export function releaseToPool(customerIds, reason = '') {
  const ids = Array.isArray(customerIds) ? customerIds : [customerIds];
  return request({
    url: '/customer/customerPool/releaseToPool',
    method: 'post',
    data: { customerIds: ids, reason }
  })
}

// 转移业务人员
export function transferSalesPerson(data) {
  return request({
    url: '/customer/customerPool/transferSalesPerson',
    method: 'put',
    data: data
  })
}

// 转移客服人员
export function transferServiceStaff(data) {
  return request({
    url: '/customer/customerPool/transferServiceStaff',
    method: 'put',
    data: data
  })
}

// 获取详情接口 (公海使用)
export function getPool(id) {
  return request({
      url: `/customer/customerPool/${id}`,
      method: 'get'
  })
}

// 获取有效客户信息详细 (有效客户使用)
export function getCustomerInfo(id) {
  return request({
    url: '/customer/customerPool/' + id,
    method: 'get'
  });
}

// 新增客户公海
export function addPool(data) {
  return request({
    url: '/customer/customerPool',
    method: 'post',
    data: data
  })
}

// 修改客户公海
export function updatePool(data) {
  return request({
    url: '/customer/customerPool',
    method: 'put',
    data: data
  })
}

// 新增客户信息
export function addCustomerInfo(data) {
  return request({
    url: '/customer/customerPool',
    method: 'post',
    data: data
  });
}

// 修改客户信息
export function updateCustomerInfo(data) {
  return request({
    url: '/customer/customerPool',
    method: 'put',
    data: data
  });
}

// 获取公司下拉列表
export function listCompanyOption() {
  return request({
    url: '/customer/customerPool/companyOptionList',
    method: 'get'
  })
}

// 获取等级下拉列表
export function listLevelOption() {
  return request({
    url: '/customer/customerPool/levelOptionList',
    method: 'get'
  })
}
