import request from '@/utils/request';
import { OrderMain, OrderProduct, OrderStatusStats } from './orderTypes';

// ==================== 订单管理 ====================

/**
 * 查询当前企业的订单列表
 */
export function getOrderList(params?: any) {
  return request({
    url: '/order/pcOrder/list',
    method: 'get',
    params: params
  });
}

/**
 * 查询订单状态统计
 */
export function getOrderStatusStats() {
  return request({
    url: '/order/pcOrder/statusStats',
    method: 'get'
  });
}

/**
 * 查询订单详情
 */
export function getOrderInfo(id: number) {
  return request({
    url: `/order/pcOrder/${id}`,
    method: 'get'
  });
}

/**
 * 根据订单ID查询订单商品明细
 */
export function getOrderProducts(orderIds: number[]) {
  return request({
    url: '/order/pcOrder/products',
    method: 'get',
    params: { orderIds: orderIds.join(',') }
  });
}

/**
 * 取消订单
 */
export function cancelOrder(data: { id: number; orderStatus?: string }) {
  return request({
    url: '/order/pcOrder/cancel',
    method: 'put',
    data: data
  });
}

/**
 * 审核订单
 * 企业客户审核自己企业的订单
 */
export function checkOrderStatus(data: { id: number; checkStatus: string }) {
  return request({
    url: '/order/pcOrder/checkStatus',
    method: 'put',
    data: data
  });
}

/**
 * 删除订单
 */
export function deleteOrder(ids: number[]) {
  return request({
    url: `/order/pcOrder/${ids.join(',')}`,
    method: 'delete'
  });
}

// ==================== 订单管理 ====================

/**
 * 查询当前企业的已评价订单
 */
export function getEvalutionList(params?: any) {
  return request({
    url: '/order/pcOrderEvaluation/list',
    method: 'get',
    params: params
  });
}

/**
 * 新增订单评价
 */
export function addOrderEvaluation(data: any) {
  return request({
    url: '/order/pcOrderEvaluation',
    method: 'post',
    data: data
  });
}
