<?php
/**
 * 获取订单金额
 */
require_once dirname(__DIR__) . '/config.php';

header('Content-Type: application/json');

$order_no = $_GET['order_no'] ?? '';

if (empty($order_no)) {
    echo json_encode(['success' => false, 'amount' => 0]);
    exit;
}

$order = $db->fetchOne("SELECT amount FROM orders WHERE order_no = '$order_no'");

if ($order) {
    echo json_encode(['success' => true, 'amount' => $order['amount']]);
} else {
    echo json_encode(['success' => false, 'amount' => 0]);
}