/**
 * 客户管理相关API
 * 复用后端 UserController 接口
 */

import { get, put } from '@/utils/request';

export interface CustomerQueryParams {
  page?: number;
  pageSize?: number;
  phone?: string;
  nickname?: string;
  status?: number;
}

export interface CustomerListResponse {
  list: any[];
  total: number;
  pageSize: number;
  currentPage: number;
}

/**
 * 获取客户列表
 */
export async function getCustomerList(params: CustomerQueryParams = {}): Promise<CustomerListResponse> {
  return get('/users/list', params);
}

/**
 * 获取客户详情
 */
export async function getCustomerDetail(id: string): Promise<any> {
  return get(`/users/${id}`);
}

/**
 * 获取客户统计数据
 */
export async function getCustomerStatistics(): Promise<any> {
  return get('/users/statistics');
}

/**
 * 更新客户状态
 */
export async function updateCustomerStatus(id: string, status: number): Promise<any> {
  return put(`/users/${id}/status`, { status });
}

/**
 * 更新客户信用分
 */
export async function updateCustomerCredit(id: string, creditScore: number): Promise<any> {
  return put(`/users/${id}/credit`, { creditScore });
}
