TaskChangedToProcessing.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
+-----------------------------------------------------------------------------------------------------------------------
* 任务自动开锁
+-----------------------------------------------------------------------------------------------------------------------
*
* PHP version 7
*
* @category App\Jobs\Gift
* @package App\Jobs\Gift
* @author Richer <yangzi1028@163.com>
* @date 2022年10月27日15:29:08
* @copyright 2022-2022 Richer (http://www.umu888.com)
* @license http://www.Richer.com License
* @link http://www.Richer.com
*/
namespace App\Jobs\Score;
use App\Jobs\BaseJob;
use App\Models\Score\Task;
/**
* Class TaskChangedToProcessing
*
* @package App\Jobs\Score
*/
class TaskChangedToProcessing extends BaseJob
{
/**
* Create a new job instance.
*
* @param Task $model
* @param integer $delay 延迟
*/
public function __construct(Task $model, int $delay)
{
$this->desc = '评分任务自动开始!';
// 执行
parent::__construct($model, $delay);
}
/**
* 定义这个任务类具体的执行逻辑
* 当队列处理器从队列中取出任务时,会调用 handle() 方法
* Execute the job.
*
* @return void
* @throws \Throwable
*/
public function handle()
{
// 记录日志
$this->log($this->desc, 'begin');
if ($this->attempts() > 1) {
$this->log('尝试次数过多');
} else {
$model = $this->model;
if ($model->status !== Task::NOT_STARTED) {
return;
}
}
$this->log($this->desc, 'end');
}
}