cleaned up code base thoroughly
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Assets;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
//Job
|
||||
use App\Jobs\Commands\Structures\ProcessAssetsJob;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Assets\AssetHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
class GetAssetsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:GetAssets';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Gets all of the assets of the holding corporation.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('GetAssets');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
ProcessAssetsJob::dispatch($charId, $corpId)->onQueue('assets');
|
||||
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use App\Library\Helpers\FinanceHelper;
|
||||
|
||||
class Test extends Command
|
||||
{
|
||||
@@ -48,27 +49,11 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
$helper = new FinanceHelper;
|
||||
$config = config('esi');
|
||||
|
||||
$receipt = $helper->GetApiWalletJournal(1, $config['primary']);
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Get the ESI Token
|
||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$stuff = $esi->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $config['corporation'],
|
||||
'division' => 1,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
dd($e);
|
||||
}
|
||||
|
||||
dd(json_decode($stuff->raw, true));
|
||||
var_dump($receipt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Finances;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Finances\ProcessWalletJournalJob;
|
||||
|
||||
class HoldingFinancesCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:HoldingJournal';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the holding corps finances.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Setup the Finances container
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
for($i = 1; $i <= 6; $i++) {
|
||||
ProcessWalletJournalJob::dispatch($i, $config['primary'])->onQueue('journal');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Finances;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Finances\ProcessWalletJournalJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
class SovBillsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:SovBills';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the holding corps sov bills from wallet 6.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$sovBill = new SovBillExpenses;
|
||||
$esiHelper = new Esi;
|
||||
$finance = new FinanceHelper();
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Create an ESI authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$char = $lookup->GetCharacterInfo($config['primary']);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Get the total pages for the journal for the sov bills from the holding corporation
|
||||
$pages = $finance->GetJournalPageCount(6, $config['primary']);
|
||||
|
||||
//Try to figure it out from the command itself.
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
printf("Getting page: " . $i . "\n");
|
||||
|
||||
try {
|
||||
$journals = $esi->page($i)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => 6,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
dd($wallet);
|
||||
foreach($wallet as $entry) {
|
||||
if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||
$sovBill->InsertSovBillExpense($entry, $corpId, $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,21 +23,11 @@ class Kernel extends ConsoleKernel
|
||||
Commands\Data\PurgeUsers::class,
|
||||
Commands\Data\EmptyJumpBridges::class,
|
||||
Commands\Data\CleanStaleDataCommand::class,
|
||||
Commands\Data\GetCorpsCommand::class,
|
||||
Commands\Data\Test::class,
|
||||
/**
|
||||
* Assets Commands
|
||||
*/
|
||||
Commands\Assets\GetAssetsCommand::class,
|
||||
/**
|
||||
* Eve Commands
|
||||
*/
|
||||
Commands\Eve\ItemPricesUpdateCommand::class,
|
||||
/**
|
||||
* Finances Commands
|
||||
*/
|
||||
Commands\Finances\HoldingFinancesCommand::class,
|
||||
Commands\Finances\SovBillsCommand::class,
|
||||
/**
|
||||
* Mining Tax Commands
|
||||
*/
|
||||
@@ -45,10 +35,6 @@ class Kernel extends ConsoleKernel
|
||||
Commands\MiningTaxes\MiningTaxesLedgers::class,
|
||||
Commands\MiningTaxes\MiningTaxesObservers::class,
|
||||
Commands\MiningTaxes\MiningTaxesPayments::class,
|
||||
/**
|
||||
* Structures Command
|
||||
*/
|
||||
Commands\Structures\GetStructuresCommand::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -61,34 +47,6 @@ class Kernel extends ConsoleKernel
|
||||
{
|
||||
//Horizon Graph Schedule
|
||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||
|
||||
/**
|
||||
* Moon Update Schedule
|
||||
*/
|
||||
|
||||
/**
|
||||
* System Rental Schedule
|
||||
*/
|
||||
$schedule->command('services:SystemRentals')
|
||||
->monthlyOn(1, '00:01')
|
||||
->withoutOverlapping();
|
||||
/**
|
||||
* Holding Corp Finance Schedule
|
||||
*/
|
||||
$schedule->command('services:HoldingJournal')
|
||||
->hourlyAt('45')
|
||||
->withoutOverlapping();
|
||||
|
||||
/**
|
||||
* Get Information Schedule
|
||||
*/
|
||||
$schedule->command('services:GetCorps')
|
||||
->monthlyOn(1, '09:00');
|
||||
$schedule->command('services:GetStructures')
|
||||
->dailyAt('09:00');
|
||||
$schedule->command('services:GetAssets')
|
||||
->hourlyAt('22');
|
||||
|
||||
/**
|
||||
* Purge Data Schedule
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ use Log;
|
||||
use DB;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Blacklist\BlacklistEntity;
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
|
||||
@@ -8,9 +8,9 @@ use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\SRP\SRPHelper;
|
||||
use App\Library\Helpers\TaxesHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
|
||||
@@ -10,9 +10,9 @@ use Khill\Lavacharts\Lavacharts;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\SRP\SRPHelper;
|
||||
use App\Library\Helpers\TaxesHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
|
||||
|
||||
@@ -1,400 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\SRP\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Doku\DokuGroupNames;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
use App\Models\SRP\SrpFleetType;
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\SRP\SrpShipType;
|
||||
use App\Models\SRP\SrpPayout;
|
||||
|
||||
|
||||
class StatisticsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Jump Bridge Statistics
|
||||
*/
|
||||
public function displayJumpBridgeStatistics() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$lava = new Lavacharts;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Taxes Statistics
|
||||
*/
|
||||
public function displayTaxes() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare variables needed for displaying items on the page
|
||||
$months = 3;
|
||||
$pi = array();
|
||||
$industry = array();
|
||||
$reprocessing = array();
|
||||
$office = array();
|
||||
$corpId = 98287666;
|
||||
$srpActual = array();
|
||||
$srpLoss = array();
|
||||
|
||||
/** Taxes Pane */
|
||||
//Declare classes needed for displaying items on the page
|
||||
$tHelper = new TaxesHelper;
|
||||
$srpHelper = new SRPHelper;
|
||||
//Get the dates for the tab panes
|
||||
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||
//Get the data for the Taxes Pane
|
||||
foreach($dates as $date) {
|
||||
//Get the srp actual pay out for the date range
|
||||
$srpActual[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($srpHelper->GetAllianceSRPActual($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
//Get the srp loss value for the date range
|
||||
$srpLoss[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($srpHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
//Get the pi taxes for the date range
|
||||
$pis[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetPIGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the industry taxes for the date range
|
||||
$industrys[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetIndustryGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the reprocessing taxes for the date range
|
||||
$reprocessings[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetReprocessingGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the office taxes for the date range
|
||||
$offices[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetOfficeGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the market taxes for the date range
|
||||
$markets[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetAllianceMarketGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the jump gate taxes for the date range
|
||||
$jumpgates[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
}
|
||||
|
||||
return view('admin.dashboards.taxes')->with('pis', $pis)
|
||||
->with('industrys', $industrys)
|
||||
->with('offices', $offices)
|
||||
->with('markets', $markets)
|
||||
->with('jumpgates', $jumpgates)
|
||||
->with('reprocessings', $reprocessings)
|
||||
->with('srpActual', $srpActual)
|
||||
->with('srpLoss', $srpLoss);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display wiki statistics
|
||||
*/
|
||||
public function displayWikiStatistics() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display SRP Statistics
|
||||
*/
|
||||
public function displaySRPStatistics() {
|
||||
$months = 3;
|
||||
$barChartData = array();
|
||||
$start = Carbon::now()->toDateTimeString();
|
||||
$end = Carbon::now()->subMonths(1)->toDateTimeString();
|
||||
|
||||
//Declare the Lavacharts variable
|
||||
$lava = new Lavacharts;
|
||||
|
||||
//We need a function from this library rather than recreating a new library
|
||||
$srpHelper = new SRPHelper();
|
||||
|
||||
/**
|
||||
* Pie chart for the number of approved, denied, and under review payouts currently in the system.
|
||||
*/
|
||||
//Get the count of open srp requests
|
||||
$pieOpen = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
//Get the count of approved srp requests
|
||||
$pieApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
//Get the count of denied srp requests
|
||||
$pieDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
|
||||
//Create a new datatable for the lavachart.
|
||||
$srp = $lava->DataTable();
|
||||
//Add string columns, number columns, and data rows for the chart
|
||||
$srp->addStringColumn('ISK Value')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['Approved', $pieApproved])
|
||||
->addRow(['Denied', $pieDenied])
|
||||
->addRow(['Under Review', $pieOpen]);
|
||||
//Create the pie chart in memory with any options needed to render the chart
|
||||
$lava->PieChart('SRP Stats', $srp, [
|
||||
'title' => 'SRP Stats',
|
||||
'is3D' => true,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Gauage chart for showing number of open srp requests
|
||||
*/
|
||||
//Create a new datatable in the
|
||||
$adur = $lava->DataTable();
|
||||
//Add string columns, number columns, and data row for the chart
|
||||
$adur->addStringColumn('Type')
|
||||
->addNumberColumn('Value')
|
||||
->addRow(['Under Review', $pieOpen]);
|
||||
//Create the gauge chart with any options needed to render the chart
|
||||
$lava->GaugeChart('SRP', $adur, [
|
||||
'width' => 400,
|
||||
'greenFrom' => 0,
|
||||
'greenTo' => 20,
|
||||
'yellowFrom' => 20,
|
||||
'yellowTo' => 40,
|
||||
'redFrom' => 40,
|
||||
'redTo' => 100,
|
||||
'majorTicks' => [
|
||||
'Safe',
|
||||
'Critical',
|
||||
],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Create a vertical chart of all of the cost codes for the ships being SRP'ed.
|
||||
* The chart will be by cost code of ships being replaced
|
||||
*/
|
||||
//Declare the data table
|
||||
$costCodeChart = $lava->DataTable();
|
||||
|
||||
//Get the approved, under review, and denied cost codes and amounts
|
||||
$t1fdcApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('paid_value');
|
||||
$t1fdcUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('loss_value');
|
||||
$t1fdcDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1bcApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('paid_value');
|
||||
$t1bcUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('loss_value');
|
||||
$t1bcDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t2fdApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('paid_value');
|
||||
$t2fdUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('loss_value');
|
||||
$t2fdDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t3dApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('paid_value');
|
||||
$t3dUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('loss_value');
|
||||
$t3dDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1t2logiApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('paid_value');
|
||||
$t1t2logiUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('loss_value');
|
||||
$t1t2logiDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('loss_value');
|
||||
|
||||
$reconsApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('paid_value');
|
||||
$reconsUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('loss_value');
|
||||
$reconsDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t2cApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('paid_value');
|
||||
$t2cUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('loss_value');
|
||||
$t2cDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t3cApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('paid_value');
|
||||
$t3cUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('loss_value');
|
||||
$t3cDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('loss_value');
|
||||
|
||||
$commandApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('paid_value');
|
||||
$commandUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('loss_value');
|
||||
$commandDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('loss_value');
|
||||
|
||||
$interdictorApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('paid_value');
|
||||
$interdictorUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('loss_value');
|
||||
$interdictorDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1bsApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('paid_value');
|
||||
$t1bsUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('loss_value');
|
||||
$t1bsDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('loss_value');
|
||||
|
||||
$dksApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('paid_value');
|
||||
$dksUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('loss_value');
|
||||
$dksDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('loss_value');
|
||||
|
||||
|
||||
//Add string column, number columns.
|
||||
$costCodeChart->addStringColumn('SRP Costs')
|
||||
->addNumberColumn('Approved')
|
||||
->addNumberColumn('Under Review')
|
||||
->addNumberColumn('Denied')
|
||||
->addRow(['T1FDC', $t1fdcApproved, $t1fdcUnderReview, $t1fdcDenied])
|
||||
->addRow(['T1BC', $t1bcApproved, $t1bcUnderReview, $t1bcDenied])
|
||||
->addRow(['T1BS', $t1bsApproved, $t1bsUnderReview, $t1bsDenied])
|
||||
->addRow(['T2FD', $t2fdApproved, $t2fdUnderReview, $t2fdDenied])
|
||||
->addRow(['T2C', $t2cApproved, $t2cUnderReview, $t2cDenied])
|
||||
->addRow(['T1T2Logi', $t1t2logiApproved, $t1t2logiUnderReview, $t1t2logiDenied])
|
||||
->addRow(['T3D', $t3dApproved, $t3dUnderReview, $t3dDenied])
|
||||
->addRow(['T3C', $t3cApproved, $t3cUnderReview, $t3cDenied])
|
||||
->addRow(['RECON', $reconsApproved, $reconsUnderReview, $reconsDenied])
|
||||
->addRow(['COMMAND', $commandApproved, $commandUnderReview, $commandDenied])
|
||||
->addRow(['DKS', $dksApproved, $dksUnderReview, $dksDenied]);
|
||||
|
||||
$lava->ColumnChart('Cost Codes', $costCodeChart, [
|
||||
'columns' => 4,
|
||||
'title' => 'Cost Code SRP Chart',
|
||||
'titleTextStyle' => [
|
||||
'color' => '#eb6b2c',
|
||||
'fontSize' => 14,
|
||||
],
|
||||
]);
|
||||
|
||||
return view('srp.admin.statistics')->with('lava', $lava);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Finances;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AdminWarpedBondsController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
$this->middleware('permission:admin.bonds');
|
||||
}
|
||||
|
||||
public function DisplayNewBondForm() {
|
||||
|
||||
}
|
||||
|
||||
public function StoreNewBond() {
|
||||
|
||||
}
|
||||
|
||||
public function DeleteBond() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Finances;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WarpedBondsController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function DisplayAvailableBonds() {
|
||||
|
||||
}
|
||||
|
||||
public function StoreBonds() {
|
||||
|
||||
}
|
||||
|
||||
public function RedeemBonds() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,13 @@ use Auth;
|
||||
use Charts;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Assets\AssetHelper;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Library\Helpers\AssetHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Asset;
|
||||
use App\Models\Structure\Service;
|
||||
|
||||
class FuelController extends Controller
|
||||
{
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Logistics;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Logistics\AnchorStructure;
|
||||
|
||||
class StructureRequestAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:fc.team');
|
||||
}
|
||||
|
||||
public function displayRequests() {
|
||||
$reqs = AnchorStructure::all();
|
||||
|
||||
return view('structurerequest.display.structurerequests')->with('reqs', $reqs);
|
||||
}
|
||||
|
||||
public function deleteRequest(Request $request) {
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
]);
|
||||
|
||||
AnchorStructure::where([
|
||||
'id' => $request->id,
|
||||
])->delete();
|
||||
|
||||
return redirect('/structures/display/requests');
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Logistics;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Logistics\AnchorStructure;
|
||||
use App\Models\User\UserPermission;
|
||||
|
||||
class StructureRequestController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displayForm() {
|
||||
return view('structurerequest.requeststructure');
|
||||
}
|
||||
|
||||
public function storeForm(Request $request) {
|
||||
$this->validate($request, [
|
||||
'corporation_name' => 'required',
|
||||
'system' => 'required',
|
||||
'structure_size' => 'required',
|
||||
'structure_type' => 'required',
|
||||
'requested_drop_time' => 'required',
|
||||
'requester' => 'required',
|
||||
]);
|
||||
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
$config = config('esi');
|
||||
|
||||
$requesterId = $lookup->CharacterNameToId($request->requester);
|
||||
$corporationId = $lookup->CorporationNameToId($request->corporation_name);
|
||||
|
||||
AnchorStructure::insert([
|
||||
'corporation_id' => $corporationId,
|
||||
'corporation_name' => $request->corporation_name,
|
||||
'system' => $request->system,
|
||||
'structure_size' => $request->structure_size,
|
||||
'structure_type' => $request->structure_type,
|
||||
'requested_drop_time' => $request->requested_drop_time,
|
||||
'requester_id' => $requesterId,
|
||||
'requester' => $request->requester,
|
||||
]);
|
||||
|
||||
//Send a mail out to the FC Team
|
||||
$fcTeam = UserPermission::where([
|
||||
'permission' => 'fc.team',
|
||||
])->get();
|
||||
|
||||
//Set the mail delay
|
||||
$delay = 30;
|
||||
|
||||
foreach($fcTeam as $fc) {
|
||||
$body = "Structure Anchor Request has been entered.<br>";
|
||||
$body .= "Please check the W4RP Services Site for the structure information.<br>";
|
||||
$body .= "<br>Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Dispatch the mail job
|
||||
$subject = "New Structure Anchor Request";
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$fc->character_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
|
||||
$delay += 30;
|
||||
}
|
||||
|
||||
return redirect('/dashboard')->with('success', 'Structure request successfully submitted.');
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ use Khill\Lavacharts\Lavacharts;
|
||||
use Auth;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moons;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Config;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\RentalMoon;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\Price;
|
||||
use App\Models\Moon\AllianceMoon;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\AllianceMoonRequest;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
class MoonsAdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* Variable for the class
|
||||
*/
|
||||
private $romans = [
|
||||
'M' => 1000,
|
||||
'CM' => 900,
|
||||
'D' => 500,
|
||||
'CD' => 400,
|
||||
'C' => 100,
|
||||
'XC' => 90,
|
||||
'L' => 50,
|
||||
'XL' => 40,
|
||||
'X' => 10,
|
||||
'IX' => 9,
|
||||
'V' => 5,
|
||||
'IV' => 4,
|
||||
'I' => 1,
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor for the class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
public function ImportMoonSurveyData(Request $request) {
|
||||
//Declare variables
|
||||
$added = 0;
|
||||
$updated = 0;
|
||||
$moon = null;
|
||||
$newMoon = false;
|
||||
$num = 0;
|
||||
$planet = null;
|
||||
$moonNumber = null;
|
||||
|
||||
foreach(explode("\n", $request->input('data')) as $row) {
|
||||
$cols = explode("\t", $row);
|
||||
dd($cols);
|
||||
}
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'Import done: ' . $added . ' moons added ' . $updated . ' moons updated.');
|
||||
}
|
||||
|
||||
private function romanNumberToInteger($roman) {
|
||||
$result = 0;
|
||||
|
||||
foreach($this->romans as $key => $value) {
|
||||
while(strpos($roman, $key) === 0) {
|
||||
$result += $value;
|
||||
$roman = substr($roman, strlen($key));
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function integerToRomanNumber($number) {
|
||||
$returnValue = '';
|
||||
while($number > 0) {
|
||||
foreach($this->romans as $roman => $int) {
|
||||
if($number >= $int) {
|
||||
$number -= $int;
|
||||
$returnValue .= $roman;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
private function arrayToCsv(array $rows) {
|
||||
//Declare needed variable as text null
|
||||
$result = '';
|
||||
|
||||
//Open the temp file
|
||||
$fp = fopen('php://temp', 'w');
|
||||
|
||||
//Process the file
|
||||
foreach($rows as $fields) {
|
||||
fputcsv($fp, $fields, ';', '"');
|
||||
|
||||
}
|
||||
|
||||
//Go back to the beginning of the file
|
||||
rewind($fp);
|
||||
|
||||
//Continue through the buffer until the end
|
||||
while(($buffer = fgets($fp, 4096)) !== false) {
|
||||
$result .= $buffer;
|
||||
}
|
||||
|
||||
//Close the temp file
|
||||
fclose($fp);
|
||||
|
||||
//Return the result
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moons;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Config;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\Price;
|
||||
use App\Models\Moon\AllianceMoon;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\AllianceMoonRequest;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
class MoonsController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Renter');
|
||||
}
|
||||
|
||||
public function displayTotalWorthForm() {
|
||||
return view('moons.user.formTotalWorth');
|
||||
}
|
||||
|
||||
public function displayTotalWorth(Request $request) {
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
||||
$composition = [
|
||||
'Tritanium' => 0,
|
||||
'Pyerite' => 0,
|
||||
'Mexallon' => 0,
|
||||
'Isogen' => 0,
|
||||
'Nocxium' => 0,
|
||||
'Zydrine' => 0,
|
||||
'Megacyte' => 0,
|
||||
'Atmospheric_Gases' => 0,
|
||||
'Evaporite_Deposits' => 0,
|
||||
'Hydrocarbons' => 0,
|
||||
'Silicates' => 0,
|
||||
'Cobalt' => 0,
|
||||
'Scandium' => 0,
|
||||
'Titanium' => 0,
|
||||
'Tungsten' => 0,
|
||||
'Cadmium' => 0,
|
||||
'Platinum' => 0,
|
||||
'Vanadium'=> 0,
|
||||
'Chromium' => 0,
|
||||
'Technetium' => 0,
|
||||
'Hafnium' => 0,
|
||||
'Caesium' => 0,
|
||||
'Mercury' => 0,
|
||||
'Dysprosium' => 0,
|
||||
'Neodymium' => 0,
|
||||
'Promethium' => 0,
|
||||
'Thulium' => 0,
|
||||
];
|
||||
|
||||
$firstOre = $request->firstOre;
|
||||
if($request->firstQuantity >= 1.00) {
|
||||
$firstQuantity = $request->firstQuantity / 100.00;
|
||||
} else {
|
||||
$firstQuantity = $request->firstQuantity;
|
||||
}
|
||||
|
||||
$secondOre = $request->secondOre;
|
||||
if($request->secondQuantity >= 1.00) {
|
||||
$secondQuantity = $request->secondQuantity / 100.00;
|
||||
} else {
|
||||
$secondQuantity = $request->secondQuantity;
|
||||
}
|
||||
|
||||
$thirdOre = $request->thirdOre;
|
||||
if($request->thirdQuantity >= 1.00) {
|
||||
$thirdQuantity = $request->thirdQuantity / 100.00;
|
||||
} else {
|
||||
$thirdQuantity = $request->thirdQuantity;
|
||||
}
|
||||
|
||||
$fourthOre = $request->fourthOre;
|
||||
if($request->fourthQuantity >= 1.00) {
|
||||
$fourthQuantity = $request->fourthQuantity / 100.00;
|
||||
} else {
|
||||
$fourthQuantity = $request->fourthQuantity;
|
||||
}
|
||||
|
||||
if($request->reprocessing >= 1.00) {
|
||||
$reprocessing = $request->reprocessing / 100.00;
|
||||
} else {
|
||||
$reprocessing = $request->reprocessing;
|
||||
}
|
||||
|
||||
//Set the reprocessing level for 84% if the value is null
|
||||
if($request->reprocessing == null) {
|
||||
$reprocessing = 0.84;
|
||||
}
|
||||
|
||||
//Get the total percentage of the ores, and normalize it to 1.00.
|
||||
$totalPercent = $firstQuantity + $secondQuantity + $thirdQuantity + $fourthQuantity;
|
||||
if($totalPercent < 1.00) {
|
||||
$firstQuantity = $firstQuantity / $totalPercent;
|
||||
$secondQuantity = $secondQuantity / $totalPercent;
|
||||
$thirdQuantity = $thirdQuantity / $totalPercent;
|
||||
$fourthQuantity = $fourthQuantity / $totalPercent;
|
||||
}
|
||||
|
||||
//Calculate the total worth of the moon
|
||||
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||
//Format the number to send to the blade.
|
||||
$totalWorth = number_format($totalWorth, 2, ".", ",");
|
||||
|
||||
//Get the composition for the first ore if it is not None.
|
||||
//Add the first ore composition to the final composition
|
||||
if($firstOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$firstComp = $moonCalc->GetOreComposition($firstOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($firstOre, $firstQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
//Compile the composition of the ore
|
||||
$composition['Tritanium'] += floor(($firstComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($firstComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($firstComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($firstComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($firstComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($firstComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($firstComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($firstComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($firstComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($firstComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($firstComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($firstComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($firstComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($firstComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($firstComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($firstComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($firstComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($firstComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($firstComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($firstComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($firstComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($firstComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($firstComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($firstComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($firstComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($firstComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($firstComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
//Get the composition for the second ore if it is not None.
|
||||
//Add the second ore composition to the final composition
|
||||
if($secondOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$secondComp = $moonCalc->GetOreComposition($secondOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($secondOre, $secondQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
$composition['Tritanium'] += floor(($secondComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($secondComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($secondComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($secondComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($secondComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($secondComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($secondComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($secondComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($secondComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($secondComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($secondComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($secondComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($secondComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($secondComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($secondComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($secondComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($secondComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($secondComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($secondComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($secondComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($secondComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($secondComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($secondComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($secondComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($secondComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($secondComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($secondComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
//Get the composition for the third ore if it is not None.
|
||||
//Add the third ore composition to the final composition
|
||||
if($thirdOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$thirdComp = $moonCalc->GetOreComposition($thirdOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($thirdOre, $thirdQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
$composition['Tritanium'] += floor(($thirdComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($thirdComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($thirdComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($thirdComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($thirdComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($thirdComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($thirdComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($thirdComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($thirdComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($thirdComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($thirdComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($thirdComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($thirdComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($thirdComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($thirdComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($thirdComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($thirdComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($thirdComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($thirdComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($thirdComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($thirdComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($thirdComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($thirdComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($thirdComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($thirdComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($thirdComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($thirdComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
//Get the composition for the fourth ore if it is not None.
|
||||
//Add the fourth ore composition to the final composition
|
||||
if($fourthOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$fourthComp = $moonCalc->GetOreComposition($fourthOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($fourthOre, $fourthQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
$composition['Tritanium'] += floor(($fourthComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($fourthComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($fourthComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($fourthComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($fourthComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($fourthComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($fourthComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($fourthComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($fourthComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($fourthComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($fourthComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($fourthComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($fourthComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($fourthComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($fourthComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($fourthComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($fourthComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($fourthComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($fourthComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($fourthComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($fourthComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($fourthComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($fourthComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($fourthComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($fourthComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($fourthComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($fourthComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
return view('moons.user.displayTotalWorth')->with('totalWorth', $totalWorth)
|
||||
->with('composition', $composition)
|
||||
->with('reprocessing', $reprocessing);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ use Khill\Lavacharts\Lavacharts;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//User Libraries
|
||||
use App\Library\SRP\SRPHelper;
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\SRPShip;
|
||||
|
||||
@@ -7,7 +7,8 @@ use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
|
||||
//User Libraries
|
||||
//Application Libraries
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\SRPShip;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Test;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Finances;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessWalletJournal;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessWalletJournalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
public $tries = 3;
|
||||
|
||||
private $division;
|
||||
private $charId;
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($division, $charId) {
|
||||
$this->division = $division;
|
||||
$this->charId = $charId;
|
||||
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* Utilized by using ProcessWalletJournalJob::dispatch()
|
||||
* The model is passed into the dispatch function, then added to the queue
|
||||
* for processing.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the class variable we need
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$finance->GetWalletJournal($this->division, $this->charId);
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process.
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception)
|
||||
{
|
||||
Log::critical($exception);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
|
||||
//Might not need this class with current implementation of the mailing system
|
||||
class MailMiningTaxesInvoiceJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Moons;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\CorpMoonLedger;
|
||||
use App\Models\Moon\CorpMoonObserver;
|
||||
|
||||
|
||||
class FetchMoonLedgerJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Private Variables
|
||||
*/
|
||||
private $charId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId)
|
||||
{
|
||||
//Set the character id
|
||||
$this->charId = $charId;
|
||||
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare Variables
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$response = null;
|
||||
$structureInfo = null;
|
||||
|
||||
//Get the configuration for the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for esi scope for the character
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($this->charId, 'esi-universe.read_structures.v1')) {
|
||||
Log::critical('The primary character does not have the necessary scopes for FetchRentalMoonLedgerCommand.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token if the scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||
|
||||
//Setup the esi information
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get the character data from the lookup table
|
||||
$character = $lookup->GetCharacterInfo($this->charId);
|
||||
|
||||
//Get the corporation data from the lookup table
|
||||
$corporation = $lookup->GetCorporationInfo($character->corporation_id);
|
||||
|
||||
//Setup the structure helper
|
||||
$structure = new StructureHelper($this->charId, $character->corporation_id, $esi);
|
||||
|
||||
//Get the moon observers from the database
|
||||
$observers = CorpMoonObserver::where([
|
||||
'corporation_id' => $character->corporation_id,
|
||||
])->get();
|
||||
|
||||
foreach($observers as $observer) {
|
||||
//Try to get the ledger data from the esi
|
||||
try {
|
||||
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
'observer_id' => $observer->observer_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//Log the exception
|
||||
Log::critical('FetchMoonLedger job failed to get the mining ledgers.');
|
||||
}
|
||||
|
||||
if($ledgers != null) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Get the ore name from the lookup table
|
||||
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||
|
||||
//Get the character name from the lookup helper
|
||||
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||
//Get the corporation info from the lookup helper
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
//Get the recorded corporation information
|
||||
$recordedCorpInfo = $lookup->GetCorporationInfo($ledger->recorded_corporation_id);
|
||||
|
||||
$entries[] = [
|
||||
'corporation_id' => $corpInfo->corporation_id,
|
||||
'corporation_name' => $corpInfo->name,
|
||||
'character_id' => $ledger->character_id,
|
||||
'character_name' => $charInfo->name,
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_name' => $observer->observer_name,
|
||||
'type_id' => $ledger->type_id,
|
||||
'ore' => $ore,
|
||||
'quantity' => $ledger->quantity,
|
||||
'recorded_corporation_id' => $ledger->recorded_corporation_id,
|
||||
'recorded_corporation_name' => $recordedCorpInfo->name,
|
||||
'last_updated' => $ledger->last_updated,
|
||||
'created_at' => $ledger->last_updated . ' 23:59:59',
|
||||
'updated_at' => $ledger->last_updated . ' 23:59:59',
|
||||
];
|
||||
}
|
||||
|
||||
//Insert or ignore each entry into the database
|
||||
CorpMoonLedger::insertOrIgnore($entries);
|
||||
|
||||
Log::info('FetchMoonLedgerJob inserted up to ' . count($entries) . 'into the database.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Moons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\CorpMoonObserver;
|
||||
|
||||
class FetchMoonObserverJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Private variables
|
||||
*/
|
||||
private $charId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId)
|
||||
{
|
||||
//Set the character id
|
||||
$this->charId = $charId;
|
||||
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the configuration from the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($this->charId, 'esi-universe.read_structures.v1')) {
|
||||
Log::warning('Esi scopes were not found for Fetch Moon Observers job.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token for the character
|
||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Get the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//With the lookup helper, get the character information
|
||||
$character = $lookup->GetCharacterInfo($this->charId);
|
||||
//With the lookup helper, get the corporation information
|
||||
$corporation = $lookup->GetCorporationInfo($character->corporation_id);
|
||||
|
||||
//Delcare the structure helper since we have the necessary data
|
||||
$structureHelper = new StructureHelper($this->charId, $character->corporation_id, $esi);
|
||||
|
||||
//Get the mining observers for the corporation's from esi
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical('FetchMoonObservers failed to get the moon observers for the corporation');
|
||||
return null;
|
||||
}
|
||||
|
||||
//Run through the mining observers, and add them to the database as needed
|
||||
foreach($response as $observer) {
|
||||
$count = CorpMoonObserver::where(['observer_id' => $observer->observer_id])->count();
|
||||
//If the observer is not found, then add it to the database
|
||||
if($count == 0) {
|
||||
//Get the structure information from the universe structure esi endpoint
|
||||
$structureInfo = $structureHelper->GetStructureInfo($observer->observer_id);
|
||||
//Create a new corp moon observer in the database
|
||||
$obs = new CorpMoonObserver;
|
||||
$obs->corporation_id = $character->corporation_id;
|
||||
$obs->corporation_name = $corporation->name;
|
||||
$obs->observer_id = $observer->observer_id;
|
||||
$obs->observer_name = $structureInfo->name;
|
||||
$obs->observer_owner_id = $structureInfo->owner_id;
|
||||
$obs->solar_system_id = $structureInfo->solar_system_id;
|
||||
$obs->observer_type = $observer->observer_type;
|
||||
$obs->observer_type_id = $structureInfo->type_id;
|
||||
$obs->last_updated = $observer->last_updated;
|
||||
$obs->save();
|
||||
} else {
|
||||
CorpMoonObserver::where([
|
||||
'observer_id' => $observer->observer_id,
|
||||
])->update([
|
||||
'last_updated' => $observer->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Moons;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\CorpMoonLedger;
|
||||
|
||||
class PurgeMoonLedgerJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$previous = Carbon::now()->subDays(60);
|
||||
|
||||
//Remove old ledger entries
|
||||
CorpMoonLedger::where('created_at', '<', $previous)->delete();
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
|
||||
/**
|
||||
* This job will send out a reminder about the moon rental payment being due
|
||||
* when it's due based on the rental paid date versus rental date. If the paid
|
||||
* date is in the future from today, then we don't need to send out a reminder.
|
||||
* If the paid date is today or less, then we need to send out a reminder about
|
||||
* paying for the moon rental.
|
||||
*/
|
||||
class SendMoonRentalPaymentReminderJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 1600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the queue connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Get today's date
|
||||
$today = Carbon::now();
|
||||
$today->second = 1;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
//Declare some other variables
|
||||
$totalCost = 0.00;
|
||||
$moonList = array();
|
||||
$delay = 30;
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
|
||||
//Get all of the contacts from the rentals group
|
||||
$contacts = AllianceMoonRental::select('rental_contact_id')->groupBy('rental_contact_id')->get();
|
||||
|
||||
//For each of the contacts, totalize the moon rentals, and create a reminder mail
|
||||
foreach($contacts as $contact) {
|
||||
//Get the moons the renter is renting, but only get the ones whose paid date is not after today.
|
||||
$dues = $this->GetMoonDueList($contact->rental_contact_id);
|
||||
|
||||
//Get the list of moons for the mail body.
|
||||
$alls = $this->GetMoonRentalList($contact->rental_contact_id);
|
||||
|
||||
//Totalize the cost for the moons whose rent is due
|
||||
$cost = $this->TotalizeMoonCost($contact->rental_contact_id);
|
||||
|
||||
//For each of the rentals, build the mail body, and totalize the cost of the moon
|
||||
$body = "Moon Rent is due for the following moons:<br>";
|
||||
foreach($rentalsDue as $due) {
|
||||
$body .= $due . "<br>";
|
||||
}
|
||||
//Put the price for the moons
|
||||
$body .= "The price for next month's rent is " . number_format($cost, 0, ".", ",") . "<br>";
|
||||
$body .= "Rental Payment is due on the 1st of the month. If the rental payment is not remitted to Spatial Forces by the 3rd of the month, the rental claim shall be forfeited.<br>";
|
||||
$body .= "Rental Payment should be transferred to Spatial Forces.<br>";
|
||||
$body .= "In the description of the payment please put the following transaction identification: " . $transId . "<br>";
|
||||
$body .= "<br>";
|
||||
$body .= $contact->contact_name . " is responsible for payment of the moons.<br>";
|
||||
$body .= "The following moons are being rented:<br>";
|
||||
foreach($alls as $all) {
|
||||
$body .= $all . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Create the subject line
|
||||
$subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
|
||||
//Dispatch the mail job if the contact type is a character, otherwise
|
||||
//dispatch the job to the ceo of the corporation instead. If the contact is an alliance
|
||||
//dispatch the job to the ceo of the holding corporation.
|
||||
if($contact->contact_type == 'Character') {
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$contact->rental_contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
//Increment the delay to get ready for the next mail job
|
||||
$delay += 30;
|
||||
} else if($contact->contact_type == 'Corporation') {
|
||||
//Get the CEO of the corporation from the lookup helper
|
||||
$corporation = $lookup->GetCorporationInfo($contact->rental_contact_id);
|
||||
$charId = $corporation->ceo_id;
|
||||
//Send out the mail
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
//Increment the delay to get ready for the next mail job
|
||||
$delay += 30;
|
||||
} else if($contact->contact_type == 'Alliance') {
|
||||
//Get the holding corporation from the lookup helper
|
||||
$alliance = $lookup->GetAllianceInfo($contact->rental_contact_id);
|
||||
//Get the CEO of the corporation of the holding corp from the lookup helper
|
||||
$corporation = $lookup->GetCorporationInfo($alliance->executor_corporation_id);
|
||||
$charId = $corporation->ceo_id;
|
||||
//Send out the mail
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primaryh'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
//Increment the detaly to get ready for the next mail job
|
||||
$delay += 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function GetMoonRentalsList($contact) {
|
||||
//Declare the variables
|
||||
$list = array();
|
||||
|
||||
$moons = AllianceMoonRental::where([
|
||||
'rental_contact_id' => $contact,
|
||||
])->get();
|
||||
|
||||
foreach($moons as $moon) {
|
||||
$temp = 'Rental: ' . $moon->region . ' - ' . $moon->system . ' - ' . $moon->planet . ' - ' . $moon->moon;
|
||||
array_push($list, $temp);
|
||||
}
|
||||
|
||||
//Return the list
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function GetMoonDueList($contact) {
|
||||
//Declare the variables
|
||||
$list = array();
|
||||
|
||||
$moons = AllianceMoonRental::where([
|
||||
'rental_contact_id' => $contact,
|
||||
])->where('paid_until', '<=', $today)->get();
|
||||
|
||||
//Create the list
|
||||
foreach($moons as $moon) {
|
||||
$temp = 'Rental: ' . $moon->region . ' - ' . $moon->system . ' - ' . $moon->planet . ' - ' . $moon->moon;
|
||||
array_push($list, $temp);
|
||||
}
|
||||
|
||||
//Return the list
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function TotalizeCost($rentals, $rentalType) {
|
||||
//Declare the stuff we need
|
||||
$totalCost = 0.00;
|
||||
|
||||
//Totalize the cost
|
||||
foreach($rentals as $rental) {
|
||||
if($rentalType = 'In Alliance') {
|
||||
$totalCost += $rental->alliance_rental_price;
|
||||
} else {
|
||||
$totalCost += $rental->out_of_alliance_rental_price;
|
||||
}
|
||||
}
|
||||
|
||||
return $totalCost;
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
class UpdateMoonRentalPaidState implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 1600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the queue connection up
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$mailDelay = 5;
|
||||
|
||||
//Get all of the moons from the rental database
|
||||
$moons = AllianceRentalMoons::all();
|
||||
|
||||
//Set today's date
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get the esi configuration
|
||||
$esiConfig = config('esi');
|
||||
|
||||
/**
|
||||
* For each of the moons check the rental until date, the paid until date,
|
||||
* and compare them to today's current date.
|
||||
*
|
||||
* If the paid date is later than the rental until date, then update the rental until
|
||||
* date to match the paid date. If the paid until date is today or less, then update the
|
||||
* paid column of the moon to not paid. If the moon hasn't been paid 2 weeks after the first
|
||||
* of the month, then remove the renter, and send an eve mail to alliance leadership, and the renter
|
||||
* denoting failure of payment has resulted in the moon rental for the current month being
|
||||
* revoked.
|
||||
*/
|
||||
foreach($moon as $rental) {
|
||||
//Setup the rental date, paid until date, and today's date as functions of Carbon library
|
||||
$rentedUntil = new Carbon($rental->rental_until);
|
||||
$paidUntil = new Carbon($rental->paid_until);
|
||||
|
||||
//If the paid date is larger than the rental date, then update the rental date
|
||||
if($paidUntil->greaterThan($rentedUntil)) {
|
||||
AllianceMoonRental::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'rental_until' => $rental->paid_until,
|
||||
]);
|
||||
}
|
||||
|
||||
//If the paid date is today or less, then update the paid column of the moon as not paid
|
||||
if($paidUntil->greaterThanOrEqualTo($today)) {
|
||||
AllianceMoonRental::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'paid' => 'No',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
|
||||
/**
|
||||
* This job performs the action of updating the moon rental price once per day.
|
||||
*/
|
||||
class UpdateMoonRentalPrice implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3200;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 1;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the helper for moon calculations
|
||||
$moonHelper = new MoonCalc;
|
||||
//Get all the moons from the rental database
|
||||
$moons = AllianceRentalMoon::all();
|
||||
|
||||
/**
|
||||
* Calculate the worth of each moon along with the rental prices.
|
||||
* For all of the moon calculations, the price of the mineral is averaged,
|
||||
* thereby, the price of the moon worth is also averaged based on the averaging
|
||||
* of the mineral price.
|
||||
*/
|
||||
foreach($moons as $rental) {
|
||||
//Calculate the total worth of the moon
|
||||
$totalWorth = $moonHelper->SpatialMoonsTotalWorth(
|
||||
$rental->first_ore, $rental->first_quantity,
|
||||
$rental->second_ore, $rental->second_quantity,
|
||||
$rental->third_ore, $rental->third_quantity,
|
||||
$rental->fourth_ore, $rental->fourth_quantity,
|
||||
);
|
||||
|
||||
//Calculate the rental prices of the moon
|
||||
$rentalPrice = $moonHelper->SpatialMoons(
|
||||
$rental->first_ore, $rental->first_quantity,
|
||||
$rental->second_ore, $rental->second_quantity,
|
||||
$rental->third_ore, $rental->third_quantity,
|
||||
$rental->fourth_ore, $rental->fourth_quantity,
|
||||
);
|
||||
|
||||
//Update the moon in the database
|
||||
AllianceRentalMoon::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'moon_worth' => $totalWorth,
|
||||
'alliance_rental_price' => $rentalPrice['alliance'],
|
||||
'out_of_alliance_rental_price' => $rentalPrice['outofalliance'],
|
||||
]);
|
||||
|
||||
Log::info('Alliance Rental Moon: ' . $rental->region . ' : ' . $rental->system . ' : ' . $rental->planet . ' : ' . $rental->moon . ' : ' . $rental->structure_name);
|
||||
Log::info('Total Worth: ' . $totalWorth);
|
||||
Log::info('Alliance Rental Price: ' . $rentalPrice['alliance']);
|
||||
Log::info('Out of Alliance Rental Price: ' . $rentalPrice['outofalliance']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Structures;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Assets\AssetHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Structure\Asset;
|
||||
|
||||
class ProcessAssetsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
private $esi;
|
||||
private $currentPage;
|
||||
private $totalPages;
|
||||
private $config;
|
||||
|
||||
protected $location_array = [
|
||||
'StructureFuel',
|
||||
'FighterBay',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId, $page)
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->currentPage = 1;
|
||||
$this->totalPages = 1;
|
||||
|
||||
$this->config = config('esi');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job's task is to get all of the information for all of the assets in
|
||||
* a structure and store them in the database. This task can take a few seconds
|
||||
* therefore we want the Horizon job queue to take care of the request rather
|
||||
* than the cronjob.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$esiHelper = new Esi;
|
||||
$aHelper = new AssetHelper($this->charId, $this->corpId);
|
||||
|
||||
//ESI Scope Check
|
||||
$assetScope = $esiHelper->HaveEsiScope($this->config['primary'], 'esi-assets.read_corporation_assets.v1');
|
||||
|
||||
if($assetScope == false) {
|
||||
Log::critical("Scope check for esi-assets.read_corporations_assets.v1 has failed in ProcessAssetsJob");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Truncate the Asset data from the table
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Create the authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$assets = $esi->page($this->currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get asset list in ProcessAssetsJob");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Set the total number of pages
|
||||
$this->totalPages = $assets->pages;
|
||||
|
||||
//Do this while the total pages is not completed
|
||||
do {
|
||||
if($currentPage > 1) {
|
||||
try {
|
||||
$assets = $esi->page($this->currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get asset list on page " . $this->currentPage . " in ProcessAssetsJob");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//Cycle through the assets, and attempt to store them.
|
||||
foreach($assets as $asset) {
|
||||
//if the asset is in one of the locations we want, then store
|
||||
//or update the asset
|
||||
if(in_array($asset->location_flag, $this->location_array)) {
|
||||
//Attempt to store the asset
|
||||
$aHelper->StoreNewAsset($asset);
|
||||
}
|
||||
}
|
||||
|
||||
//Increment the current page before doing the loop again
|
||||
$this->currentPage++;
|
||||
} while($this->currentPage <= $this->totalPages);
|
||||
|
||||
//Once all the data is stored and updated, purge stale data
|
||||
$aHelper->PurgeStaleData();
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Structures;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exceptions\RequestionFailedException;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
|
||||
class ProcessStructureJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $totalPages;
|
||||
private $currentPage;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId)
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->currentPage = 1;
|
||||
$this->totalPages = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job's task is to get all of the information for a particular structure
|
||||
* and store it in the database. This task can take a few seconds because of the ESI
|
||||
* calls required to store the information. We leave this type of job up to the queue
|
||||
* in order to take the load off of the cron job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$config = config('esi');
|
||||
$sHelper = new StructureHelper($this->charId, $this->corpId);
|
||||
$structures = null;
|
||||
|
||||
//ESI Scope Check
|
||||
$esiHelper = new Esi;
|
||||
$structureScope = $esiHelper->HaveEsiScope($charId, 'esi-universe.read_structures.v1');
|
||||
$corpStructureScope = $esiHelper->HaveEsiScope($charId, 'esi-corporations.read_structures.v1');
|
||||
|
||||
//Check scopes
|
||||
if($structureScope == false || $corpStructureScope == false) {
|
||||
if($structureScope == false) {
|
||||
Log::critical("Scope check for esi-universe.read_structures.v1 has failed.");
|
||||
}
|
||||
if($corpStructureScope == false) {
|
||||
Log::critical("Scope check for esi-corporations.read_structures.v1 has failed.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Create the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Attempt to get the ESI data
|
||||
try {
|
||||
$structures = $esi->page($this->currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch (RequestFailedException $e) {
|
||||
Log::critical("Failed to get structure list in ProcessStructureJob");
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->totalPages = $structures->pages;
|
||||
|
||||
//Truncate the structures and the structure services in order to add the latest data
|
||||
Structure::truncate();
|
||||
Service::truncate();
|
||||
|
||||
do {
|
||||
if($this->currentPage > 1) {
|
||||
try {
|
||||
$structures = $esi->page($this->currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get structure list on page" . $this->currentPage . " in ProcessStructureJob.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//For each set of data, process the data
|
||||
foreach($structures as $structure) {
|
||||
$sHelper->ProcessStructure($structure);
|
||||
}
|
||||
//Increment the current page
|
||||
$this->currentPage++;
|
||||
} while($this->currentPage <= $this->totalPages);
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,20 @@ class Esi {
|
||||
return $realDate;
|
||||
}
|
||||
|
||||
public function TokenExpired($token) {
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
//Create the carbon time for expiration time
|
||||
$expires = $token->inserted_at + $token->expires_in;
|
||||
$tokenExpiration = Carbon::createFromTimeStamp($expires)->toDateTimeString();
|
||||
|
||||
if($currentTime->greaterThan($tokenExpiration->subSeconds(5))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetRefreshToken($charId) {
|
||||
//Declare variables
|
||||
$currentTime = Carbon::now();
|
||||
@@ -89,7 +103,8 @@ class Esi {
|
||||
$expires = $token->inserted_at + $token->expires_in;
|
||||
$tokenExpiration = Carbon::createFromTimestamp($expires)->toDateTimeString();
|
||||
//If the access token has expired, we need to do a request for a new access token
|
||||
if($currentTime > $tokenExpiration) {
|
||||
//We give ourselves around 5 seconds leeway in order to deal with an expired token
|
||||
if($currentTime->greaterThan($tokenExpiration->subSeconds(5))) {
|
||||
//Get the current scopes of the token
|
||||
$scopesArr = EsiScope::where([
|
||||
'character_id' => $token->character_id,
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\AllianceMarketJournal;
|
||||
|
||||
class AllianceMarketTax {
|
||||
public function EntryExists($journal) {
|
||||
if(AllianceMarketJournal::where(['id' => $journal['id']])->exists()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function InsertMarketTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!AllianceMarketJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new AllianceMarketJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,218 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances\Helper;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Finances\AllianceMarketTax;
|
||||
use App\Library\Finances\PlayerDonation;
|
||||
use App\Library\Finances\ReprocessingTax;
|
||||
use App\Library\Finances\JumpBridgeTax;
|
||||
use App\Library\Finances\StructureIndustryTax;
|
||||
use App\Library\Finances\OfficeFee;
|
||||
use App\Library\Finances\PlanetProductionTax;
|
||||
use App\Library\Finances\PISale;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Finances\SovBillExpenses;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
class FinanceHelper {
|
||||
|
||||
public function GetWalletJournal($division, $charId) {
|
||||
//Declare new class variables
|
||||
$market = new AllianceMarketTax();
|
||||
$reprocessing = new ReprocessingTax();
|
||||
$jb = new JumpBridgeTax();
|
||||
$other = new PlayerDonation();
|
||||
$industry = new StructureIndustryTax();
|
||||
$office = new OfficeFee();
|
||||
$esiHelper = new Esi();
|
||||
$sovBillHelper = new SovBillExpenses();
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
if($hasScope == false) {
|
||||
Log::critical('Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||
return null;
|
||||
}
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
//Create an ESI authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Set our current page to 1 which is the one we are starting on.
|
||||
$currentPage = 1;
|
||||
//Set our default total pages to 1 in case our try section fails out.
|
||||
$totalPages = 1;
|
||||
|
||||
//If more than one page is found, decode the first set of wallet entries, then call for the next pages
|
||||
do {
|
||||
//Call the first page of the wallet journal, as we are always going to get at least one page.
|
||||
//If we have more pages, then we will continue through the while loop.
|
||||
try {
|
||||
$journals = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($currentPage == 1) {
|
||||
//Set the total pages we need to cycle through.
|
||||
$totalPages = $journals->pages;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
//For each journal entry, attempt to store it in the database.
|
||||
//The PutWalletJournal function checks to see if it's already in the database.
|
||||
foreach($wallet as $entry) {
|
||||
if($entry['ref_type'] == 'brokers_fee') {
|
||||
$market->InsertMarketTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'reprocessing_tax') {
|
||||
$reprocessing->InsertReprocessingTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'structure_gate_jump') {
|
||||
$jb->InsertJumpBridgeTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'player_donation' ||
|
||||
($entry['ref_type'] == 'corporation_account_withdrawal' && $entry['second_party_id'] == 98287666)) {
|
||||
$other->InsertPlayerDonation($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'industry_job_tax' && $entry['second_party_id'] == 98287666) {
|
||||
$industry->InsertStructureIndustryTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'office_rental_fee' && $entry['second_party_id'] == 98287666) {
|
||||
$office->InsertOfficeFee($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||
$sovBillHelper->InsertSovBillExpense($entry, $corpId, $division);
|
||||
}
|
||||
}
|
||||
|
||||
//Increment the current page we are on.
|
||||
$currentPage++;
|
||||
//Continue looping through the do while loop until the current page is greater than or equal to the total pages.
|
||||
} while ($currentPage < $totalPages);
|
||||
}
|
||||
|
||||
private function GetPIMaterialsArray() {
|
||||
//Setup array for PI items
|
||||
$pi_items = [
|
||||
//R0 Materials
|
||||
'2073',
|
||||
'2667',
|
||||
'2268',
|
||||
'2270',
|
||||
'2272',
|
||||
'2286',
|
||||
'2287',
|
||||
'2288',
|
||||
'2305',
|
||||
'2306',
|
||||
'2307',
|
||||
'2308',
|
||||
'2309',
|
||||
'2310',
|
||||
'2311',
|
||||
//P1 Materials
|
||||
'2389',
|
||||
'2390',
|
||||
'2392',
|
||||
'2393',
|
||||
'2395',
|
||||
'2396',
|
||||
'2397',
|
||||
'2398',
|
||||
'2399',
|
||||
'2400',
|
||||
'2401',
|
||||
'3645',
|
||||
'3683',
|
||||
'3779',
|
||||
'9828',
|
||||
//P2 Materials
|
||||
'44',
|
||||
'2312',
|
||||
'2317',
|
||||
'2319',
|
||||
'2321',
|
||||
'2327',
|
||||
'2328',
|
||||
'2329',
|
||||
'2463',
|
||||
'3689',
|
||||
'3691',
|
||||
'3693',
|
||||
'3695',
|
||||
'3697',
|
||||
'3725',
|
||||
'3775',
|
||||
'3828',
|
||||
'9830',
|
||||
'9832',
|
||||
'9836',
|
||||
'9838',
|
||||
'9840',
|
||||
'9842',
|
||||
'15317',
|
||||
//P3 Materials
|
||||
'2344',
|
||||
'2345',
|
||||
'2346',
|
||||
'2348',
|
||||
'2349',
|
||||
'2351',
|
||||
'2352',
|
||||
'2354',
|
||||
'2358',
|
||||
'2360',
|
||||
'2361',
|
||||
'2366',
|
||||
'2367',
|
||||
'9834',
|
||||
'9846',
|
||||
'9848',
|
||||
'12836',
|
||||
'17136',
|
||||
'17392',
|
||||
'17898',
|
||||
'28974',
|
||||
//P4 Materials
|
||||
'2867',
|
||||
'2868',
|
||||
'2869',
|
||||
'2870',
|
||||
'2871',
|
||||
'2872',
|
||||
'2875',
|
||||
'2876',
|
||||
];
|
||||
|
||||
return $pi_items;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
|
||||
/** W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Internal Library
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\JumpBridgeJournal;
|
||||
|
||||
class JumpBridgeTax {
|
||||
private $date;
|
||||
private $days;
|
||||
|
||||
public function __construct($days = null) {
|
||||
if($days === null) {
|
||||
$this->date = Carbon::now();
|
||||
$this->days = 0;
|
||||
} else {
|
||||
$this->date = Carbon::now()->subDays($days);
|
||||
$this->days = $days;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to insert journal entries into the database
|
||||
*/
|
||||
public function InsertJumpBridgeTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!JumpBridgeJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new JumpBridgeJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the overall usage for statistics
|
||||
*/
|
||||
public function OverallTax() {
|
||||
|
||||
//Get the total usage
|
||||
$usage = JumpBridgeJournal::select('amount')
|
||||
->whereTime('date', '>', $this->date)
|
||||
->sum('amount');
|
||||
|
||||
//Return the usage
|
||||
return $usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific briddge usage statistics for overall usage
|
||||
*/
|
||||
public function JBOverallUsage($structure) {
|
||||
|
||||
$usage = DB::table('jump_bridge_journal')
|
||||
->select('amount')
|
||||
->where('context_id', $structure)
|
||||
->sum('amount');
|
||||
|
||||
return $usage;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\OfficeFeesJournal;
|
||||
|
||||
class OfficeFee {
|
||||
|
||||
public function InsertOfficeFee($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!OfficeFeesJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new OfficeFeesJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\PISaleJournal;
|
||||
|
||||
class PISale {
|
||||
|
||||
public function InsertPISale($journal, $corpId) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Insert the PI Sale into the database
|
||||
if(!PISaleJournal::where(['journal_ref_id' => $journal['journal_ref_id']])->exists()) {
|
||||
$entry = new PISaleJournal;
|
||||
if(isset($journal['client_id'])) {
|
||||
$entry->client_id = $journal['client_id'];
|
||||
}
|
||||
if(isset($journal['date'])) {
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
}
|
||||
if(isset($journal['is_buy'])) {
|
||||
$entry->is_buy = $journal['is_buy'];
|
||||
}
|
||||
if(isset($journal['journal_ref_id'])) {
|
||||
$entry->journal_ref_id = $journal['journal_ref_id'];
|
||||
}
|
||||
if(isset($journal['location_id'])) {
|
||||
$entry->location_id = $journal['location_id'];
|
||||
}
|
||||
if(isset($journal['quantity'])) {
|
||||
$entry->quantity = $journal['quantity'];
|
||||
}
|
||||
if(isset($journal['transaction_id'])) {
|
||||
$entry->transaction_id = $journal['transaction_id'];
|
||||
}
|
||||
if(isset($journal['type_id'])) {
|
||||
$entry->type_id = $journal['type_id'];
|
||||
}
|
||||
if(isset($journal['unit_price'])) {
|
||||
$entry->unit_price = $journal['unit_price'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\PlanetProductionTaxJournal;
|
||||
|
||||
class PlanetProductionTax {
|
||||
|
||||
public function InsertPlanetProductionTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!PlanetProductionTaxJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new PlanetProductionTaxJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\PlayerDonationJournal;
|
||||
|
||||
class PlayerDonation {
|
||||
public function InsertPlayerDonation($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!PlayerDonationJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new PlayerDonationJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\ReprocessingTaxJournal;
|
||||
|
||||
class ReprocessingTax {
|
||||
public function InsertReprocessingTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!ReprocessingTaxJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new ReprocessingTaxJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\SovBillJournal;
|
||||
|
||||
class SovBillExpenses {
|
||||
public function InsertSovBillExpense($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!SovBillJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new SovBillJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||
|
||||
class StructureIndustryTax {
|
||||
|
||||
public function InsertStructureIndustryTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!StructureIndustryTaxJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new StructureIndustryTaxJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Assets;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
226
app/Library/Helpers/FinanceHelper.php
Normal file
226
app/Library/Helpers/FinanceHelper.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
class FinanceHelper {
|
||||
|
||||
public function GetApiWalletJournal($division, $charId) {
|
||||
//Declare class variables
|
||||
$lookup = new LookupHelper;
|
||||
$finance = new FinanceHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the esi container.
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Check the scope
|
||||
if(!$esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1')) {
|
||||
Log::critical('Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||
return null;
|
||||
}
|
||||
|
||||
//Reference the character id to the corporation id
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Set the current page to 1 which is the page we start on
|
||||
$currentPage = 1;
|
||||
//Set the total pages to 1, but in the future we will set it to another number
|
||||
$totalPages = 1;
|
||||
//Setup a page failed variable
|
||||
$pageFailed = false;
|
||||
|
||||
do {
|
||||
/**
|
||||
* During the course of the operation, we want to ensure our token hasn't expired.
|
||||
* If the token has expired, then resetup the authentication container, which will refresh the
|
||||
* access token.
|
||||
*/
|
||||
if($esiHelper->TokenExpired($token)) {
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the data from the esi api. If it fails, we skip the page, and go onto the next page, unless
|
||||
* the failed page is the first page.
|
||||
*/
|
||||
try {
|
||||
$journals = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get wallet journal page ' . $currentPage . ' for character id: ' . $charId);
|
||||
$pageFailed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the current page is the first one and the page didn't fail, then update the total pages.
|
||||
* If the first page failed, just return as we aren't going to be able to get the total amount of data needed.
|
||||
*/
|
||||
if($currentPage == 1 && $pageFailed == false) {
|
||||
$totalPages = $journals->pages;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the page was successfully pulled, we need to decode the data, then cycle through the data, and save it
|
||||
* where we can.
|
||||
*/
|
||||
if($pageFailed == false) {
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
//Foreach journal entry, add the journal entry to the table
|
||||
foreach($wallet as $entry) {
|
||||
AllianceWalletJournal::insertOrIgnore([
|
||||
'id' => $entry->id,
|
||||
'corporation_id' => $corpId,
|
||||
'divison' => $division,
|
||||
'amount' => $entry->amount,
|
||||
'balance' => $entry->balance,
|
||||
'context_id' => $entry->context_id,
|
||||
'date' => $esi->DecodeDate($entry->date),
|
||||
'description' => $entry->description,
|
||||
'first_party_id' => $entry->first_party_id,
|
||||
'reason' => $entry->reason,
|
||||
'ref_type' => $entry->ref_type,
|
||||
'tax' => $entry->tax,
|
||||
'tax_receiver_id' => $entry->tax_receiver_id,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* If the current page failed to get data from the esi, then reset the page failed data.
|
||||
* Continue to try to pull the next page of data. We might be able to get the current failed page
|
||||
* later in another pull if it is successful.
|
||||
*/
|
||||
$pageFailed = false;
|
||||
}
|
||||
|
||||
$currentPage++;
|
||||
} while($currentPage <= $totalPages);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function GetPIMaterialsArray() {
|
||||
//Setup array for PI items
|
||||
$pi_items = [
|
||||
//R0 Materials
|
||||
'2073',
|
||||
'2667',
|
||||
'2268',
|
||||
'2270',
|
||||
'2272',
|
||||
'2286',
|
||||
'2287',
|
||||
'2288',
|
||||
'2305',
|
||||
'2306',
|
||||
'2307',
|
||||
'2308',
|
||||
'2309',
|
||||
'2310',
|
||||
'2311',
|
||||
//P1 Materials
|
||||
'2389',
|
||||
'2390',
|
||||
'2392',
|
||||
'2393',
|
||||
'2395',
|
||||
'2396',
|
||||
'2397',
|
||||
'2398',
|
||||
'2399',
|
||||
'2400',
|
||||
'2401',
|
||||
'3645',
|
||||
'3683',
|
||||
'3779',
|
||||
'9828',
|
||||
//P2 Materials
|
||||
'44',
|
||||
'2312',
|
||||
'2317',
|
||||
'2319',
|
||||
'2321',
|
||||
'2327',
|
||||
'2328',
|
||||
'2329',
|
||||
'2463',
|
||||
'3689',
|
||||
'3691',
|
||||
'3693',
|
||||
'3695',
|
||||
'3697',
|
||||
'3725',
|
||||
'3775',
|
||||
'3828',
|
||||
'9830',
|
||||
'9832',
|
||||
'9836',
|
||||
'9838',
|
||||
'9840',
|
||||
'9842',
|
||||
'15317',
|
||||
//P3 Materials
|
||||
'2344',
|
||||
'2345',
|
||||
'2346',
|
||||
'2348',
|
||||
'2349',
|
||||
'2351',
|
||||
'2352',
|
||||
'2354',
|
||||
'2358',
|
||||
'2360',
|
||||
'2361',
|
||||
'2366',
|
||||
'2367',
|
||||
'9834',
|
||||
'9846',
|
||||
'9848',
|
||||
'12836',
|
||||
'17136',
|
||||
'17392',
|
||||
'17898',
|
||||
'28974',
|
||||
//P4 Materials
|
||||
'2867',
|
||||
'2868',
|
||||
'2869',
|
||||
'2870',
|
||||
'2871',
|
||||
'2872',
|
||||
'2875',
|
||||
'2876',
|
||||
];
|
||||
|
||||
return $pi_items;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Lookups;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Libraries
|
||||
use Log;
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Library\Moons;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\SRP;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Libraries
|
||||
use Carbon\Carbon;
|
||||
@@ -5,7 +5,7 @@
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Structures;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Taxes;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Library
|
||||
use Carbon\Carbon;
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\JumpBridges;
|
||||
|
||||
//Internal Libraries
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\JumpBridgeJournal;
|
||||
|
||||
class JumpBridgeHelper {
|
||||
|
||||
public function __construct() {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Corporation;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceCorp extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'AllianceCorps';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'corporation_id',
|
||||
'name',
|
||||
];
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Corporation;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class HoldingCorpJournal extends Model
|
||||
{
|
||||
// Table Name
|
||||
protected $table = 'HoldingCorpFinancesJournal';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = false;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceMarketJournal extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'alliance_market_journal';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'corporation_id',
|
||||
'division',
|
||||
'amount',
|
||||
'balance',
|
||||
'context_id',
|
||||
'context_id_type',
|
||||
'date',
|
||||
'description',
|
||||
'first_party_id',
|
||||
'reason',
|
||||
'ref_type',
|
||||
'second_party_id',
|
||||
'tax',
|
||||
'tax_receiver_id',
|
||||
];
|
||||
}
|
||||
@@ -4,12 +4,12 @@ namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PlayerDonationJournal extends Model
|
||||
class AllianceWalletJournal extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'player_donation_journal';
|
||||
protected $table = 'alliance_wallet_journal';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JumpBridgeJournal extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'jump_bridge_journal';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'corporation_id',
|
||||
'division',
|
||||
'amount',
|
||||
'balance',
|
||||
'context_id',
|
||||
'context_id_type',
|
||||
'date',
|
||||
'description',
|
||||
'first_party_id',
|
||||
'reason',
|
||||
'ref_type',
|
||||
'second_party_id',
|
||||
'tax',
|
||||
'tax_receiver_id',
|
||||
];
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OfficeFeesJournal extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'office_fees_journal';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'corporation_id',
|
||||
'division',
|
||||
'amount',
|
||||
'balance',
|
||||
'context_id',
|
||||
'context_id_type',
|
||||
'date',
|
||||
'description',
|
||||
'first_party_id',
|
||||
'reason',
|
||||
'ref_type',
|
||||
'second_party_id',
|
||||
'tax',
|
||||
'tax_receiver_id',
|
||||
];
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PISaleJournal extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'pi_sale_journal';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'division',
|
||||
'client_id',
|
||||
'date',
|
||||
'is_buy',
|
||||
'journal_ref_id',
|
||||
'location_id',
|
||||
'quantity',
|
||||
'transaction_id',
|
||||
'type_id',
|
||||
'unit_price',
|
||||
];
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PlanetProductionTaxJournal extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'planet_production_tax_journal';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'corporation_id',
|
||||
'division',
|
||||
'amount',
|
||||
'balance',
|
||||
'context_id',
|
||||
'context_id_type',
|
||||
'date',
|
||||
'description',
|
||||
'first_party_id',
|
||||
'reason',
|
||||
'ref_type',
|
||||
'second_party_id',
|
||||
'tax',
|
||||
'tax_receiver_id',
|
||||
];
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ReprocessingTaxJournal extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'reprocessing_tax_journal';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'corporation_id',
|
||||
'division',
|
||||
'amount',
|
||||
'balance',
|
||||
'context_id',
|
||||
'context_id_type',
|
||||
'date',
|
||||
'description',
|
||||
'first_party_id',
|
||||
'reason',
|
||||
'ref_type',
|
||||
'second_party_id',
|
||||
'tax',
|
||||
'tax_receiver_id',
|
||||
];
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SovBillJournal extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'sov_bill_journal';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'corporation_id',
|
||||
'division',
|
||||
'amount',
|
||||
'balance',
|
||||
'context_id',
|
||||
'context_id_type',
|
||||
'date',
|
||||
'description',
|
||||
'first_party_id',
|
||||
'reason',
|
||||
'ref_type',
|
||||
'second_party_id',
|
||||
'tax',
|
||||
'tax_receiver_id',
|
||||
];
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class StructureIndustryTaxJournal extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'structure_industry_tax_journal';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'corporation_id',
|
||||
'division',
|
||||
'amount',
|
||||
'balance',
|
||||
'context_id',
|
||||
'context_id_type',
|
||||
'date',
|
||||
'description',
|
||||
'first_party_id',
|
||||
'reason',
|
||||
'ref_type',
|
||||
'second_party_id',
|
||||
'tax',
|
||||
'tax_receiver_id',
|
||||
];
|
||||
}
|
||||
@@ -31,10 +31,6 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
||||
return in_array($user->name, [
|
||||
'Minerva Arbosa',
|
||||
'Rock Onzo',
|
||||
'Niloh Shuran',
|
||||
'Lowjack Tzetsu',
|
||||
'Amaren Otsada',
|
||||
'Resource',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAllianceJournalTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if(!Schema::hasTable('alliance_wallet_journal')) {
|
||||
Schema::create('alliance_wallet_journal', function (Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
$table->unsignedBigInteger('corporation_id');
|
||||
$table->unsignedInteger('division');
|
||||
$table->decimal('amount', 20, 2)->nullable();
|
||||
$table->decimal('balance', 20, 2)->nullable();
|
||||
$table->unsignedBigInteger('context_id')->nullable();
|
||||
$table->enum('context_id_type', [
|
||||
'structure_id',
|
||||
'station_id',
|
||||
'market_transaction_id',
|
||||
'character_id',
|
||||
'corporation_id',
|
||||
'alliance_id',
|
||||
'eve_system',
|
||||
'industry_job_id',
|
||||
'contract_id',
|
||||
'planet_id',
|
||||
'system_id',
|
||||
'type_id',
|
||||
]);
|
||||
$table->dateTime('date')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->unsignedBigInteger('first_party_id')->nulalble();
|
||||
$table->string('reason')->nullable();
|
||||
$table->enum('ref_type', [
|
||||
'acceleration_gate_fee',
|
||||
'advertisement_listing_fee',
|
||||
'agent_donation',
|
||||
'agent_location_services',
|
||||
'agent_miscellaneous',
|
||||
'agent_mission_collateral_paid',
|
||||
'agent_mission_collateral_refunded',
|
||||
'agent_mission_reward',
|
||||
'agent_mission_reward_corporation_tax',
|
||||
'agent_mission_time_bonus_reward',
|
||||
'agent_mission_time_bonus_reward_corporation_tax',
|
||||
'agent_security_services',
|
||||
'agent_services_rendered',
|
||||
'agents_preward',
|
||||
'alliance_maintainance_fee',
|
||||
'alliance_registration_fee',
|
||||
'asset_safety_recovery_tax',
|
||||
'bounty',
|
||||
'bounty_prize',
|
||||
'bounty_prize_corporation_tax',
|
||||
'bounty_prizes',
|
||||
'bounty_reimbursement',
|
||||
'bounty_surcharge',
|
||||
'brokers_fee',
|
||||
'clone_activation',
|
||||
'clone_transfer',
|
||||
'contraband_fine',
|
||||
'contract_auction_bid',
|
||||
'contract_auction_bid_corp',
|
||||
'contract_auction_bid_refund',
|
||||
'contract_auction_sold',
|
||||
'contract_brokers_fee',
|
||||
'contract_brokers_fee_corp',
|
||||
'contract_collateral',
|
||||
'contract_collateral_deposited_corp',
|
||||
'contract_collateral_payout',
|
||||
'contract_collateral_refund',
|
||||
'contract_deposit',
|
||||
'contract_deposit_corp',
|
||||
'contract_deposit_refund',
|
||||
'contract_deposit_sales_tax',
|
||||
'contract_price',
|
||||
'contract_price_payment_corp',
|
||||
'contract_reversal',
|
||||
'contract_reward',
|
||||
'contract_reward_deposited',
|
||||
'contract_reward_deposited_corp',
|
||||
'contract_reward_refund',
|
||||
'contract_sales_tax',
|
||||
'copying',
|
||||
'corporate_reward_payout',
|
||||
'corporate_reward_tax',
|
||||
'corporation_account_withdrawal',
|
||||
'corporation_bulk_payment',
|
||||
'corporation_dividend_payment',
|
||||
'corporation_liquidation',
|
||||
'corporation_logo_change_cost',
|
||||
'corporation_payment',
|
||||
'corporation_registration_fee',
|
||||
'courier_mission_escrow',
|
||||
'cspa',
|
||||
'cspaofflinerefund',
|
||||
'datacore_fee',
|
||||
'dna_modification_fee',
|
||||
'docking_fee',
|
||||
'duel_wager_escrow',
|
||||
'duel_wager_payment',
|
||||
'duel_wager_refund',
|
||||
'ess_escrow_transfer',
|
||||
'factory_slot_rental_fee',
|
||||
'gm_cash_transfer',
|
||||
'industry_job_tax',
|
||||
'infrastructure_hub_maintenance',
|
||||
'inheritance',
|
||||
'insurance',
|
||||
'item_trader_payment',
|
||||
'jump_clone_activation_fee',
|
||||
'jump_clone_installation_fee',
|
||||
'kill_right_fee',
|
||||
'lp_store',
|
||||
'manufacturing',
|
||||
'market_escrow',
|
||||
'market_fine_paid',
|
||||
'market_transaction',
|
||||
'medal_creation',
|
||||
'medal_issued',
|
||||
'mission_completion',
|
||||
'mission_cost',
|
||||
'mission_expiration',
|
||||
'mission_reward',
|
||||
'office_rental_fee',
|
||||
'operation_bonus',
|
||||
'opportunity_reward',
|
||||
'planetary_construction',
|
||||
'planetary_export_tax',
|
||||
'planetary_import_tax',
|
||||
'player_donation',
|
||||
'player_trading',
|
||||
'project_discovery_reward',
|
||||
'project_discovery_tax',
|
||||
'reaction',
|
||||
'release_of_impounded_property',
|
||||
'repair_bill',
|
||||
'reprocessing_tax',
|
||||
'researching_material_productivity',
|
||||
'researching_technology',
|
||||
'researching_time_productivity',
|
||||
'resource_wars_reward',
|
||||
'reverse_engineering',
|
||||
'security_processing_fee',
|
||||
'shares',
|
||||
'skill_purchase',
|
||||
'sovereignity_bill',
|
||||
'store_purchase',
|
||||
'store_purchase_refund',
|
||||
'structure_gate_jump',
|
||||
'transaction_tax',
|
||||
'upkeep_adjustment_fee',
|
||||
'war_ally_contract',
|
||||
'war_fee',
|
||||
'war_fee_surrender',
|
||||
]);
|
||||
$table->unsignedBigInteger('second_party_id')->nullable();
|
||||
$table->decimal('tax', 20, 2)->default(0.00);
|
||||
$table->unsignedBigInteger('tax_receiver_id')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
//Drop the old tables which we don't want to use anymore
|
||||
Schema::dropIfExists('CorpJournals');
|
||||
Schema::dropIfExists('HoldingCorpFinancesJournal');
|
||||
Schema::dropIfExists('jump_bridge_journal');
|
||||
Schema::dropIfExists('player_donation_journal');
|
||||
Schema::dropIfExists('reprocessing_tax_journal');
|
||||
Schema::dropIfExists('office_fees_journal');
|
||||
Schema::dropIfExists('structure_industry_tax_journal');
|
||||
Schema::dropIfExists('planet_production_tax_journal');
|
||||
Schema::dropIfExists('monthly_market_taxes');
|
||||
Schema::dropIfExists('pi_sale_journal');
|
||||
Schema::dropIfExists('alliance_market_journal');
|
||||
Schema::dropIfExists('corp_market_journal');
|
||||
Schema::dropIfExists('corp_market_structures');
|
||||
Schema::dropIfExists('sov_bill_journal');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('alliance_journal');
|
||||
}
|
||||
}
|
||||
@@ -64,21 +64,11 @@ Route::group(['middleware' => ['auth']], function(){
|
||||
Route::post('/dashboard/alt/delete', 'Dashboard\DashboardController@removeAlt');
|
||||
Route::get('/profile', 'Dashboard\DashboardController@profile');
|
||||
|
||||
/**
|
||||
* Fuel Controller display pages
|
||||
*/
|
||||
Route::get('/logistics/fuel/structures', 'Logistics\FuelController@displayStructures');
|
||||
|
||||
/**
|
||||
* Mining Moon Tax display pages
|
||||
*/
|
||||
//Route::get('/mining/display', 'Mining\MiningsController@displayMiningTax');
|
||||
|
||||
/**
|
||||
* Moon Ledger Controller display pages
|
||||
*/
|
||||
Route::get('/moons/ledger/display/moons', 'Moons\MoonLedgerController@displayMoonLedger');
|
||||
|
||||
/**
|
||||
* Scopes Controller display pages
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user