feat: Add IT Support catalog and related migrations, seeders, and email templates
- Created migration to add 'group_label' to 'product_type_fields' table. - Implemented ItSupportCatalogSeeder to populate IT Support features and tiers. - Added ProductCategorySeeder for initial product categories. - Developed ProductMockupSeeder for mockup products in various categories. - Introduced ProductTypeFieldSeeder to define fields for different product types. - Created email templates for VPS service information and service renewal reminders.
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs\VirtualMachine\Provision;
|
||||
|
||||
use App\Http\Services\Telegram;
|
||||
use App\Jobs\Mail\SendInformationVirtualMachine;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\ModuleVmware;
|
||||
use App\Services\VirtualMachine\VmCredentialsEmailDataBuilder;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Admin-triggered resend of the VPS credentials email — same email as
|
||||
* SendVmCredentialsEmailJob, but without re-running service/VM activation
|
||||
* or the admin "new order" notification.
|
||||
*/
|
||||
class ResendVmCredentialsEmailJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public int $tries = 3;
|
||||
public int $timeout = 60;
|
||||
|
||||
public function __construct(
|
||||
public readonly int $moduleVmwareId,
|
||||
) {}
|
||||
|
||||
public function handle(Telegram $telegram): void
|
||||
{
|
||||
$vm = ModuleVmware::with([
|
||||
'customer',
|
||||
'os.osGroup',
|
||||
'order.orderItems.service',
|
||||
])->find($this->moduleVmwareId);
|
||||
|
||||
if (!$vm) {
|
||||
$msg = "ResendVmCredentialsEmailJob: ModuleVmware #{$this->moduleVmwareId} not found";
|
||||
Log::error($msg);
|
||||
$telegram->SendErrorMessage($msg);
|
||||
return;
|
||||
}
|
||||
|
||||
$customer = $vm->customer;
|
||||
|
||||
if (!$customer?->email) {
|
||||
$msg = "ResendVmCredentialsEmailJob: customer or email missing for ModuleVmware #{$this->moduleVmwareId}";
|
||||
Log::error($msg, ['module_vmware_id' => $this->moduleVmwareId]);
|
||||
$telegram->SendErrorMessage($msg);
|
||||
return;
|
||||
}
|
||||
|
||||
$orderItem = $vm->order?->orderItems?->first();
|
||||
$emailData = app(VmCredentialsEmailDataBuilder::class)->build($vm, $orderItem);
|
||||
|
||||
$invoice = Invoice::where('order_id', $vm->order_id)->first();
|
||||
|
||||
SendInformationVirtualMachine::dispatch($emailData, $customer, $invoice?->id);
|
||||
|
||||
Log::info('ResendVmCredentialsEmailJob: email dispatched', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'customer_email' => $customer->email,
|
||||
]);
|
||||
}
|
||||
|
||||
public function failed(\Throwable $e): void
|
||||
{
|
||||
Log::error('ResendVmCredentialsEmailJob: failed', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user