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

const prefix = 'register/';

export interface RegisterOrderItem {
  id: number;
  order_no: string;
  order_number?: number;
  price: number;
  is_pay: 0 | 1;
  type: number;
  status: number;
  refund_status?: number;
  refund_time?: string;
  created_at: string;
  store_id?: number;
  doctor_info?: {
    avatar?: string;
    depart?: { name: string };
    name: string;
  };
  user_patient?: { age?: number; mobile?: string; name: string; sex?: number };
  store?: { id?: number; mobile?: string; name: string; position?: string };
  salesperson_id?: number;
  salesperson?: { avatar?: string; id: number; nick_name: string };
  prescription?: { id: number; prescription_no: string }[];
  /** 详情弹窗使用的支付/取消/拒诊等扩展字段，后端 selectField 全量返回 */
  [key: string]: any;
}

export async function getRegisterListApi(data: Record<string, unknown>) {
  return requestClient.get<{ items: RegisterOrderItem[]; total: number }>(
    `${prefix}list`,
    { params: data },
  );
}

export async function refundRegisterApi(data: Record<string, unknown>) {
  return requestClient.post<any>(`${prefix}refund`, data);
}
