moon rentals again

This commit is contained in:
2021-05-30 16:19:12 +09:00
parent c3becc324b
commit 751a412185
15 changed files with 408 additions and 42 deletions

View File

@@ -0,0 +1,73 @@
<?php
//Namespace
namespace App\Console\Commands\Files;
//Internal Library
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\File;
use Carbon\Carbon;
use Log;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use DB;
//Application Library
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
use App\Library\Helpers\LookupHelper;
//Models
use App\Models\MoonRental\AllianceMoonOre;
use App\Models\MoonRental\AllianceMoon;
class ImportAllianceMoons extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'files:import:moons';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Import moons from tab-delimited text.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
//Declare variables
$lookup = new LookupHelper;
//Create the collection of lines for the input file.
$lines = new Collection;
///universe/moons/{moon_id}/
//Create the file handler
$data = Storage::get('public/alliance_moons.txt');
//Split the string into separate arrays based on the line
$data = preg_split("/\n/", $data);
var_dump($data);
dd();
}
}

View File

@@ -39,6 +39,7 @@ class Kernel extends ConsoleKernel
Commands\MiningTaxes\ExecuteProcesssMiningTaxesPaymentsCommand::class,
Commands\Structures\ExecuteFetchAllianceStructuresCommand::class,
Commands\Structures\ExecuteFetchAllianceAssetsCommand::class,
Commands\Files\ImportAllianceMoons::class,
];
/**

View File

@@ -33,6 +33,27 @@ class MiningTaxesAdminController extends Controller
$this->middleware('role:Admin');
}
/**
* Display the page to setup the form for corporations to rent a moon
*/
public function DisplayMoonRentalForm() {
}
/**
* Store the details for the form for corporations renting a specific moon
*/
public function StoreMoonRentalForm() {
}
/**
* Remove a moon from being rented from a specific corporation
*/
public function DeleteMoonRental(Request $request) {
}
/**
* Display current unpaid invoices
*/

View File

@@ -40,6 +40,11 @@ class MiningTaxesController extends Controller
$this->middleware('role:User');
}
/**
* Display an invoice based on it's id
*
* @var $invoiceId
*/
public function DisplayInvoice($invoiceId) {
$ores = array();
$totalPrice = 0.00;

View File

@@ -18,14 +18,11 @@ class MoonRentalController extends Controller
* Display all of the available moons for rental
*/
public function displayMoons() {
$moons = AllianceMoon::where([
'rented' => 'No',
])->get();
}
/**
* Display form to request new moon structure be placed
*/
public function displayNewMoonRequestForm() {
return view('moon.rental.available.display')->with('moons', $moons);
}
/**
@@ -41,4 +38,11 @@ class MoonRentalController extends Controller
public function storeMoonRentalRequest() {
}
/**
* Request a mail job be added to the mail queue to resend mining bill instantly
*/
public function requestMoonRentalBill() {
}
}

View File

@@ -19,6 +19,7 @@ use App\Models\Lookups\CorporationLookup;
use App\Models\Lookups\AllianceLookup;
use App\Models\Lookups\SolarSystem;
use App\Models\Lookups\ItemLookup;
use App\Models\Lookups\MoonLookup;
class LookupHelper {
@@ -252,6 +253,58 @@ class LookupHelper {
}
}
/**
* Get moon information from the database, or store it in the database if it's not found
*/
public function GetMoonInfo($moonId) {
//Check our own database first
$moon = $this->LookupMoonInfo($moonId);
//If no data was found in the database, then save the data, and return what is found through esi
if( $moon == null) {
try {
$response = $this->esi->invoke('get', '/universe/moons/{moon_id}/', [
'moon_id' => $moonId,
]);
} catch(RequestFailedException $e) {
Log::critical("Failed to get moon information in LookupHelper.");
return null;
}
$this->SaveMoonInfo($response);
return $response;
} else {
//Return the moon info
return $moon;
}
}
/**
* Lookup moon info from the database
*/
private function LookupMoonInfo($moonId) {
$moon = MoonLookup::where([
'moon_id' => $moonId,
])->first();
return $moon;
}
/**
* Save moon info into the lookup database
*/
private function SaveMoonInfo($moon) {
$newMoon = new MoonLookup;
$newMoon->moon_id = $moon->id;
$newMoon->name = $moon->name;
$newMoon->position_x = $moon->position->x;
$newMoon->position_y = $moon->position->y;
$newMoon->position_z = $moon->position->z;
$newMoon->system_id = $moon->system_id;
$newMoon->save();
}
public function GetCharacterInfo($charId) {
//Check our own database first
$char = $this->LookupCharacter($charId, null);

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Models\Lookups;
use Illuminate\Database\Eloquent\Model;
class MoonLookup extends Model
{
/**
* Table Name
*/
public $table = 'moon_lookup';
/**
* Primary Key
*/
public $primaryKey = 'id';
/**
* Timestamps
*/
public $timestamps = false;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'moon_id',
'name',
'position_x',
'position_y',
'position_z',
'system_id',
];
}

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Models\MoonRental;
use Illuminate\Database\Eloquent\Model;
class AllianceMoon extends Model
{
/**
* Table Name
*/
public $table = 'alliance_moons';
/**
* Primary Key
*/
public $primaryKey = 'id';
/**
* Timestamps
*/
public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'moon_id',
'name',
'system_id'
'system_name',
'worth_amount',
'rented',
'rental_amount',
];
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class AllianceMoonOre extends Model
{
/**
* Table Name
*/
public $table = 'alliance_moon_ores';
/**
* Primary Key
*/
public $primaryKey = 'id';
/**
* Timestamps
*/
public $timestamps = false;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'moon_id',
'name',
'ore_type_id',
'ore_name',
];
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Models\MoonRental;
use Illuminate\Database\Eloquent\Model;
class AllianceMoonRental extends Model
{
/**
* Table Name
*/
public $table = 'alliance_moon_rentals';
/**
* Primary Key
*/
public $primaryKey = 'id';
/**
* Timestamps
*/
public $timestamps = true;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'moon_id',
'moon_name',
'rental_amount',
'rental_start',
'rental_end',
'next_billing_date',
'entity_id',
'entity_name',
'entity_type',
];
}

View File

@@ -0,0 +1,91 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNewMoonRentalTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('alliance_moons');
if(!Schema::hasTable('moon_lookup')) {
Schema::create('moon_lookup', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('moon_id');
$table->string('name');
$table->double('position_x');
$table->double('position_y');
$table->double('position_z');
$table->unsignedBigInteger('system_id');
});
}
if(!Schema::hasTable('alliance_moons')) {
Schema::create('alliance_moons', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('moon_id');
$table->string('name');
$table->unsignedBigInteger('system_id');
$table->string('system_name');
$table->decimal('worth_amount');
$table->enum('rented', [
'No',
'Yes',
]);
$table->decimal('rental_amount');
$table->timestamps();
});
}
if(!Schema::hasTable('alliance_moon_ores')) {
Schema::create('alliance_moons', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('moon_id');
$table->string('name');
$table->unsignedBigInteger('ore_type_id');
$table->string('ore_name');
});
}
if(!Schema::hasTable('alliance_moon_rentals')) {
Schema::create('alliance_moon_rentals', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('moon_id');
$table->string('moon_name');
$table->decimal('rental_amount', 20, 2);
$table->date('rental_start')->nullable();
$table->date('rental_end')->nullable();
$table->date('next_billing_date')->nullable();
$table->unsignedBigInteger('entity_id')->nullable();
$table->string('entity_name')->nullable();
$table->enum('entity_type', [
'None',
'Character',
'Corporation',
'Alliance',
])->default('None');
$table->timestamps();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('moon_lookup');
Schema::dropIfExists('alliance_moons');
Schema::dropIfExists('alliance_moon_ores');
Schema::dropIfExists('alliance_moon_rentals');
}
}

View File

@@ -42,8 +42,6 @@ namespace Composer\Autoload;
*/
class ClassLoader
{
private $vendorDir;
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
@@ -59,13 +57,6 @@ class ClassLoader
private $missingClasses = array();
private $apcuPrefix;
private static $registeredLoaders = array();
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
@@ -309,17 +300,6 @@ class ClassLoader
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}
/**
@@ -328,10 +308,6 @@ class ClassLoader
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}
/**
@@ -391,16 +367,6 @@ class ClassLoader
return $file;
}
/**
* Returns the currently registered loaders indexed by their corresponding vendor directories.
*
* @return self[]
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup

View File

@@ -81,6 +81,7 @@ return array(
'App\\Library\\Helpers\\FinanceHelper' => $baseDir . '/app/Library/Helpers/FinanceHelper.php',
'App\\Library\\Helpers\\LookupHelper' => $baseDir . '/app/Library/Helpers/LookupHelper.php',
'App\\Library\\Helpers\\MiningLedgerHelper' => $baseDir . '/app/Library/Helpers/MiningLedgerHelper.php',
'App\\Library\\Helpers\\MiningTaxHelper' => $baseDir . '/app/Library/Helpers/MiningTaxHelper.php',
'App\\Library\\Helpers\\SRPHelper' => $baseDir . '/app/Library/Helpers/SRPHelper.php',
'App\\Library\\Helpers\\StructureHelper' => $baseDir . '/app/Library/Helpers/StructureHelper.php',
'App\\Library\\Helpers\\TaxesHelper' => $baseDir . '/app/Library/Helpers/TaxesHelper.php',

View File

@@ -25,7 +25,7 @@ class ComposerAutoloaderInitc3f953f8a7291d41a76e1664339777c9
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInitc3f953f8a7291d41a76e1664339777c9', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitc3f953f8a7291d41a76e1664339777c9', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());

View File

@@ -631,6 +631,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Library\\Helpers\\FinanceHelper' => __DIR__ . '/../..' . '/app/Library/Helpers/FinanceHelper.php',
'App\\Library\\Helpers\\LookupHelper' => __DIR__ . '/../..' . '/app/Library/Helpers/LookupHelper.php',
'App\\Library\\Helpers\\MiningLedgerHelper' => __DIR__ . '/../..' . '/app/Library/Helpers/MiningLedgerHelper.php',
'App\\Library\\Helpers\\MiningTaxHelper' => __DIR__ . '/../..' . '/app/Library/Helpers/MiningTaxHelper.php',
'App\\Library\\Helpers\\SRPHelper' => __DIR__ . '/../..' . '/app/Library/Helpers/SRPHelper.php',
'App\\Library\\Helpers\\StructureHelper' => __DIR__ . '/../..' . '/app/Library/Helpers/StructureHelper.php',
'App\\Library\\Helpers\\TaxesHelper' => __DIR__ . '/../..' . '/app/Library/Helpers/TaxesHelper.php',