SendProduct.php
3.8 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
* @remark :
* @name :SendProduct.php
* @author :lyh
* @method :post
* @time :2024/8/30 14:41
*/
namespace App\Console\Commands\Product;
use App\Models\Blog\Blog;
use App\Models\Domain\DomainInfo;
use App\Models\News\News;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SendProduct extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'send_product';
/**
* The console command description.
*
* @var string
*/
protected $description = '自动发布--根据发布时间发布产品';
/**
* @remark :发布
* @name :handle
* @author :lyh
* @method :post
* @time :2024/8/30 14:42
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['delete_status'=>0]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$domainModel = new DomainInfo();
$domain = $domainModel->getProjectIdDomain($v['id']);
if(empty($domain)){
continue;
}
$arr1 = $this->sendProduct();
$arr2 = $this->sendBlog();
$arr3 = $this->sendNews();
$url = array_merge((array)$arr1,(array)$arr2,(array)$arr3);
if(!empty($url)){
$c_url = $domain.'api/update_page/';
$param = [
'project_id' => $v['id'],
'type' => 1,
'route' => 3,
'url' => $url,
'language'=> [],
'is_sitemap' => 0
];
http_post($c_url, json_encode($param));
}
//TODO::通知C端生成界面
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :发布产品
* @name :sendProduct
* @author :lyh
* @method :post
* @time :2024/8/30 14:44
*/
public function sendProduct(){
$start_date = date('Y-m-d 00:00:00');
$end_date = date('Y-m-d 23:59:59');
$productModel = new Product();
$arr = $productModel->formatQuery(['send_time'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('route')->toArray();
$productModel->edit(['status'=>1],['send_time'=>['between',[$start_date,$end_date]],'status'=>3]);
return $arr;
}
/**
* @remark :定时发布博客
* @name :sendBlog
* @author :lyh
* @method :post
* @time :2024/8/30 15:19
*/
public function sendBlog(){
$start_date = date('Y-m-d 00:00:00');
$end_date = date('Y-m-d 23:59:59');
$blogModel = new Blog();
$arr = $blogModel->formatQuery(['release_at'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('url')->toArray();
$blogModel->edit(['status'=>1],['release_at'=>['between',[$start_date,$end_date]],'status'=>3]);
return $arr;
}
/**
* @remark :定时发布新闻
* @name :sendNews
* @author :lyh
* @method :post
* @time :2024/8/30 15:19
*/
public function sendNews(){
$start_date = date('Y-m-d 00:00:00');
$end_date = date('Y-m-d 23:59:59');
$newsModel = new News();
$arr = $newsModel->formatQuery(['release_at'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('url')->toArray();
$newsModel->edit(['status'=>1],['release_at'=>['between',[$start_date,$end_date]],'status'=>3]);
return $arr;
}
}