feat: add manual deposit system, implement Bank model, remove Docker configs, and initialize comprehensive Laravel best practice documentation for AI agents.
This commit is contained in:
@@ -4,12 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs\VirtualMachine\Provision;
|
||||
|
||||
use App\Http\Services\Telegram;
|
||||
use App\Jobs\Mail\Admin\AdminOrderNotificationJob;
|
||||
use App\Jobs\Mail\SendInformationVirtualMachine;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\ModuleVmware;
|
||||
use App\Models\Setting;
|
||||
use App\Services\InvoicePdfService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -37,23 +37,23 @@ class SendVmCredentialsEmailJob implements ShouldQueue
|
||||
public readonly int $moduleVmwareId,
|
||||
) {}
|
||||
|
||||
public function handle(): void
|
||||
public function handle(Telegram $telegram): void
|
||||
{
|
||||
$vm = ModuleVmware::with(['customer', 'os.osGroup', 'order.orderItems'])->find($this->moduleVmwareId);
|
||||
|
||||
if (!$vm) {
|
||||
Log::error('SendVmCredentialsEmailJob: ModuleVmware not found', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
]);
|
||||
$msg = "SendVmCredentialsEmailJob: ModuleVmware #{$this->moduleVmwareId} not found";
|
||||
Log::error($msg);
|
||||
$telegram->SendErrorMessage($msg);
|
||||
return;
|
||||
}
|
||||
|
||||
$customer = $vm->customer;
|
||||
|
||||
if (!$customer?->email) {
|
||||
Log::error('SendVmCredentialsEmailJob: customer or email missing', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
]);
|
||||
$msg = "SendVmCredentialsEmailJob: customer or email missing for ModuleVmware #{$this->moduleVmwareId}";
|
||||
Log::error($msg, ['module_vmware_id' => $this->moduleVmwareId]);
|
||||
$telegram->SendErrorMessage($msg);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -87,35 +87,17 @@ class SendVmCredentialsEmailJob implements ShouldQueue
|
||||
: 'N/A',
|
||||
];
|
||||
|
||||
// Generate invoice PDF attachment (synchronous, no queue)
|
||||
$invoicePdf = null;
|
||||
$invoicePdfFileName = null;
|
||||
// Resolve invoice ID — PDF is generated inside SendInformationVirtualMachine::handle()
|
||||
// to avoid passing large binary blobs through the queue payload
|
||||
$invoice = Invoice::where('order_id', $vm->order_id)->first();
|
||||
|
||||
$invoice = Invoice::where('order_id', $vm->order_id)
|
||||
->with(['invoiceItems.product', 'customer', 'order.orderItems'])
|
||||
->first();
|
||||
|
||||
if ($invoice) {
|
||||
try {
|
||||
$pdfService = app(InvoicePdfService::class);
|
||||
$invoicePdf = $pdfService->generate($invoice);
|
||||
$invoicePdfFileName = $pdfService->generateFileName($invoice);
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('SendVmCredentialsEmailJob: failed to generate invoice PDF', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'invoice_id' => $invoice->id,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
SendInformationVirtualMachine::dispatch($emailData, $customer, $invoicePdf, $invoicePdfFileName);
|
||||
SendInformationVirtualMachine::dispatch($emailData, $customer, $invoice?->id);
|
||||
|
||||
Log::info('SendVmCredentialsEmailJob: email dispatched', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'customer_email' => $customer->email,
|
||||
'ip' => $vm->ip,
|
||||
'invoice_attached' => $invoicePdf !== null,
|
||||
'invoice_id' => $invoice?->id,
|
||||
]);
|
||||
|
||||
// Notify admin with VM credentials after successful provisioning
|
||||
@@ -146,6 +128,18 @@ class SendVmCredentialsEmailJob implements ShouldQueue
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
try {
|
||||
app(Telegram::class)->SendErrorMessage([
|
||||
'job' => 'SendVmCredentialsEmailJob',
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'error' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
]);
|
||||
} catch (\Throwable $te) {
|
||||
Log::error('SendVmCredentialsEmailJob: could not send Telegram notification: ' . $te->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user