PairMatchCommand.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace App\Console\Commands\Pair;
  3. use App\Models\Fpdx\ActivityModel;
  4. use App\Services\Pair\PairFirstMatch;
  5. use Illuminate\Console\Command;
  6. class PairMatchCommand extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'pair:match {task=first} {stage_id?}';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = '分配对象活动匹配';
  20. /** @var int 需要匹配的活动ID */
  21. protected $stageId;
  22. /**
  23. * Create a new command instance.
  24. *
  25. * @return void
  26. */
  27. public function __construct()
  28. {
  29. parent::__construct();
  30. }
  31. /**
  32. * Execute the console command.
  33. *
  34. * @return void
  35. */
  36. public function handle()
  37. {
  38. $stageId = $this->argument('stage_id');
  39. if ($stageId) {
  40. $this->stageId = $stageId;
  41. } else {
  42. if (
  43. !$activity = ActivityModel::currently()->first()
  44. ) {
  45. $this->error("没有找到该期");
  46. return;
  47. }
  48. $this->stageId = $stageId;
  49. }
  50. $task = $this->argument('task');
  51. if (method_exists($this, $task)) {
  52. $this->{$task}();
  53. } else {
  54. $this->error("没有找到该函数");
  55. return;
  56. }
  57. }
  58. public function preview()
  59. {
  60. }
  61. public function first()
  62. {
  63. $pairFirstMatch = new PairFirstMatch($this->stageId);
  64. $pairFirstMatch->run();
  65. dump($pairFirstMatch->matchResult);
  66. }
  67. public function reMatch()
  68. {
  69. }
  70. }