InquiryVisit.php 1.3 KB
<?php

namespace App\Console\Commands\Test;

use App\Models\SyncSubmitTask\SyncSubmitTask;
use App\Models\Visit\Visit;
use App\Services\ProjectServer;
use Illuminate\Console\Command;

class InquiryVisit extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'temp_inquiry_visit';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '临时脚本(akun)';

    public function handle()
    {
        $list = SyncSubmitTask::select(['id', 'project_id', 'data', 'created_at'])->where('project_id', '>', 0)->where('type', 'inquiry')->where('status', 1)->get();

        foreach ($list as $item) {
            $project_id = $item->project_id;
            $data = $item->data;
            $day_time = substr($item->created_at, 0, 10);
            ProjectServer::useProject($project_id);

            $visit = Visit::where("ip", $data['ip'])->where("created_at", ">=", $day_time . ' 00:00:00')
                ->where("created_at", "<=", $day_time . ' 23:59:59')
                ->first();
            if ($visit) {
                $visit->is_inquiry = 1;
                $visit->save();
                dump($item->id);
            }
        }
    }
}