diff --git a/app/Console/Commands/CalculatePayouts.php b/app/Console/Commands/CalculatePayouts.php index 673b1d89f869..326fda0fe525 100644 --- a/app/Console/Commands/CalculatePayouts.php +++ b/app/Console/Commands/CalculatePayouts.php @@ -6,6 +6,7 @@ use Illuminate\Console\Command; use App\Models\DbServer; use App\Models\User; use App\Models\Company; +use App\Libraries\CurlUtils; class CalculatePayouts extends Command { @@ -14,14 +15,14 @@ class CalculatePayouts extends Command * * @var string */ - protected $signature = 'ninja:calculate-payouts'; + protected $signature = 'ninja:calculate-payouts {--type=} {--url=} {--password=}'; /** * The console command description. * * @var string */ - protected $description = 'Calculate referral payouts'; + protected $description = 'Calculate payouts'; /** @@ -42,7 +43,20 @@ class CalculatePayouts extends Command public function handle() { $this->info('Running CalculatePayouts...'); + $type = strtolower($this->option('type')); + switch ($type) { + case 'referral': + $this->referralPayouts(); + break; + case 'reseller': + $this->resellerPayouts(); + break; + } + } + + private function referralPayouts() + { $servers = DbServer::orderBy('id')->get(['name']); $userMap = []; @@ -81,10 +95,22 @@ class CalculatePayouts extends Command } } + private function resellerPayouts() + { + $response = CurlUtils::post($this->option('url') . '/reseller_stats', [ + 'password' => $this->option('password') + ]); + + $this->info('Response:'); + $this->info($response); + } + protected function getOptions() { return [ - + ['type', null, InputOption::VALUE_OPTIONAL, 'Type', null], + ['url', null, InputOption::VALUE_OPTIONAL, 'Url', null], + ['password', null, InputOption::VALUE_OPTIONAL, 'Password', null], ]; } diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php index 7d92ba73a9eb..f9290d2221da 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/AppController.php @@ -391,7 +391,7 @@ class AppController extends BaseController public function stats() { - if (! hash_equals(Input::get('password'), env('RESELLER_PASSWORD'))) { + if (! hash_equals(Input::get('password') ?: '', env('RESELLER_PASSWORD'))) { sleep(3); return '';