代码初始化
This commit is contained in:
61
application/cron/controller/TenSeconds.php
Normal file
61
application/cron/controller/TenSeconds.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\cron\controller;
|
||||
|
||||
use think\Db;
|
||||
|
||||
|
||||
/*
|
||||
* 定时任务,每秒执行的方法
|
||||
*/
|
||||
class TenSeconds
|
||||
{
|
||||
/*
|
||||
* 运行函数
|
||||
*/
|
||||
function index()
|
||||
{
|
||||
echo "房间在线人数:\n";
|
||||
$this->auction_end_notice();//拍卖房结束提醒
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
|
||||
protected function auction_end_notice()
|
||||
{
|
||||
$auction_list = db::name('vs_room')->field('id')->where(['room_status'=>1,'apply_status' => 2,'type_id' =>['<>',6]])->select();
|
||||
$data_count = 0;
|
||||
$data_number = 0;
|
||||
if($auction_list){
|
||||
foreach ($auction_list as &$value){
|
||||
$num = model('api/Room')->room_online_number($value['id']);
|
||||
// $on_pit_num = db::name('vs_room_pit')->field('user_id')->where(['room_id' => $value['id'],'user_id' => ['<>',0]])->count();
|
||||
if($num['code'] == 1){
|
||||
if($num['data']['online_number'] > 0){
|
||||
$text = [
|
||||
'online_number' => $num['data']['online_number'],
|
||||
'room_id' => $value['id'],//接受房间id
|
||||
];
|
||||
model('api/Chat')->sendMsg(1036,$value['id'],$text);
|
||||
$data_number++;
|
||||
}
|
||||
}
|
||||
// else{
|
||||
// if($on_pit_num > 0){
|
||||
// $text = [
|
||||
// 'online_number' => $on_pit_num,
|
||||
// 'room_id' => $value['id'],//接受房间id
|
||||
// ];
|
||||
// model('api/Chat')->sendMsg(1036,$value['id'],$text);
|
||||
// $data_number++;
|
||||
// }
|
||||
// }
|
||||
|
||||
$data_count++;
|
||||
}
|
||||
}
|
||||
echo "房间共" . $data_count . "条数据\n";
|
||||
echo "房间在线人数>0 的总共" . $data_number . "条数据\n";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user