item price update issue
This commit is contained in:
@@ -6,7 +6,7 @@ use Illuminate\Console\Command;
|
|||||||
|
|
||||||
//Library
|
//Library
|
||||||
use App\Library\Moons\MoonCalc;
|
use App\Library\Moons\MoonCalc;
|
||||||
use Comamnds\Library\CommandHelper;
|
use Commands\Library\CommandHelper;
|
||||||
|
|
||||||
//Job
|
//Job
|
||||||
use App\Jobs\Commands\Eve\ItemPricesUpdateJob;
|
use App\Jobs\Commands\Eve\ItemPricesUpdateJob;
|
||||||
|
|||||||
@@ -95,26 +95,6 @@ class MiningTaxesInvoices extends Command
|
|||||||
|
|
||||||
//Generate a unique invoice id
|
//Generate a unique invoice id
|
||||||
$invoiceId = uniqid();
|
$invoiceId = uniqid();
|
||||||
|
|
||||||
//Save the invoice model
|
|
||||||
$invoice = new Invoice;
|
|
||||||
$invoice->character_id = $charId;
|
|
||||||
$invoice->character_name = $charName;
|
|
||||||
$invoice->invoice_id = $invoiceId;
|
|
||||||
$invoice->invoice_amount = $invoiceAmount;
|
|
||||||
$invoice->date_issued = Carbon::now();
|
|
||||||
$invoice->date_due = Carbon::now()->addDays(7);
|
|
||||||
$invoice->status = 'Pending';
|
|
||||||
$invoice->save();
|
|
||||||
|
|
||||||
//Update the ledger entries
|
|
||||||
Ledger::where([
|
|
||||||
'character_id' => $charId,
|
|
||||||
'invoiced' => 'No',
|
|
||||||
])->update([
|
|
||||||
'invoiced' => 'Yes',
|
|
||||||
'invoice_id' => $invoiceId,
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Create the mail body
|
//Create the mail body
|
||||||
$body .= "Dear Miner,<br><br>";
|
$body .= "Dear Miner,<br><br>";
|
||||||
@@ -143,6 +123,27 @@ class MiningTaxesInvoices extends Command
|
|||||||
|
|
||||||
//Send the Eve Mail Job to the queue to be dispatched
|
//Send the Eve Mail Job to the queue to be dispatched
|
||||||
ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail');
|
ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail');
|
||||||
|
|
||||||
|
//Save the invoice model
|
||||||
|
$invoice = new Invoice;
|
||||||
|
$invoice->character_id = $charId;
|
||||||
|
$invoice->character_name = $charName;
|
||||||
|
$invoice->invoice_id = $invoiceId;
|
||||||
|
$invoice->invoice_amount = $invoiceAmount;
|
||||||
|
$invoice->date_issued = Carbon::now();
|
||||||
|
$invoice->date_due = Carbon::now()->addDays(7);
|
||||||
|
$invoice->status = 'Pending';
|
||||||
|
$invoice->mail_body = $body;
|
||||||
|
$invoice->save();
|
||||||
|
|
||||||
|
//Update the ledger entries
|
||||||
|
Ledger::where([
|
||||||
|
'character_id' => $charId,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->update([
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
'invoice_id' => $invoiceId,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set the task as stopped
|
//Set the task as stopped
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ class Kernel extends ConsoleKernel
|
|||||||
Commands\MiningTaxes\MiningTaxesLedgers::class,
|
Commands\MiningTaxes\MiningTaxesLedgers::class,
|
||||||
Commands\MiningTaxes\MiningTaxesObservers::class,
|
Commands\MiningTaxes\MiningTaxesObservers::class,
|
||||||
Commands\MiningTaxes\MiningTaxesPayments::class,
|
Commands\MiningTaxes\MiningTaxesPayments::class,
|
||||||
Commands\MiningTaxes\MiningTaxesDataCleanup::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,9 +88,6 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->command('MiningTaxes:Payments')
|
$schedule->command('MiningTaxes:Payments')
|
||||||
->hourlyAt('15')
|
->hourlyAt('15')
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
$schedule->command('MiningTaxes:CleanupData')
|
|
||||||
->weekly(7, '11:15')
|
|
||||||
->withoutOverlapping();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class FetchMiningTaxesLedgersJob implements ShouldQueue
|
|||||||
|
|
||||||
//Dispatch jobs to process each of the mining ledger entries
|
//Dispatch jobs to process each of the mining ledger entries
|
||||||
foreach($ledgers as $ledger) {
|
foreach($ledgers as $ledger) {
|
||||||
ProcessMiningTaxesLedgersJob::dispatch($ledger)->onQueue('miningtaxes');
|
ProcessMiningTaxesLedgersJob::dispatch($ledger, $this->observerId)->onQueue('miningtaxes');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,19 +40,21 @@ class ProcessMiningTaxesLedgersJob implements ShouldQueue
|
|||||||
* Job Variables
|
* Job Variables
|
||||||
*/
|
*/
|
||||||
private $ledger;
|
private $ledger;
|
||||||
|
private $observerId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct($ledger)
|
public function __construct($ledger, $observerId)
|
||||||
{
|
{
|
||||||
//Set the connection for the job
|
//Set the connection for the job
|
||||||
$this->connection = 'redis';
|
$this->connection = 'redis';
|
||||||
|
|
||||||
//Import variables from the calling function
|
//Import variables from the calling function
|
||||||
$this->ledger = $ledger;
|
$this->ledger = $ledger;
|
||||||
|
$this->observerId = $observerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,25 +76,38 @@ class ProcessMiningTaxesLedgersJob implements ShouldQueue
|
|||||||
//Calculate the total price based on the amount
|
//Calculate the total price based on the amount
|
||||||
$amount = $price * $this->ledger->quantity;
|
$amount = $price * $this->ledger->quantity;
|
||||||
|
|
||||||
//Insert or update the entry in the database
|
$found = Ledger::where([
|
||||||
$item = Ledger::updateOrCreate([
|
|
||||||
'character_id' => $ledger->character_id,
|
])->count();
|
||||||
'character_name' => $charName,
|
|
||||||
'observer_id' => $obs->observer_id,
|
if($found > 0) {
|
||||||
'last_updated' => $ledger->last_updated,
|
Ledger::where([
|
||||||
'type_id' => $ledger->type_id,
|
'character_id' => $this->ledger->character_id,
|
||||||
'ore_name' => $typeName,
|
'character_name' => $charName,
|
||||||
'quantity' => $ledger->quantity,
|
'observer_id' => $this->observerId,
|
||||||
'amount' => $amount,
|
'type_id' => $this->ledger->type_id,
|
||||||
], [
|
'ore_name' => $typeName,
|
||||||
'character_id' => $ledger->character_id,
|
])->update([
|
||||||
'character_name' => $charName,
|
'character_id' => $this->ledger->character_id,
|
||||||
'observer_id' => $obs->observer_id,
|
'character_name' => $charName,
|
||||||
'last_updated' => $ledger->last_updated,
|
'observer_id' => $this->observerId,
|
||||||
'type_id' => $ledger->type_id,
|
'last_updated' => $this->ledger->last_updated,
|
||||||
'ore_name' => $typeName,
|
'type_id' => $this->ledger->type_id,
|
||||||
'quantity' => $ledger->quantity,
|
'ore_name' => $typeName,
|
||||||
'amount' => $amount,
|
'quantity' => $this->ledger->quantity,
|
||||||
]);
|
'amount' => $amount,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$ledg = new Ledger;
|
||||||
|
$ledg->character_id = $this->character_id;
|
||||||
|
$ledg->character_name = $charName;
|
||||||
|
$ledg->observer_id = $this->observerId;
|
||||||
|
$ledg->last_updated = $ledger->last_updated;
|
||||||
|
$ledg->type_id = $ledger->type_id;
|
||||||
|
$ledg->ore_name = $typeName;
|
||||||
|
$ledg->quantity = $ledger->quantity;
|
||||||
|
$ledg->amount = $amount;
|
||||||
|
$ledg->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class Invoice extends Model
|
|||||||
'date_issued',
|
'date_issued',
|
||||||
'date_due',
|
'date_due',
|
||||||
'status',
|
'status',
|
||||||
|
'mail_body',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getPayment() {
|
public function getPayment() {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class CreateMiningTaxTables extends Migration
|
|||||||
'Deferred',
|
'Deferred',
|
||||||
'Deleted',
|
'Deleted',
|
||||||
])->default('Pending');
|
])->default('Pending');
|
||||||
|
$table->text('mail_body')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user