import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ZhongcheReturnVO, ZhongcheReturnForm, ZhongcheReturnQuery } from '@/api/order/zhongcheReturn/types';

/**
 * 查询中车售后单列表
 * @param query
 * @returns {*}
 */

export const listZhongcheReturn = (query?: ZhongcheReturnQuery): AxiosPromise<ZhongcheReturnVO[]> => {
  return request({
    url: '/order/zhongcheReturn/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询中车售后单详细
 * @param id
 */
export const getZhongcheReturn = (id: string | number): AxiosPromise<ZhongcheReturnVO> => {
  return request({
    url: '/order/zhongcheReturn/' + id,
    method: 'get'
  });
};

/**
 * 新增中车售后单
 * @param data
 */
export const addZhongcheReturn = (data: ZhongcheReturnForm) => {
  return request({
    url: '/order/zhongcheReturn',
    method: 'post',
    data: data
  });
};

/**
 * 修改中车售后单
 * @param data
 */
export const updateZhongcheReturn = (data: ZhongcheReturnForm) => {
  return request({
    url: '/order/zhongcheReturn',
    method: 'put',
    data: data
  });
};

/**
 * 删除中车售后单
 * @param id
 */
export const delZhongcheReturn = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/zhongcheReturn/' + id,
    method: 'delete'
  });
};

/**
 * 接受售后
 */
export const acceptAfterSale = (data: any) => {
  return request({
    url: '/order/zhongcheReturn/accept/aftersale',
    method: 'put',
    data: data
  });
};

/**
 * 拒绝售后
 */
export const rejectAfterSale = (id: number | string, rejectReason: string) => {
  return request({
    url: '/order/zhongcheReturn/reject/aftersale',
    method: 'put',
    params: { id, rejectReason }
  });
};

/**
 * 确认收到退货
 */
export const confirmReceived = (id: number | string) => {
  return request({
    url: '/order/zhongcheReturn/confirm/received',
    method: 'put',
    params: { id }
  });
};

/**
 * 确认退款完成
 */
export const refundAfterSale = (id: number | string) => {
  return request({
    url: '/order/zhongcheReturn/refund/aftersale',
    method: 'put',
    params: { id }
  });
};
