import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SubOrderAppealVO, SubOrderAppealQuery, SubOrderAppealForm, SubOrderAppealAudit } from './types';

/**
 * 查询子订单申诉列表
 * @param query 查询对象
 */
export function listSubOrderAppeal(query: SubOrderAppealQuery): AxiosPromise<SubOrderAppealVO[]> {
  return request({
    url: '/order/subOrderAppeal/list',
    method: 'get',
    params: query
  });
}

/**
 * 获取子订单申诉详细信息
 * @param id 主键
 */
export function getSubOrderAppeal(id: string | number): AxiosPromise<SubOrderAppealVO> {
  return request({
    url: '/order/subOrderAppeal/' + id,
    method: 'get'
  });
}

/**
 * 新增子订单申诉
 * @param data 申诉表单对象
 */
export function addSubOrderAppeal(data: SubOrderAppealForm) {
  return request({
    url: '/order/subOrderAppeal',
    method: 'post',
    data: data
  });
}

/**
 * 修改子订单申诉
 * @param data 申诉表单对象
 */
export function updateSubOrderAppeal(data: SubOrderAppealForm) {
  return request({
    url: '/order/subOrderAppeal',
    method: 'put',
    data: data
  });
}

/**
 * 删除子订单申诉
 * @param ids 主键串
 */
export function delSubOrderAppeal(ids: string | number | (string | number)[]) {
  return request({
    url: '/order/subOrderAppeal/' + ids,
    method: 'delete'
  });
}

/**
 * 审核子订单申诉
 * @param data 审核对象
 */
export function auditSubOrderAppeal(data: SubOrderAppealAudit) {
  return request({
    url: '/order/subOrderAppeal/audit',
    method: 'put',
    data: data
  });
}

/**
 * 根据订单ID查询服务变更记录列表
 * @param orderId 订单ID
 */
export function listSubOrderAppealByOrderId(orderId: string | number): AxiosPromise<SubOrderAppealVO[]> {
  return request({
    url: '/order/subOrderAppeal/listByOrderId/' + orderId,
    method: 'get'
  });
}

