Example #1
0
 /**
  * Retreive Wallet Journal Entries for a Character
  *
  * @param int  $character_id
  * @param bool $get
  * @param int  $chunk
  *
  * @return
  */
 public function getCharacterWalletJournal(int $character_id, bool $get = true, int $chunk = 50)
 {
     $journal = WalletJournal::leftJoin('eve_ref_types', 'character_wallet_journals.refTypeID', '=', 'eve_ref_types.refTypeID')->where('characterID', $character_id);
     if ($get) {
         return $journal->orderBy('date', 'desc')->paginate($chunk);
     }
     return $journal;
 }
Example #2
0
 /**
  * Run the Update
  *
  * @return mixed|void
  */
 public function call()
 {
     $pheal = $this->setScope('char')->getPheal();
     foreach ($this->api_info->characters as $character) {
         // Define the first MAX from_id to use when
         // retreiving transactions.
         $from_id = PHP_INT_MAX;
         // Set the transaction overlap marker. This will
         // be checked after processing an API response to
         // see if any of the transactions we got back was
         // already known.
         $transaction_overlap = false;
         // This infinite loop needs to be broken out of
         // once we have reached the end of the backwards
         // journal walking. Walking ends when we have
         // either received less rows than asked for, or
         // we have reached a known transaction hash.
         while (true) {
             $result = $pheal->WalletJournal(['characterID' => $character->characterID, 'rowCount' => $this->rows_per_call] + ($from_id == PHP_INT_MAX ? [] : ['fromID' => $from_id]));
             foreach ($result->transactions as $transaction) {
                 // Ensure that $from_id is at its lowest
                 $from_id = min($transaction->refID, $from_id);
                 // Transactions are uniquely identified by applying a
                 // quick hash function over a few identifying fields.
                 // This is because transactionID's may exhaust their
                 // lifetime and lapse.
                 $transaction_hash = $this->hash_transaction($character->characterID, $transaction->date, $transaction->ownerID1, $transaction->refID);
                 // Check if the transaction is known. If it is,
                 // then we can just continue to the next. We will
                 // also use this opportunity to mark that the results
                 // received overlapped an existing record, meaning
                 // that we can stop calling the API for more wallet
                 // transactions. We dont immediately break because
                 // the transactions are not always received in any
                 // order for the fromID that was specified.
                 if (WalletJournalModel::where('characterID', $character->characterID)->where('hash', $transaction_hash)->first()) {
                     $transaction_overlap = true;
                     continue;
                 }
                 WalletJournalModel::create(['characterID' => $character->characterID, 'hash' => $transaction_hash, 'refID' => $transaction->refID, 'date' => $transaction->date, 'refTypeID' => $transaction->refTypeID, 'ownerName1' => $transaction->ownerName1, 'ownerID1' => $transaction->ownerID1, 'ownerName2' => $transaction->ownerName2, 'ownerID2' => $transaction->ownerID2, 'argName1' => $transaction->argName1, 'argID1' => $transaction->argID1, 'amount' => $transaction->amount, 'balance' => $transaction->balance, 'reason' => $transaction->reason, 'taxReceiverID' => $transaction->taxReceiverID, 'taxAmount' => $transaction->taxAmount, 'owner1TypeID' => $transaction->owner1TypeID, 'owner2TypeID' => $transaction->owner2TypeID]);
             }
             // Foreach transactions
             // As previously mentioned, there may be a few
             // conditions where we may decide its time to
             // break out of the infinite loop. This is where
             // we will be doing those checks. The most ob-
             // vious one being that we may have received less
             // than the total amount of rows asked for.
             if (count($result->transactions) < $this->rows_per_call) {
                 break;
             }
             // If the response contained known transactions,
             // stop processing for this character.
             if ($transaction_overlap) {
                 break;
             }
         }
         // while(true)
     }
     return;
 }
Example #3
0
 /**
  * Retreive Wallet Journal Entries for a Character
  *
  * @param                          $character_id
  * @param int                      $chunk
  * @param \Illuminate\Http\Request $request
  *
  * @return mixed
  */
 public function getCharacterWalletJournal($character_id, $chunk = 50, Request $request = null)
 {
     $journal = WalletJournal::leftJoin('eve_ref_types', 'character_wallet_journals.refTypeID', '=', 'eve_ref_types.refTypeID')->where('characterID', $character_id);
     // Apply any received filters
     if ($request && $request->filter) {
         $journal = $this->where_filter($journal, $request->filter, config('web.filter.rules.character_journal'));
     }
     return $journal->orderBy('date', 'desc')->paginate($chunk);
 }
Example #4
0
 /**
  * @param int $character_id
  * @param int $profile_id
  *
  * @return
  */
 public function getCharacterJournalStandingsWithProfile(int $character_id, int $profile_id)
 {
     return WalletJournal::select(DB::raw('count(*) as total'), 'character_affiliations.characterName', 'character_affiliations.characterID', 'character_affiliations.corporationName', 'character_affiliations.corporationID', 'character_affiliations.allianceName', 'character_affiliations.allianceID', 'standings_profile_standings.elementID as standing_match_on', 'standings_profile_standings.type as standing_type', 'standings_profile_standings.standing as standing')->leftJoin('character_affiliations', function ($join) {
         $join->on('character_affiliations.characterID', '=', 'character_wallet_journals.ownerID1');
         $join->orOn('character_affiliations.characterID', '=', 'character_wallet_journals.ownerID2');
     })->join('standings_profile_standings', function ($join) {
         $join->on('standings_profile_standings.elementID', '=', 'character_affiliations.characterID');
         $join->orOn('standings_profile_standings.elementID', '=', 'character_affiliations.corporationID');
         $join->orOn('standings_profile_standings.elementID', '=', 'character_affiliations.allianceID');
     })->where('character_wallet_journals.characterID', $character_id)->where('standings_profile_standings.standings_profile_id', $profile_id)->groupBy('standings_profile_standings.elementID');
 }