f605aa1c98
- 创建vip_customers表存储VIP客户信息 - 实现VIP客户添加、查看和删除功能 - 在预约页面增加VIP客户选择功能 - 添加VIP管理页面和API接口
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_db';
|
|
$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);
|
|
}
|
|
?>
|