import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SettlementLevelVO, SettlementLevelForm, SettlementLevelQuery } from '@/api/customer/settlementLevel/types';

/**
 * 查询结算等级列表
 * @param query
 * @returns {*}
 */

export const listSettlementLevel = (query?: SettlementLevelQuery): AxiosPromise<SettlementLevelVO[]> => {
  return request({
    url: '/system/settlementLevel/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询结算等级详细
 * @param id
 */
export const getSettlementLevel = (id: string | number): AxiosPromise<SettlementLevelVO> => {
  return request({
    url: '/system/settlementLevel/' + id,
    method: 'get'
  });
};

/**
 * 新增结算等级
 * @param data
 */
export const addSettlementLevel = (data: SettlementLevelForm) => {
  return request({
    url: '/system/settlementLevel',
    method: 'post',
    data: data
  });
};

/**
 * 修改结算等级
 * @param data
 */
export const updateSettlementLevel = (data: SettlementLevelForm) => {
  return request({
    url: '/system/settlementLevel',
    method: 'put',
    data: data
  });
};

/**
 * 删除结算等级
 * @param id
 */
export const delSettlementLevel = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/settlementLevel/' + id,
    method: 'delete'
  });
};

export function changeShowStatus(id: string | number, isShow: string) {
  const data = {
    id,
    isShow
  };
  return request({
    url: '/system/settlementLevel/changeStatus',
    method: 'put',
    data: data
  });
}
