import request from '@/utils/request';
import type { ApiResult } from '@/api';
import { Order, OrderParam } from '@/api/order/model';

/**
 * 菜品预定统计
 */
export async function countOrderGoods(params: any) {
  const res = await request.get<ApiResult<any>>(
    '/apps/bc-statistics/baoCanUsers',
    {
      params
    }
  );
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function repairData(params?: OrderParam) {
  const res = await request.get<ApiResult<Order[]>>(
    '/apps/bc-statistics/repairData',
    {
      params
    }
  );
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
