0) ? ($amount / $rate) : $amount; $expires_at = date('Y-m-d H:i:s', strtotime('+30 minutes')); // Create order with status 'matching' $stmt = $pdo->prepare("INSERT INTO fiat_orders (user_id, amount, usdt_amount, exchange_rate, currency, status, expires_at, created_at) VALUES (?, ?, ?, ?, ?, 'matching', ?, CURRENT_TIMESTAMP)"); $stmt->execute([$user_id, $amount, $usdt_amount, $rate, $currency, $expires_at]); $order_id = $pdo->lastInsertId(); // Get user IP $user_ip = $_SERVER['REMOTE_ADDR']; if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $user_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } // Explicit notification message for admin/chat $method_info = ($type === 'usdt') ? "USDT ($network)" : "法币 ($currency)"; $msg = "👉 用户发起充值,金额 $amount $currency\n订单号: #$order_id\n方式: $method_info"; $stmt = $pdo->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'user', ?)"); $stmt->execute([$user_id, $msg]); // Redirect to chat header("Location: chat.php"); exit; } else { header("Location: deposit.php"); exit; }