PairCommand.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace App\Console\Commands\Partner;
  3. use Illuminate\Console\Command;
  4. /**
  5. * Class PairCommand
  6. * @package App\Console\Commands\Partner
  7. */
  8. class PairCommand extends Command
  9. {
  10. /**
  11. * The name and signature of the console command.
  12. *
  13. * @var string
  14. */
  15. protected $signature = 'partner:pair';
  16. /**
  17. * The console command description.
  18. *
  19. * @var string
  20. */
  21. protected $description = '分配对象操作';
  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 mixed
  35. * @throws \Exception
  36. */
  37. public function handle()
  38. {
  39. $pairObj = new \App\Http\Controllers\Crontab\Pair();
  40. $name = $this->choice('【分配对象】 请选择执行操作', [
  41. 'pair' => '对象预匹配',
  42. 'account' => '分销',
  43. 'sync' => '同步历史匹配',
  44. ]);
  45. if ($this->confirm('每次活动只能执行一次,是否确定 ?')) {
  46. switch ($name) {
  47. case 'pair':
  48. $stage_id = $this->ask('请选择期数:');
  49. $begin = time();
  50. $this->line('对象匹配,正在执行...');
  51. $pairObj->prePipei($stage_id);
  52. $i = (time() - $begin) / 60;
  53. $this->line("对象匹配,执行成功,耗时{$i}分钟");
  54. break;
  55. case 'account':
  56. $stage_id = $this->ask('请输入期数:(0表示上一期)');
  57. $mediaObj = new \App\Http\Controllers\Fpdx\Media();
  58. $mediaObj->autoCpAccount($stage_id);
  59. $this->line('执行成功!');
  60. break;
  61. default:
  62. $this->error('参数错误!');
  63. }
  64. }
  65. }
  66. }