import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MemberVO, MemberForm, MemberQuery, MemberLevelCountVO, vipLevelVO } from '@/api/dgtmedicine/member/types';

/**
 * 查询会员信息列表
 * @param query
 * @returns {*}
 */

export const listMember = (query?: MemberQuery): AxiosPromise<MemberVO[]> => {
  return request({
    url: '/dgtmedicine/member/list',
    method: 'get',
    params: query
  });
};


/**
 * 查询审核会员信息列表
 * @param query
 * @returns {*}
 */

export const listMemberApproval = (query?: MemberQuery): AxiosPromise<MemberVO[]> => {
  return request({
    url: '/dgtmedicine/member/listMemberApproval',
    method: 'get',
    params: query
  });
};

/**
 * 查询会员信息详细
 * @param id
 */
export const getMember = (id: string | number): AxiosPromise<MemberVO> => {
  return request({
    url: '/dgtmedicine/member/getInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增会员信息
 * @param data
 */
export const addMember = (data: MemberForm) => {
  return request({
    url: '/dgtmedicine/member/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改会员信息
 * @param data
 */
export const updateMember = (data: MemberForm) => {
  return request({
    url: '/dgtmedicine/member/edit',
    method: 'post',
    data: data
  });
};

/**
 * 删除会员信息
 * @param id
 */
export const delMember = (id: string | number | Array<string | number>) => {
  return request({
    url: '/dgtmedicine/member/del/' + id,
    method: 'get'
  });
};


/**
 * 会员等级统计
 * @param id
 */
export const countLevelMember = (query?: MemberQuery): AxiosPromise<MemberLevelCountVO[]> => {
  return request({
    url: '/dgtmedicine/member/queryMemberCount',
    method: 'get',
    params: query
  });
};

/**
 * 会员等级列表
 * @param id
 */
export const vipLevelList = (): AxiosPromise<vipLevelVO[]> => {
  return request({
    url: '/dgtmedicine/vipLevel/list',
    method: 'get'
  });
};
/**
 * 入会审核状态统计
 * @param id
 */
export const queryMemberApprovalCount = (query?: any): AxiosPromise<any> => {
  return request({
    url: '/dgtmedicine/member/queryMemberApprovalCount',
    method: 'get',
    params: query
  });
};
/**
 * 修改级别
 * @param id
 */
export const editVipLevel = (data: any): AxiosPromise<any> => {
  return request({
    url: '/dgtmedicine/member/editLevel',
    method: 'post',
    data: data
  });
};
/**
 * 修改有效期
 * @param id
 */
export const editValidityDate = (data: any): AxiosPromise<any> => {
  return request({
    url: '/dgtmedicine/member/editValidityDate',
    method: 'post',
    data: data
  });
};


