CheckCommand.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace App\Console\Commands\Pair;
  3. use App\Models\Fpdx\PairModel;
  4. use App\Services\Pair\CheckService;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Facades\Redis;
  7. class CheckCommand extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'pair:check';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = '分配对象::匹配检测';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return mixed
  34. */
  35. public function handle()
  36. {
  37. $stage_id = $this->ask('选择期数?');
  38. $type = $this->choice('【分配对象】 请选择执行操作', [
  39. 'check' => '检验',
  40. 'baocun' => '保存',
  41. 'luodan' => '落单',
  42. 'data' => 'data'
  43. ]);
  44. $checkService = new CheckService();
  45. switch ($type) {
  46. case 'baocun':
  47. $checkService->baocun($stage_id);
  48. break;
  49. case 'check':
  50. $errors = $checkService->check($stage_id);
  51. dump($errors);
  52. break;
  53. case "luodan":
  54. $uid = $this->ask('请输入uid?');
  55. $pair = PairModel::where('uid', $uid)->where('stage_id', $stage_id)->first();
  56. $errors = $checkService->luodan($pair);
  57. break;
  58. case "data":
  59. $this->__data();
  60. break;
  61. }
  62. }
  63. private function __data()
  64. {
  65. $pairs = Redis::ZRANGE('pair:data', 0, -1, 'WITHSCORES');
  66. foreach ($pairs as $key => $pair_id) {
  67. $data = json_decode($key);
  68. $user = $data->user;
  69. $other = $data->other;
  70. $pair = $data->pair;
  71. if ($pair->score > 90) {
  72. echo $pair->uid . ",";
  73. }
  74. }
  75. }
  76. }