added tagging to jobs

This commit is contained in:
2021-04-27 00:49:49 +09:00
parent fdbc7ddf1b
commit ae4436d3f1
25 changed files with 312 additions and 94 deletions
+9
View File
@@ -190,4 +190,13 @@ class PurgeUsers implements ShouldQueue
}
}
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['Data', 'PurgeUsers'];
}
}
@@ -37,4 +37,13 @@ class ItemPricesUpdate implements ShouldQueue
$moonHelper->FetchNewPrices();
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['Eve', 'ItemPricesUpdate'];
}
}
@@ -62,4 +62,13 @@ class UpdateAllianceWalletJournalJob implements ShouldQueue
UpdateAllianceWalletJournalPage::dispatch(1, $config['primary'], $i)->onQueue('journal');
}
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['UpdateAllianceWalletJournal', 'Finances'];
}
}
@@ -77,7 +77,7 @@ class UpdateAllianceWalletJournalPage implements ShouldQueue
* the failed page is the first page.
*/
try {
$journals = $esi->page($currentPage)
$journals = $esi->page($this->page)
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
'corporation_id' => $corpId,
'division' => $division,
@@ -141,4 +141,13 @@ class UpdateAllianceWalletJournalPage implements ShouldQueue
//Return as completed
return 0;
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['UpdateAllianceWalletJournalPage', 'Finances'];
}
}
@@ -53,4 +53,13 @@ class UpdateItemPrices implements ShouldQueue
//Fetch new prices from fuzzwork.co.uk for the item pricing schemes
$moonHelper->FetchNewPrices();
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['UpdateItemPrices', 'Finances'];
}
}
@@ -151,4 +151,13 @@ class FetchMiningTaxesLedgers implements ShouldQueue
} while($currentPage <= $totalPages);
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['FetchMiningTaxesLedgers', 'MiningTaxes', 'MiningTaxesLedgers'];
}
}
@@ -57,6 +57,7 @@ class FetchMiningTaxesObservers implements ShouldQueue
//Declare variables
$config = config('esi');
$lookup = new LookupHelper;
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
$esiHelper = new Esi;
//Check for the esi scope
@@ -66,6 +67,12 @@ class FetchMiningTaxesObservers implements ShouldQueue
return;
}
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
Log::critical('Esi scope esi-universe.read_structures.v1 was not found for FetchMiningTaxesObserversJob.');
print("Esi scopes not found 2");
return;
}
$char = $lookup->GetCharacterInfo($config['primary']);
//Get the refresh token for the character
@@ -82,23 +89,36 @@ class FetchMiningTaxesObservers implements ShouldQueue
//Run through the mining observers, and add them to the database
foreach($resp as $observer) {
if($observer->observer_id > 1030000000000) {
//Get the observer name from esi as well
$structureInfo = $sHelper->GetStructureInfo($observer->observer_id);
//See if the observer is found in the database
$found = Observer::where([
'observer_id' => $observer->observer_id,
])->count();
//If found, then update the structure
if($found > 0) {
Observer::where([
'observer_id' => $observer->observer_id,
])->update([
'observer_id' => $observer->observer_id,
'observer_type' => $observer->observer_type,
'observer_name' => $observerName,
'last_updated' => $observer->last_updated,
'solar_system_id' => $structureInfo->solar_system_id,
'solar_system_name' => $sHelper->GetSolarSystemName($structureInfo->solar_system_id),
]);
} else {
//Add a new observer into the observer table
$newObs = new Observer;
$newObs->observer_id = $observer->observer_id;
$newObs->observer_type = $observer->observer_type;
$newObs->observer_name = $observerName;
$newObs->last_updated = $observer->last_updated;
$newObs->solar_system_id = $structureInfo->solar_system_id;
$newObs->solar_system_name = $sHelper->GetSolarSystemName($structureInfo->solar_system_id);
$newObs->save();
}
}
@@ -179,6 +199,6 @@ class FetchMiningTaxesObservers implements ShouldQueue
* @var array
*/
public function tags() {
return ['FetchMiningObservers'];
return ['FetchMiningObservers', 'MiningTaxes'];
}
}
@@ -65,4 +65,13 @@ class PreFetchMiningTaxesLedgers implements ShouldQueue
FetchMiningTaxesLedgers::dispatch($config['primary'], $config['corporation'], $obs->observer_id)->onQueue('miningtaxes');
}
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['PreFetchMiningTaxesLedgers', 'MiningTaxes', 'MiningTaxesLedgers'];
}
}
@@ -120,4 +120,13 @@ class ProcessMiningTaxesLedgers implements ShouldQueue
return 0;
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['ProcessMiningTaxesLedgers', 'MiningTaxes', 'MiningTaxesLedgers'];
}
}
@@ -120,4 +120,13 @@ class ProcessMiningTaxesPayments implements ShouldQueue
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['ProcessMiningTaxesPayments', 'MiningTaxes', 'Payments'];
}
}
@@ -200,17 +200,22 @@ class SendMiningTaxesInvoices implements ShouldQueue
private function CreateInvoice($charId, $ledgers, &$mailDelay) {
$invoice = array();
$ores = array();
$characters = array();
$totalPrice = 0.00;
$body = null;
$lookup = new LookupHelper;
if(sizeof($ledgers) > 0) {
foreach($ledgers as $ledger) {
if(!isset($ores[$row['type_id']])) {
$ores[$row['type_id']] = 0;
if(!isset($ores[$ledger['type_id']])) {
$ores[$ledger['type_id']] = 0;
}
$ores[$ledger['type_id']] = $ores[$ledger['type_id']] + $ledger['quantity'];
$totalPrice = $totalPrice + $ledger['amount'];
if(!isset($characters[$ledger['character_name']])) {
$characters[$ledger['character_name']] = $ledger['character_name'];
}
$ores[$row['type_id']] = $ores[$row['type_id']] + $row['quantity'];
$totalPrice = $totalPrice + $row['amount'];
}
$invoiceAmount = round(($totalPrice * $config['mining_tax']), 2);
@@ -224,7 +229,7 @@ class SendMiningTaxesInvoices implements ShouldQueue
$numberMiningTax = number_format(($config['mining_tax'] * 100.00), 2, ".", ",");
//Create the mail body
$body .= "Dear Miner,<br><br>";
$body .= "Dear " . $charName . ",<br><br>";
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
foreach($ores as $ore => $quantity) {
$oreName = $lookup->ItemIdToName($ore);
@@ -242,11 +247,16 @@ class SendMiningTaxesInvoices implements ShouldQueue
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
}
$body .= "<br>";
$body .= "Characters Processed: <br>";
foreach($characters as $character) {
$body .= $character['character_name'] . "<br>";
}
$body .= "<br>";
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
//Check if the mail body is greater than 2000 characters. If greater than 2,000 characters, then
if(strlen($body) > 2000) {
$body = "Dear Miner,<br><br>";
$body = "Dear " . $charName . "<br><br>";
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
$body .= "<br><br>";
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
@@ -303,12 +313,21 @@ class SendMiningTaxesInvoices implements ShouldQueue
'main_id' => $charId,
])->get();
$altCount = UserAlt::where([
'main_id' => $charId,
])->count();
$rows = Ledger::where([
'character_id' => $charId,
'invoiced' => 'No',
])->get();
if($rows->count() > 0) {
$mainCount = Ledger::where([
'character_id' => $charId,
'invoiced' => 'No',
])->count();
if($mainCount > 0) {
foreach($rows as $row) {
array_push($ledgers, [
'character_id' => $row->character_id,
@@ -325,26 +344,33 @@ class SendMiningTaxesInvoices implements ShouldQueue
}
}
if($alts->count() > 0) {
if($altCount > 0) {
foreach($alts as $alt) {
$rows = Ledger::where([
'character_id' => $alt->character_id,
'invoiced' => 'No',
])->get();
foreach($rows as $row) {
array_push($ledgers, [
'character_id' => $row->character_id,
'character_name' => $row->character_name,
'observer_id' => $row->observer_id,
'last_updated' => $row->last_updated,
'type_id' => $row->type_id,
'ore_name' => $row->ore_name,
'quantity' => $row->quantity,
'amount' => $row->amount,
'invoiced' => $row->invoiced,
'invoice_id' => $row->invoice_id,
]);
$rowCount = Ledger::where([
'character_id' => $alt->character_id,
'invoiced' => 'No',
])->count();
if($rowCount > 0) {
foreach($rows as $row) {
array_push($ledgers, [
'character_id' => $row->character_id,
'character_name' => $row->character_name,
'observer_id' => $row->observer_id,
'last_updated' => $row->last_updated,
'type_id' => $row->type_id,
'ore_name' => $row->ore_name,
'quantity' => $row->quantity,
'amount' => $row->amount,
'invoiced' => $row->invoiced,
'invoice_id' => $row->invoice_id,
]);
}
}
}
}
@@ -352,4 +378,13 @@ class SendMiningTaxesInvoices implements ShouldQueue
//Return the ledgers
return $ledgers;
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['MiningTaxes', 'SendMiningTaxesInvoices', 'Invoices'];
}
}
@@ -81,4 +81,13 @@ class UpdateMiningTaxesLateInvoices15th implements ShouldQueue
}
}
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['UpdateMiningTaxesLateInvoices', 'MiningTaxes', 'Invoices'];
}
}
@@ -81,4 +81,13 @@ class UpdateMiningTaxesLateInvoices1st implements ShouldQueue
}
}
}
/**
* Set the tags for Horzion
*
* @var array
*/
public function tags() {
return ['UpdateMiningTaxesLateInvoices', 'MiningTaxes', 'Invoices'];
}
}
+1 -2
View File
@@ -73,9 +73,8 @@ class StructureHelper {
}
}
private function GetSolarSystemName($systemId) {
public function GetSolarSystemName($systemId) {
//Declare some variables
$esiHelper = new Esi;
$lookup = new LookupHelper;
$solar = $lookup->SystemIdToName($systemId);
+2
View File
@@ -25,5 +25,7 @@ class Observer extends Model
'observer_id',
'observer_type',
'observer_name',
'solar_system_name',
'solar_system_id',
];
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class RentalInvoice extends Model
{
//
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class RentalLedger extends Model
{
//
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class RentalPayment extends Model
{
//
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class RentalStructure extends Model
{
//
}