item price update issue

This commit is contained in:
2021-03-15 20:44:27 +09:00
parent 0c5b9aeb19
commit ade9da5be7
7 changed files with 61 additions and 47 deletions

View File

@@ -6,7 +6,7 @@ use Illuminate\Console\Command;
//Library
use App\Library\Moons\MoonCalc;
use Comamnds\Library\CommandHelper;
use Commands\Library\CommandHelper;
//Job
use App\Jobs\Commands\Eve\ItemPricesUpdateJob;

View File

@@ -95,26 +95,6 @@ class MiningTaxesInvoices extends Command
//Generate a unique invoice id
$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
$body .= "Dear Miner,<br><br>";
@@ -143,6 +123,27 @@ class MiningTaxesInvoices extends Command
//Send the Eve Mail Job to the queue to be dispatched
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

View File

@@ -36,7 +36,6 @@ class Kernel extends ConsoleKernel
Commands\MiningTaxes\MiningTaxesLedgers::class,
Commands\MiningTaxes\MiningTaxesObservers::class,
Commands\MiningTaxes\MiningTaxesPayments::class,
Commands\MiningTaxes\MiningTaxesDataCleanup::class,
];
/**
@@ -89,9 +88,6 @@ class Kernel extends ConsoleKernel
$schedule->command('MiningTaxes:Payments')
->hourlyAt('15')
->withoutOverlapping();
$schedule->command('MiningTaxes:CleanupData')
->weekly(7, '11:15')
->withoutOverlapping();
}
/**

View File

@@ -141,7 +141,7 @@ class FetchMiningTaxesLedgersJob implements ShouldQueue
//Dispatch jobs to process each of the mining ledger entries
foreach($ledgers as $ledger) {
ProcessMiningTaxesLedgersJob::dispatch($ledger)->onQueue('miningtaxes');
ProcessMiningTaxesLedgersJob::dispatch($ledger, $this->observerId)->onQueue('miningtaxes');
}
}

View File

@@ -40,19 +40,21 @@ class ProcessMiningTaxesLedgersJob implements ShouldQueue
* Job Variables
*/
private $ledger;
private $observerId;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($ledger)
public function __construct($ledger, $observerId)
{
//Set the connection for the job
$this->connection = 'redis';
//Import variables from the calling function
$this->ledger = $ledger;
$this->observerId = $observerId;
}
/**
@@ -74,25 +76,38 @@ class ProcessMiningTaxesLedgersJob implements ShouldQueue
//Calculate the total price based on the amount
$amount = $price * $this->ledger->quantity;
//Insert or update the entry in the database
$item = Ledger::updateOrCreate([
'character_id' => $ledger->character_id,
'character_name' => $charName,
'observer_id' => $obs->observer_id,
'last_updated' => $ledger->last_updated,
'type_id' => $ledger->type_id,
'ore_name' => $typeName,
'quantity' => $ledger->quantity,
'amount' => $amount,
], [
'character_id' => $ledger->character_id,
'character_name' => $charName,
'observer_id' => $obs->observer_id,
'last_updated' => $ledger->last_updated,
'type_id' => $ledger->type_id,
'ore_name' => $typeName,
'quantity' => $ledger->quantity,
'amount' => $amount,
]);
$found = Ledger::where([
])->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,
'ore_name' => $typeName,
])->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->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();
}
}
}

View File

@@ -28,6 +28,7 @@ class Invoice extends Model
'date_issued',
'date_due',
'status',
'mail_body',
];
public function getPayment() {

View File

@@ -30,6 +30,7 @@ class CreateMiningTaxTables extends Migration
'Deferred',
'Deleted',
])->default('Pending');
$table->text('mail_body')->nullable();
$table->timestamps();
});
}