作者 赵彬吉

update

@@ -41,9 +41,9 @@ class SyncSubmitTask extends Command @@ -41,9 +41,9 @@ class SyncSubmitTask extends Command
41 $time = time(); 41 $time = time();
42 42
43 43
44 -// DB::enableQueryLog(); //启用查询日志  
45 -// //清除之前的查询日志  
46 -// DB::flushQueryLog(); 44 + DB::enableQueryLog(); //启用查询日志
  45 + //清除之前的查询日志
  46 + DB::flushQueryLog();
47 47
48 $task_info = SyncSubmitTaskModel::find($task_id); 48 $task_info = SyncSubmitTaskModel::find($task_id);
49 if (empty($task_info) || $task_info->status !=3) { 49 if (empty($task_info) || $task_info->status !=3) {
@@ -56,9 +56,7 @@ class SyncSubmitTask extends Command @@ -56,9 +56,7 @@ class SyncSubmitTask extends Command
56 throw new \Exception('项目不存在'); 56 throw new \Exception('项目不存在');
57 } 57 }
58 $task_info->project_id = $project->id; 58 $task_info->project_id = $project->id;
59 - $time2 = time();  
60 SyncSubmitTaskService::handler($task_info); 59 SyncSubmitTaskService::handler($task_info);
61 - $this->output('处理用时:' . (time() - $time2));  
62 $task_info->status = 1; 60 $task_info->status = 1;
63 $task_info->save(); 61 $task_info->save();
64 62
@@ -87,11 +85,10 @@ class SyncSubmitTask extends Command @@ -87,11 +85,10 @@ class SyncSubmitTask extends Command
87 $use_time = time() - $time; 85 $use_time = time() - $time;
88 if($use_time > 1){ 86 if($use_time > 1){
89 //数据库查询 87 //数据库查询
90 - $this->output('任务用时:' .$use_time);  
91 -// $this->output('任务用时:' .$use_time . ' | ' . json_encode(DB::getQueryLog(),JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); 88 + $this->output('任务用时:' .$use_time . ' | ' . json_encode(DB::getQueryLog(),JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
92 } 89 }
93 //清除之前的查询日志 90 //清除之前的查询日志
94 -// DB::flushQueryLog(); 91 + DB::flushQueryLog();
95 } 92 }
96 } 93 }
97 94
@@ -88,9 +88,11 @@ class SyncSubmitTaskService @@ -88,9 +88,11 @@ class SyncSubmitTaskService
88 } 88 }
89 } 89 }
90 90
  91 + $time = time();
91 if(!ProjectServer::useProject($project['id'])){ 92 if(!ProjectServer::useProject($project['id'])){
92 return false; 93 return false;
93 } 94 }
  95 + echo date('Y-m-d H:i:s') . ' | useProject time:' . (time() - $time) . PHP_EOL;
94 96
95 $action = $task['type']; 97 $action = $task['type'];
96 98
@@ -106,7 +108,7 @@ class SyncSubmitTaskService @@ -106,7 +108,7 @@ class SyncSubmitTaskService
106 } 108 }
107 $filed == 'email' && $action = 'subscribe'; 109 $filed == 'email' && $action = 'subscribe';
108 } 110 }
109 - 111 +
110 $handler = new self(); 112 $handler = new self();
111 return $handler->$action($data, $date, $task['id'], $task['traffic']); 113 return $handler->$action($data, $date, $task['id'], $task['traffic']);
112 } 114 }
@@ -297,6 +299,7 @@ class SyncSubmitTaskService @@ -297,6 +299,7 @@ class SyncSubmitTaskService
297 if(!$ip){ 299 if(!$ip){
298 return ''; 300 return '';
299 } 301 }
  302 +
300 $res = Http::withoutVerifying()->get('http://ip.globalso.com', ['ip' => $ip]); 303 $res = Http::withoutVerifying()->get('http://ip.globalso.com', ['ip' => $ip]);
301 if($res->status() == 200){ 304 if($res->status() == 200){
302 return $res->body(); 305 return $res->body();
@@ -334,7 +337,9 @@ class SyncSubmitTaskService @@ -334,7 +337,9 @@ class SyncSubmitTaskService
334 if($ip == "127.0.0.1"){ 337 if($ip == "127.0.0.1"){
335 throw new InquiryFilterException('127.0.0.1过滤'); 338 throw new InquiryFilterException('127.0.0.1过滤');
336 } 339 }
  340 + $time = time();
337 $country = self::getCountryByIp($ip); 341 $country = self::getCountryByIp($ip);
  342 + echo date('Y-m-d H:i:s') . ' | getCountryByIp time:' . (time() - $time) . PHP_EOL;
338 //访问记录过滤国内 343 //访问记录过滤国内
339 if ($type == SyncSubmitTask::TYPE_VISIT && $country == "中国" && !$project->is_record_china_visit){ 344 if ($type == SyncSubmitTask::TYPE_VISIT && $country == "中国" && !$project->is_record_china_visit){
340 throw new InquiryFilterException('中国内地过滤'); 345 throw new InquiryFilterException('中国内地过滤');