import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace EnergyHydrogenDetailApi {
  export interface Detail {
    id?: number;
    stationId?: number;
    stationName?: string;
    customerId?: number;
    customerName?: string;
    contractId?: number;
    vehicleId?: number;
    plateNumber?: string;
    hydrogenDate?: string;
    hydrogenQuantity?: number;
    costPrice?: number;
    costAmount?: number;
    customerPrice?: number;
    customerAmount?: number;
    auditStatus?: number;
    deductionStatus?: number;
    settlementStatus?: number;
    billId?: number;
    remark?: string;
    createTime?: string;
  }
}

export function getHydrogenDetailPage(params: PageParam) {
  return requestClient.get<PageResult<EnergyHydrogenDetailApi.Detail>>(
    '/energy/hydrogen-detail/page',
    { params },
  );
}

export function getHydrogenDetail(id: number) {
  return requestClient.get<EnergyHydrogenDetailApi.Detail>(
    '/energy/hydrogen-detail/get',
    { params: { id } },
  );
}

export function updateHydrogenDetail(data: EnergyHydrogenDetailApi.Detail) {
  return requestClient.put('/energy/hydrogen-detail/update', data);
}

export function auditHydrogenDetail(id: number, approved: boolean, remark?: string) {
  return requestClient.post('/energy/hydrogen-detail/audit', null, {
    params: { id, approved, remark },
  });
}

export function batchAuditHydrogenDetail(ids: number[], approved: boolean, remark?: string) {
  return requestClient.post('/energy/hydrogen-detail/batch-audit', null, {
    params: { ids: ids.join(','), approved, remark },
  });
}

export function exportHydrogenDetail(params: any) {
  return requestClient.download('/energy/hydrogen-detail/export-excel', { params });
}
