合并分支 'lyh-server' 到 'master'
变更数据 查看合并请求 !2928
正在显示
2 个修改的文件
包含
30 行增加
和
16 行删除
| @@ -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 |
app/Models/Geo/DomainDa.php
0 → 100644
-
请 注册 或 登录 后发表评论