import { request } from '@/utils/request';

// 商家订单列表
export function getSellerOrders(params: {
  page?: number;
  pageSize?: number;
  status?: string;
  orderNo?: string;
}) {
  return request({
    url: '/api/merchant/orders',
    method: 'GET',
    data: params,
    useSellerToken: true,
  });
}

// 商家订单详情
export function getSellerOrderDetail(orderNo: string) {
  return request({
    url: `/api/merchant/orders/${orderNo}`,
    method: 'GET',
    useSellerToken: true,
  });
}

// 确认订单
export function confirmOrder(orderNo: string) {
  return request({
    url: `/api/merchant/orders/${orderNo}/confirm`,
    method: 'PUT',
    useSellerToken: true,
  });
}

// 拒绝订单
export function rejectOrder(orderNo: string, reason: string) {
  return request({
    url: `/api/merchant/orders/${orderNo}/reject`,
    method: 'PUT',
    data: { reason },
    useSellerToken: true,
  });
}

// 办理入住
export function checkinOrder(orderNo: string) {
  return request({
    url: `/api/merchant/orders/${orderNo}/checkin`,
    method: 'PUT',
    useSellerToken: true,
  });
}

// 确认离店
export function checkoutOrder(orderNo: string) {
  return request({
    url: `/api/merchant/orders/${orderNo}/checkout`,
    method: 'PUT',
    useSellerToken: true,
  });
}

// 同意退款
export function approveRefund(orderNo: string) {
  return request({
    url: `/api/merchant/orders/${orderNo}/approve-refund`,
    method: 'PUT',
    useSellerToken: true,
  });
}

// 拒绝退款
export function rejectRefund(orderNo: string, reason: string) {
  return request({
    url: `/api/merchant/orders/${orderNo}/reject-refund`,
    method: 'PUT',
    data: { reason },
    useSellerToken: true,
  });
}
