| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace App\Console\Commands\Redis;
- use App\Http\helper\Redis;
- use App\Http\logic\api\ExtensionLogic;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Log;
- use function AlibabaCloud\Client\envConversion;
- class SubCommand extends Command
- {
- // 1005=>TP、2030=>Rummy、2050=>Rummy两人、2060=>TPJoker玩法、2061=>TPAK玩法、2070=>Rummy10Card、2090=>Rummy两人十张
- // 2010=>百人TP、 2012=>百人AB 暂时忽略
- protected $GameIDs = [1005, 2030, 2050, 2060, 2061, 2070, 2090];
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'subcommand';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '裂变-游戏对局';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- dd(22);
- //设置php脚本执行时间
- set_time_limit(0);
- //设置socket连接超时时间redis-cli -h 8.129.91.11 -p 16973 -a 0949jfi959t*fbf0o
- //ini_set('default_socket_timeout', -1);
- try {
- $redis = \Illuminate\Support\Facades\Redis::connection('test');
- $channels = ['gameCount'];
- echo 'start' . "\n";
- $redis->unsubscribe($channels);
- $redis->psubscribe($channels, function ($channel, $message) {
- // Log::channel('SubCommand')->info('channel: ' . $channel . ' message: ' . $message);
- echo "channel:" . $channel . ",message:" . $message . "\n";
- //
- $data = explode(',', $channel);
- if (in_array($data[1], $this->GameIDs)) {
- Log::channel('SubCommand')->info('进来了,channel: ' . $channel . ' message: ' . $message);
- $redis = Redis::getInstance();
- $redis = $redis->redis_content();
- $redis->lPush('fission', $data[0]);
- $UserID = $data[0];
- (new ExtensionLogic())->userProfit($UserID, 0);
- //
- //// if (isset($r['code'])) {
- //// $msg = $r['msg'] ?? '';
- //// Log::channel('SubCommand')->info('执行结果:' . $msg);
- //// }
- //
- // Log::channel('SubCommand')->info('执行结束!!!');
- }
- });
- } catch (\Exception $e) {
- echo $e->getMessage();
- }
- }
- }
|