命令行改版 remove

This commit is contained in:
ASUS 2025-10-28 14:47:51 +08:00
parent 694c6369e2
commit c40d59f66d
1 changed files with 63 additions and 0 deletions

63
scripts/applysmstemp.php Normal file
View File

@ -0,0 +1,63 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../support/bootstrap.php';
use PhpAmqpLib\Connection\AMQPStreamConnection;
use support\Log;
use Webman\RedisQueue\Redis;
// 申请新短信模版/营销短信发送
$host = config('cons.mq.host');
$port = config('cons.mq.port');
$user = config('cons.mq.user');
$password = config('cons.mq.password');
$queue = config('cons.mq.queue_t') . '-apply.sms.temp';
// 防止空闲时间断线必须设置心跳
$connection = new AMQPStreamConnection($host, $port, $user, $password,
'/',
false,
'AMQPLAIN',
null,
'en_US',
60,
60,
null,
false,
30
);
$rabbit_channel = $connection->channel();
$rabbit_channel->queue_declare($queue, false, true, false, false, false, [
// 'x-message-ttl' => ['I', 180000]
]);
$callback = function ($msg) use ($queue){
$data = $msg->body;
Log::info('MQ收到消息[申请新短信模版/营销短信发送/微信模版消息]--->' . $data . "\n");
$arr = explode(',', $data);
if(isset($arr[2])) {
$type = $arr[2];
if($type == 'applySmsTemp') {
// 发给队列 短信模版审核
$a = Redis::send('apply.sms.temp', $data);
Log::info('消息队列投递结果----》' . $a);
}elseif ($type == 'sendMarkSms') {
// 发给队列 营销短信发送
Redis::send('send.mark.sms', $data);
}elseif ($type == 'sendWechatTemp') {
// 发给队列 发送微信模版消息
Redis::send('send.wechat.temp', $data);
}
}else {
Log::info('MQ收到消息[申请新短信模版/营销短信发送/微信模版消息]格式错误');
}
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
};
$rabbit_channel->basic_consume($queue, '', false, false, false, false, $callback);
while ($rabbit_channel->is_consuming()) {
$rabbit_channel->wait();
}
$rabbit_channel->close();
$connection->close();