StatisticsTrend.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace App\Console\Commands\Bside\Statistics;
use App\Models\Bside\Statistics\TrafficStatistics;
use App\Models\CustomerVisit\CustomerVisit;
use Illuminate\Console\Command;
class StatisticsTrend extends Command
{
public $error = 0;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'statistics_trend';
/**
* The console command description.
*
* @var string
*/
protected $description = '统计当天流量趋势数据PV|IP数量';
/**
* @name :(定时执行)handle
* @author :lyh
* @method :post
* @time :2023/5/12 14:48
*/
public function handle()
{
echo $this->statistics_trend();
}
/**
* 统计当天流量趋势数据PV|IP数量
* @return int|mixed
*/
protected function statistics_trend()
{
$customerVisit = new CustomerVisit();
$date = date('Y-m-d');
$ip_count = $customerVisit->getDayIPCount();
$pv_count = $customerVisit->getDayPVCount();
$trafficStatistics = new TrafficStatistics();
$trafficStatistics->type = TrafficStatistics::TYPE_TREND;
$trafficStatistics->
$data = [
'date' => $date,
'ip_count' => $ip_count,
'pv_count' => $pv_count,
];
// $res = $customerVisit->insert($data);
if ($res) {
$this->info('统计当天流量趋势数据PV|IP数量成功');
} else {
$this->error++;
$this->info('统计当天流量趋势数据PV|IP数量失败');
}
return $this->error;
}
}