Crontab.php
728 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use think\Db;
/**
* 定时任务
*/
class Crontab extends Frontend
{
protected $layout = '';
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
}
/**
* 每月1号凌晨清空用户暂存的上月的打卡总工时
*/
public function clear()
{
Db::name('user')->where('1=1')->update([
'work_hours_month'=>0,
'work_salary_month'=>0,
'work_subsidy_month'=>0,
'recruit_subsidy_month'=>0,
'log_days_month'=>0
]);
echo '执行成功';
}
}