ContinueReadTool.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: z-yang
  5. * Date: 2020/5/11
  6. * Time: 10:51
  7. */
  8. namespace pp\Console\Commands\ToolA;
  9. use Illuminate\Console\Command;
  10. class ContinueReadTool extends Command
  11. {
  12. /**
  13. * The name and signature of the console command.
  14. *
  15. * @var string
  16. */
  17. protected $signature = 'Tool:ContinueReadTool';
  18. /**
  19. * The console command description.
  20. *
  21. * @var string
  22. */
  23. protected $description = '继续阅读推送表迁移';
  24. /**
  25. * Create a new command instance.
  26. *
  27. * @return void
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. }
  33. /**
  34. * Execute the console command.
  35. *
  36. * @return mixed
  37. */
  38. public function handle()
  39. {
  40. }
  41. //寻找custom_push_keep_continue表距离当前一天的记录id
  42. private function findId(){
  43. $id = 0;
  44. while (true){
  45. if($id){
  46. $result = DB::connection('api_mysql')
  47. ->table('custom_push_keep_continue')
  48. ->where('id','<',$id)
  49. ->select('id','created_at')->orderBy('id','desc')->first();
  50. }else{
  51. $result = DB::connection('api_mysql')->table('custom_push_keep_continue')->select('id','created_at')->orderBy('id','desc')->first();
  52. }
  53. if($result){
  54. foreach ($result as $item){
  55. $id = $item->id;
  56. if(strtotime($item->created_at) <= time()-86400*1.5){
  57. return $item->id;
  58. }
  59. }
  60. }else{
  61. break;
  62. }
  63. }
  64. return $id;
  65. }
  66. }