tweaked some jobs
This commit is contained in:
@@ -68,51 +68,55 @@ class ProcessMiningTaxesLedgersJob implements ShouldQueue
|
||||
$mHelper = new MoonCalc;
|
||||
$config = config('esi');
|
||||
|
||||
//Get some of the basic information we need to work with
|
||||
$charName = $lookup->CharacterIdToName($this->ledger->character_id);
|
||||
//Get the type name from the ledger ore
|
||||
$typeName = $lookup->ItemIdToName($this->ledger->type_id);
|
||||
//Get the price from the helper function
|
||||
$price = $mHelper->CalculateOrePrice($this->ledger->type_id);
|
||||
//Calculate the total price based on the amount
|
||||
$amount = (($price * $this->ledger->quantity) * $config['refine_rate']);
|
||||
//Create a starting date for the ledger
|
||||
$ledgerDate = Carbon::createFromFormat('Y-m-d', $this->ledger->last_updated);
|
||||
|
||||
//If the ledger is more than one day old, then process it, otherwise, we don't process it
|
||||
//or add it to the database as it may still be updating.
|
||||
if($ledgerDate->lessThan(Carbon::now()->subDay())) {
|
||||
//Get some of the basic information we need to work with
|
||||
$charName = $lookup->CharacterIdToName($this->ledger->character_id);
|
||||
//Get the type name from the ledger ore
|
||||
$typeName = $lookup->ItemIdToName($this->ledger->type_id);
|
||||
//Get the price from the helper function
|
||||
$price = $mHelper->CalculateOrePrice($this->ledger->type_id);
|
||||
//Calculate the total price based on the amount
|
||||
$amount = (($price * $this->ledger->quantity) * $config['refine_rate']);
|
||||
|
||||
$found = Ledger::where([
|
||||
'character_id' => $this->ledger->character_id,
|
||||
'observer_id' => $this->observerId,
|
||||
'type_id' => $this->ledger->type_id,
|
||||
'last_updated' => $this->ledger->last_updated,
|
||||
])->count();
|
||||
|
||||
if($found > 0) {
|
||||
Ledger::where([
|
||||
$found = Ledger::where([
|
||||
'character_id' => $this->ledger->character_id,
|
||||
'character_name' => $charName,
|
||||
'observer_id' => $this->observerId,
|
||||
'type_id' => $this->ledger->type_id,
|
||||
'quantity' => $this->ledger->quantity,
|
||||
'last_updated' => $this->ledger->last_updated,
|
||||
])->update([
|
||||
'character_id' => $this->ledger->character_id,
|
||||
'character_name' => $charName,
|
||||
'observer_id' => $this->observerId,
|
||||
'last_updated' => $this->ledger->last_updated,
|
||||
'type_id' => $this->ledger->type_id,
|
||||
'ore_name' => $typeName,
|
||||
'quantity' => $this->ledger->quantity,
|
||||
'amount' => $amount,
|
||||
]);
|
||||
} else {
|
||||
$ledg = new Ledger;
|
||||
$ledg->character_id = $this->ledger->character_id;
|
||||
$ledg->character_name = $charName;
|
||||
$ledg->observer_id = $this->observerId;
|
||||
$ledg->last_updated = $this->ledger->last_updated;
|
||||
$ledg->type_id = $this->ledger->type_id;
|
||||
$ledg->ore_name = $typeName;
|
||||
$ledg->quantity = $this->ledger->quantity;
|
||||
$ledg->amount = $amount;
|
||||
$ledg->save();
|
||||
])->count();
|
||||
|
||||
if($found > 0) {
|
||||
Ledger::where([
|
||||
'character_id' => $this->ledger->character_id,
|
||||
'character_name' => $charName,
|
||||
'observer_id' => $this->observerId,
|
||||
'type_id' => $this->ledger->type_id,
|
||||
'quantity' => $this->ledger->quantity,
|
||||
'last_updated' => $this->ledger->last_updated,
|
||||
])->update([
|
||||
'last_updated' => $this->ledger->last_updated,
|
||||
'quantity' => $this->ledger->quantity,
|
||||
'amount' => $amount,
|
||||
]);
|
||||
} else {
|
||||
$ledg = new Ledger;
|
||||
$ledg->character_id = $this->ledger->character_id;
|
||||
$ledg->character_name = $charName;
|
||||
$ledg->observer_id = $this->observerId;
|
||||
$ledg->last_updated = $this->ledger->last_updated;
|
||||
$ledg->type_id = $this->ledger->type_id;
|
||||
$ledg->ore_name = $typeName;
|
||||
$ledg->quantity = $this->ledger->quantity;
|
||||
$ledg->amount = $amount;
|
||||
$ledg->save();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user