作者 lyh

gx

@@ -49,8 +49,9 @@ class GoogleSearchKeyword extends Command @@ -49,8 +49,9 @@ class GoogleSearchKeyword extends Command
49 * @time :2025/3/31 11:37 49 * @time :2025/3/31 11:37
50 */ 50 */
51 public function handle(){ 51 public function handle(){
  52 + $noticeModel = new NoticeLog();
52 while (true){ 53 while (true){
53 - $list = NoticeLog::where('type', NoticeLog::GOOGLE_SEARCH)->where('status', NoticeLog::STATUS_PENDING)->get(); 54 + $list = $noticeModel->list(['type'=>NoticeLog::GOOGLE_SEARCH,'status'=>NoticeLog::STATUS_PENDING]);;
54 if(empty($list)){ 55 if(empty($list)){
55 sleep(50); 56 sleep(50);
56 return true; 57 return true;
@@ -58,7 +59,12 @@ class GoogleSearchKeyword extends Command @@ -58,7 +59,12 @@ class GoogleSearchKeyword extends Command
58 foreach ($list as $val){ 59 foreach ($list as $val){
59 $data = json_decode($val['data'],true); 60 $data = json_decode($val['data'],true);
60 echo '执行的任务id:'.$val['id'].',项目id:'.$data['project_id']??''.PHP_EOL; 61 echo '执行的任务id:'.$val['id'].',项目id:'.$data['project_id']??''.PHP_EOL;
61 - $this->_action($data['domain'],$data['type'],$data['project_id']); 62 + $result = $this->_action($data['domain'],$data['type'],$data['project_id']);
  63 + $status = NoticeLog::STATUS_SUCCESS;
  64 + if($result === false){
  65 + $status = NoticeLog::STATUS_FAIL;
  66 + }
  67 + $noticeModel->edit(['status'=>$status],['id'=>$val['id']]);
62 echo '任务结束'.PHP_EOL; 68 echo '任务结束'.PHP_EOL;
63 } 69 }
64 } 70 }
@@ -77,7 +83,7 @@ class GoogleSearchKeyword extends Command @@ -77,7 +83,7 @@ class GoogleSearchKeyword extends Command
77 $data = $googleService->googleSearch($domain,$type); 83 $data = $googleService->googleSearch($domain,$type);
78 if(empty($data)){ 84 if(empty($data)){
79 echo '域名:'.$domain.'拉取数据为空.'.PHP_EOL; 85 echo '域名:'.$domain.'拉取数据为空.'.PHP_EOL;
80 - return true; 86 + return false;
81 } 87 }
82 //保存一条主记录诗句 88 //保存一条主记录诗句
83 $searchModel = new GoogleSearch(); 89 $searchModel = new GoogleSearch();