import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import type { ComplaintForm, ComplaintVO, ComplaintPageVO } from './types';

/**
 * 新增投诉
 * @param data
 */
export const addComplaint = (data: ComplaintForm): AxiosPromise<void> => {
  return request({
    url: '/fulfiller/complaint/add',
    method: 'post',
    data: data
  });
};

/**
 * 根据订单查询投诉记录
 * @param orderId
 */
export const listComplaintByOrder = (orderId: string | number): AxiosPromise<ComplaintVO[]> => {
  return request({
    url: '/fulfiller/complaint/listByOrder',
    method: 'get',
    params: { orderId }
  });
};

/**
 * 根据履约者分页查询投诉记录
 * @param params
 */
export const pageComplaintByFulfiller = (params: { fulfiller: string | number; pageNum: number; pageSize: number }): AxiosPromise<{ total: number; rows: ComplaintPageVO[] }> => {
  return request({
    url: '/fulfiller/complaint/pageByFulfiller',
    method: 'get',
    params
  });
};
