完成
This commit is contained in:
@@ -16,23 +16,17 @@ class ExpiredRedis
|
||||
|
||||
// 如果Redis需要密码认证
|
||||
$redis->auth($resis_pwd);
|
||||
|
||||
// 选择数据库(默认0)
|
||||
$redis->select(0);
|
||||
|
||||
// 设置读取超时(-1表示不超时)
|
||||
$redis->setOption(\Redis::OPT_READ_TIMEOUT, -1);
|
||||
|
||||
// 订阅键过期事件频道
|
||||
// __keyevent@0__:expired 表示监听0号数据库的键过期事件
|
||||
$redis->psubscribe(['__keyevent@0__:expired'], function ($pattern, $channel, $key) use($redis){
|
||||
// 这里可以添加你的业务逻辑
|
||||
// 例如根据键名前缀处理不同业务
|
||||
$str = 'expired:sms:';
|
||||
if (strpos($key, $str) === 0) {
|
||||
Log::info ("替换之前: " . $key);
|
||||
$id = str_replace($str, '', $key);
|
||||
Log::info ("替换过的ID: " . $id);
|
||||
// 发给队列
|
||||
Redis::send('send.mark.sms', '1,' . $id);
|
||||
Log::info ("处理订单过期: {$id}\n{}");
|
||||
|
||||
@@ -9,11 +9,29 @@ class MessagePushTask
|
||||
{
|
||||
public function onWorkerStart()
|
||||
{
|
||||
// 每月1号 查询短信发送状态
|
||||
new Crontab('0 0 1 * *', function(){
|
||||
Log::info('营销接收次数更新开始执行---->');
|
||||
\app\model\SaveUserPushNumber::savePushNumber();
|
||||
Log::info('营销接收次数更新执行结束---->');
|
||||
// 查询短信发送状态
|
||||
new Crontab('0 */5 * * * *', function(){
|
||||
$command = 'cd ' . BASE_PATH . ' && php webman querysmsstatus';
|
||||
// 存储命令输出的数组
|
||||
$output = [];
|
||||
// 存储命令返回状态码(0为成功,非0为失败)
|
||||
$status = 0;
|
||||
// 执行命令
|
||||
exec($command, $output, $status);
|
||||
// 处理执行结果
|
||||
Log::info('查询短信发送状态:执行状态'. $status . '/执行结果:' . json_encode($output, JSON_UNESCAPED_UNICODE));
|
||||
});
|
||||
// 查询模版审核状态
|
||||
new Crontab('0 */5 * * * *', function(){
|
||||
$command = 'cd ' . BASE_PATH . ' && php webman querysmstempstatus';
|
||||
// 存储命令输出的数组
|
||||
$output = [];
|
||||
// 存储命令返回状态码(0为成功,非0为失败)
|
||||
$status = 0;
|
||||
// 执行命令
|
||||
exec($command, $output, $status);
|
||||
// 处理执行结果
|
||||
Log::info('查询模版审核状态:执行状态'. $status . '/执行结果:' . json_encode($output, JSON_UNESCAPED_UNICODE));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user