作者 李宇航

合并分支 'lyh-server' 到 'master'

变更数据



查看合并请求 !2928
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 namespace App\Http\Logic\Aside\Geo; 10 namespace App\Http\Logic\Aside\Geo;
11 11
12 use App\Http\Logic\Aside\BaseLogic; 12 use App\Http\Logic\Aside\BaseLogic;
  13 +use App\Models\Geo\DomainDa;
13 use App\Models\Geo\GeoLink; 14 use App\Models\Geo\GeoLink;
14 use App\Services\Geo\GeoService; 15 use App\Services\Geo\GeoService;
15 use Illuminate\Support\Carbon; 16 use Illuminate\Support\Carbon;
@@ -117,27 +118,23 @@ class GeoLinkLogic extends BaseLogic @@ -117,27 +118,23 @@ class GeoLinkLogic extends BaseLogic
117 if($info === false){ 118 if($info === false){
118 $this->fail('当前数据不存在或者已被删除'); 119 $this->fail('当前数据不存在或者已被删除');
119 } 120 }
120 - $geoService = new GeoService();  
121 - if(!empty($info['time'])){  
122 - $start = Carbon::parse($info['time']);  
123 - $end = Carbon::parse(date('Y-m-d'));  
124 - $diff = $start->diffInDays($end);  
125 - if($diff >= 60){  
126 - $host = $this->getDomainWithWWW($info['url']);  
127 - $result = $geoService->daResult($host);  
128 - }else{  
129 - return $this->success($info);  
130 - }  
131 - }else{  
132 - $host = $this->getDomainWithWWW($info['url']);  
133 - $result = $geoService->daResult($host); 121 + $host = $this->getDomainWithWWW($info['url']);
  122 + $domainDaModel = new DomainDa();
  123 + $daInfo = $domainDaModel->read(['domain'=>$host]);
  124 + if($daInfo !== false){
  125 + $info['da'] = $daInfo['da'];
  126 + $this->model->edit(['da'=>$daInfo['da']], ['id'=>$info['id']]);
  127 + return $this->success($info);
134 } 128 }
  129 + $geoService = new GeoService();
  130 + $result = $geoService->daResult($host);
135 if(!isset($result['data']) || empty($result['data'])){ 131 if(!isset($result['data']) || empty($result['data'])){
136 - $this->model->edit(['time'=>date('Y-m-d')], ['id'=>$info['id']]);  
137 return $this->success($info); 132 return $this->success($info);
138 } 133 }
139 $info['da'] = (int)$result['data']['mozDA'];//获取数据中的da值 134 $info['da'] = (int)$result['data']['mozDA'];//获取数据中的da值
140 - $this->model->edit(['time'=>date('Y-m-d'),'da'=>$info['da']], ['id'=>$info['id']]); 135 + //保存数据
  136 + $domainDaModel->addReturnId(['da'=>$info['da'],'domain'=>$host,'result'=>json_encode($result,true)]);
  137 + $this->model->edit(['da'=>$info['da']], ['id'=>$info['id']]);
141 return $this->success($result); 138 return $this->success($result);
142 } 139 }
143 140
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :DomainDa.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/10/11 10:18
  8 + */
  9 +
  10 +namespace App\Models\Geo;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class DomainDa extends Base
  15 +{
  16 + protected $table = 'gl_domain_da';
  17 +}