0eb0cf12fb
移除不再需要的测试脚本、调试页面和解决方案文档,包括: - 各种测试PHP文件(test.php, test_filters.php等) - VIP功能测试和调试页面(test_vip*.php, vip_debug_page.html等) - 数据库连接测试脚本(test_db_connection.php) - 解决方案文档(SOLUTIONS.md, VIP_*_Report.md)
245 lines
8.8 KiB
PHP
245 lines
8.8 KiB
PHP
<?php
|
|
// VIP客户数据验证脚本
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
|
|
// 数据库连接
|
|
function connectDatabase() {
|
|
$servername = "localhost";
|
|
$username = "root";
|
|
$password = "";
|
|
$database = "carwash_booking";
|
|
|
|
try {
|
|
$pdo = new PDO("mysql:host=$servername;dbname=$database;charset=utf8", $username, $password);
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
return $pdo;
|
|
} catch(PDOException $e) {
|
|
die("数据库连接失败: " . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
$pdo = connectDatabase();
|
|
|
|
echo "<!DOCTYPE html>
|
|
<html lang='zh-CN'>
|
|
<head>
|
|
<meta charset='UTF-8'>
|
|
<title>VIP客户数据验证</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; }
|
|
.container { max-width: 1200px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
|
h1, h2 { color: #333; }
|
|
.table { width: 100%; border-collapse: collapse; margin: 20px 0; }
|
|
.table th, .table td { border: 1px solid #ddd; padding: 12px; text-align: left; }
|
|
.table th { background-color: #f2f2f2; font-weight: bold; }
|
|
.table tr:nth-child(even) { background-color: #f9f9f9; }
|
|
.success { color: #28a745; font-weight: bold; }
|
|
.error { color: #dc3545; font-weight: bold; }
|
|
.warning { color: #ffc107; font-weight: bold; }
|
|
.info { color: #17a2b8; }
|
|
.query-box { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 15px; margin: 10px 0; }
|
|
.count-box { background: #e9ecef; border-radius: 4px; padding: 15px; margin: 10px 0; text-align: center; }
|
|
.count-number { font-size: 24px; font-weight: bold; color: #007bff; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class='container'>
|
|
<h1>🔍 VIP客户数据验证报告</h1>";
|
|
|
|
// 1. 检查VIP客户表是否存在
|
|
echo "<h2>1. 数据库表检查</h2>";
|
|
try {
|
|
$stmt = $pdo->query("SHOW TABLES LIKE 'vip_customers'");
|
|
$tableExists = $stmt->rowCount() > 0;
|
|
|
|
if ($tableExists) {
|
|
echo "<p class='success'>✅ vip_customers 表存在</p>";
|
|
|
|
// 获取表结构
|
|
$stmt = $pdo->query("DESCRIBE vip_customers");
|
|
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
echo "<h3>表结构:</h3>";
|
|
echo "<table class='table'>";
|
|
echo "<tr><th>字段名</th><th>类型</th><th>是否为空</th><th>键</th><th>默认值</th><th>额外</th></tr>";
|
|
foreach ($columns as $column) {
|
|
echo "<tr>";
|
|
echo "<td>{$column['Field']}</td>";
|
|
echo "<td>{$column['Type']}</td>";
|
|
echo "<td>{$column['Null']}</td>";
|
|
echo "<td>{$column['Key']}</td>";
|
|
echo "<td>{$column['Default']}</td>";
|
|
echo "<td>{$column['Extra']}</td>";
|
|
echo "</tr>";
|
|
}
|
|
echo "</table>";
|
|
|
|
} else {
|
|
echo "<p class='error'>❌ vip_customers 表不存在</p>";
|
|
}
|
|
} catch (Exception $e) {
|
|
echo "<p class='error'>❌ 表检查失败: " . $e->getMessage() . "</p>";
|
|
}
|
|
|
|
// 2. VIP客户总数统计
|
|
echo "<h2>2. VIP客户统计</h2>";
|
|
try {
|
|
// 总数
|
|
$stmt = $pdo->query("SELECT COUNT(*) as total FROM vip_customers");
|
|
$totalResult = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
$totalCount = $totalResult['total'];
|
|
|
|
echo "<div class='count-box'>";
|
|
echo "<p>VIP客户总数</p>";
|
|
echo "<div class='count-number'>$totalCount</div>";
|
|
echo "</div>";
|
|
|
|
// 活跃状态统计
|
|
$stmt = $pdo->query("SELECT is_active, COUNT(*) as count FROM vip_customers GROUP BY is_active");
|
|
$activeStats = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
echo "<h3>按状态统计:</h3>";
|
|
echo "<table class='table'>";
|
|
echo "<tr><th>状态</th><th>数量</th><th>说明</th></tr>";
|
|
foreach ($activeStats as $stat) {
|
|
$status = $stat['is_active'] ? '活跃' : '非活跃';
|
|
$class = $stat['is_active'] ? 'success' : 'warning';
|
|
echo "<tr class='$class'>";
|
|
echo "<td>$status</td>";
|
|
echo "<td>{$stat['count']}</td>";
|
|
echo "<td>" . ($stat['is_active'] ? '可搜索' : '不可搜索') . "</td>";
|
|
echo "</tr>";
|
|
}
|
|
echo "</table>";
|
|
|
|
} catch (Exception $e) {
|
|
echo "<p class='error'>❌ 统计查询失败: " . $e->getMessage() . "</p>";
|
|
}
|
|
|
|
// 3. 活跃VIP客户详细数据
|
|
echo "<h2>3. 活跃VIP客户详细数据</h2>";
|
|
try {
|
|
$stmt = $pdo->query("SELECT * FROM vip_customers WHERE is_active = 1 ORDER BY created_at DESC");
|
|
$vipCustomers = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if (count($vipCustomers) > 0) {
|
|
echo "<p class='success'>✅ 找到 " . count($vipCustomers) . " 个活跃VIP客户</p>";
|
|
|
|
echo "<table class='table'>";
|
|
echo "<tr>";
|
|
echo "<th>ID</th>";
|
|
echo "<th>客户姓名</th>";
|
|
echo "<th>手机号</th>";
|
|
echo "<th>邮箱</th>";
|
|
echo "<th>车型</th>";
|
|
echo "<th>车牌号</th>";
|
|
echo "<th>注册时间</th>";
|
|
echo "</tr>";
|
|
|
|
foreach ($vipCustomers as $customer) {
|
|
echo "<tr>";
|
|
echo "<td>{$customer['id']}</td>";
|
|
echo "<td><strong>{$customer['customer_name']}</strong></td>";
|
|
echo "<td>{$customer['phone']}</td>";
|
|
echo "<td>{$customer['email']}</td>";
|
|
echo "<td>{$customer['car_model']}</td>";
|
|
echo "<td>{$customer['car_number']}</td>";
|
|
echo "<td>{$customer['created_at']}</td>";
|
|
echo "</tr>";
|
|
}
|
|
echo "</table>";
|
|
|
|
// 显示原始JSON数据
|
|
echo "<h3>原始JSON数据 (API返回格式):</h3>";
|
|
echo "<div class='query-box'>";
|
|
echo "<pre>" . json_encode($vipCustomers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "</pre>";
|
|
echo "</div>";
|
|
|
|
} else {
|
|
echo "<p class='warning'>⚠️ 没有找到活跃的VIP客户</p>";
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
echo "<p class='error'>❌ 查询VIP客户失败: " . $e->getMessage() . "</p>";
|
|
}
|
|
|
|
// 4. 搜索功能测试
|
|
echo "<h2>4. 搜索功能测试</h2>";
|
|
if (isset($vipCustomers) && count($vipCustomers) > 0) {
|
|
echo "<p>基于实际数据进行搜索测试:</p>";
|
|
|
|
// 测试各种搜索词
|
|
$testQueries = [
|
|
'姓名首字' => substr($vipCustomers[0]['customer_name'], 0, 1),
|
|
'姓名中字' => mb_substr($vipCustomers[0]['customer_name'], 1, 1, 'UTF-8'),
|
|
'手机前3位' => substr($vipCustomers[0]['phone'], 0, 3),
|
|
'手机后4位' => substr($vipCustomers[0]['phone'], -4),
|
|
'姓氏' => '张',
|
|
'号段' => '139'
|
|
];
|
|
|
|
foreach ($testQueries as $description => $query) {
|
|
echo "<div class='query-box'>";
|
|
echo "<strong>测试: $description (搜索词: '$query')</strong><br>";
|
|
|
|
$results = [];
|
|
foreach ($vipCustomers as $customer) {
|
|
$nameMatch = mb_stripos($customer['customer_name'], $query, 0, 'UTF-8') !== false;
|
|
$phoneMatch = stripos($customer['phone'], $query) !== false;
|
|
|
|
if ($nameMatch || $phoneMatch) {
|
|
$results[] = $customer['customer_name'] . ' (' . $customer['phone'] . ')';
|
|
}
|
|
}
|
|
|
|
if (count($results) > 0) {
|
|
echo "<span class='success'>✅ 找到 " . count($results) . " 个结果:</span><br>";
|
|
foreach ($results as $result) {
|
|
echo "• $result<br>";
|
|
}
|
|
} else {
|
|
echo "<span class='warning'>⚠️ 未找到匹配结果</span>";
|
|
}
|
|
echo "</div>";
|
|
}
|
|
|
|
} else {
|
|
echo "<p class='warning'>⚠️ 没有VIP客户数据可供测试</p>";
|
|
}
|
|
|
|
// 5. API端点测试
|
|
echo "<h2>5. API端点测试</h2>";
|
|
echo "<p>测试 get_vip_customers.php 接口:</p>";
|
|
|
|
if (file_exists('get_vip_customers.php')) {
|
|
echo "<p class='success'>✅ get_vip_customers.php 文件存在</p>";
|
|
|
|
// 模拟API调用
|
|
ob_start();
|
|
include 'get_vip_customers.php';
|
|
$apiOutput = ob_get_clean();
|
|
|
|
echo "<div class='query-box'>";
|
|
echo "<strong>API输出:</strong><br>";
|
|
echo "<pre>" . htmlspecialchars($apiOutput) . "</pre>";
|
|
echo "</div>";
|
|
|
|
// 尝试解析JSON
|
|
try {
|
|
$apiData = json_decode($apiOutput, true);
|
|
if (json_last_error() === JSON_ERROR_NONE) {
|
|
echo "<p class='success'>✅ API返回有效JSON数据</p>";
|
|
echo "<p>数据记录数: " . (is_array($apiData) ? count($apiData) : 'N/A') . "</p>";
|
|
} else {
|
|
echo "<p class='error'>❌ API返回无效JSON: " . json_last_error_msg() . "</p>";
|
|
}
|
|
} catch (Exception $e) {
|
|
echo "<p class='error'>❌ JSON解析失败: " . $e->getMessage() . "</p>";
|
|
}
|
|
|
|
} else {
|
|
echo "<p class='error'>❌ get_vip_customers.php 文件不存在</p>";
|
|
}
|
|
|
|
echo "</div></body></html>";
|
|
?>
|