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

相关推荐
漏刻有时12 小时前
PHP GeoJSON转PNG地图渲染程序开发笔记、源码解读、问题复盘与整改方案
android·笔记·php
always_TT14 小时前
【Python 日志记录:logging 模块入门】
开发语言·python·php
Immortal__y17 小时前
Upload-Labs 关卡防御方式
php
JonLee202019 小时前
适配 Yii 3.0,php-casbin/yii-permission 3.0 正式发布
安全·php·rbac·yii·权限·casbin
Web3李李20 小时前
自建公链:Web3生态长期可持续发展的核心底层布局
web3·区块链·软件开发·定制开发·公链开发·主链开发·主网开发
QH1392923188021 小时前
# R&S ZNB43 ZNA43 ZNA67矢量网络分析仪
开发语言·网络·php
名字还没想好☜1 天前
Python concurrent.futures 实战:用 ThreadPoolExecutor 并发处理 + as_completed 收结果
数据库·python·php·并发
风样滴男人哟1 天前
PHP特性之反射类ReflectionClass机制
android·开发语言·php
nvd111 天前
GCP L4 Passthrough 负载均衡器“假死超时”深度排查复盘
运维·php·负载均衡
2601_965798471 天前
ForumLab Review: Fast PHP Script for SEO Forum Sites
android·adb·php