import { post, get, put } from '@/utils/request';

export function createOrder(data: {
  roomId: number;
  checkInDate: string;
  checkOutDate: string;
  contactName: string;
  contactPhone: string;
  roomCount?: number;
  guestCount?: number;
  contactIdCard?: string;
  couponId?: number;
  remark?: string;
  paymentMethod?: string;
}) {
  return post('/api/app/orders', data);
}

export function getOrderList(params: { page?: number; pageSize?: number; status?: string }) {
  return get('/api/app/orders', params);
}

export function getOrderDetail(orderNo: string) {
  return get(`/api/app/orders/${orderNo}`);
}

export function cancelOrder(orderNo: string, reason: string) {
  return put(`/api/app/orders/${orderNo}/cancel`, { reason });
}

export function refundOrder(orderNo: string, reason: string) {
  return put(`/api/app/orders/${orderNo}/refund`, { reason });
}

export function payOrder(orderNo: string, paymentMethod: 'wechat' | 'alipay' | 'balance' = 'wechat') {
  return post('/api/app/orders/pay', { orderNo, paymentMethod });
}
