cleaned up old code from Commands
This commit is contained in:
@@ -16,18 +16,7 @@ use App\Models\Esi\EsiScope;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Finances\AllianceMarketTax;
|
||||
use App\Library\Finances\CorpMarketTax;
|
||||
use App\Library\Finances\MarketTax;
|
||||
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;
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Moons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Moons\FetchMoonLedgerJob;
|
||||
use App\Jobs\Commands\Moons\FetchMoonObserverJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class MoonsUpdateCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:MoonUpdate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update all of the moons registered for observers and ledgers.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$delay = 0;
|
||||
$characters = array();
|
||||
|
||||
//Get all of the characters who have registered structures for moon ledgers
|
||||
$miningChars = EsiScope::where([
|
||||
'scope' => 'esi-industry.read_corporation_mining.v1',
|
||||
])->get();
|
||||
|
||||
foreach($miningChars as $mChars) {
|
||||
$universe = EsiScope::where([
|
||||
'character_id' => $mChars->character_id,
|
||||
'scope' => 'esi-universe.read_structures.v1',
|
||||
])->first();
|
||||
|
||||
if($universe != null) {
|
||||
array_push($characters, $universe->character_id);
|
||||
}
|
||||
}
|
||||
|
||||
//Cycle through each of the character Ids which have the correct scopes,
|
||||
//and dispatch jobs accordingly.
|
||||
foreach($characters as $charId) {
|
||||
//Fetch all of the corp observers with the job dispatch
|
||||
FetchMoonObserverJob::dispatch($charId);
|
||||
//Fetch all of the corp ledgers with the job dispatch
|
||||
FetchMoonLedgerJob::dispatch($charId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\RentalMoons\SendMoonRentalPaymentReminderJob;
|
||||
use App\Jobs\Commands\RentalMoons\UpdateMoonRentalPaidState;
|
||||
|
||||
class AllianceRentalMoonInvoiceCreationCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:RentalInvoices';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send out rental invoice reminders';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Send the job for the invoice creation command
|
||||
SendMoonRentalPaymentReminderJob::dispatch()->delay(Carbon::now()->addSeconds(10));
|
||||
|
||||
//Update the paid state for the moons
|
||||
UpdateMoonRentalPaidState::dispatch()->delay(Carbon::now()->addSeconds(600));
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
//Job
|
||||
use App\Jobs\Commands\RentalMoons\UpdateMoonRentalPrice;
|
||||
|
||||
class AllianceRentalMoonUpdatePricingCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:UpdateRentalPrice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update alliance rental moon prices.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
UpdateMoonRentalPrice::dispatch();
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\SystemRental;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Rentals\RentalSystem;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
class SystemRentalCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:SystemRentals';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Mail out bill for system rentals.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create other variables
|
||||
$body = null;
|
||||
$delay = 30;
|
||||
|
||||
//Get today's date
|
||||
$today = Carbon::now();
|
||||
$today->second = 2;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Get all of the contacts for the system rentals
|
||||
$contacts = RentalSystem::select('contact_id')->orderBy('contact_id')->get();
|
||||
|
||||
//For each of the contacts send a reminder mail about the total of the systems they are paying for
|
||||
foreach($contacts as $contact) {
|
||||
//Get all of the systems
|
||||
$systems = RentalSystem::where([
|
||||
'contact_id' => $contact->contact_id,
|
||||
])->get();
|
||||
|
||||
//Totalize the total cost of all of the systems
|
||||
$totalCost = $this->TotalizeCost($systems);
|
||||
|
||||
//Build the body of the mail
|
||||
$body = "System Rental Cost is due for the following systems:<br>";
|
||||
foreach($systems as $system) {
|
||||
$body .= $system->system_name . "<br>";
|
||||
}
|
||||
|
||||
//Create the rest of the email body
|
||||
$body .= "Total Cost: " . number_format($totalCost, 2, ".", ",");
|
||||
$body .= "Please remite payment to White Wolves Holding.<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Fill in the subject
|
||||
$subject = "Warped Intentions System Rental Bill Due";
|
||||
|
||||
//Dispatch the mail job
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$contact->contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
|
||||
//Increase the delay for the next mail job
|
||||
$delay += 60;
|
||||
|
||||
//After the mail is dispatched, save the sent mail record
|
||||
$this->SaveSentRecord($config['primary'], $subject, $body, (int)$contact->contact_id, 'character');
|
||||
}
|
||||
}
|
||||
|
||||
private function TotalizeCost($systems) {
|
||||
//Declare the starting total cost
|
||||
$totalCost = 0.00;
|
||||
|
||||
foreach($systems as $system) {
|
||||
$totalCost += $system->rental_cost;
|
||||
}
|
||||
|
||||
return $totalCost;
|
||||
}
|
||||
|
||||
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
||||
$sentmail = new SentMail;
|
||||
$sentmail->sender = $sender;
|
||||
$sentmail->subject = $subject;
|
||||
$sentmail->body = $body;
|
||||
$sentmail->recipient = $recipient;
|
||||
$sentmail->recipient_type = $recipientType;
|
||||
$sentmail->save();
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ class Kernel extends ConsoleKernel
|
||||
Commands\Data\PurgeUsers::class,
|
||||
Commands\Data\EmptyJumpBridges::class,
|
||||
Commands\Data\CleanStaleDataCommand::class,
|
||||
Commands\Data\PurgeCorpMoonLedgers::class,
|
||||
Commands\Data\GetCorpsCommand::class,
|
||||
/**
|
||||
* Assets Commands
|
||||
@@ -38,15 +37,6 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
Commands\Finances\HoldingFinancesCommand::class,
|
||||
Commands\Finances\SovBillsCommand::class,
|
||||
/**
|
||||
* Moon Commands
|
||||
*/
|
||||
Commands\Moons\MoonsUpdateCommand::class,
|
||||
/**
|
||||
* Rental Moon Commands
|
||||
*/
|
||||
Commands\RentalMoons\AllianceRentalMoonInvoiceCreationCommand::class,
|
||||
Commands\RentalMoons\AllianceRentalMoonUpdatePricingCommand::class,
|
||||
/**
|
||||
* Structures Command
|
||||
*/
|
||||
@@ -74,16 +64,6 @@ class Kernel extends ConsoleKernel
|
||||
$schedule->command('services:SystemRentals')
|
||||
->monthlyOn(1, '00:01')
|
||||
->withoutOverlapping();
|
||||
|
||||
/**
|
||||
* Rentals / Flex Schedule
|
||||
*/
|
||||
$schedule->command('services:UpdateRentalPrice')
|
||||
->dailyAt('11:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:FlexStructures')
|
||||
->monthlyOn(2, '00:01');
|
||||
|
||||
/**
|
||||
* Holding Corp Finance Schedule
|
||||
*/
|
||||
|
||||
@@ -32,286 +32,6 @@ class MoonsController extends Controller
|
||||
$this->middleware('role:Renter');
|
||||
}
|
||||
|
||||
public function displayRentalMoonPage() {
|
||||
return view('moons.user.requestrental');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display all alliance moons and pass data to the blade template
|
||||
*/
|
||||
public function displayMoons() {
|
||||
//Setup variables for moons
|
||||
$moons = array();
|
||||
$systems = array();
|
||||
|
||||
//Get all of the alliance moon systems from the database
|
||||
$systems = AllianceMoon::groupBy('System')->pluck('System');
|
||||
|
||||
//Get all of the alliance moons from the database
|
||||
$moons = AllianceMoon::all();
|
||||
|
||||
$gasGoo = [
|
||||
'Zeolites',
|
||||
'Sylvite',
|
||||
'Bitumens',
|
||||
'Coesite',
|
||||
];
|
||||
|
||||
$r8Goo = [
|
||||
'Cobaltite',
|
||||
'Euxenite',
|
||||
'Titanite',
|
||||
'Scheelite',
|
||||
];
|
||||
|
||||
$r16Goo = [
|
||||
'Otavite',
|
||||
'Sperrylite',
|
||||
'Vanadinite',
|
||||
'Chromite',
|
||||
];
|
||||
|
||||
$r32Goo = [
|
||||
'Carnotite',
|
||||
'Zircon',
|
||||
'Pollucite',
|
||||
'Cinnabar',
|
||||
];
|
||||
|
||||
$r64Goo = [
|
||||
'Xenotime',
|
||||
'Monazite',
|
||||
'Loparite',
|
||||
'Ytterbite',
|
||||
];
|
||||
|
||||
return view('moons.user.allmoons')->with('systems', $systems)
|
||||
->with('moons', $moons)
|
||||
->with('gasGoo', $gasGoo)
|
||||
->with('r8Goo', $r8Goo)
|
||||
->with('r16Goo', $r16Goo)
|
||||
->with('r32Goo', $r32Goo)
|
||||
->with('r64Goo', $r64Goo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display moon request form
|
||||
*/
|
||||
public function displayRequestAllianceMoon() {
|
||||
return view('moons.user.requestmoon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to store the moon request
|
||||
*/
|
||||
public function storeRequestAllianceMoon(Request $request) {
|
||||
$this->validate($request, [
|
||||
'system' => 'required',
|
||||
'planet' => 'required',
|
||||
'moon' => 'required',
|
||||
]);
|
||||
|
||||
//Declare some necessary arrays for figuring out what region a moon resides in
|
||||
$catch = [
|
||||
'6X7-JO',
|
||||
'A803-L',
|
||||
'I8-D0G',
|
||||
'WQH-4K',
|
||||
'GJ0-JO',
|
||||
'Q-S7ZD',
|
||||
'JWZ2-V',
|
||||
'J-ODE7',
|
||||
'OGL8-Q',
|
||||
'R-K4QY',
|
||||
];
|
||||
|
||||
$immensea = [
|
||||
'ZBP-TP',
|
||||
'XVV-21',
|
||||
'B9E-H6',
|
||||
'JDAS-0',
|
||||
'Y19P-1',
|
||||
'LN-56V',
|
||||
'O7-7UX',
|
||||
'Y2-QUV',
|
||||
'SPBS-6',
|
||||
'A4B-V5',
|
||||
'GXK-7F',
|
||||
'78TS-Q',
|
||||
'CJNF-J',
|
||||
'EA-HSA',
|
||||
'FYI-49',
|
||||
'WYF8-8',
|
||||
'NS2L-4',
|
||||
'B-S347',
|
||||
'AF0-V5',
|
||||
'QI-S9W',
|
||||
'B-A587',
|
||||
'PPFB-U',
|
||||
'L-5JCJ',
|
||||
'4-GB14',
|
||||
'REB-KR',
|
||||
'QE-E1D',
|
||||
'LK1K-5',
|
||||
'Z-H2MA',
|
||||
'B-KDOZ',
|
||||
'E8-YS9',
|
||||
'DY-P7Q',
|
||||
];
|
||||
|
||||
//Declare lookup variables
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Get all of the information needed to create the database entry
|
||||
$charId = auth()->user()->getId();
|
||||
$charInfo = $lookup->GetCharacterInfo($charId);
|
||||
$charName = $charInfo->name;
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
$corpId = $corpInfo->corporation_id;
|
||||
$corpName = $corpInfo->name;
|
||||
$corpTicker = $corpInfo->ticker;
|
||||
//Declare the region variable as null for the lookup if statement
|
||||
$region = null;
|
||||
|
||||
//Get the region the moon resides in from the system
|
||||
if(in_array($request->system, $catch, true)) {
|
||||
$region = 'Catch';
|
||||
} else if(in_array($request->system, $immensea, true)) {
|
||||
$region = 'Immensea';
|
||||
} else {
|
||||
//False value. Redirect back to page
|
||||
return redirct('/moons/display/request')->with('error', 'Region was not found.');
|
||||
}
|
||||
|
||||
//Check to see if the moon has been previously inputted for
|
||||
$allMoons = AllianceMoon::all();
|
||||
foreach($allMoons as $moon) {
|
||||
if($moon->Region == $region && $moon->System == $request->system && $moon->Planet == $request->planet && $moon->Moon == $request->moon) {
|
||||
if($moon->Availability != 'Available') {
|
||||
return redirect('moons/display/request')->with('error', 'The moon has already been reserved by another party.');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Create the new object to save into the database
|
||||
$moonRequest = new AllianceMoonRequest;
|
||||
$moonRequest->region = $region;
|
||||
$moonRequest->system = $request->system;
|
||||
$moonRequest->planet = $request->planet;
|
||||
$moonRequest->moon = $request->moon;
|
||||
$moonRequest->corporation_id = $corpId;
|
||||
$moonRequest->corporation_name = $corpName;
|
||||
$moonRequest->corporation_ticker = $corpTicker;
|
||||
$moonRequest->requestor_name = $charName;
|
||||
$moonRequest->requestor_id = $charId;
|
||||
$moonRequest->status = 'Pending';
|
||||
$moonRequest->save();
|
||||
|
||||
//Update the current moon's status in the model AllianceMoon
|
||||
AllianceMoon::where([
|
||||
'Region' => $region,
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->update([
|
||||
'Availability' => 'Request Pending',
|
||||
]);
|
||||
|
||||
//Send a mail over to the site admins to approve the moon request
|
||||
$config = config('esi');
|
||||
$body = 'A new moon request has been entered into the services site. Please approve or deny the request within 3 business days.<br><br>';
|
||||
$body .= 'Sincerely,<br>';
|
||||
$body .= 'W4RP Services Site';
|
||||
$subject = 'New Moon Request Available';
|
||||
|
||||
ProcessSendEveMailJob::dispatch($body, 92947432, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
ProcessSendEveMailJob::dispatch($body, 92626011, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(60));
|
||||
|
||||
return redirect('/moons/display/request')->with('success', 'Moon request submitted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons and pass to the blade template
|
||||
* Function description will be updated in a future release.
|
||||
*/
|
||||
public function displayRentalMoons() {
|
||||
//Declare variables
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
$today = Carbon::now();
|
||||
$table = array();
|
||||
$moonprice = null;
|
||||
|
||||
//Get the user type from the user Auth class
|
||||
$type = auth()->user()->getUserType();
|
||||
//Get all of the rental moons from the database
|
||||
$moons = AllianceRentalMoon::orderBy('system', 'ASC')
|
||||
->orderBy('planet', 'ASC')
|
||||
->orderBy('moon', 'ASC')
|
||||
->get();
|
||||
|
||||
//For each of the moons let's format the data for the display table
|
||||
foreach($moons as $moon) {
|
||||
$color = null;
|
||||
$rentalTemp = null;
|
||||
$rentalEnd = null;
|
||||
|
||||
//Check if someone is currently renting the moon
|
||||
if($moon->rental_type == 'In Alliance' || $moon->rental_type == 'Out of Alliance') {
|
||||
$rentalTemp = new Carbon($moon->rental_until);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Setup the correct color for the table
|
||||
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
|
||||
$color = 'table-warning';
|
||||
} else if($today->lessThan($rentalTemp)) {
|
||||
$color = 'table-danger';
|
||||
} else {
|
||||
$color = 'table-primary';
|
||||
}
|
||||
} else if($moon->rental_type == 'Alliance') {
|
||||
$rentalTemp = Carbon::now()->endOfMonth();
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
$color = 'table-info';
|
||||
} else {
|
||||
//Set the rental date for if someone is not renting the moon
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
$color = 'table-primary';
|
||||
}
|
||||
|
||||
//Get the price of the moon from the database based on if the person is in Warped Intentions
|
||||
$userType = auth()->user()->getUserType();
|
||||
if($userType == 'W4RP') {
|
||||
$moonprice = $moon->alliance_rental_price;
|
||||
} else {
|
||||
$moonprice = $moon->out_of_alliance_rental_price;
|
||||
}
|
||||
|
||||
//Add the data to the html array to be passed to the view
|
||||
array_push($table, [
|
||||
'SPM' => $moon->system . " - " . $moon->planet . " - " . $moon->moon,
|
||||
'StructureName' => $moon->structure_name,
|
||||
'FirstOre' => $moon->first_ore,
|
||||
'FirstQuantity' => number_format($moon->first_quantity, 0, ".", ","),
|
||||
'SecondOre' => $moon->second_ore,
|
||||
'SecondQuantity' => number_format($moon->second_quantity, 0, ".", ","),
|
||||
'ThirdOre' => $moon->third_ore,
|
||||
'ThirdQuantity' => number_format($moon->third_quantity, 0, ".", ","),
|
||||
'FourthOre' => $moon->fourth_ore,
|
||||
'FourthQuantity' => number_format($moon->fourth_quantity, 0, ".", ","),
|
||||
'Price' => number_format($moonprice, 0, ".", ","),
|
||||
'Worth' => number_format($moon->moon_worth, 0, ".", ","),
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
]);
|
||||
}
|
||||
|
||||
//Pass the data to the view
|
||||
return view('moons.user.moon')->with('table', $table);
|
||||
}
|
||||
|
||||
public function displayTotalWorthForm() {
|
||||
return view('moons.user.formTotalWorth');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user