import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SettlementMethodVO, SettlementMethodForm, SettlementMethodQuery } from '@/api/customer/settlementMethod/types';

/**
 * 查询结算方式列表
 * @param query
 * @returns {*}
 */

export const listSettlementMethod = (query?: SettlementMethodQuery): AxiosPromise<SettlementMethodVO[]> => {
  return request({
    url: '/system/settlementMethod/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询结算方式详细
 * @param id
 */
export const getSettlementMethod = (id: string | number): AxiosPromise<SettlementMethodVO> => {
  return request({
    url: '/system/settlementMethod/' + id,
    method: 'get'
  });
};

/**
 * 新增结算方式
 * @param data
 */
export const addSettlementMethod = (data: SettlementMethodForm) => {
  return request({
    url: '/system/settlementMethod',
    method: 'post',
    data: data
  });
};

/**
 * 修改结算方式
 * @param data
 */
export const updateSettlementMethod = (data: SettlementMethodForm) => {
  return request({
    url: '/system/settlementMethod',
    method: 'put',
    data: data
  });
};

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

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