添加每日清除火热值脚本

This commit is contained in:
2025-08-11 17:44:54 +08:00
parent ada241ce02
commit fbe214c9a4
2 changed files with 50 additions and 0 deletions

View File

@@ -24,4 +24,11 @@ class Cron
$cron = new \app\cron\controller\TenSeconds(); $cron = new \app\cron\controller\TenSeconds();
$cron->index(); $cron->index();
} }
//每天执行
public function DaySeconds()
{
$cron = new \app\cron\controller\DaySeconds();
$cron->index();
}
} }

View File

@@ -0,0 +1,43 @@
<?php
namespace app\cron\controller;
use think\Db;
/*
* 定时任务,每秒执行的方法
*/
class DaySeconds
{
/*
* 运行函数
*/
function index()
{
echo "清除房间热度值:\n";
$this->clear_room_today_hot_value();//0点以后房间热度值清零
echo "\n";
}
/*
* 0点以后房间热度值清零
* 配置:定时脚本每天 0点 执行
* 配置http://vschat.qxmier.com/api/Cron/DaySeconds
*/
public function clear_room_today_hot_value() {
$where = [];
$where['delete_time'] = 0;
$where['is_show_room'] = 1;
$room = db::name('vs_room')->where($where)->select();
echo date('Y-m-d H:i:s').' 开始清零:'.count($room)."\n";
foreach ($room as $key => $value) {
$data = [
'today_hot_value' => 0,
];
db::name('vs_room')->where(['id' => $value['id']])->save($data);
}
echo date('Y-m-d H:i:s').' 完成'."\n";
die;
}
}