StatisticsTrend.php 1.7 KB
<?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;
    }
}