feat(vip): 添加VIP客户管理功能
- 创建vip_customers表存储VIP客户信息 - 实现VIP客户添加、查看和删除功能 - 在预约页面增加VIP客户选择功能 - 添加VIP管理页面和API接口
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
|
||||
// 数据库连接配置
|
||||
$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);
|
||||
|
||||
// 查询所有VIP客户,按创建时间倒序排列
|
||||
$stmt = $pdo->query("
|
||||
SELECT id, customer_name, phone, car_model, car_number, email, birthday, is_active
|
||||
FROM vip_customers
|
||||
WHERE is_active = 1
|
||||
ORDER BY created_at DESC
|
||||
");
|
||||
|
||||
$vipCustomers = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
echo json_encode($vipCustomers, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
|
||||
} catch(PDOException $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'error' => '数据库连接失败',
|
||||
'message' => $e->getMessage()
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user