import request from '../utils/request';

/**
 * 创建订单
 * @param {number} workId - 作品ID
 */
export const createOrder = async (workId) => {
  try {
    const response = await request.post('/orders/create', {
      work_id: workId
    });
    return {
      success: true,
      data: response
    };
  } catch (error) {
    return {
      success: false,
      message: error.message
    };
  }
};

/**
 * 获取我的订单列表
 */
export const getMyOrders = async () => {
  try {
    const response = await request.get('/orders/my');
    return {
      success: true,
      data: response
    };
  } catch (error) {
    return {
      success: false,
      message: error.message
    };
  }
};

/**
 * 模拟支付（仅用于测试）
 * @param {number} orderId - 订单ID
 */
export const mockPay = async (orderId) => {
  try {
    const response = await request.post(`/orders/pay/${orderId}`);
    return {
      success: true,
      data: response
    };
  } catch (error) {
    return {
      success: false,
      message: error.message
    };
  }
};
