BtEvents.php
1.5 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
67
68
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2022/11/03
* Time: 09:53
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Class BtEvents
* @package App\Models
*/
class BtEvents extends Model
{
/**
* @var string $table
*/
protected $table = 'bt_events';
// 最大执行次数
const MAX_TRIES_TIMES = 3;
const STATUS_INIT = 0;
const STATUS_FINISH = 1;
const STATUS_ERROR = 9;
const TYPE_CREATE_SITE = 1;
const TYPE_DELETE_SITE = 2;
const TYPE_CREATE_SSL = 3;
const TYPE_RENEWAL_SSL = 4;
const TYPE_HTTP_TO_HTTPS_OPEN = 5;
const TYPE_HTTP_TO_HTTPS_CLOSE = 6;
const TYPE_EVENT_CALLBACK = 99;
/**
* @return array
*/
public static function typeMap()
{
return [
self::TYPE_CREATE_SITE => '创建站点',
self::TYPE_DELETE_SITE => '删除站点',
self::TYPE_CREATE_SSL => '创建ssl证书',
self::TYPE_RENEWAL_SSL => '续签ssl证书',
self::TYPE_HTTP_TO_HTTPS_OPEN => '开启强制https',
self::TYPE_HTTP_TO_HTTPS_CLOSE => '关闭强制https',
];
}
/**
* @param $type
* @param $param
* @return mixed
*/
public static function createBtEvent($type, $param, $start_at = '')
{
$start_at = $start_at ?: date('Y-m-d H:i:s');
$event = new self();
$event->type = $type;
$event->param = $param;
$event->start_at = $start_at;
$event->save();
return $event->id;
}
}