Yesterday.php 1.5 KB
<?php

namespace App\Console\Commands\YesterdayCount;

use App\Models\CustomerVisit\CustomerVisitItem;
use App\Models\Project\DeployBuild;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class Yesterday extends Command
{
    public $error = 0;
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'yesterday_count';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '统计昨日数据';
    /**
     * @name   :(定时执行)handle
     * @author :lyh
     * @method :post
     * @time   :2023/5/12 14:48
     */
    public function handle()
    {
        $deployModel = new DeployBuild();
        $list = $deployModel->list();
        $data = [];
        foreach ($list as $v){
            $arr = [];
            $yesterday = now()->subDay();
            $arr['yesterday_pv_num'] = DB::table('gl_customer_visit_item')->whereDate('created_at', $yesterday)->where('domain',$v['test_domain'])->count();
            $arr['yesterday_ip_num'] = DB::table('gl_customer_visit')->whereDate('created_at', $yesterday)->where('domain',$v['test_domain'])->count();
            $arr['inquiry_num'] = DB::table('gl_inquiry_set')->whereDate('created_at', $yesterday)->where('project_id',$v['project_id'])->count();
            $arr['rank_compliance_num'] = DB::table('rank_compliance_num')->whereDate('created_at', $yesterday)->where('project_id',$v['project_id'])->count();
        }
    }
}