command for moon mailer
This commit is contained in:
@@ -9,14 +9,14 @@ use Commands\Library\CommandHelper;
|
||||
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
class UpdateMoonPricing extends Command
|
||||
class UpdateMoonPriceCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:updatemoonprice';
|
||||
protected $signature = 'services:UpdateMoonPrice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
|
||||
@@ -22,14 +22,14 @@ use App\Models\Mail\EveMail;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
class CalculateMarketTax extends Command
|
||||
class CalculateMarketTaxCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:calculatemarkettax';
|
||||
protected $signature = 'services:CalculateMarketTax';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
|
||||
@@ -14,14 +14,14 @@ use App\Models\Corporation\CorpStructure;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CorpJournal extends Command
|
||||
class CorpJournalCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:corpjournal';
|
||||
protected $signature = 'services:CorpJournal';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
|
||||
@@ -14,14 +14,14 @@ use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
|
||||
class GetCorps extends Command
|
||||
class GetCorpsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:getcorps';
|
||||
protected $signature = 'services:GetCorps';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -51,9 +51,7 @@ class GetCorps extends Command
|
||||
$task = new CommandHelper('CorpJournal');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
//Set the parameters for ESI
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->logfile_location = 'var/www/w4rpservices/storage/logs/eseye';
|
||||
|
||||
//Create the ESI container
|
||||
$esi = new Eseye();
|
||||
//try the esi call to get all of the corporations in the alliance
|
||||
|
||||
@@ -7,21 +7,21 @@ use Illuminate\Console\Command;
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
class holdingfinances extends Command
|
||||
class HoldingFinancesCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:holdingjournal';
|
||||
protected $signature = 'services:HoldingJournal';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
protected $description = 'Get the holding corps finances.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Console\Command;
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Moons\MoonMailer;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
@@ -51,11 +52,52 @@ class MoonMailerCommand extends Command
|
||||
//Add the entry into the jobs table saying the job has started
|
||||
$task->SetStartStatus();
|
||||
|
||||
|
||||
//Declare the moon calc class variable to utilize the library to update the price
|
||||
$moonCalc = new MoonCalc();
|
||||
|
||||
|
||||
//Get all of the moons from the rental list
|
||||
$rentals = MoonRent::all();
|
||||
|
||||
//Send a mail to the contact listing the moons, and how much is owed
|
||||
//Update the price for all moon rentals before sending out the mail
|
||||
foreach($rentals as $rental) {
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($rental->FirstOre, $rental->FirstQuantity, $rental->SecondOre, $rental->SecondQuantity,
|
||||
$rental->ThirdOre, $rental->ThirdQuantity, $rental->FourthOre, $rental->FourthQuantity);
|
||||
|
||||
//Update the moon rental price
|
||||
MoonRent::where([
|
||||
'System' => $rental->System,
|
||||
'Planet' => $rental->Planet,
|
||||
'Moon' => $rental->Moon,
|
||||
])->update([
|
||||
'Price' => $price[$rental->Type],
|
||||
]);
|
||||
}
|
||||
|
||||
//Re-pull all of the rentals from the database
|
||||
$rentals = MoonRent::all();
|
||||
//Cycle through each rental and send a mail out
|
||||
foreach($rentals as $rental) {
|
||||
//Create the body for the mail to be sentout
|
||||
$body = "Moon Rent is due for " . $rental->System . " Planet: " . $rental->Planet . " Moon: " . $rental->Moon . "<br>";
|
||||
$body .= "The price for next month's rent is " . $rental->Price . "<br>";
|
||||
$body .= "Please remite payment to Spatial Forces by the 1st should you continue to wish to rent the moon.<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Spatial Forces<br>";
|
||||
//Send a mail to the contact listing for the moon
|
||||
$mail = new EveMail;
|
||||
$mail->sender = 93738489;
|
||||
$mail->subject = "Moon Rental";
|
||||
$mail->body = $body;
|
||||
$mail->recipient = (int)$rental->contact;
|
||||
$mail->recipient_type = 'character';
|
||||
$mail->save();
|
||||
|
||||
//Dispatch the job and cycle to the next moon rental
|
||||
SendEveMail::dispatch($mail)->delay(Carbon::now()->addseconds(15));
|
||||
}
|
||||
|
||||
//Remove all moon rentals from the database
|
||||
DB::table('moon_rents')->delete();
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Esi\Mail;
|
||||
|
||||
use App\User;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\ScheduledTask\ScheduleJob;
|
||||
use App\Models\Market\MonthlyMarketTax;
|
||||
use App\Models\Mail\EveMail;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
|
||||
class SendMail extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:sendmail';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send mail to a character for not having the correct ESI scopes.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
* Gather the taxes needed and add them together.
|
||||
* Send a mail to the character owning the ESI scope with the taxes
|
||||
* owed to the holding corp
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('SendMail');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Retrieve the token for main character to send mails from
|
||||
$token = EsiToken::where(['character_id' => 93738489])->first();
|
||||
|
||||
//Set the date
|
||||
$date = Carbon::now()->subMonth();
|
||||
//Set the mail helper variable
|
||||
$mHelper = new Mail();
|
||||
//Create a new esi container and authentication
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token->refresh_token,
|
||||
]);
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
//Check for the correct tokens for each of the people holding structures.
|
||||
//If the token is not found, then send a mail asking to have the token registered.
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,12 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
Commands\CorpJournal::class,
|
||||
Commands\GetCorps::class,
|
||||
Commands\UpdateMoonPricing::class,
|
||||
Commands\CalculateMarketTax::class,
|
||||
Commands\holdingfinances::class,
|
||||
Commands\CorpJournalCommand::class,
|
||||
Commands\GetCorpsCommand::class,
|
||||
Commands\UpdateMoonPriceCommand::class,
|
||||
Commands\CalculateMarketTaxCommand::class,
|
||||
Commands\HoldingFinancesCommand::class,
|
||||
Commands\MoonMailerCommand::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -28,21 +29,24 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('services:corpjournal')
|
||||
$schedule->command('services:CorpJournal')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:holdingjournal')
|
||||
$schedule->command('services:HoldingJournal')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:updatemoonprice')
|
||||
$schedule->command('services:UpdateMoonPrice')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:getcorps')
|
||||
$schedule->command('services:GetCorps')
|
||||
->monthlyOn(1, '09:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:calculatemarkettax')
|
||||
$schedule->command('services:CalculateMarketTax')
|
||||
->monthlyOn(1, '08:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:MoonMailer')
|
||||
->monthlyOn(27, '00:01')
|
||||
->withoutOverlapping();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -94,6 +94,7 @@ class MoonsAdminController extends Controller
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['alliance'],
|
||||
'Type' => 'alliance',
|
||||
]);
|
||||
} else {
|
||||
MoonRent::insert([
|
||||
@@ -104,6 +105,7 @@ class MoonsAdminController extends Controller
|
||||
'RentalEnd' => $date,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['outofalliance'],
|
||||
'Type' => 'outofalliance',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ class CreateMoonRentsTable extends Migration
|
||||
$table->dateTime('RentalEnd');
|
||||
$table->string('Contact');
|
||||
$table->string('Price');
|
||||
$table->string('Type');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user