471aed949c
添加VIP客户管理页面和测试页面,更新数据库名称为carwash_booking 在SQL文件中添加示例VIP客户数据,完善VIP功能展示页面
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
header('Cache-Control: no-cache, must-revalidate');
|
|
|
|
// 获取客户ID
|
|
$id = $_GET['id'] ?? null;
|
|
|
|
if (!$id) {
|
|
http_response_code(400);
|
|
echo json_encode(['error' => '缺少客户ID参数'], JSON_UNESCAPED_UNICODE);
|
|
exit;
|
|
}
|
|
|
|
// 数据库连接配置
|
|
$host = 'localhost';
|
|
$dbname = 'carwash_booking';
|
|
$username = 'root';
|
|
$password = '';
|
|
|
|
try {
|
|
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $username, $password);
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
// 查询指定ID的VIP客户
|
|
$stmt = $pdo->prepare("
|
|
SELECT id, customer_name, phone, car_model, car_number, email, birthday, notes, is_active
|
|
FROM vip_customers
|
|
WHERE id = ? AND is_active = 1
|
|
");
|
|
$stmt->execute([$id]);
|
|
|
|
$vipCustomer = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($vipCustomer) {
|
|
echo json_encode($vipCustomer, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
|
} else {
|
|
http_response_code(404);
|
|
echo json_encode(['error' => 'VIP客户不存在'], JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
} catch(PDOException $e) {
|
|
http_response_code(500);
|
|
echo json_encode([
|
|
'error' => '数据库连接失败',
|
|
'message' => $e->getMessage()
|
|
], JSON_UNESCAPED_UNICODE);
|
|
}
|
|
?>
|