diff --git a/app/Console/Commands/InviteAddTemporary.php b/app/Console/Commands/InviteAddTemporary.php index cb237a930..97bafb303 100644 --- a/app/Console/Commands/InviteAddTemporary.php +++ b/app/Console/Commands/InviteAddTemporary.php @@ -12,14 +12,14 @@ class InviteAddTemporary extends Command * * @var string */ - protected $signature = 'invite:tmp {uid} {days} {count}'; + protected $signature = 'invite:tmp {idRedisKey} {days} {count}'; /** * The console command description. * * @var string */ - protected $description = 'Add temporary invite to user, argument: uid(Multiple comma separated), days, count'; + protected $description = 'Add temporary invite to user, argument: idRedisKey, days, count'; /** * Execute the console command. @@ -28,14 +28,13 @@ class InviteAddTemporary extends Command */ public function handle() { - $uid = $this->argument('uid'); + $idRedisKey = $this->argument('idRedisKey'); $days = $this->argument('days'); $count = $this->argument('count'); - $log = "uid: $uid, days: $days, count: $count"; + $log = "idRedisKey: $idRedisKey, days: $days, count: $count"; $this->info($log); do_log($log); - $uidArr = preg_split('/[\s,]+/', $uid); - GenerateTemporaryInvite::dispatch($uidArr, $days, $count); + GenerateTemporaryInvite::dispatch($idRedisKey, $days, $count); return Command::SUCCESS; } } diff --git a/app/Jobs/GenerateTemporaryInvite.php b/app/Jobs/GenerateTemporaryInvite.php index 2791cc347..a064d0914 100644 --- a/app/Jobs/GenerateTemporaryInvite.php +++ b/app/Jobs/GenerateTemporaryInvite.php @@ -12,6 +12,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Str; +use Nexus\Database\NexusDB; class GenerateTemporaryInvite implements ShouldQueue { @@ -19,7 +20,7 @@ class GenerateTemporaryInvite implements ShouldQueue private int $count; - private array $uidArr; + private string $idRedisKey; private int $days; @@ -28,9 +29,9 @@ class GenerateTemporaryInvite implements ShouldQueue * * @return void */ - public function __construct(array $uidArr, int $days, int $count) + public function __construct(string $idRedisKey, int $days, int $count) { - $this->uidArr = $uidArr; + $this->idRedisKey = $idRedisKey; $this->days = $days; $this->count = $count; } @@ -57,7 +58,13 @@ public function retryUntil() public function handle() { $toolRep = new ToolRepository(); - foreach ($this->uidArr as $uid) { + $idStr = NexusDB::cache_get($this->idRedisKey); + if (empty($idStr)) { + do_log("no idStr of idRedisKey: {$this->idRedisKey}..."); + return; + } + $idArr = explode(",", $idStr); + foreach ($idArr as $uid) { try { $hashArr = $toolRep->generateUniqueInviteHash([], $this->count, $this->count); $data = []; diff --git a/public/take-increment-bulk.php b/public/take-increment-bulk.php index 702a21a34..b0d4b2cc7 100644 --- a/public/take-increment-bulk.php +++ b/public/take-increment-bulk.php @@ -59,10 +59,12 @@ break; } $idStr = implode(',', $idArr); + $idRedisKey = sprintf("temporary_invite:%d", microtime(true)); + \Nexus\Database\NexusDB::cache_put($idRedisKey, $idStr); if ($isTypeTmpInvite) { $command = sprintf( 'invite:tmp %s %s %s', - $idStr, $duration, $amount + $idRedisKey, $duration, $amount ); $output = executeCommand($command, 'string', true); do_log(sprintf('command: %s, output: %s', $command, $output));