作者 lyh

gx

@@ -66,7 +66,27 @@ class UpdateRoute extends Command @@ -66,7 +66,27 @@ class UpdateRoute extends Command
66 */ 66 */
67 public function handle() 67 public function handle()
68 { 68 {
69 - $this->insertData(); 69 + return $this->_action();
  70 + }
  71 +
  72 + /**
  73 + * @remark :清洗数据
  74 + * @name :_action
  75 + * @author :lyh
  76 + * @method :post
  77 + * @time :2025/4/10 17:08
  78 + */
  79 + public function _action(){
  80 + $projectModel = new Project();
  81 + $lists = $projectModel->list(['delete_status'=>0,'extend_type'=>0],'id','desc');
  82 + $keywordModel = new Keyword();
  83 + foreach ($lists as $v){
  84 + ProjectServer::useProject($v['id']);
  85 + echo date('Y-m-d H:i:s').' 执行的项目id:'.$v['id'].PHP_EOL;
  86 + $keywordModel->edit(['type'=>1],['id'=>['!=',0]]);
  87 + DB::disconnect('custom_mysql');
  88 + }
  89 + return true;
70 } 90 }
71 /** 91 /**
72 * @remark : 92 * @remark :
@@ -73,10 +73,9 @@ class OptimizeSetKeywordSync extends Command @@ -73,10 +73,9 @@ class OptimizeSetKeywordSync extends Command
73 { 73 {
74 $keywords = explode("\n", $keywords); 74 $keywords = explode("\n", $keywords);
75 $keywords = array_unique(array_filter($keywords)); 75 $keywords = array_unique(array_filter($keywords));
76 -  
77 ProjectServer::useProject($project_id); 76 ProjectServer::useProject($project_id);
78 $keywordModel = new Keyword(); 77 $keywordModel = new Keyword();
79 - $keywordModel->saveBKeyword($project_id,$keywords); 78 + $keywordModel->saveBKeyword($project_id,$keywords,Keyword::TYPE_ORDER_KEYWORD);
80 DB::disconnect('custom_mysql'); 79 DB::disconnect('custom_mysql');
81 return true; 80 return true;
82 } 81 }
@@ -21,6 +21,8 @@ class Keyword extends Base @@ -21,6 +21,8 @@ class Keyword extends Base
21 //连接数据库 21 //连接数据库
22 protected $connection = 'custom_mysql'; 22 protected $connection = 'custom_mysql';
23 23
  24 + const TYPE_ORDER_KEYWORD = 1;//关键词标识,预约关键词标识
  25 +
24 const STATUS_ACTIVE = 1; 26 const STATUS_ACTIVE = 1;
25 //获取字母对应数字 27 //获取字母对应数字
26 public $firstNumWord = [ 28 public $firstNumWord = [
@@ -110,7 +112,7 @@ class Keyword extends Base @@ -110,7 +112,7 @@ class Keyword extends Base
110 public static function extendKeyword($project_id) 112 public static function extendKeyword($project_id)
111 { 113 {
112 $result = []; 114 $result = [];
113 - $keywords = self::where(['project_id' => $project_id])->pluck('seo_title', 'title')->toArray(); 115 + $keywords = self::where(['project_id' => $project_id])->where('type',self::TYPE_ORDER_KEYWORD)->pluck('seo_title', 'title')->toArray();
114 if (empty($keywords)) 116 if (empty($keywords))
115 return $result; 117 return $result;
116 // $item:前缀 + 关键词 + 后缀 118 // $item:前缀 + 关键词 + 后缀
@@ -149,7 +151,7 @@ class Keyword extends Base @@ -149,7 +151,7 @@ class Keyword extends Base
149 * @method :post 151 * @method :post
150 * @time :2025/3/25 16:28 152 * @time :2025/3/25 16:28
151 */ 153 */
152 - public function saveBKeyword($project_id,$keywords){ 154 + public function saveBKeyword($project_id,$keywords,$type = 0){
153 foreach ($keywords as $v){ 155 foreach ($keywords as $v){
154 if(empty($v)){ 156 if(empty($v)){
155 continue; 157 continue;
@@ -159,6 +161,7 @@ class Keyword extends Base @@ -159,6 +161,7 @@ class Keyword extends Base
159 $param['project_id'] = $project_id; 161 $param['project_id'] = $project_id;
160 $param['title'] = $v; 162 $param['title'] = $v;
161 $param['first_word'] = $this->first_word($param['title']); 163 $param['first_word'] = $this->first_word($param['title']);
  164 + $param['type'] = $type;
162 $this->addReturnId($param); 165 $this->addReturnId($param);
163 } 166 }
164 } 167 }