合并分支 'lyh-server' 到 'master'
Lyh server 查看合并请求 !1785
正在显示
3 个修改的文件
包含
15 行增加
和
4 行删除
| @@ -1206,6 +1206,9 @@ function paginateArray($array, $page = 1, $pageSize = 20) { | @@ -1206,6 +1206,9 @@ function paginateArray($array, $page = 1, $pageSize = 20) { | ||
| 1206 | * @time :2025/4/3 16:19 | 1206 | * @time :2025/4/3 16:19 |
| 1207 | */ | 1207 | */ |
| 1208 | function getDomain($url) { | 1208 | function getDomain($url) { |
| 1209 | + if(empty($url)){ | ||
| 1210 | + return $url; | ||
| 1211 | + } | ||
| 1209 | $parsedUrl = parse_url($url); | 1212 | $parsedUrl = parse_url($url); |
| 1210 | return $parsedUrl['host'] ?? $url; // 如果解析失败,返回原始 URL | 1213 | return $parsedUrl['host'] ?? $url; // 如果解析失败,返回原始 URL |
| 1211 | } | 1214 | } |
| @@ -26,15 +26,16 @@ class GoogleLinkController extends BaseController | @@ -26,15 +26,16 @@ class GoogleLinkController extends BaseController | ||
| 26 | public function getLink(){ | 26 | public function getLink(){ |
| 27 | $linkModel = new GoogleLink(); | 27 | $linkModel = new GoogleLink(); |
| 28 | $this->map['project_id'] = $this->user['project_id']; | 28 | $this->map['project_id'] = $this->user['project_id']; |
| 29 | - $lists = $linkModel->lists($this->map,$this->page,$this->row,'id',['url','moz_da','status','google_search','date','project_id','domain']); | 29 | + $this->map['status'] = 1; |
| 30 | + $this->map['created_at'] = ['<=', date('Y-m-d 00:00:00', strtotime('-7 days'))]; | ||
| 31 | + $lists = $linkModel->lists($this->map,$this->page,$this->row,'id',['url','moz_da','status','url_domian','google_search','date','project_id','domain']); | ||
| 30 | if(empty($lists['list'])){ | 32 | if(empty($lists['list'])){ |
| 31 | $linkService = new GoogleLinkService(); | 33 | $linkService = new GoogleLinkService(); |
| 32 | $data = $linkService->linkPageData($this->user['domain'],$this->user['project_id']); | 34 | $data = $linkService->linkPageData($this->user['domain'],$this->user['project_id']); |
| 33 | if(is_array($data)){ | 35 | if(is_array($data)){ |
| 34 | $lists = paginateArray($data,$this->page,$this->row); | 36 | $lists = paginateArray($data,$this->page,$this->row); |
| 35 | }else{ | 37 | }else{ |
| 36 | - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($data, true) . PHP_EOL, FILE_APPEND); | ||
| 37 | - $this->response('success',Code::SUCCESS,[]); | 38 | + $this->response('success'); |
| 38 | } | 39 | } |
| 39 | } | 40 | } |
| 40 | $lists['y_total'] = $linkModel->counts(['status'=>1,'project_id'=>$this->user['project_id']]); | 41 | $lists['y_total'] = $linkModel->counts(['status'=>1,'project_id'=>$this->user['project_id']]); |
| @@ -90,6 +90,9 @@ class GoogleLinkService | @@ -90,6 +90,9 @@ class GoogleLinkService | ||
| 90 | foreach ($data as $val){ | 90 | foreach ($data as $val){ |
| 91 | $timestamp = strtotime($val['created_at']); | 91 | $timestamp = strtotime($val['created_at']); |
| 92 | $date = date('Y-m-d H:i:s', $timestamp ?? time()); | 92 | $date = date('Y-m-d H:i:s', $timestamp ?? time()); |
| 93 | + if($val['status'] != 1){ | ||
| 94 | + continue; | ||
| 95 | + } | ||
| 93 | $saveData[] = [ | 96 | $saveData[] = [ |
| 94 | 'url'=>$val['url'], | 97 | 'url'=>$val['url'], |
| 95 | 'moz_da'=>$val['mozDA'], | 98 | 'moz_da'=>$val['mozDA'], |
| @@ -97,11 +100,15 @@ class GoogleLinkService | @@ -97,11 +100,15 @@ class GoogleLinkService | ||
| 97 | 'google_search'=>$val['googlesearch'], | 100 | 'google_search'=>$val['googlesearch'], |
| 98 | 'date'=>$date, | 101 | 'date'=>$date, |
| 99 | 'project_id'=>$project_id, | 102 | 'project_id'=>$project_id, |
| 100 | - 'domain'=>$domain | 103 | + 'domain'=>$domain, |
| 104 | + 'url_domain'=>getDomain($val['url'] ?? '') | ||
| 101 | ]; | 105 | ]; |
| 102 | } | 106 | } |
| 103 | $linkModel = new GoogleLink(); | 107 | $linkModel = new GoogleLink(); |
| 108 | + if(!empty($saveData)){ | ||
| 109 | + $linkModel->del(['project_id'=>$project_id]); | ||
| 104 | $linkModel->insertAll($saveData); | 110 | $linkModel->insertAll($saveData); |
| 111 | + } | ||
| 105 | return $saveData; | 112 | return $saveData; |
| 106 | } | 113 | } |
| 107 | } | 114 | } |
-
请 注册 或 登录 后发表评论