lyhDemo.php
10.0 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
/**
* @remark :
* @name :lyhDemo.php
* @author :lyh
* @method :post
* @time :2025/3/24 9:38
*/
namespace App\Console\Commands\LyhTest;
use App\Console\Commands\Domain\DomainInfo;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\Ai\AiBlogAuthor;
use App\Models\Com\NoticeLog;
use App\Models\Com\V6WeeklyReport;
use App\Models\Project\AiBlogTask;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\Project\ProjectAiSetting;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Models\RouteMap\RouteMap;
use App\Models\Visit\Visit;
use App\Models\WebSetting\WebLanguage;
use App\Models\WebSetting\WebSetting;
use App\Models\Workchat\MessagePush;
use App\Services\AiBlogService;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
class lyhDemo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'lyh_demo';
/**
* The console command description.
*
* @var string
*/
protected $description = '更新路由';
public function handle(){
$projectArr = [3257,1835,1834];
$v6WeekModel = new V6WeeklyReport();
foreach ($projectArr as $item){
$projectModel = new Project();
$latest = $v6WeekModel->formatQuery(['project_id'=>$item])->orderBy('id', 'desc')->first();
$list = $projectModel->read(['delete_status'=>0,'id'=>$item],['id','title','is_weekly_report','main_lang_id']);
$latest['main_lang_id'] = $list['main_lang_id'];
$latest['is_weekly_report'] = $list['is_weekly_report'];
$latest['title'] = $list['title'];
$this->workChatMessage($latest,$item);
}
return true;
}
public function workChatMessage($data,$project_id){
$arr = [];
//项目是否有绑定群
$friend_id = ProjectAssociation::where('project_id', $project_id)
->where('status', ProjectAssociation::STATUS_NORMAL)
->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)
->value('friend_id');
if(!$friend_id){
echo date('Y-m-d H:i:s') . '没有绑定企微群:'.$project_id . PHP_EOL;
return false;
}
$content = '';
$content1 = '';
if(!empty($data['inquiry_total'])){
$content1 .= '项目共计已收到询盘 '.$data['inquiry_total'].'条,';
if(!empty($data['week_inquiry_total'])){
$content1 .= '本周新收 '.$data['week_inquiry_total'].' 封询盘。';
}
if(!empty($data['inquiry_country'])){
$data['inquiry_country'] = json_decode($data['inquiry_country'],true);
arsort($data['inquiry_country']);
$data['inquiry_country'] = array_slice($data['inquiry_country'], 0, 4, true);
$country = '';
foreach ($data['inquiry_country'] as $k => $v){
$country .= $k.',';
};
$country = trim($country,',');
if(!empty($country)){
$content1 .= '询盘主要来源于'.$country.'等国家地区。';
}
}
$content1 .= '如有高质量客户,请您密切关注与跟进;';
}
if(!empty($content1)){
$arr[] = $content1;
}
$content2 = '';
if(!empty($data['google_indexed_num']) || !empty($data['google_links_num']) || !empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num']) || !empty($data['daily_average_num'])){
$content2 .= '项目截止目前';
if($data['main_lang_id'] == 8){
$title = 'Yandex';
}else{
$title = '谷歌';
}
if(!empty($data['google_indexed_num'])){
$content2 .= $title.'收录量:'.$data['google_indexed_num'].'条,';
}
if(!empty($data['google_links_num'])){
//获取上一次的外链数
$latestRecord = V6WeeklyReport::where(['project_id'=>$project_id])->orderBy('id', 'desc')->first();
if(!empty($latestRecord)){
if($latestRecord['google_links_num'] != $data['google_links_num']){
$content2 .= '外链量:'.$data['google_links_num'].'条,';
}
}else{
$content2 .= '外链量:'.$data['google_links_num'].'条,';
}
}
if(!empty($data['keyword_home_num']) || !empty($data['keyword_three_num']) || !empty($data['keyword_five_num']) || !empty($data['keyword_ten_num'])){
$content2 .= $title.'搜索排名';
if(!empty($data['keyword_home_num'])){
$content2 .= '首页关键词数量为:'.$data['keyword_home_num'].'个,';
}
if(!empty($data['keyword_three_num'])){
$content2 .= '前三页关键词数量为:'.$data['keyword_three_num'].'个,';
}
if(!empty($data['keyword_five_num'])){
$content2 .= '前五页关键词数量为:'.$data['keyword_five_num'].'个,';
}
if(!empty($data['keyword_ten_num'])){
$content2 .= '前十页关键词数量为:'.$data['keyword_ten_num'].'个,';
}
}
if(!empty($data['daily_average_num'])){
$content2 .= '本周日均访客量:'.$data['daily_average_num'].'+。';
}
$content2 .= PHP_EOL.'全球搜建议用户持续分析、选择、添加企业、产品、服务等相关关键词进行优化和监控,以覆盖更多相关排名和流量;';
}
if(!empty($content2)){
$arr[] = $content2;
}
$content3 = '';
if(!empty($data['product_num']) || !empty($data['news_num']) || !empty($data['week_product_num']) || !empty($data['week_news_num'])){
if(!empty($data['product_num']) || !empty($data['news_num'])){
$content3 .= '项目截止目前';
if(!empty($data['product_num'])){
$content3 .= '发布产品:'.$data['product_num'].'条,';
}
if(!empty($data['news_num'])){
$content3 .= '发布新闻:'.$data['news_num'].'条。';
}
}
if(!empty($data['week_product_num']) || !empty($data['week_news_num'])){
$content3 .= '本周新增';
if(!empty($data['week_product_num'])){
$content3 .= '产品:'.$data['week_product_num'].'条,';
}
if(!empty($data['week_news_num'])){
$content3 .= '新闻:'.$data['week_news_num'].'条。';
}
}
$content3 .= PHP_EOL.'全球搜建议用户保持网站内容的持续更新与完善,可参考谷歌关于创建实用、可靠、以用户为中心的内容的相关建议:https://developers.google.com/search/docs/fundamentals/creating-helpful-content?hl=zh-cn;';
}
if(!empty($content3)){
$arr[] = $content3;
}
$content4 = '';
if(!empty($data['main_update_num'])){
$content4 .= '网站加载速度维护及主站页面更新'.$data['main_update_num'].'次。';
}
if(!empty($data['aggregation_update_num'])){
$content4 .= '聚合页主站页面更新'.$data['aggregation_update_num'].'次。';
}
if(!empty($data['minor_update_num'])){
$content4 .= '小语种站页面更新'.$data['minor_update_num'].'次。';
}
if(!empty($data['aggregation_minor_update_num'])){
$content4 .= '聚合页小语种站页面'.$data['aggregation_minor_update_num'].'次。';
}
if(!empty($content4)){
$content4 = PHP_EOL.'本周主要优化工作包括:TDK、H标签、Img标签等优化设置排查与进一步完善,Sitemap更新与网页收录提交,外链新增与排查。'.$content4;
}
if(!empty($content4)){
$arr[] = $content4;
}
if(empty($arr)){
return true;
}
foreach ($arr as $key => $val){
$content .= ($key+1).','.$val.PHP_EOL.PHP_EOL;
}
$tomorrowNineAM = date('Y-m-d 09:00:00', time());
if(empty($content)){
return true;
}
$tips = 'Tips:'.PHP_EOL.'1、全球搜V6.0系统提供网页TDK、H标签、Img标签等用户自定义编辑接口且辅以AI创作工具,用户可进一步对相关优化设置进行精细化优化与调整;'.PHP_EOL.'2、全球搜V6.0系统提供小语种页面精准校对翻译功能,用户可进一步对已翻译小语种页面进行人工翻译校对;'.PHP_EOL.'3、全球搜V6.0系统支持绑定Facebook、LinkedIn、X(原Twitter)等社媒账号,可一键同步转发网站上发布的产品和新闻至社媒账号动态,建议用户用起来哦;'.PHP_EOL.'4、如用户有较丰富的企业、产品、服务相关视频素材,全球搜建议用户及时创建YouTube主页,并在YouTube和网站相关网页上同步发布视频;';
$message = "【全球搜V6.0周报】" . PHP_EOL . $content . PHP_EOL . $tips;
$param = [
'project_id'=>$project_id,
'friend_id'=>$friend_id,
'type'=>MessagePush::TYPE_WEEK,
'content'=> $message,
'ref_ids'=>'',
'send_time'=>$tomorrowNineAM,
'status'=>0,
];
//写入一条推送消息 自动消费
$messagePushModel = new MessagePush();
$messagePushModel->add($param);
return true;
}
}