You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
34 lines
1.0 KiB
4 months ago
|
<?php
|
||
|
namespace app\home\job;
|
||
|
|
||
|
use think\facade\Log;
|
||
|
use think\queue\Job;
|
||
|
|
||
|
class RegDone
|
||
|
{
|
||
|
public function fire(Job $job, $data)
|
||
|
{
|
||
|
Log::info("think-queue 邮箱注册后的队列任务开始:" . json_encode($data));
|
||
|
try {
|
||
|
$phpEmail = new \app\utility\SendEmail();
|
||
|
for($times = 1; $times <= 3; $times++) {
|
||
|
$bool = $phpEmail->sendEmail($data['email'], $data['title'], $data['content']);
|
||
|
if ($bool) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
Log::info("think-queue 邮箱注册后的队列任务正常结束." );
|
||
|
} catch (\Exception $e) {
|
||
|
Log::info("think-queue 邮箱注册后的队列任务异常:message=".$e->getMessage().'date='.json_encode($data));
|
||
|
}
|
||
|
|
||
|
// 删除任务
|
||
|
$job->delete();
|
||
|
}
|
||
|
|
||
|
// 任务失败后执行的方法
|
||
|
public function failed($data)
|
||
|
{
|
||
|
Log::info("think-queue 用户注册后的队列任务执行失败:" . json_encode($data));
|
||
|
}
|
||
|
}
|