<?php
/**
 * Created by PhpStorm.
 * User: z-yang
 * Date: 2020/5/11
 * Time: 10:51
 */

namespace pp\Console\Commands\ToolA;


use Illuminate\Console\Command;

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

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '继续阅读推送表迁移';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
    }

    //寻找custom_push_keep_continue表距离当前一天的记录id
    private function findId(){
        $id = 0;
        while (true){
            if($id){
                $result = DB::connection('api_mysql')
                    ->table('custom_push_keep_continue')
                    ->where('id','<',$id)
                    ->select('id','created_at')->orderBy('id','desc')->first();
            }else{
                $result = DB::connection('api_mysql')->table('custom_push_keep_continue')->select('id','created_at')->orderBy('id','desc')->first();
            }
            if($result){
                foreach ($result as $item){
                    $id = $item->id;
                    if(strtotime($item->created_at) <= time()-86400*1.5){
                        return $item->id;
                    }
                }
            }else{
                break;
            }
        }
        return $id;
    }


}