From 955a5581a31a0bcf321a1b266d8062298b69da41 Mon Sep 17 00:00:00 2001 From: drkthunder02 Date: Tue, 25 May 2021 02:08:05 +0900 Subject: [PATCH] new mining tax invoice job --- .../SendMiningTaxesInvoicesOld.php | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/app/Jobs/Commands/MiningTaxes/SendMiningTaxesInvoicesOld.php b/app/Jobs/Commands/MiningTaxes/SendMiningTaxesInvoicesOld.php index b390fd1fd..1e095e055 100644 --- a/app/Jobs/Commands/MiningTaxes/SendMiningTaxesInvoicesOld.php +++ b/app/Jobs/Commands/MiningTaxes/SendMiningTaxesInvoicesOld.php @@ -72,8 +72,8 @@ class SendMiningTaxesInvoicesOld implements ShouldQueue //Pluck all the users from the database of ledgers to determine if they are mains or alts. $tempMains = Ledger::where([ - 'invoiced' => 'Yes', - ])->where('last_updated', '>', Carbon::now()->subMonths(3))->pluck('character_id'); + 'invoiced' => 'No', + ])->where('last_updated', '>', Carbon::now()->subDays(7))->pluck('character_id'); //Get the unique character ids from the ledgers in the previous statement $tempMains = $tempMains->unique()->values()->all(); @@ -92,21 +92,20 @@ class SendMiningTaxesInvoicesOld implements ShouldQueue */ foreach($mains as $main) { //Declare some variables for each run through the for loop - $mainLedgerCount = 0; $ledgers = new Collection; //Count the ledgers for the main $mainLedgerCount = Ledger::where([ 'character_id' => $main, - 'invoiced' => 'Yes', - ])->where('last_updated', '>', Carbon::now()->subMonths(3))->count(); + 'invoiced' => 'No', + ])->where('last_updated', '>', Carbon::now()->subDays(7))->count(); //If there are ledgers for the main, then let's grab them if($mainLedgerCount > 0) { $mainLedgers = Ledger::where([ 'character_id' => $main, - 'invoiced' => 'Yes', - ])->where('last_updated', '>', Carbon::now()->subMonths(3))->get(); + 'invoiced' => 'No', + ])->where('last_updated', '>', Carbon::now()->subDays(7))->get(); //Cycle through the entries, and add them to the ledger to send with the invoice foreach($mainLedgers as $row) { @@ -116,7 +115,7 @@ class SendMiningTaxesInvoicesOld implements ShouldQueue 'observer_id' => $row->observer_id, 'type_id' => $row->type_id, 'ore_name' => $row->ore_name, - 'quantity' => $row->quantity, + 'quantity' => (int)$row->quantity, 'amount' => (float)$row->amount, 'last_updated' => $row->last_updated, ]); @@ -135,14 +134,14 @@ class SendMiningTaxesInvoicesOld implements ShouldQueue foreach($alts as $alt) { $altLedgerCount = Ledger::where([ 'character_id' => $alt->character_id, - 'invoiced' => 'Yes', - ])->where('last_updated', '>', Carbon::now()->subMonths(3))->count(); + 'invoiced' => 'No', + ])->where('last_updated', '>', Carbon::now()->subDays(7))->count(); if($altLedgerCount > 0) { $altLedgers = Ledger::where([ 'character_id' => $alt->character_id, - 'invoiced' => 'Yes', - ])->where('last_updated', '>', Carbon::now()->subMonths(3))->get(); + 'invoiced' => 'No', + ])->where('last_updated', '>', Carbon::now()->subDays(7))->get(); foreach($altLedgers as $row) { $ledgers->push([ @@ -151,7 +150,7 @@ class SendMiningTaxesInvoicesOld implements ShouldQueue 'observer_id' => $row->observer_id, 'type_id' => $row->type_id, 'ore_name' => $row->ore_name, - 'quantity' => $row->quantity, + 'quantity' => (int)$row->quantity, 'amount' => (float)$row->amount, 'last_updated' => $row->last_updated, ]); @@ -164,7 +163,7 @@ class SendMiningTaxesInvoicesOld implements ShouldQueue * Send the collected information over to the function to send the actual mail */ if($ledgers->count() > 0) { - $this->CreateInvoice($main->character_id, $ledgers, $mailDelay); + $this->CreateInvoice($main, $ledgers, $mailDelay); } } }