|
@@ -3,6 +3,10 @@ |
|
@@ -3,6 +3,10 @@ |
|
3
|
namespace App\Console\Commands;
|
3
|
namespace App\Console\Commands;
|
|
4
|
|
4
|
|
|
5
|
use App\Helper\Common;
|
5
|
use App\Helper\Common;
|
|
|
|
6
|
+use App\Helper\Translate;
|
|
|
|
7
|
+use App\Models\Ai\AiCommand as AiCommandModel;
|
|
|
|
8
|
+use App\Models\Project\DeployOptimize;
|
|
|
|
9
|
+use App\Models\Project\Project;
|
|
6
|
use App\Services\ProjectServer;
|
10
|
use App\Services\ProjectServer;
|
|
7
|
use Illuminate\Console\Command;
|
11
|
use Illuminate\Console\Command;
|
|
8
|
use Illuminate\Support\Facades\DB;
|
12
|
use Illuminate\Support\Facades\DB;
|
|
@@ -83,20 +87,26 @@ class UpdateSeoTdk extends Command |
|
@@ -83,20 +87,26 @@ class UpdateSeoTdk extends Command |
|
83
|
$seo_arr = json_decode($v['seo_mate'], true) ?: [];
|
87
|
$seo_arr = json_decode($v['seo_mate'], true) ?: [];
|
|
84
|
//更新seo_title
|
88
|
//更新seo_title
|
|
85
|
if(!isset($seo_arr['title'])){
|
89
|
if(!isset($seo_arr['title'])){
|
|
|
|
90
|
+ $setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first()->toArray();
|
|
86
|
//生成seo_title
|
91
|
//生成seo_title
|
|
87
|
- $seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']);
|
92
|
+ if(!empty($setting['product_prefix']) && !empty($setting['product_suffix'])){
|
|
|
|
93
|
+ $seo_arr['title'] = $setting['product_prefix'] . '-' . $seo_arr['title'] . '-' . $setting['product_suffix'];
|
|
|
|
94
|
+ }else{
|
|
|
|
95
|
+ $seo_arr['title'] = $this->ai_send('seo_title',$seo_arr['title']);
|
|
|
|
96
|
+ }
|
|
88
|
}
|
97
|
}
|
|
89
|
//更新seo_keyword
|
98
|
//更新seo_keyword
|
|
90
|
if(!isset($seo_arr['keyword'])){
|
99
|
if(!isset($seo_arr['keyword'])){
|
|
91
|
- $seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']);
|
100
|
+ $seo_arr['keyword'] = $this->ai_send('seo_keywords',$v['title']);
|
|
92
|
}
|
101
|
}
|
|
93
|
//更新seo_keyword
|
102
|
//更新seo_keyword
|
|
94
|
if(!isset($seo_arr['description'])){
|
103
|
if(!isset($seo_arr['description'])){
|
|
95
|
- $seo_arr['description'] = $this->ai_send('product_seo_description',$v['title']);
|
104
|
+ $seo_arr['description'] = $this->ai_send('seo_meta_description',$v['title']);
|
|
96
|
}
|
105
|
}
|
|
97
|
$ser_str = json_encode($seo_arr,true);
|
106
|
$ser_str = json_encode($seo_arr,true);
|
|
98
|
DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update(['seo_mate'=>$ser_str]);
|
107
|
DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update(['seo_mate'=>$ser_str]);
|
|
99
|
}
|
108
|
}
|
|
|
|
109
|
+
|
|
100
|
}
|
110
|
}
|
|
101
|
return true;
|
111
|
return true;
|
|
102
|
}
|
112
|
}
|
|
@@ -115,13 +125,19 @@ class UpdateSeoTdk extends Command |
|
@@ -115,13 +125,19 @@ class UpdateSeoTdk extends Command |
|
115
|
$v = (array)$v;
|
125
|
$v = (array)$v;
|
|
116
|
$data = [];
|
126
|
$data = [];
|
|
117
|
if(empty($v['seo_title'])){
|
127
|
if(empty($v['seo_title'])){
|
|
118
|
- $data['seo_title'] = $this->ai_send('news_seo_title',$v['name']);
|
128
|
+ $setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first()->toArray();
|
|
|
|
129
|
+ //生成seo_title
|
|
|
|
130
|
+ if(!empty($setting['single_page_suffix'])){
|
|
|
|
131
|
+ $data['seo_title'] = $v['name'] . '-' . $setting['single_page_suffix'];
|
|
|
|
132
|
+ }else{
|
|
|
|
133
|
+ $data['seo_title'] = $this->ai_send('seo_title',$v['name']);
|
|
|
|
134
|
+ }
|
|
119
|
}
|
135
|
}
|
|
120
|
if(empty($v['seo_keywords'])){
|
136
|
if(empty($v['seo_keywords'])){
|
|
121
|
- $data['seo_keywords'] = $this->ai_send('news_seo_keyword',$v['name']);
|
137
|
+ $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
|
|
122
|
}
|
138
|
}
|
|
123
|
if(empty($v['seo_description'])){
|
139
|
if(empty($v['seo_description'])){
|
|
124
|
- $data['seo_description'] = $this->ai_send('news_seo_description',$v['name']);
|
140
|
+ $data['seo_description'] = $this->ai_send('seo_meta_description',$v['name']);
|
|
125
|
}
|
141
|
}
|
|
126
|
if(!$data){
|
142
|
if(!$data){
|
|
127
|
continue;
|
143
|
continue;
|
|
@@ -146,13 +162,19 @@ class UpdateSeoTdk extends Command |
|
@@ -146,13 +162,19 @@ class UpdateSeoTdk extends Command |
|
146
|
$v = (array)$v;
|
162
|
$v = (array)$v;
|
|
147
|
$data = [];
|
163
|
$data = [];
|
|
148
|
if(empty($v['seo_title'])){
|
164
|
if(empty($v['seo_title'])){
|
|
149
|
- $data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']);
|
165
|
+ $setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first()->toArray();
|
|
|
|
166
|
+ //生成seo_title
|
|
|
|
167
|
+ if(!empty($setting['single_page_suffix'])){
|
|
|
|
168
|
+ $data['seo_title'] = $v['name'] . '-' . $setting['single_page_suffix'];
|
|
|
|
169
|
+ }else{
|
|
|
|
170
|
+ $data['seo_title'] = $this->ai_send('seo_title',$v['name']);
|
|
|
|
171
|
+ }
|
|
150
|
}
|
172
|
}
|
|
151
|
if(empty($v['seo_keywords'])){
|
173
|
if(empty($v['seo_keywords'])){
|
|
152
|
- $data['seo_keywords'] = $this->ai_send('blog_seo_keyword',$v['name']);
|
174
|
+ $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
|
|
153
|
}
|
175
|
}
|
|
154
|
if(empty($v['seo_description'])){
|
176
|
if(empty($v['seo_description'])){
|
|
155
|
- $data['seo_description'] = $this->ai_send('blog_seo_description',$v['name']);
|
177
|
+ $data['seo_description'] = $this->ai_send('seo_meta_description',$v['name']);
|
|
156
|
}
|
178
|
}
|
|
157
|
if(!$data){
|
179
|
if(!$data){
|
|
158
|
continue;
|
180
|
continue;
|
|
@@ -164,6 +186,70 @@ class UpdateSeoTdk extends Command |
|
@@ -164,6 +186,70 @@ class UpdateSeoTdk extends Command |
|
164
|
}
|
186
|
}
|
|
165
|
|
187
|
|
|
166
|
/**
|
188
|
/**
|
|
|
|
189
|
+ * @remark :单页面更新tdk
|
|
|
|
190
|
+ * @name :updatePage
|
|
|
|
191
|
+ * @author :lyh
|
|
|
|
192
|
+ * @method :post
|
|
|
|
193
|
+ * @time :2023/10/30 11:04
|
|
|
|
194
|
+ */
|
|
|
|
195
|
+ public function updatePage($project_id){
|
|
|
|
196
|
+ $list = DB::connection('custom_mysql')->select(['title','keywords','description','project_id'])->table('gl_web_custom_template')->where(['project_id'=>$project_id])->get()->toArray();
|
|
|
|
197
|
+ if(!empty($list)){
|
|
|
|
198
|
+ foreach ($list as $v){
|
|
|
|
199
|
+ $v = (array)$v;
|
|
|
|
200
|
+ $data = [];
|
|
|
|
201
|
+ if(empty($v['seo_title'])){
|
|
|
|
202
|
+ $setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first()->toArray();
|
|
|
|
203
|
+ //生成seo_title
|
|
|
|
204
|
+ if(!empty($setting['single_page_suffix'])){
|
|
|
|
205
|
+ $data['title'] = $v['title'] . '-' . $setting['single_page_suffix'];
|
|
|
|
206
|
+ }else{
|
|
|
|
207
|
+ $data['title'] = $this->ai_send('seo_title',$v['title']);
|
|
|
|
208
|
+ }
|
|
|
|
209
|
+ }
|
|
|
|
210
|
+ if(empty($v['keywords'])){
|
|
|
|
211
|
+ //
|
|
|
|
212
|
+ $data['keywords'] = $this->ai_send('seo_keywords',$v['title']);
|
|
|
|
213
|
+ }
|
|
|
|
214
|
+ if(empty($v['description'])){
|
|
|
|
215
|
+ $data['description'] = $this->ai_send('page_meta_description',$v['title']);
|
|
|
|
216
|
+ }
|
|
|
|
217
|
+ if(!$data){
|
|
|
|
218
|
+ continue;
|
|
|
|
219
|
+ }
|
|
|
|
220
|
+ DB::connection('custom_mysql')->table('gl_blog')->where(['id'=>$v['id']])->update($data);
|
|
|
|
221
|
+ }
|
|
|
|
222
|
+ }
|
|
|
|
223
|
+ }
|
|
|
|
224
|
+
|
|
|
|
225
|
+ /**
|
|
|
|
226
|
+ * @remark :获取公司名称
|
|
|
|
227
|
+ * @name :companyName
|
|
|
|
228
|
+ * @author :lyh
|
|
|
|
229
|
+ * @method :post
|
|
|
|
230
|
+ * @time :2023/10/30 11:22
|
|
|
|
231
|
+ */
|
|
|
|
232
|
+ public function companyName($project_id){
|
|
|
|
233
|
+ $projectModel = new Project();
|
|
|
|
234
|
+ $info = $projectModel->read(['project_id'=>$project_id],['id','company']);
|
|
|
|
235
|
+ return $info['company'];
|
|
|
|
236
|
+ }
|
|
|
|
237
|
+
|
|
|
|
238
|
+ /**
|
|
|
|
239
|
+ * @remark :获取公司核心关键词
|
|
|
|
240
|
+ * @name :companyName
|
|
|
|
241
|
+ * @author :lyh
|
|
|
|
242
|
+ * @method :post
|
|
|
|
243
|
+ * @time :2023/10/30 11:22
|
|
|
|
244
|
+ */
|
|
|
|
245
|
+ public function mainKeywords($project_id){
|
|
|
|
246
|
+ $projectOptimizeModel = new DeployOptimize();
|
|
|
|
247
|
+ $info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','main_keywords']);
|
|
|
|
248
|
+ explode(',',$info[])
|
|
|
|
249
|
+ return $info['company'];
|
|
|
|
250
|
+ }
|
|
|
|
251
|
+
|
|
|
|
252
|
+ /**
|
|
167
|
* @remark :AI发送
|
253
|
* @remark :AI发送
|
|
168
|
* @name :ai_send
|
254
|
* @name :ai_send
|
|
169
|
* @author :lyh
|
255
|
* @author :lyh
|
|
@@ -171,7 +257,7 @@ class UpdateSeoTdk extends Command |
|
@@ -171,7 +257,7 @@ class UpdateSeoTdk extends Command |
|
171
|
* @time :2023/8/19 10:40
|
257
|
* @time :2023/8/19 10:40
|
|
172
|
*/
|
258
|
*/
|
|
173
|
public function ai_send($key,$keywords){
|
259
|
public function ai_send($key,$keywords){
|
|
174
|
- $chat_url = 'v2/openai_chat';
|
260
|
+ $chat_url = 'v2/openai_chat_qqs';
|
|
175
|
$param = [
|
261
|
$param = [
|
|
176
|
'key'=>$key,
|
262
|
'key'=>$key,
|
|
177
|
'keywords'=>$keywords,
|
263
|
'keywords'=>$keywords,
|
|
@@ -179,4 +265,5 @@ class UpdateSeoTdk extends Command |
|
@@ -179,4 +265,5 @@ class UpdateSeoTdk extends Command |
|
179
|
$data = Common::send_openai_msg($chat_url,$param);
|
265
|
$data = Common::send_openai_msg($chat_url,$param);
|
|
180
|
return $data['text'];
|
266
|
return $data['text'];
|
|
181
|
}
|
267
|
}
|
|
|
|
268
|
+
|
|
182
|
} |
269
|
} |