update bug
This commit is contained in:
@@ -4,13 +4,13 @@ namespace App\Jobs\VirtualMachine;
|
||||
|
||||
use App\Enums\Invoice\InvoiceStatus;
|
||||
use App\Enums\Order\OrderStatus;
|
||||
use App\Http\Services\Discord;
|
||||
use App\Http\Services\Telegram;
|
||||
use App\Http\Services\Invoice\InvoiceService;
|
||||
use App\Jobs\VirtualMachine\Create\CreateVirtualMachineJob;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderItem;
|
||||
use App\Services\VMDataService;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -39,7 +39,7 @@ class ProcessOrderPaymentJob implements ShouldQueue
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(InvoiceService $invoiceService, Discord $discord): void
|
||||
public function handle(InvoiceService $invoiceService, Telegram $telegram): void
|
||||
{
|
||||
try {
|
||||
$user = $this->order->customer;
|
||||
@@ -57,7 +57,7 @@ class ProcessOrderPaymentJob implements ShouldQueue
|
||||
'user_credit' => $user->credit,
|
||||
'order_amount' => $this->order->amount
|
||||
]);
|
||||
$discord->SendErrorMessage($errorMessage, 'ProcessOrderPaymentJob - Insufficient Credit');
|
||||
$telegram->SendErrorMessage($errorMessage, 'ProcessOrderPaymentJob - Insufficient Credit');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class ProcessOrderPaymentJob implements ShouldQueue
|
||||
if (!$hasVMCreationAttempt) {
|
||||
$errorMessage = "Không có sản phẩm VPS nào được xử lý trong đơn hàng #{$this->order->order_num}";
|
||||
Log::error($errorMessage);
|
||||
$discord->SendErrorMessage($errorMessage, 'ProcessOrderPaymentJob - No VM Creation Attempt');
|
||||
$telegram->SendErrorMessage($errorMessage, 'ProcessOrderPaymentJob - No VM Creation Attempt');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class ProcessOrderPaymentJob implements ShouldQueue
|
||||
if (empty($vmCreationResults)) {
|
||||
$errorMessage = "Không có kết quả tạo VM nào được trả về cho đơn hàng #{$this->order->order_num}";
|
||||
Log::error($errorMessage);
|
||||
$discord->SendErrorMessage($errorMessage, 'ProcessOrderPaymentJob - Empty VM Results');
|
||||
$telegram->SendErrorMessage($errorMessage, 'ProcessOrderPaymentJob - Empty VM Results');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -129,8 +129,8 @@ class ProcessOrderPaymentJob implements ShouldQueue
|
||||
$invoiceService->markAsPaid($invoice);
|
||||
$this->order->update(['status' => OrderStatus::ACTIVE->value]);
|
||||
|
||||
// Gửi thông báo Discord
|
||||
$discord->SendOrderPaidNotification($invoice);
|
||||
// Gửi thông báo Telegram
|
||||
$telegram->SendOrderPaidNotification($invoice);
|
||||
|
||||
DB::commit();
|
||||
|
||||
@@ -156,7 +156,7 @@ class ProcessOrderPaymentJob implements ShouldQueue
|
||||
// Kiểm tra trường hợp đặc biệt: có VPS nhưng không có VM nào thành công
|
||||
if (count($vmCreationResults) > 0 && count($successfulVMs) === 0) {
|
||||
Log::error("Có sản phẩm VPS nhưng không có VM nào được tạo thành công", $errorDetails);
|
||||
$discord->SendErrorMessage(array_merge($errorDetails, [
|
||||
$telegram->SendErrorMessage(array_merge($errorDetails, [
|
||||
'error' => 'Tất cả VM đều thất bại - không có VM nào thành công'
|
||||
]), 'ProcessOrderPaymentJob - All VMs Failed');
|
||||
}
|
||||
@@ -172,7 +172,7 @@ class ProcessOrderPaymentJob implements ShouldQueue
|
||||
// Đã thử hết số lần, gửi thông báo lỗi
|
||||
Log::error("Đã thử tạo VM {$this->retryCount} lần nhưng vẫn thất bại", $errorDetails);
|
||||
|
||||
$discord->SendErrorMessage(array_merge($errorDetails, [
|
||||
$telegram->SendErrorMessage(array_merge($errorDetails, [
|
||||
'error' => 'Không thể tạo VM sau nhiều lần thử',
|
||||
'retry_count' => $this->retryCount
|
||||
]), 'ProcessOrderPaymentJob - VM Creation Failed After Retries');
|
||||
@@ -189,7 +189,7 @@ class ProcessOrderPaymentJob implements ShouldQueue
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
|
||||
$discord->SendErrorMessage([
|
||||
$telegram->SendErrorMessage([
|
||||
'error' => $e->getMessage(),
|
||||
'order_id' => $this->order->id,
|
||||
'order_num' => $this->order->order_num,
|
||||
@@ -206,11 +206,10 @@ class ProcessOrderPaymentJob implements ShouldQueue
|
||||
{
|
||||
try {
|
||||
$vCenter = app(\App\Http\Services\vCenter::class);
|
||||
$discord = app(Discord::class);
|
||||
$vmDataService = app(VMDataService::class);
|
||||
$telegram = app(\App\Http\Services\Telegram::class);
|
||||
|
||||
$vmJob = new CreateVirtualMachineJob($item, $this->retryCount > 0);
|
||||
return $vmJob->handle($vCenter, $discord, $vmDataService);
|
||||
return $vmJob->handle($vCenter, $telegram);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
Log::error("Lỗi khi tạo VM cho order item #{$item->id}: " . $e->getMessage(), [
|
||||
|
||||
Reference in New Issue
Block a user