import { request } from '@/utils/request'
import { Customer } from '@/enums/api'
import {
  AddCustomerReqParams,
  CustomerListReqParams,
  ModifyCustomerReqParams,
  CustomerListResParams,
  AddCustomerResParams,
  CustomerDetailResParams,
  CustomerStatResParams
} from '@/types/customer'

/**
 * 获取客户信息列表
 * @param params RequestCustomerListParams
 * @returns
 */
export const getCustomerList = (params: CustomerListReqParams) => {
  return request.post<CustomerListResParams>({
    url: Customer.BIZ_CUSTOMER_LIST,
    data: params
  })
}

/**
 * 添加客户
 * @param params RequestAddCustomerParams
 * @returns
 */
export const addCustomer = (params: AddCustomerReqParams) => {
  return request.post<AddCustomerResParams>({
    url: Customer.BIZ_CUSTOMER_ADD,
    data: params
  })
}

/**
 * 修改客户信息
 * @param params RequestModifyCustomerParams
 * @returns
 */
export const modifyCustomer = (params: ModifyCustomerReqParams) => {
  return request.post<BaseResParams>({
    url: Customer.BIZ_CUSTOMER_MODIFY,
    data: params
  })
}

/**
 * 删除客户
 * @param id 客户编号
 * @returns
 */
export const removeCustomer = (id: string) => {
  return request.post<BaseResParams>({
    url: Customer.BIZ_CUSTOMER_REMOVE,
    data: { id }
  })
}

/**
 * 获取客户详情
 * @param id 客户编号
 * @returns
 */
export const getCustomerDetail = (id: string) => {
  return request.post<CustomerDetailResParams>({
    url: Customer.BIZ_CUSTOMER_DETAIL,
    data: { id }
  })
}

/**
 * 获取客户统计信息
 * @returns
 */
export const getCustomerStat = () => {
  return request.post<CustomerStatResParams>({
    url: Customer.BIZ_CUSTOMER_STAT,
    data: {}
  })
}
