job troubleshooting

This commit is contained in:
2019-05-04 00:09:13 -05:00
parent 9cfd5a1a83
commit 9a4271bf0d
3 changed files with 41 additions and 8 deletions

View File

@@ -38,8 +38,6 @@ class ProcessWalletJournalJob implements ShouldQueue
* @return void
*/
public function __construct(JobProcessWalletJournal $pwj) {
dd($pwj);
$this->division = $pwj->division;
$this->charId = $pwj->charId;
$this->page = $pwj->page;

View File

@@ -338,14 +338,9 @@ class FinanceHelper {
//Declare the lookup class helper
$lookups = new LookupHelper;
//If the token is not found, send the user an eve mail, and just exit out of the function
if($this->TokenNotFound($token, $scope, $charId)) {
return null;
}
//Reference to see if the character is in our look up table for corporations and characters
$corpId = $lookups->LookupCharacter($charId);
$corpId = $lookups->LookupCorporation($charId);
//Create an ESI authentication container
$config = config('esi');

View File

@@ -97,6 +97,46 @@ class LookupHelper {
}
}
public function LookupCorporation($charId) {
//Check for the character in the user_to_corporation table
$found = CharacterToCorporation::where('character_id', $charId)->get(['corporation_id']);
//If we don't find the character in the table, then we retrieve from ESI
//and add the character to the table
if(!isset($found[0]->corporation_id)) {
//Get the configuration for ESI from the environmental variables
$config = config('esi');
//Setup a new ESI container
$esi = new Eseye();
//Try to get the character information, then the corporation information
try {
$character = $esi->invoke('get', '/characters/{character_id}/', [
'character_id' => $charId,
]);
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
'corporation_id' => $character->corporation_id,
]);
} catch(RequestFailedException $e){
return null;
}
//Save all of the data to the database
$char = new CharacterToCorporation;
$char->character_id = $charId;
$char->character_name = $character->name;
$char->corporation_id = $character->corporation_id;
$char->corporation_name = $corporation->name;
$char->save();
//Return the corporation_id which is what the calling function is looking for
return $character->corporation_id;
} else {
//Return the corporation_id if it was found in the database as it is what the calling function is looking for
return $found[0]->corporation_id;
}
}
/**
* Function to retrieve a corporation name from the lookup tables
* or add the details of the corporation if it's not found