This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
carwash_order/get_daily_booking_duration.php
T
wsh5485 b963c2b513 feat: 新增预约系统功能及优化
- 添加获取每日预约时长的API接口
- 实现0元订单自动标记为已付款功能
- 优化预约信息复制功能,增加服务时长和备注
- 新增预约信息模板系统
- 在待处理预约页面添加时长提示功能
- 优化移动端触摸反馈和倒计时显示
2025-12-06 05:05:15 +08:00

29 lines
818 B
PHP

<?php
// 引入数据库连接文件
require 'db_connect.php';
// 获取请求参数
$date = $_GET['date'];
// 验证日期格式
if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $date)) {
echo json_encode(['error' => 'Invalid date format']);
exit;
}
try {
// 查询指定日期的总预约时长
$sql = "SELECT SUM(duration) as total_duration FROM bookings WHERE DATE(start_time) = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$date]);
$row = $stmt->fetch();
// 获取总时长,如果没有预约则返回0
$total_duration = $row['total_duration'] ? $row['total_duration'] : 0;
// 返回结果
echo json_encode(['total_duration' => $total_duration]);
} catch (PDOException $e) {
echo json_encode(['error' => 'Database query failed: ' . $e->getMessage()]);
}