Notice.php
2.3 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* @remark :
* @name :Notice.php
* @author :lyh
* @method :post
* @time :2024/3/6 16:01
*/
namespace App\Console\Commands\Notice;
use App\Models\Com\KeywordVideoTaskLog;
use App\Models\Domain\DomainInfo;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/**
* @remark :通知C端生成界面
* @name :Notice
* @author :lyh
* @method :post
* @time :2024/3/6 16:01
*/
class Notice extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'notice_c';
/**
* The console command description.
*
* @var string
*/
protected $description = '通知C端生成界面';
/**
* @remark :通知C端生成界面
* @name :handle
* @author :lyh
* @method :post
* @time :2023/11/20 15:13
*/
public function handle(){
$yesterday = date('Y-m-d', strtotime('yesterday'));
$keywordVideoModel = new KeywordVideoTaskLog();
$list = $keywordVideoModel->select('project_id')
->groupBy('project_id')->whereBetween('created_at', [$yesterday.' 00:00:00',$yesterday.' 23:59:59'])->get()->toArray();
$project_arr = [];
if(empty($list)){
echo date('Y-m-d H:i:s') . '无需通知' . PHP_EOL;
return false;
}
foreach ($list as $k => $v){
$project_arr[] = $v['project_id'];
}
$domainModel = new DomainInfo();
$domainList = $domainModel->formatQuery(['project_id'=>['in',$project_arr]])->get()->toArray();
if(empty($domainList)){
echo date('Y-m-d H:i:s') . '无域名:'.json_encode($domainList) . PHP_EOL;
return false;
}
foreach ($domainList as $v1){
//TODO::通知C端
$this->curlDelRoute($v1['domain'],$v1['project_id']);
}
return true;
}
/**
* @remark :删除路由通知C端
* @name :curlDelRoute
* @author :lyh
* @method :post
* @time :2023/11/30 14:43
*/
public function curlDelRoute($domain,$project_id){
if (strpos($domain, 'https://') === false) {
$domain = 'https://' . $domain . '/';
}
$url = $domain.'api/update_page/?project_id='.$project_id.'&route=6';
shell_exec('curl -k "'.$url.'"');
return true;
}
}