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,6 +4,8 @@ namespace App\Jobs\Mail;
|
||||
|
||||
use App\Http\Services\Telegram;
|
||||
use App\Mail\CreateVirtualMachine;
|
||||
use App\Models\Invoice;
|
||||
use App\Services\InvoicePdfService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -19,50 +21,71 @@ class SendInformationVirtualMachine implements ShouldQueue
|
||||
|
||||
public $data = [];
|
||||
public $customer;
|
||||
public ?int $invoiceId;
|
||||
|
||||
protected ?string $invoicePdf;
|
||||
protected ?string $invoicePdfFileName;
|
||||
|
||||
public function __construct($data = [], $customer = [], ?string $invoicePdf = null, ?string $invoicePdfFileName = null)
|
||||
public function __construct($data = [], $customer = [], ?int $invoiceId = null)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->customer = $customer;
|
||||
$this->invoicePdf = $invoicePdf;
|
||||
$this->invoicePdfFileName = $invoicePdfFileName;
|
||||
$this->data = $data;
|
||||
$this->customer = $customer;
|
||||
$this->invoiceId = $invoiceId;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
try {
|
||||
// Generate PDF inside the job — never pass binary blobs through queue payload
|
||||
$invoicePdf = null;
|
||||
$invoicePdfFileName = null;
|
||||
|
||||
$email = new CreateVirtualMachine(2, $this->data, $this->invoicePdf, $this->invoicePdfFileName);
|
||||
if ($this->invoiceId) {
|
||||
try {
|
||||
$invoice = Invoice::with(['invoiceItems.product', 'customer', 'order.orderItems'])
|
||||
->find($this->invoiceId);
|
||||
|
||||
if ($invoice) {
|
||||
$pdfService = app(InvoicePdfService::class);
|
||||
$invoicePdf = $pdfService->generate($invoice);
|
||||
$invoicePdfFileName = $pdfService->generateFileName($invoice);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('SendInformationVirtualMachine: PDF generation failed, sending without attachment', [
|
||||
'invoice_id' => $this->invoiceId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$email = new CreateVirtualMachine(2, $this->data, $invoicePdf, $invoicePdfFileName);
|
||||
|
||||
Mail::to($this->customer->email)->send($email);
|
||||
|
||||
\App\Models\Mail::create([
|
||||
'template_id' => 2,
|
||||
'subject' => $email->envelope()->subject,
|
||||
'to' => $this->customer->email,
|
||||
'subject' => $email->envelope()->subject,
|
||||
'to' => $this->customer->email,
|
||||
'customer_id' => $this->customer->id,
|
||||
'message' => $email->render()
|
||||
'message' => $email->render(),
|
||||
]);
|
||||
|
||||
} catch (\Exception $exception)
|
||||
{
|
||||
throw new \Exception( $exception->getMessage());
|
||||
} catch (\Throwable $exception) {
|
||||
throw new \Exception($exception->getMessage(), 0, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
public function failed(\Throwable $exception, Telegram $telegram)
|
||||
public function failed(\Throwable $exception): void
|
||||
{
|
||||
Log::channel('Custom')->error("SendInformationVirtualMachine failed at " . Carbon::now() . ": " . $exception->getMessage());
|
||||
|
||||
Log::channel('Custom')->info("=================================");
|
||||
Log::channel('Custom')->info("Thông báo lỗi lúc: " .Carbon::now());
|
||||
Log::channel('Custom')->info("Notification Send Information VirtualMachine: ");
|
||||
Log::channel('Custom')->info("========");
|
||||
Log::channel('Custom')->info($exception->getMessage());
|
||||
Log::channel('Custom')->info("=================================");
|
||||
|
||||
$telegram->SendErrorMessage(json_decode($exception->getMessage()));
|
||||
try {
|
||||
app(Telegram::class)->SendErrorMessage([
|
||||
'job' => 'SendInformationVirtualMachine',
|
||||
'email' => $this->customer->email ?? 'unknown',
|
||||
'error' => $exception->getMessage(),
|
||||
'file' => $exception->getFile(),
|
||||
'line' => $exception->getLine(),
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('SendInformationVirtualMachine: could not send Telegram notification: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user