作者 lyh

gx

@@ -18,6 +18,8 @@ use App\Models\Manage\EntryPosition; @@ -18,6 +18,8 @@ use App\Models\Manage\EntryPosition;
18 use App\Models\Manage\ManageHr; 18 use App\Models\Manage\ManageHr;
19 use App\Models\Product\Keyword; 19 use App\Models\Product\Keyword;
20 use App\Models\Product\Product; 20 use App\Models\Product\Product;
  21 +use App\Models\Project\DeployOptimize;
  22 +use App\Models\Project\MinorLanguages;
21 use App\Models\Project\Project; 23 use App\Models\Project\Project;
22 use App\Models\WebSetting\WebSettingService; 24 use App\Models\WebSetting\WebSettingService;
23 use App\Services\ProjectServer; 25 use App\Services\ProjectServer;
@@ -262,74 +264,29 @@ class Demo extends Command @@ -262,74 +264,29 @@ class Demo extends Command
262 // } 264 // }
263 265
264 public function handle(){ 266 public function handle(){
265 -// $projectModel = new Project();  
266 -// $list = $projectModel->list(['delete_status'=>0]);  
267 -// foreach ($list as $v){  
268 - ProjectServer::useProject(150);  
269 - $this->getKeywordImage();  
270 - DB::disconnect('custom_mysql');  
271 -// }  
272 - }  
273 -  
274 - /**  
275 - * @remark :根据关键字获取产品主图  
276 - * @name :getKeywordList  
277 - * @author :lyh  
278 - * @method :post  
279 - * @time :2024/2/23 16:28  
280 - */  
281 - public function getKeywordImage($keyword_id = 1,$project_id = 150){  
282 - $keywordModel = new Keyword();  
283 - $keywordInfo = $keywordModel->read(['id'=>$keyword_id]);  
284 - //TODO::所有产品  
285 - $thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id);  
286 - $domainModel = new DomainInfo();  
287 - $domainInfo = $domainModel->read(['project_id'=>$project_id]);  
288 - if(!empty($domainInfo)){  
289 - $keywordInfo['route'] = $domainInfo['domain'].'/'.$keywordInfo['route'];  
290 - }  
291 - $data = [  
292 - 'url'=>$keywordInfo['route'],  
293 - 'title'=>$keywordInfo['title'],  
294 - 'keyword_title'=>$keywordInfo['keyword_title'],  
295 - 'keyword_content'=>$keywordInfo['keyword_content'],  
296 - 'product_list'=>$thumb ?? []  
297 - ];  
298 - dd($data);  
299 - return $data;  
300 - }  
301 -  
302 - /**  
303 - * 关键词聚合页-推荐&热门产品  
304 - */  
305 - public function getRecommendAndHotProducts($route,$project_id): ?array  
306 - {  
307 - $productIds = [];  
308 - $productKeyword = Keyword::where("project_id",$project_id)->where("route",$route)->first();  
309 - if (!empty($productKeyword)){  
310 - $productsQuery = Product::where("project_id", $project_id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get();  
311 - if (!empty($productsQuery)){  
312 - foreach ($productsQuery as $item){  
313 - $productIds[] = $item->id; 267 + $projectModel = new DeployOptimize();
  268 + $list = $projectModel->list();
  269 + foreach ($list as $v){
  270 + $data = [];
  271 + if(!empty($v['minor_languages'])){
  272 + foreach ($v['minor_languages'] as $k1=> $v1){
  273 + if(!empty($v1['tl']) && !empty($v1['type'])){
  274 + $data[] = [
  275 + 'language'=>$v1['tl'],
  276 + 'type'=>$v1['type'],
  277 + 'keywords'=>$v1['keywords'],
  278 + 'service_day'=>$v1['service_day'],
  279 + 'project_id'=>$v['project_id']
  280 + ];
  281 + }
314 } 282 }
315 - if (count($productIds)<7){  
316 - $randomData = Product::where("project_id", $project_id)->where("status",1)->whereNotIn('id', $productIds)->inRandomOrder()->take(13-count($productIds))->get();  
317 - $products = $productsQuery->merge($randomData);  
318 - }else{  
319 - $products = $productsQuery;  
320 - }  
321 - }else{  
322 - $products = Product::where("project_id", $project_id)->where("status",1)->inRandomOrder()->take(13)->get();  
323 - }  
324 - }  
325 - $data = [];  
326 - if (!empty($products)){  
327 - foreach ($products as $item){  
328 - $data[] = !empty($item->thumb) && $item->thumb['url'] != "" ? getImageUrl($item->thumb['url']) : "";  
329 } 283 }
  284 + $languageModel = new MinorLanguages();
  285 + $languageModel->insert($data);
330 } 286 }
331 - return $data; 287 +
332 } 288 }
  289 +
333 public function printMessage() 290 public function printMessage()
334 { 291 {
335 $client = new Client(); 292 $client = new Client();