pro如何添加定时任务

Pro v2.4版本开始后台可以开关控制定时任务,那如何添加新的定时任务呢?

第一步:设置定时任务名称及标识;

文件app\controller\admin\v1\system\SystemTimer中task_name()方法

复制代码
/**定时任务名称及标识

 * @return mixed

 */

public function task_name() {

    $data = [

        'auto_cancel' => '自动取消订单',

        'auto_take' => '自动确认收货',

        'auto_comment' => '自动好评',

        'auto_clear_integral' => '自动清空用户积分',

        'auto_off_user_svip' => '自动取消用户到期svip',

        'auto_agent' => '自动解绑上下级',

        'auto_clear_poster' => '自动清除昨日海报',

        'auto_sms_code' => '更新短信状态',

        'auto_live' => '自动更新直播产品状态和直播间状态',

        'auto_pink' => '拼团状态自动更新',

        'auto_show' => '自动上下架商品',

        'auto_channel' => '渠道码定时任务',

        'auto_moment' => '定时创建发送朋友圈任务',

        'auto_group_task' => '定时发送群发任务',

        'auto_seckill' => '定时清理秒杀数据过期的数据缓存'

    ];

    return $this->success($data);

}

如:auto_group_task是标识 '定时发送群发任务' 是定时任务名称

第二步:写定时任务内容;

文件app\listener\system\timer\SystemTimer 中implement_timer()方法

方法中 case 加定时任务标识;如:

第三步:后台设置新增定时任务执行周期后,重启swoole

相关推荐
Web极客码1 天前
如何通过GUI或命令行更改Ubuntu 20.04的DNS设置
linux·ubuntu·php
毕设源码-朱学姐1 天前
【开题答辩全过程】以 基于PHP的高校心理测评系统的设计与实现为例,包含答辩的问题和答案
开发语言·php
JaguarJack1 天前
PHP 8.6 新增 clamp() 函数
后端·php
BingoGo1 天前
PHP 8.6 新增 clamp() 函数
后端·php
真正的醒悟1 天前
图解网络39
网络·智能路由器·php
无名修道院2 天前
DVWA 靶场搭建:Windows11(phpstudy 搭建)(步骤 + 截图 + 常见问题)
数据库·网络安全·渗透测试·靶场·php·dvwa·phpstudy
爱倒腾的老唐2 天前
00、Altium Designer 23 使用问题记录
笔记·php
catchadmin2 天前
PHP 8.5 垃圾回收改进
php
云和数据.ChenGuang2 天前
`post_max_size`、`max_execution_time`、`max_input_time` 是 **PHP 核心配置参数**
开发语言·mysql·php·zabbix·mariadb
Evan芙2 天前
php多版本编译安装
开发语言·php