新增功能
This commit is contained in:
@@ -14,16 +14,16 @@ use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 挂号单状态自动更新
|
||||
* - 预约时间已过:status -> 4(已过号)
|
||||
* - 预约时间已过超过8小时:status -> 2(已取消)
|
||||
* - 不处理:status=3(已完成)、未到时间的单子
|
||||
* - 预约时间已过超过 35 分钟(且未满 8 小时):status -> 4(已过号)
|
||||
* - 预约时间已过超过 8 小时:status -> 2(已取消)
|
||||
* - 不处理:status=3(已完成)、未到时间、刚过号未满 35 分钟的单子
|
||||
*/
|
||||
class UpdateAppointmentStatus extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('update_appointment_status')
|
||||
->setDescription('自动更新挂号单状态:过号->4,超8小时->2(已取消)')
|
||||
->setDescription('自动更新挂号单状态:过号超35分钟->4,超8小时->2(已取消)')
|
||||
->addOption('dry', null, Option::VALUE_NONE, '仅预览不执行');
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ class UpdateAppointmentStatus extends Command
|
||||
$cancelSql = "UPDATE {$table} SET status = 2, update_time = ? WHERE {$cancelWhere}";
|
||||
$cancelCount = $dryRun ? 0 : Db::execute($cancelSql, [$now]);
|
||||
|
||||
// 2. 已过时间但未超8小时 -> 已过号(status=4)
|
||||
$missedWhere = "status = 1 AND CONCAT(appointment_date, ' ', IFNULL(appointment_time, '00:00:00')) < NOW() AND CONCAT(appointment_date, ' ', IFNULL(appointment_time, '00:00:00')) > DATE_SUB(NOW(), INTERVAL 8 HOUR)";
|
||||
// 2. 已过预约时间超过 35 分钟且未满 8 小时 -> 已过号(status=4)
|
||||
$missedWhere = "status = 1 AND CONCAT(appointment_date, ' ', IFNULL(appointment_time, '00:00:00')) < DATE_SUB(NOW(), INTERVAL 35 MINUTE) AND CONCAT(appointment_date, ' ', IFNULL(appointment_time, '00:00:00')) > DATE_SUB(NOW(), INTERVAL 8 HOUR)";
|
||||
$missedSql = "UPDATE {$table} SET status = 4, update_time = ? WHERE {$missedWhere}";
|
||||
$missedCount = $dryRun ? 0 : Db::execute($missedSql, [$now]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user