Files
yusheng-php/application/cron/controller/DaySeconds.php

43 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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点 执行
* 配置app.qxcms.com/Core/ClearUserRoomCion/index
*/
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;
}
}