import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UsrCustomerVO, UsrCustomerForm, UsrCustomerQuery, CustomerOnOrderVO, CustomerOnOrderQuery, UsrCustomerRemarkForm } from '@/api/archieves/customer/types';

/**
 * 查询用户列表
 */
export const listCustomer = (query?: UsrCustomerQuery): AxiosPromise<UsrCustomerVO[]> => {
  return request({
    url: '/archieves/customer/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询全部用户（不分页）
 */
export const listAllCustomer = (query?: UsrCustomerQuery): AxiosPromise<UsrCustomerVO[]> => {
  return request({
    url: '/archieves/customer/listAll',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户详细
 */
export const getCustomer = (id: string | number): AxiosPromise<UsrCustomerVO> => {
  return request({
    url: '/archieves/customer/' + id,
    method: 'get'
  });
};

/**
 * 新增用户
 */
export const addCustomer = (data: UsrCustomerForm) => {
  return request({
    url: '/archieves/customer',
    method: 'post',
    data: data
  });
};

/**
 * 下单页新增用户
 */
export const addCustomerOnOrder = (data: UsrCustomerForm) => {
  return request({
    url: '/archieves/customer/addOnOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户
 */
export const updateCustomer = (data: UsrCustomerForm) => {
  return request({
    url: '/archieves/customer',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户
 */
export const delCustomer = (id: string | number | Array<string | number>) => {
  return request({
    url: '/archieves/customer/' + id,
    method: 'delete'
  });
};

/**
 * 切换用户状态
 */
export const changeCustomerStatus = (id: string | number, status: number) => {
  return request({
    url: '/archieves/customer/changeStatus',
    method: 'put',
    data: { id, status }
  });
};

/**
 * 下单页宠主列表
 */
export const listCustomerOnOrder = (query?: CustomerOnOrderQuery): AxiosPromise<CustomerOnOrderVO[]> => {
  return request({
    url: '/archieves/customer/listOnOrder',
    method: 'get',
    params: query
  });
};

/**
 * 客户备注更新
 */
export const updateCustomerRemark = (data: UsrCustomerRemarkForm) => {
  return request({
    url: '/archieves/customer/remark',
    method: 'post',
    data: data
  });
};
