workerman/app/controller/IndexController.php

63 lines
1.6 KiB
PHP

<?php
namespace app\controller;
use support\Request;
use support\Db;
use app\result\Result;
use Carbon\Carbon;
use app\model\Timetable;
class IndexController
{
public function index(Request $request)
{
static $readme;
if (!$readme) {
$readme = '700';
// $readme = file_get_contents(base_path('README.md'));
}
return $readme;
}
/**
* 更新时间
*/
public function updated($whether_manual = 1)
{
// 获取当前时间
$current = Carbon::now();
// 添加 21 天到当前时间
$trialExpires = $current->addDays(21);
$timetable=new Timetable;
$timetable->date=$trialExpires->toDateString();
$timetable->tip=$whether_manual==0?'自动提交':'手动提交';
$timetable->save();
return Result::show(200, 'ok', ['time' => $timetable]);
}
/**
* 每天访问一次的任务
*/
public function scheduled_tasks($name = 'ThinkPHP6')
{
$db_time = Timetable::where('id', Timetable::where('id','>',0)->max('id'))->first();
$time = $db_time['date'];
// 获取当前时间
$current = Carbon::now();
for ($i = 0; $i < 8; $i++) {
$current->subDay($i);
if (strcmp($current->toDateString(), $time) == 0) {
$i == 7 ? $this->updated(0) : '';
return Result::show(200, 'ok', ['time' => $current->toDateString(), 'time2' => $time]);
}
}
return Result::show(200,'ok','');
}
public function send_msg($title, $body)
{
}
}