mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Code for payouts
This commit is contained in:
parent
89ca5fb393
commit
99a90aa345
@ -6,6 +6,7 @@ use Illuminate\Console\Command;
|
|||||||
use App\Models\DbServer;
|
use App\Models\DbServer;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
use App\Libraries\CurlUtils;
|
||||||
|
|
||||||
class CalculatePayouts extends Command
|
class CalculatePayouts extends Command
|
||||||
{
|
{
|
||||||
@ -14,14 +15,14 @@ class CalculatePayouts extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'ninja:calculate-payouts';
|
protected $signature = 'ninja:calculate-payouts {--type=} {--url=} {--password=}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Calculate referral payouts';
|
protected $description = 'Calculate payouts';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,7 +43,20 @@ class CalculatePayouts extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$this->info('Running CalculatePayouts...');
|
$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']);
|
$servers = DbServer::orderBy('id')->get(['name']);
|
||||||
$userMap = [];
|
$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()
|
protected function getOptions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
['type', null, InputOption::VALUE_OPTIONAL, 'Type', null],
|
||||||
|
['url', null, InputOption::VALUE_OPTIONAL, 'Url', null],
|
||||||
|
['password', null, InputOption::VALUE_OPTIONAL, 'Password', null],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ class AppController extends BaseController
|
|||||||
|
|
||||||
public function stats()
|
public function stats()
|
||||||
{
|
{
|
||||||
if (! hash_equals(Input::get('password'), env('RESELLER_PASSWORD'))) {
|
if (! hash_equals(Input::get('password') ?: '', env('RESELLER_PASSWORD'))) {
|
||||||
sleep(3);
|
sleep(3);
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user