ReceiveRecord.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\RejectedBill;
  4. use Carbon\Carbon;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Facades\Log;
  7. class ReceiveRecord extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'record:scan';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'scan rejected record status';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. private static $delayedHour = 48;
  31. /**
  32. * Execute the console command.
  33. *
  34. */
  35. public function handle()
  36. {
  37. $delayedDateTime = Carbon::now()->subHours(self::$delayedHour)->toDateTimeString();
  38. Log::info("退件记录",["signTime"=>$delayedDateTime,"result"=>\App\ReceiveRecord::query()->where("record_at","<=",$delayedDateTime)
  39. ->where("delayed",0)->select("logistic_number")->pluck("logistic_number")->toArray()]);
  40. \App\ReceiveRecord::query()->where("record_at","<=",$delayedDateTime)
  41. ->where("delayed",0)
  42. ->update(["delayed"=>2]);
  43. \App\ReceiveRecord::query()
  44. ->where("record_at",">",$delayedDateTime)
  45. ->where("delayed",0)
  46. ->whereIn("logistic_number",RejectedBill::query()->select("logistic_number_return")
  47. ->where("created_at",">",$delayedDateTime)->whereIn("logistic_number_return",
  48. \App\ReceiveRecord::query()->select("logistic_number")
  49. ->where("record_at",">",$delayedDateTime)
  50. ->where("delayed",0)))->update(["delayed"=>1]);
  51. }
  52. }