import request from '@/utils/request';

/**
 * 查询客户信息列表
 * @param query
 */
export function listCustomerInfo(query?: any) {
  return request({
    url: '/customer/customerInfo/list',
    method: 'get',
    params: query
  });
}

/**
 * 查询所有客户下拉列表 (不分页)
 * @param query
 */
export function listCustomerOption(query?: any) {
  return request({
    url: '/customer/customerInfo/optionList',
    method: 'get',
    params: query
  });
}

/**
 * 获取客户信息详细
 * @param id
 */
export function getCustomerInfo(id: string | number) {
  return request({
    url: '/customer/customerInfo/' + id,
    method: 'get'
  });
}

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

/**
 * 修改客户信息
 * @param data
 */
export function updateCustomerInfo(data: any) {
  return request({
    url: '/customer/customerInfo',
    method: 'put',
    data: data
  });
}
/**
 * 客户列表-分页查询 (主表查询)
 * @param query
 */
export function listCustomerListPage(query?: any) {
  return request({
    url: '/customer/customerInfo/customerList',
    method: 'get',
    params: query
  });
}

/**
 * 查询有效客户列表（已合作）
 * @param query
 */
export function listValidCustomer(query?: any) {
  return request({
    url: '/customer/customerInfo/list',
    method: 'get',
    params: {
      ...query,
      isHighSeas: 'false'
    }
  });
}
/**
 * 转移业务人员
 */
export function transferSalesPerson(data: any) {
  return request({
    url: '/customer/customerInfo/transferSalesPerson',
    method: 'put',
    data: data
  });
}

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

/**
 * 退回到公海（支持批量）
 * @param customerIds 客户ID列表
 * @param reason 原因
 */
export function releaseToPool(customerIds: (number | string)[] | number | string, reason: string = '') {
  // 兼容单个 ID 或数组
  const ids = Array.isArray(customerIds) ? customerIds : [customerIds];
  return request({
    url: '/customer/customerInfo/releaseToPool',
    method: 'post',
    data: { customerIds: ids, reason }
  });
}

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

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