import axios from 'axios';
import qs from 'query-string';
import type { CommonPageResult } from './common';
import type { Pagination } from '@/types/global';

export interface OrderSummaryParams extends Pagination {
  roadUid?: string;
  date?: string;
}

export interface OrderSummaryRecord {
  merchantUid: string;
  merchantName: string;
  succeedCount: number;
  succeedShowAmount: number;
  succeedFactAmount: number;
  totalShowAmount: number;
  totalFactAmount: number;
  totalCount: number;
  rate: number;
  date: string;
  failedCount: number;
  waitedCount: number;
}

export function queryOrderSummaryList(params: OrderSummaryParams) {
  return axios.get<CommonPageResult<OrderSummaryRecord>>(
    '/api/orderInfo/summary/getList',
    {
      params,
      paramsSerializer: obj => {
        return qs.stringify(obj);
      }
    }
  );
}
