import request from '@/utils/request';

/**
 * 取消订单
 * @param {Object} data - 请求参数
 * @param {number} data.orderId - 订单ID
 * @author antigravity
 */
export function cancelOrderApi(data) {
    return request({
        url: '/order/subOrder/cancel',
        method: 'PUT',
        data
    });
}

/**
 * 拒绝接单
 * @param {Object} data - 请求参数
 * @param {number} data.orderId - 订单ID
 * @param {string} data.rejectReason - 拒绝理由
 * @author antigravity
 */
export function rejectOrderApi(data) {
    return request({
        url: '/order/subOrder/reject',
        method: 'PUT',
        data
    });
}

/**
 * 获取待接单列表
 * @param {Object} params - { service, minPrice, maxPrice, pageNum, pageSize }
 */
export function getPendingOrders(params) {
  return request({
    url: '/order/subOrder/listPendingAccept',
    method: 'GET',
    data: params
  })
}

/**
 * 接单
 * @param {number} orderId - 订单ID
 */
export function acceptOrder(orderId) {
  return request({
    url: '/order/subOrder/accept',
    method: 'PUT',
    data: { orderId }
  })
}

/**
 * 获取订单数量统计数据
 */
export function getOrderCount() {
  return request({
    url: '/order/subOrder/count',
    method: 'GET'
  })
}

/**
 * 分页获取统计页面的订单列表
 * @param {Object} params - { status, pageNum, pageSize }
 */
export function getStatisticOrders(params) {
  return request({
    url: '/order/subOrder/listOnStatistic',
    method: 'GET',
    data: params
  })
}

/**
 * 获取我的订单列表
 * @param {Object} params - { status, content, service, startServiceTime, endServiceTime }
 */
export function getMyOrders(params) {
  return request({
    url: '/order/subOrder/listOnMyOrder',
    method: 'GET',
    data: params
  })
}

/**
 * 获取订单详情
 * @param {number} id - 订单ID
 */
export function getOrderInfo(id) {
  return request({
    url: `/order/subOrder/getInfo?id=${id}`,
    method: 'GET'
  })
}

/**
 * 订单打卡
 * @param {Object} data - { orderId, photos, content, step, title, startFlag, endFlag }
 */
export function clockIn(data) {
  return request({
    url: '/order/subOrder/clockIn',
    method: 'PUT',
    data
  })
}

/**
 * 提交宠护小结
 * @param {Object} data - { orderId, content }
 */
export function submitNursingSummary(data) {
  return request({
    url: '/order/subOrder/nursingSummary',
    method: 'PUT',
    data
  })
}
