Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop
正在显示
12 个修改的文件
包含
172 行增加
和
14 行删除
| @@ -138,7 +138,7 @@ class HtmlCollect extends Command | @@ -138,7 +138,7 @@ class HtmlCollect extends Command | ||
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | 140 | ||
| 141 | - $update_log = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('project_id', 'asc')->first(); | 141 | + $update_log = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('updated_at', 'asc')->first(); |
| 142 | if (!$update_log) { | 142 | if (!$update_log) { |
| 143 | return false; | 143 | return false; |
| 144 | } | 144 | } |
| @@ -527,7 +527,7 @@ class ProjectUpdate extends Command | @@ -527,7 +527,7 @@ class ProjectUpdate extends Command | ||
| 527 | return $task_id; | 527 | return $task_id; |
| 528 | } | 528 | } |
| 529 | 529 | ||
| 530 | - $task_list = UpdateLog::where('status', UpdateLog::STATUS_UN)->orderBy('sort', 'asc')->orderBy('project_id', 'asc')->limit(20)->get(); | 530 | + $task_list = UpdateLog::where('status', UpdateLog::STATUS_UN)->orderBy('sort', 'asc')->orderBy('updated_at', 'asc')->limit(20)->get(); |
| 531 | if ($task_list->count() == 0) { | 531 | if ($task_list->count() == 0) { |
| 532 | return false; | 532 | return false; |
| 533 | } | 533 | } |
| @@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel | @@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel | ||
| 18 | // $schedule->command('inspire')->hourly(); | 18 | // $schedule->command('inspire')->hourly(); |
| 19 | $schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长 | 19 | $schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长 |
| 20 | $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务 | 20 | $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务 |
| 21 | - $schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次 | 21 | + $schedule->command('rank_data')->dailyAt('07:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次 |
| 22 | $schedule->command('rank_data_speed')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次 | 22 | $schedule->command('rank_data_speed')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次 |
| 23 | $schedule->command('rank_data_external_links')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次 | 23 | $schedule->command('rank_data_external_links')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次 |
| 24 | $schedule->command('rank_data_indexed_pages')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次 | 24 | $schedule->command('rank_data_indexed_pages')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次 |
| @@ -103,7 +103,7 @@ class QuanqiusouApi | @@ -103,7 +103,7 @@ class QuanqiusouApi | ||
| 103 | Cache::put($key, $res, 2 * 3600); | 103 | Cache::put($key, $res, 2 * 3600); |
| 104 | } | 104 | } |
| 105 | } catch (\Exception | GuzzleException $e) { | 105 | } catch (\Exception | GuzzleException $e) { |
| 106 | - errorLog('获取谷歌排名数据失败', $api_no, $e); | 106 | + errorLog('获取谷歌排名数据失败', [$api_no], $e); |
| 107 | return false; | 107 | return false; |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
app/Http/Controllers/Api/BaseController.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2024/1/4 | ||
| 6 | + * Time: 16:25 | ||
| 7 | + */ | ||
| 8 | +namespace App\Http\Controllers\Api; | ||
| 9 | + | ||
| 10 | +use App\Http\Controllers\Controller; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Class BaseController | ||
| 14 | + * @package App\Http\Controllers\Api | ||
| 15 | + */ | ||
| 16 | +class BaseController extends Controller | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * @param array $data | ||
| 20 | + * @param string $message | ||
| 21 | + * @param int $status | ||
| 22 | + * @return false|string | ||
| 23 | + */ | ||
| 24 | + protected function success($data = [], $message = 'success', $status = 200) | ||
| 25 | + { | ||
| 26 | + $array = compact('status', 'message', 'data'); | ||
| 27 | + return json_encode($array, JSON_UNESCAPED_UNICODE); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * @param string $message | ||
| 32 | + * @param int $status | ||
| 33 | + * @param array $data | ||
| 34 | + * @return false|string | ||
| 35 | + */ | ||
| 36 | + protected function error($message = 'error', $status = 400, $data = []) | ||
| 37 | + { | ||
| 38 | + $array = compact('status', 'message', 'data'); | ||
| 39 | + return json_encode($array, JSON_UNESCAPED_UNICODE); | ||
| 40 | + } | ||
| 41 | +} |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2024/01/04 | ||
| 6 | + * Time: 16:08 | ||
| 7 | + */ | ||
| 8 | +namespace App\Http\Controllers\Api; | ||
| 9 | + | ||
| 10 | +use App\Models\Visit\SyncSubmitTask; | ||
| 11 | +use App\Models\Visit\Visit; | ||
| 12 | +use Illuminate\Http\Request; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * Class NoticeController | ||
| 16 | + * @package App\Http\Controllers\Api | ||
| 17 | + */ | ||
| 18 | +class NoticeController extends BaseController | ||
| 19 | +{ | ||
| 20 | + /** | ||
| 21 | + * 网站引流 | ||
| 22 | + * FIXME 当前接口给内部引流用, 使用简易接口, 后期需要添加完整校验机制以及多数据接口 | ||
| 23 | + * @param Request $request | ||
| 24 | + * @return false|string | ||
| 25 | + */ | ||
| 26 | + public function trafficVisit(Request $request) | ||
| 27 | + { | ||
| 28 | + $ip = $request->input('ip'); | ||
| 29 | + $url = $request->input('url'); | ||
| 30 | + $device_port = intval($request->input('device_port')); | ||
| 31 | + $referrer_url = $request->input('referrer_url'); | ||
| 32 | + $user_agent = $request->input('user_agent'); | ||
| 33 | + | ||
| 34 | + if (empty($ip)) | ||
| 35 | + return $this->error('IP不能为空'); | ||
| 36 | + if (empty($url)) | ||
| 37 | + return $this->error('访问链接不能为空'); | ||
| 38 | + if (empty($user_agent)) | ||
| 39 | + return $this->error('请求头信息user_agent不能为空'); | ||
| 40 | + | ||
| 41 | + // | ||
| 42 | + $url_array = parse_url($url); | ||
| 43 | + $array = [ | ||
| 44 | + 'ip' => $ip, | ||
| 45 | + 'domain' => $url_array['host'] ?? '', | ||
| 46 | + 'referer' => $referrer_url, | ||
| 47 | + 'user_agent' => $user_agent, | ||
| 48 | + 'data' => [ | ||
| 49 | + 'url' => $url, | ||
| 50 | + 'domain' => empty($url_array['host']) ? '' : $url_array['scheme'] . '://' . $url_array['host'], | ||
| 51 | + 'device_port' => in_array($device_port, array_keys(Visit::deviceMap())) ? $device_port : Visit::DEVICE_PC, | ||
| 52 | + 'referrer_url' => $referrer_url | ||
| 53 | + ] | ||
| 54 | + ]; | ||
| 55 | + SyncSubmitTask::createTask($array, SyncSubmitTask::TYPE_VISIT); | ||
| 56 | + return $this->success([]); | ||
| 57 | + } | ||
| 58 | +} |
| @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Aside\Com; | @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Aside\Com; | ||
| 12 | use App\Helper\Common; | 12 | use App\Helper\Common; |
| 13 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 14 | use App\Models\Com\UpdateLog; | 14 | use App\Models\Com\UpdateLog; |
| 15 | +use App\Models\Com\UpdateOldInfo; | ||
| 15 | use App\Models\Domain\DomainInfo; | 16 | use App\Models\Domain\DomainInfo; |
| 16 | use App\Models\Project\ProjectUpdateTdk; | 17 | use App\Models\Project\ProjectUpdateTdk; |
| 17 | use App\Services\ProjectServer; | 18 | use App\Services\ProjectServer; |
| @@ -75,9 +76,25 @@ class UpdateController extends BaseController | @@ -75,9 +76,25 @@ class UpdateController extends BaseController | ||
| 75 | $this->fail('非升级无法进行采集操作'); | 76 | $this->fail('非升级无法进行采集操作'); |
| 76 | } | 77 | } |
| 77 | 78 | ||
| 79 | + if ($this->param['test_domain']) { | ||
| 80 | + $test_domain_arr = parse_url($this->param['test_domain']); | ||
| 81 | + $this->param['test_domain'] = $test_domain_arr['host'] ?? ''; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + //查看项目是否已上线 | ||
| 85 | + $domain_info = DomainInfo::where('project_id', $this->param['project_id'])->first(); | ||
| 86 | + | ||
| 87 | + if ($domain_info && !$this->param['test_domain']) { | ||
| 88 | + $this->fail('已上线项目需填写采集的测试站域名'); | ||
| 89 | + } | ||
| 90 | + | ||
| 78 | try { | 91 | try { |
| 79 | DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'"); | 92 | DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'"); |
| 80 | - DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''"); | 93 | + if ($domain_info) { |
| 94 | + DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $this->param['test_domain'] . "' WHERE `language` = ''"); | ||
| 95 | + } else { | ||
| 96 | + DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''"); | ||
| 97 | + } | ||
| 81 | } catch (\Exception $e) { | 98 | } catch (\Exception $e) { |
| 82 | errorLog('重新采集升级项目数据', $this->param, $e); | 99 | errorLog('重新采集升级项目数据', $this->param, $e); |
| 83 | 100 | ||
| @@ -87,9 +104,6 @@ class UpdateController extends BaseController | @@ -87,9 +104,6 @@ class UpdateController extends BaseController | ||
| 87 | //关闭数据库 | 104 | //关闭数据库 |
| 88 | DB::disconnect('custom_mysql'); | 105 | DB::disconnect('custom_mysql'); |
| 89 | 106 | ||
| 90 | - //查看项目是否已上线 | ||
| 91 | - $domain_info = DomainInfo::where('project_id', $this->param['project_id'])->first(); | ||
| 92 | - | ||
| 93 | $update = ['collect_status' => 0]; | 107 | $update = ['collect_status' => 0]; |
| 94 | if ($this->param['type'] == 2 && !$domain_info) { | 108 | if ($this->param['type'] == 2 && !$domain_info) { |
| 95 | $update['status'] = 0; | 109 | $update['status'] = 0; |
| @@ -371,7 +371,7 @@ class RankDataLogic extends BaseLogic | @@ -371,7 +371,7 @@ class RankDataLogic extends BaseLogic | ||
| 371 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { | 371 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { |
| 372 | $res = $api->getGoogleRank($api_no, 0, 7, $force); | 372 | $res = $api->getGoogleRank($api_no, 0, 7, $force); |
| 373 | if (!$res) { | 373 | if (!$res) { |
| 374 | - throw new \Exception('接口数据获取失败'); | 374 | + throw new \Exception("接口数据获取失败,api_no:{$api_no}"); |
| 375 | } | 375 | } |
| 376 | //收录数 | 376 | //收录数 |
| 377 | $indexed_pages_num = $site_res[$api_no] ?? 0; | 377 | $indexed_pages_num = $site_res[$api_no] ?? 0; |
| @@ -384,7 +384,7 @@ class RankDataLogic extends BaseLogic | @@ -384,7 +384,7 @@ class RankDataLogic extends BaseLogic | ||
| 384 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { | 384 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { |
| 385 | $res = $api->getGoogleRank($api_no, 1, 7, $force); | 385 | $res = $api->getGoogleRank($api_no, 1, 7, $force); |
| 386 | if (!$res) { | 386 | if (!$res) { |
| 387 | - throw new \Exception('接口数据获取失败'); | 387 | + throw new \Exception("接口数据获取失败,api_no:{$api_no},lang"); |
| 388 | } | 388 | } |
| 389 | $data = []; | 389 | $data = []; |
| 390 | //不同的小语种取出来 | 390 | //不同的小语种取出来 |
| @@ -48,7 +48,7 @@ class CollectTask extends Base | @@ -48,7 +48,7 @@ class CollectTask extends Base | ||
| 48 | ]; | 48 | ]; |
| 49 | 49 | ||
| 50 | if ($link_type > 0 && $language_list && in_array($url_arr['path'], $page_list)) { | 50 | if ($link_type > 0 && $language_list && in_array($url_arr['path'], $page_list)) { |
| 51 | - $domain_arr = explode('.', $url_arr['host']); | 51 | + $domain_arr = explode('.', $url_arr['host'] ?? $domain); |
| 52 | foreach ($language_list as $v_lan) { | 52 | foreach ($language_list as $v_lan) { |
| 53 | if ($link_type == 1) { | 53 | if ($link_type == 1) { |
| 54 | //二级域名 | 54 | //二级域名 |
| @@ -56,7 +56,7 @@ class CollectTask extends Base | @@ -56,7 +56,7 @@ class CollectTask extends Base | ||
| 56 | $new_domain = implode('.', $domain_arr); | 56 | $new_domain = implode('.', $domain_arr); |
| 57 | } else { | 57 | } else { |
| 58 | //二级目录 | 58 | //二级目录 |
| 59 | - $new_domain = $url_arr['host'] . '/' . $v_lan; | 59 | + $new_domain = $url_arr['host'] ?? $domain . '/' . $v_lan; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | $data[] = [ | 62 | $data[] = [ |
app/Models/Visit/SyncSubmitTask.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2024/1/5 | ||
| 6 | + * Time: 14:16 | ||
| 7 | + */ | ||
| 8 | +namespace App\Models\Visit; | ||
| 9 | + | ||
| 10 | +use App\Models\Base; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Class SyncSubmitTask | ||
| 14 | + * @package App\Models\Visit | ||
| 15 | + */ | ||
| 16 | +class SyncSubmitTask extends Base | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * 表名 | ||
| 20 | + * @var string | ||
| 21 | + */ | ||
| 22 | + protected $table = 'gl_sync_submit_task'; | ||
| 23 | + | ||
| 24 | + const TYPE_INQUIRY = 'inquiry'; | ||
| 25 | + const TYPE_VISIT = 'visit'; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @param $data | ||
| 29 | + * @param string $type | ||
| 30 | + * @return mixed | ||
| 31 | + */ | ||
| 32 | + public static function createTask($data, $type = self::TYPE_VISIT) | ||
| 33 | + { | ||
| 34 | + $task = new self(); | ||
| 35 | + $task->data = json_encode($data); | ||
| 36 | + $task->type = $type; | ||
| 37 | + $task->save(); | ||
| 38 | + return $task->id; | ||
| 39 | + } | ||
| 40 | +} |
| @@ -20,10 +20,13 @@ class Visit extends Base | @@ -20,10 +20,13 @@ class Visit extends Base | ||
| 20 | protected $connection = 'custom_mysql'; | 20 | protected $connection = 'custom_mysql'; |
| 21 | protected $appends = ['device_text']; | 21 | protected $appends = ['device_text']; |
| 22 | 22 | ||
| 23 | + const DEVICE_PC = 1; | ||
| 24 | + const DEVICE_MOBILE = 2; | ||
| 25 | + | ||
| 23 | public static function deviceMap(){ | 26 | public static function deviceMap(){ |
| 24 | return [ | 27 | return [ |
| 25 | - 1 => 'PC', | ||
| 26 | - 2 => '移动端' | 28 | + self::DEVICE_PC => 'PC', |
| 29 | + self::DEVICE_MOBILE => '移动端' | ||
| 27 | ]; | 30 | ]; |
| 28 | } | 31 | } |
| 29 | 32 |
| @@ -17,3 +17,5 @@ use Illuminate\Support\Facades\Route; | @@ -17,3 +17,5 @@ use Illuminate\Support\Facades\Route; | ||
| 17 | Route::middleware('auth:sanctum')->get('/user', function (Request $request) { | 17 | Route::middleware('auth:sanctum')->get('/user', function (Request $request) { |
| 18 | return $request->user(); | 18 | return $request->user(); |
| 19 | }); | 19 | }); |
| 20 | + | ||
| 21 | +Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, 'trafficVisit'])->name('api.traffic_visit'); |
-
请 注册 或 登录 后发表评论