import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ReturnReasonVO, ReturnReasonForm, ReturnReasonQuery } from '@/api/order/returnReason/types';

/**
 * 查询退货原因列表
 * @param query
 * @returns {*}
 */

export const listReturnReason = (query?: ReturnReasonQuery): AxiosPromise<ReturnReasonVO[]> => {
  return request({
    url: '/system/returnReason/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询退货原因详细
 * @param id
 */
export const getReturnReason = (id: string | number): AxiosPromise<ReturnReasonVO> => {
  return request({
    url: '/system/returnReason/' + id,
    method: 'get'
  });
};

/**
 * 新增退货原因
 * @param data
 */
export const addReturnReason = (data: ReturnReasonForm) => {
  return request({
    url: '/system/returnReason',
    method: 'post',
    data: data
  });
};

/**
 * 修改退货原因
 * @param data
 */
export const updateReturnReason = (data: ReturnReasonForm) => {
  return request({
    url: '/system/returnReason',
    method: 'put',
    data: data
  });
};

/**
 * 删除退货原因
 * @param id
 */
export const delReturnReason = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/returnReason/' + id,
    method: 'delete'
  });
};

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