作者 lyh
@@ -8,6 +8,7 @@ use App\Helper\OaGlobalsoApi; @@ -8,6 +8,7 @@ use App\Helper\OaGlobalsoApi;
8 use App\Models\Channel\Channel; 8 use App\Models\Channel\Channel;
9 use App\Models\Com\NoticeLog; 9 use App\Models\Com\NoticeLog;
10 use App\Models\Com\UpdateLog; 10 use App\Models\Com\UpdateLog;
  11 +use App\Models\Com\UpdateVisit;
11 use App\Models\Project\After; 12 use App\Models\Project\After;
12 use App\Models\Project\DeployBuild; 13 use App\Models\Project\DeployBuild;
13 use App\Models\Project\DeployOptimize; 14 use App\Models\Project\DeployOptimize;
@@ -244,6 +245,7 @@ class SyncProject extends Command @@ -244,6 +245,7 @@ class SyncProject extends Command
244 foreach ($task_list as $task){ 245 foreach ($task_list as $task){
245 UpdateLog::createLog($id,$task,$param['get_data_url']); 246 UpdateLog::createLog($id,$task,$param['get_data_url']);
246 } 247 }
  248 + UpdateVisit::createLog($id,$param['get_data_url']);
247 } 249 }
248 DB::commit(); 250 DB::commit();
249 }catch (\Exception $e){ 251 }catch (\Exception $e){
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Test; @@ -5,6 +5,7 @@ namespace App\Console\Commands\Test;
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Models\Collect\CollectTask; 6 use App\Models\Collect\CollectTask;
7 use App\Models\Com\UpdateLog; 7 use App\Models\Com\UpdateLog;
  8 +use App\Models\Com\UpdateVisit;
8 use App\Models\Product\Product; 9 use App\Models\Product\Product;
9 use App\Services\ProjectServer; 10 use App\Services\ProjectServer;
10 use Illuminate\Console\Command; 11 use Illuminate\Console\Command;
@@ -29,31 +30,12 @@ class Temp extends Command @@ -29,31 +30,12 @@ class Temp extends Command
29 30
30 public function handle() 31 public function handle()
31 { 32 {
32 - $data_project = [162];  
33 -  
34 - foreach ($data_project as $project_id) {  
35 - $project = ProjectServer::useProject($project_id);  
36 - if ($project) {  
37 - $list = Product::get();  
38 - foreach ($list as $item) {  
39 - $seo = $item->seo_mate;  
40 - if ($seo) {  
41 - $seo['title'] = substr(strip_tags($seo['title']??''), 0, 70);  
42 - $seo['keyword'] = substr(strip_tags($seo['keyword']??''), 0, 255);  
43 - $seo['description'] = substr(strip_tags($seo['description']??''), 0, 200);  
44 - $item->seo_mate = Arr::a2s($seo);  
45 - try {  
46 - $item->save();  
47 - }catch (\Exception $e){  
48 - continue;  
49 - }  
50 - }  
51 - }  
52 - }  
53 - //关闭数据库  
54 - DB::disconnect('custom_mysql');  
55 -  
56 - echo $project_id . '成功, product' . PHP_EOL; 33 + $data = UpdateLog::where('api_type','website_info')->get();
  34 +
  35 + foreach ($data as $item) {
  36 + UpdateVisit::createLog($item->project_id,$item->api_url);
  37 +
  38 + echo $item->project_id . '成功' . PHP_EOL;
57 } 39 }
58 } 40 }
59 } 41 }
@@ -94,6 +94,10 @@ class ProjectVisit extends Command @@ -94,6 +94,10 @@ class ProjectVisit extends Command
94 if (isset($item['id']) && $item['id']) { 94 if (isset($item['id']) && $item['id']) {
95 if ($item['id'] > $task->max_id) { 95 if ($item['id'] > $task->max_id) {
96 $url_arr = parse_url($item['request'] ?? ''); 96 $url_arr = parse_url($item['request'] ?? '');
  97 + $domain = $url_arr['host'] ?? '';
  98 + if(strlen($domain) > 50){
  99 + continue;
  100 + }
97 $insert[] = [ 101 $insert[] = [
98 'url' => $item['request'] ?? '', 102 'url' => $item['request'] ?? '',
99 'referrer_url' => $item['referrer'] ?? '', 103 'referrer_url' => $item['referrer'] ?? '',
@@ -101,7 +105,7 @@ class ProjectVisit extends Command @@ -101,7 +105,7 @@ class ProjectVisit extends Command
101 'country' => $item['ip_area'] ?? '', 105 'country' => $item['ip_area'] ?? '',
102 'ip' => $item['ip'] ?? '', 106 'ip' => $item['ip'] ?? '',
103 'depth' => $item['pv'], 107 'depth' => $item['pv'],
104 - 'domain' => $url_arr['host'] ?? '', 108 + 'domain' => $domain,
105 'is_inquiry' => $item['is_cf'] ?? 0, 109 'is_inquiry' => $item['is_cf'] ?? 0,
106 'created_at' => date('Y-m-d H:i:s', isset($item['update']) && $item['update'] ? $item['update'] : time()), 110 'created_at' => date('Y-m-d H:i:s', isset($item['update']) && $item['update'] ? $item['update'] : time()),
107 'updated_at' => date('Y-m-d H:i:s', isset($item['update']) && $item['update'] ? $item['update'] : time()), 111 'updated_at' => date('Y-m-d H:i:s', isset($item['update']) && $item['update'] ? $item['update'] : time()),
@@ -12,4 +12,39 @@ class UpdateVisit extends Model @@ -12,4 +12,39 @@ class UpdateVisit extends Model
12 const STATUS_UN = 0;//未开始 12 const STATUS_UN = 0;//未开始
13 const STATUS_ING = 1;//导入中 13 const STATUS_ING = 1;//导入中
14 const STATUS_COM = 2;//导入完成 14 const STATUS_COM = 2;//导入完成
  15 +
  16 + /**
  17 + * 创建更新日志
  18 + * @param $project_id
  19 + * @param $url
  20 + * @return mixed
  21 + */
  22 + public static function createLog($project_id, $url)
  23 + {
  24 + $count = self::where('project_id', $project_id)->count('id');
  25 + if (!$count) {
  26 + $time = date('Y-m-d H:i:s');
  27 + $data = [
  28 + [
  29 + 'project_id' => $project_id,
  30 + 'api_type' => 'visit_list',
  31 + 'api_url' => str_replace('update_v6.php?w=website_info&page=1&pagesize=20', 'extend_api.php', $url),
  32 + 'sort' => 0,
  33 + 'created_at' => $time,
  34 + 'updated_at' => $time
  35 + ],
  36 + [
  37 + 'project_id' => $project_id,
  38 + 'api_type' => 'visit_detail_list',
  39 + 'api_url' => str_replace('update_v6.php?w=website_info&page=1&pagesize=20', 'extend_api.php', $url),
  40 + 'sort' => 1,
  41 + 'created_at' => $time,
  42 + 'updated_at' => $time
  43 + ]
  44 + ];
  45 +
  46 + return self::insert($data);
  47 + }
  48 + return true;
  49 + }
15 } 50 }