作者 lyh

变更数据

@@ -4,6 +4,7 @@ namespace App\Console\Commands\Ai; @@ -4,6 +4,7 @@ namespace App\Console\Commands\Ai;
4 4
5 use App\Http\Logic\Aside\Project\ProjectLogic; 5 use App\Http\Logic\Aside\Project\ProjectLogic;
6 use App\Models\Ai\AiBlog; 6 use App\Models\Ai\AiBlog;
  7 +use App\Models\Ai\AiBlogKeyword;
7 use App\Models\Ai\AiBlogOpenLog; 8 use App\Models\Ai\AiBlogOpenLog;
8 use App\Models\Project\AiBlogTask as AiBlogTaskModel; 9 use App\Models\Project\AiBlogTask as AiBlogTaskModel;
9 use App\Models\Project\Project; 10 use App\Models\Project\Project;
@@ -77,6 +78,9 @@ class AiBlogAutoPublish extends Command @@ -77,6 +78,9 @@ class AiBlogAutoPublish extends Command
77 $this->output("项目{$project->id}未到执行时间" . $next_auto_date); 78 $this->output("项目{$project->id}未到执行时间" . $next_auto_date);
78 continue; 79 continue;
79 } 80 }
  81 + $aiKeywordModel = new AiBlogKeyword();
  82 + $keywords = $aiKeywordModel->getValue(['project_id'=>$this->user['project_id']],'keywords');
  83 + if(!empty($keywords)){
80 //核心关键词+网站关键词+白帽关键词 84 //核心关键词+网站关键词+白帽关键词
81 $main_keywords = ProjectKeyword::where('project_id', $project->id)->value('main_keyword'); 85 $main_keywords = ProjectKeyword::where('project_id', $project->id)->value('main_keyword');
82 $main_keywords = explode("\r\n", $main_keywords); 86 $main_keywords = explode("\r\n", $main_keywords);
@@ -88,6 +92,11 @@ class AiBlogAutoPublish extends Command @@ -88,6 +92,11 @@ class AiBlogAutoPublish extends Command
88 $site_keywords = explode(",", $site_keywords); 92 $site_keywords = explode(",", $site_keywords);
89 $keywords = array_filter(array_merge($main_keywords, $site_keywords, $seo_keywords)); 93 $keywords = array_filter(array_merge($main_keywords, $site_keywords, $seo_keywords));
90 $keywords = array_map('trim', $keywords); 94 $keywords = array_map('trim', $keywords);
  95 + }else{
  96 + $keywords = explode("\r\n", $keywords);
  97 + $keywords = array_map('trim', $keywords); // 清理空格
  98 + $keywords = array_filter($keywords); // 移除空值
  99 + }
91 if (empty($keywords)) { 100 if (empty($keywords)) {
92 $this->output("项目{$project->id}未获取到关键词"); 101 $this->output("项目{$project->id}未获取到关键词");
93 continue; 102 continue;
@@ -11,6 +11,10 @@ namespace App\Http\Logic\Bside\Ai; @@ -11,6 +11,10 @@ namespace App\Http\Logic\Bside\Ai;
11 11
12 use App\Http\Logic\Bside\BaseLogic; 12 use App\Http\Logic\Bside\BaseLogic;
13 use App\Models\Ai\AiBlogKeyword; 13 use App\Models\Ai\AiBlogKeyword;
  14 +use App\Models\Project\ProjectKeyword;
  15 +use App\Models\WebSetting\WebSetting;
  16 +use App\Services\ProjectServer;
  17 +use Illuminate\Support\Facades\DB;
14 18
15 class AiBlogKeywordLogic extends BaseLogic 19 class AiBlogKeywordLogic extends BaseLogic
16 { 20 {
@@ -32,6 +36,22 @@ class AiBlogKeywordLogic extends BaseLogic @@ -32,6 +36,22 @@ class AiBlogKeywordLogic extends BaseLogic
32 public function getKeywordInfo() 36 public function getKeywordInfo()
33 { 37 {
34 $data = $this->model->read(['project_id'=>$this->user['project_id']]); 38 $data = $this->model->read(['project_id'=>$this->user['project_id']]);
  39 + if($data === false){
  40 + //核心关键词+网站关键词+白帽关键词
  41 + $main_keywords = ProjectKeyword::where('project_id', $this->user['project_id'])->value('main_keyword');
  42 + $main_keywords = explode("\r\n", $main_keywords);
  43 + $seo_keywords = ProjectKeyword::where('project_id', $this->user['project_id'])->value('seo_keywords');
  44 + $seo_keywords = explode("\r\n", $seo_keywords);
  45 + $site_keywords = WebSetting::where('project_id', $this->user['project_id'])->value('keyword');
  46 + $site_keywords = explode(",", $site_keywords);
  47 + $keywords = array_filter(array_merge($main_keywords, $site_keywords, $seo_keywords));
  48 + $keywords = array_map('trim', $keywords);
  49 + $keywords_string = implode("\n", $keywords);
  50 + $data = [
  51 + 'project_id'=>$this->user['project_id'],
  52 + 'keywords'=>$keywords_string
  53 + ];
  54 + }
35 return $this->success($data); 55 return $this->success($data);
36 } 56 }
37 57