SubCommand.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace App\Console\Commands\Redis;
  3. use App\Http\helper\Redis;
  4. use App\Http\logic\api\ExtensionLogic;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Facades\Log;
  7. use function AlibabaCloud\Client\envConversion;
  8. class SubCommand extends Command
  9. {
  10. // 1005=>TP、2030=>Rummy、2050=>Rummy两人、2060=>TPJoker玩法、2061=>TPAK玩法、2070=>Rummy10Card、2090=>Rummy两人十张
  11. // 2010=>百人TP、 2012=>百人AB 暂时忽略
  12. protected $GameIDs = [1005, 2030, 2050, 2060, 2061, 2070, 2090];
  13. /**
  14. * The name and signature of the console command.
  15. *
  16. * @var string
  17. */
  18. protected $signature = 'subcommand';
  19. /**
  20. * The console command description.
  21. *
  22. * @var string
  23. */
  24. protected $description = '裂变-游戏对局';
  25. /**
  26. * Create a new command instance.
  27. *
  28. * @return void
  29. */
  30. public function __construct()
  31. {
  32. parent::__construct();
  33. }
  34. /**
  35. * Execute the console command.
  36. *
  37. * @return mixed
  38. */
  39. public function handle()
  40. {
  41. dd(22);
  42. //设置php脚本执行时间
  43. set_time_limit(0);
  44. //设置socket连接超时时间redis-cli -h 8.129.91.11 -p 16973 -a 0949jfi959t*fbf0o
  45. //ini_set('default_socket_timeout', -1);
  46. try {
  47. $redis = \Illuminate\Support\Facades\Redis::connection('test');
  48. $channels = ['gameCount'];
  49. echo 'start' . "\n";
  50. $redis->unsubscribe($channels);
  51. $redis->psubscribe($channels, function ($channel, $message) {
  52. // Log::channel('SubCommand')->info('channel: ' . $channel . ' message: ' . $message);
  53. echo "channel:" . $channel . ",message:" . $message . "\n";
  54. //
  55. $data = explode(',', $channel);
  56. if (in_array($data[1], $this->GameIDs)) {
  57. Log::channel('SubCommand')->info('进来了,channel: ' . $channel . ' message: ' . $message);
  58. $redis = Redis::getInstance();
  59. $redis = $redis->redis_content();
  60. $redis->lPush('fission', $data[0]);
  61. $UserID = $data[0];
  62. (new ExtensionLogic())->userProfit($UserID, 0);
  63. //
  64. //// if (isset($r['code'])) {
  65. //// $msg = $r['msg'] ?? '';
  66. //// Log::channel('SubCommand')->info('执行结果:' . $msg);
  67. //// }
  68. //
  69. // Log::channel('SubCommand')->info('执行结束!!!');
  70. }
  71. });
  72. } catch (\Exception $e) {
  73. echo $e->getMessage();
  74. }
  75. }
  76. }