feat: implement admin SMTP settings management and automated order notification system
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Services\Api\Order;
|
||||
|
||||
use App\Enums\Order\OrderStatus;
|
||||
use App\Helpers\OrderHelper;
|
||||
use App\Jobs\Mail\Admin\AdminOrderNotificationJob;
|
||||
use App\Jobs\VirtualMachine\Create\CreateVirtualMachineJob;
|
||||
use App\Models\Addon;
|
||||
use App\Models\Log as CustomerActivityLog;
|
||||
@@ -151,6 +152,8 @@ class OrderService
|
||||
$this->provisionService($processedOrder, $item, $customer);
|
||||
}
|
||||
|
||||
$this->dispatchAdminNotification($processedOrder, $customer);
|
||||
|
||||
return $processedOrder;
|
||||
});
|
||||
}
|
||||
@@ -268,6 +271,32 @@ class OrderService
|
||||
};
|
||||
}
|
||||
|
||||
private function dispatchAdminNotification(Order $order, $customer): void
|
||||
{
|
||||
try {
|
||||
$item = $order->orderItems->first();
|
||||
$product = $item?->product;
|
||||
$productType = $product?->category?->name ?? $product?->type ?? 'N/A';
|
||||
|
||||
AdminOrderNotificationJob::dispatch([
|
||||
'order_num' => $order->order_num,
|
||||
'customer_name' => trim($customer->firstname . ' ' . $customer->lastname),
|
||||
'customer_email' => $customer->email,
|
||||
'client_ip' => $order->client_ip ?? request()?->ip(),
|
||||
'product_name' => $product?->name ?? 'N/A',
|
||||
'product_type' => $productType,
|
||||
'billing_cycle' => $item?->billing_cycle ?? 'N/A',
|
||||
'total' => $order->total,
|
||||
'created_at' => now()->format('d/m/Y H:i:s'),
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
Log::error('OrderService: failed to dispatch admin notification', [
|
||||
'order_id' => $order->id,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enrich raw addon entries with resolved price & subtotal.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user