workerman/app/controller/IndexController.php

64 lines
1.6 KiB
PHP
Raw Normal View History

2024-04-16 10:41:39 +08:00
<?php
namespace app\controller;
use support\Request;
2024-04-20 11:04:06 +08:00
use support\Db;
2024-04-20 14:59:53 +08:00
use app\result\Result;
use Carbon\Carbon;
2024-04-16 10:41:39 +08:00
class IndexController
{
public function index(Request $request)
{
static $readme;
if (!$readme) {
2024-04-20 11:04:06 +08:00
$readme = '70';
// $readme = file_get_contents(base_path('README.md'));
2024-04-16 10:41:39 +08:00
}
return $readme;
}
2024-04-20 14:59:53 +08:00
/**
* 更新时间
*/
public function updated($name = 'ThinkPHP6')
2024-04-16 10:41:39 +08:00
{
2024-04-20 14:59:53 +08:00
// 获取当前时间
$current = Carbon::now();
// 添加 21 天到当前时间
$trialExpires = $current->addDays(21);
$data = ['date' => $trialExpires->toDateString(), 'tip' => ' '];
// $result = Db::table("demo")->where("id",1)->find();
// dump($result);
Db::table('time_log')->insert($data);
return Result::show(200, 'ok', ['time' => $trialExpires]);
2024-04-16 10:41:39 +08:00
}
2024-04-20 11:04:06 +08:00
2024-04-20 14:59:53 +08:00
/**
* 每天访问一次的任务
*/
public function scheduled_tasks($name = 'ThinkPHP6')
{
$db_time = Db::table('time_log')->where('id', Db::table('time_log')->max('id'))->first();
//dump($db_time);
$time = $db_time['date'];
// 获取当前时间
$current = Carbon::now();
for ($i = 0; $i < 8; $i++) {
$current->subDay($i);
if (strcmp($current->toDateString(), $time) == 0) {
echo "to do ";
//$this->updated("");
$i == 7 ? $this->updated("") : '';
return Result::show(200, 'ok', ['time' => $current->toDateString(), 'time2' => $time]);
}
}
2024-04-16 10:41:39 +08:00
}
2024-04-20 14:59:53 +08:00
public function send_msg($title, $body)
2024-04-20 11:09:02 +08:00
{
}
2024-04-16 10:41:39 +08:00
}