This commit is contained in:
baodev0
2026-10-08 11:25:28 +07:00
parent 1544629a1f
commit 8651dde6b1
45 changed files with 1543 additions and 357 deletions
+5 -4
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Mail\Admin;
use App\Mail\TemplateMailable;
use App\Support\EmailTemplateShell;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
@@ -26,11 +27,11 @@ class AdminOrderNotification extends TemplateMailable
protected function variables(): array
{
$vmFields = ['ip' => '🌐 IP Address', 'username' => '👤 Username', 'password' => '🔑 Password'];
$vmFields = ['ip' => 'IP Address', 'username' => 'Username', 'password' => 'Password'];
$vmRows = '';
foreach ($vmFields as $field => $label) {
if (!empty($this->data[$field])) {
$vmRows .= '<div class="vm-row"><span class="vm-label">' . $label . '</span><span class="vm-value">' . e($this->data[$field]) . '</span></div>';
$vmRows .= EmailTemplateShell::row($label, e($this->data[$field]));
}
}
@@ -40,14 +41,14 @@ class AdminOrderNotification extends TemplateMailable
'customer_name' => $this->data['customer_name'] ?? 'N/A',
'customer_email' => $this->data['customer_email'] ?? 'N/A',
'client_ip_row' => !empty($this->data['client_ip'])
? '<tr><td>IP đặt hàng</td><td>' . e($this->data['client_ip']) . '</td></tr>'
? EmailTemplateShell::row('IP đặt hàng', e($this->data['client_ip']))
: '',
'product_name' => $this->data['product_name'] ?? 'N/A',
'product_type' => $this->data['product_type'] ?? 'N/A',
'billing_cycle' => $this->data['billing_cycle'] ?? 'N/A',
'total_formatted' => number_format((float) ($this->data['total'] ?? 0), 0, ',', '.') . ' VNĐ',
'vm_block' => $vmRows
? '<div class="section-label">Thông tin dịch vụ Cloud VPS</div><div class="vm-box">' . $vmRows . '</div>'
? EmailTemplateShell::heading('Thông tin dịch vụ Cloud VPS') . EmailTemplateShell::infoTable([], $vmRows)
: '',
'company_name' => $this->data['company_name'] ?? 'Portal Admin',
];
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Mail\Admin;
use App\Mail\TemplateMailable;
use App\Support\EmailTemplateShell;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
@@ -27,7 +28,7 @@ class HostingAccountCreatedAdminNotification extends TemplateMailable
protected function variables(): array
{
$row = fn (string $label, ?string $value) => $value
? '<div class="cred-row"><span class="cred-label">' . $label . '</span><span class="cred-value">' . e($value) . '</span></div>'
? EmailTemplateShell::row($label, e($value))
: '';
return [
@@ -41,10 +42,10 @@ class HostingAccountCreatedAdminNotification extends TemplateMailable
'plesk_client_id' => $this->data['plesk_client_id'] ?? 'N/A',
'plesk_subscription_id' => $this->data['plesk_subscription_id'] ?? 'N/A',
'ftp_username' => $this->data['ftp_username'] ?? 'N/A',
'ftp_password_row' => $row('🔑 FTP Password', $this->data['ftp_password'] ?? null),
'ftp_password_row' => $row('FTP Password', $this->data['ftp_password'] ?? null),
'plesk_panel_url' => $this->data['plesk_panel_url'] ?? 'N/A',
'plesk_login' => $this->data['plesk_login'] ?? 'N/A',
'plesk_password_row' => $row('🔑 Password', $this->data['plesk_password'] ?? null),
'plesk_password_row' => $row('Plesk Password', $this->data['plesk_password'] ?? null),
'company_name' => $this->data['company_name'] ?? 'Portal Admin',
];
}
@@ -3,6 +3,7 @@
namespace App\Mail\Admin;
use App\Mail\TemplateMailable;
use App\Support\EmailTemplateShell;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
@@ -30,14 +31,14 @@ class ManualDepositPendingNotification extends TemplateMailable
'customer_name' => $this->data['customer_name'] ?? 'N/A',
'customer_email' => $this->data['customer_email'] ?? 'N/A',
'customer_phone_row' => !empty($this->data['customer_phone'])
? '<tr><td>Số điện thoại</td><td>' . e($this->data['customer_phone']) . '</td></tr>'
? EmailTemplateShell::row('Số điện thoại', e($this->data['customer_phone']))
: '',
'client_ip_row' => !empty($this->data['client_ip'])
? '<tr><td>IP gửi yêu cầu</td><td>' . e($this->data['client_ip']) . '</td></tr>'
? EmailTemplateShell::row('IP gửi yêu cầu', e($this->data['client_ip']))
: '',
'amount_formatted' => number_format((float) ($this->data['amount'] ?? 0), 0, ',', '.') . ' VNĐ',
'proof_row' => !empty($this->data['proof_image_url'])
? '<tr><td>Chứng từ</td><td><a href="' . e($this->data['proof_image_url']) . '">Xem chứng từ chuyển khoản</a></td></tr>'
? EmailTemplateShell::row('Chứng từ', '<a style="color: #f16723;" href="' . e($this->data['proof_image_url']) . '" target="_blank" rel="noopener">Xem chứng từ chuyển khoản</a>')
: '',
'company_name' => $this->data['company_name'] ?? 'Portal Admin',
];
+2 -1
View File
@@ -3,6 +3,7 @@
namespace App\Mail\Admin;
use App\Mail\TemplateMailable;
use App\Support\EmailTemplateShell;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
@@ -33,7 +34,7 @@ class TrialRegistrationRequest extends TemplateMailable
'ssd' => $this->data['ssd'] ?? '-',
'os' => $this->data['os'] ?? '-',
'other_row' => !empty($this->data['other'])
? '<tr><td>Yêu cầu khác</td><td>' . e($this->data['other']) . '</td></tr>'
? EmailTemplateShell::row('Yêu cầu khác', e($this->data['other']))
: '',
'company_name' => $this->data['company_name'] ?? 'Portal Admin',
'created_at' => $this->data['created_at'] ?? now()->format('d/m/Y H:i:s'),
+11 -10
View File
@@ -3,6 +3,7 @@
namespace App\Mail\Customer;
use App\Mail\TemplateMailable;
use App\Support\EmailTemplateShell;
use App\Support\MailGlobals;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
@@ -28,17 +29,17 @@ class HostingAccountCreated extends TemplateMailable
$data = [...MailGlobals::values(), ...$this->data];
$row = fn (string $label, ?string $value) => $value
? "<tr><td style=\"padding: 7px 11px; border-right: 1px solid #e8e8e8;\">{$label}</td><td style=\"padding: 7px 11px; border-right: 1px solid #e8e8e8;\"><strong>{$value}</strong></td></tr>"
? EmailTemplateShell::row($label, e($value))
: '';
$pleskBlock = '';
if (!empty($data['plesk_login'])) {
$pleskBlock = '<p style="color: #f16723;"><strong>TÀI KHOẢN ĐĂNG NHẬP PLESK PANEL</strong></p>'
. '<table cellpadding="0" cellspacing="0" border="0" style="width: 100%; table-layout: fixed; border: 1px solid #e8e8e8; border-right: 0;"><tbody>'
. '<tr><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8; width: 200px;">Địa chỉ Panel:</td><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;"><a style="color: #f16723; text-decoration: none;" href="' . ($data['plesk_panel_url'] ?? '') . '" target="_blank" rel="noopener">' . ($data['plesk_panel_url'] ?? '') . '</a></td></tr>'
. '<tr bgcolor="#FFF1E6"><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;">Tên đăng nhập:</td><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;"><strong>' . ($data['plesk_login'] ?? '') . '</strong></td></tr>'
. (!empty($data['plesk_password']) ? '<tr><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;">Mật khẩu:</td><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;"><strong>' . $data['plesk_password'] . '</strong></td></tr>' : '')
. '</tbody></table>';
$pleskBlock = EmailTemplateShell::paragraph('<strong style="color: #f16723;">TÀI KHOẢN ĐĂNG NHẬP PLESK PANEL</strong>')
. EmailTemplateShell::infoTable(array_filter([
'Địa chỉ Panel' => '<a style="color: #f16723; text-decoration: none;" href="' . e($data['plesk_panel_url'] ?? '') . '" target="_blank" rel="noopener">' . e($data['plesk_panel_url'] ?? '') . '</a>',
'Tên đăng nhập' => e($data['plesk_login']),
'Mật khẩu' => !empty($data['plesk_password']) ? e($data['plesk_password']) : null,
]));
}
return [
@@ -46,9 +47,9 @@ class HostingAccountCreated extends TemplateMailable
'full_name' => $data['customer_name'] ?? 'Quý khách',
'domain_name' => $data['domain_name'] ?? '',
'hosting_plan' => $data['hosting_plan'] ?? '',
'server_host_row' => $row('Máy chủ / FTP Host:', $data['server_host'] ?? null),
'ftp_username_row' => $row('Tài khoản FTP:', $data['ftp_username'] ?? null),
'ftp_password_row' => $row('Mật khẩu FTP:', $data['ftp_password'] ?? null),
'server_host_row' => $row('Máy chủ / FTP Host', $data['server_host'] ?? null),
'ftp_username_row' => $row('Tài khoản FTP', $data['ftp_username'] ?? null),
'ftp_password_row' => $row('Mật khẩu FTP', $data['ftp_password'] ?? null),
'ftp_password_notice' => !empty($data['ftp_password'])
? '<p style="text-align: justify; color: #b45309; font-size: 13px;">Lưu ý: Vì lý do bảo mật, mật khẩu FTP chỉ được gửi một lần duy nhất qua email và không được lưu trữ trên hệ thống. Vui lòng lưu lại ở nơi an toàn.</p>'
: '',
+2 -1
View File
@@ -3,6 +3,7 @@
namespace App\Mail\Customer;
use App\Mail\TemplateMailable;
use App\Support\EmailTemplateShell;
use App\Support\MailGlobals;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
@@ -38,7 +39,7 @@ class ManualDepositStatus extends TemplateMailable
'status_message' => $data['status_message'] ?? ($data['message'] ?? ''),
'deposit_date' => $data['deposit_date'] ?? now()->format('d/m/Y H:i:s'),
'processed_date_row' => !empty($data['processed_date'])
? '<tr><td style="padding:12px 16px;background-color:#fafafa;color:#78909c;width:42%">Thời gian xử lý</td><td style="padding:12px 16px;color:#263238">' . $data['processed_date'] . '</td></tr>'
? EmailTemplateShell::row('Thời gian xử lý', e($data['processed_date']))
: '',
'portal_url' => $data['portal_url'] ?? MailGlobals::frontendUrl() . '/nap-tien',
];
+7 -6
View File
@@ -3,6 +3,7 @@
namespace App\Mail\Customer;
use App\Mail\TemplateMailable;
use App\Support\EmailTemplateShell;
use App\Support\MailGlobals;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Attachment;
@@ -44,21 +45,21 @@ class VmCredentials extends TemplateMailable
$data = [...MailGlobals::values(), ...$this->data];
$row = fn (string $label, ?string $value) => $value
? "<tr bgcolor=\"#FFF1E6\"><td style=\"padding: 7px 11px; border-right: 1px solid #e8e8e8; width: 200px;\">{$label}</td><td style=\"padding: 7px 11px; border-right: 1px solid #e8e8e8;\"><strong>{$value}</strong></td></tr>"
? EmailTemplateShell::row($label, e($value))
: '';
return [
'app_name' => $data['company_name'] ?? config('app.name', 'The Gioi So'),
'full_name' => $data['client_name'] ?? 'Quý khách',
'product_name' => $data['product_name'] ?? 'Cloud VPS',
'product_billing_row' => $row('Chu kỳ thanh toán:', $data['product_billing'] ?? null),
'product_price_row' => $row('Giá dịch vụ:', !empty($data['product_price']) ? $data['product_price'] . ' VNĐ' : null),
'os_name_row' => $row('Hệ điều hành:', $data['os_name'] ?? null),
'product_billing_row' => $row('Chu kỳ thanh toán', $data['product_billing'] ?? null),
'product_price_row' => $row('Giá dịch vụ', !empty($data['product_price']) ? $data['product_price'] . ' VNĐ' : null),
'os_name_row' => $row('Hệ điều hành', $data['os_name'] ?? null),
'service_host' => $data['service_host'] ?? '',
'service_username' => $data['service_username'] ?? '',
'service_password' => $data['service_password'] ?? '',
'service_port_row' => $row('Cổng kết nối:', $data['service_port'] ?? null),
'service_due_exp_row' => $row('Hạn sử dụng:', $data['service_due_exp'] ?? null),
'service_port_row' => $row('Cổng kết nối', $data['service_port'] ?? null),
'service_due_exp_row' => $row('Hạn sử dụng', $data['service_due_exp'] ?? null),
];
}
}
+2 -1
View File
@@ -3,6 +3,7 @@
namespace App\Mail\Customer;
use App\Mail\TemplateMailable;
use App\Support\EmailTemplateShell;
use App\Support\MailGlobals;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
@@ -33,7 +34,7 @@ class VmPasswordChanged extends TemplateMailable
'full_name' => $data['fullname'] ?? 'Quý khách',
'vm_name' => $data['vm_name'] ?? '',
'new_password_row' => $newPassword
? '<div>Mật khẩu mới: <strong style="font-family: \'Menlo\',\'Consolas\',monospace; color: #111827;">' . $newPassword . '</strong></div>'
? EmailTemplateShell::row('Mật khẩu mới', '<span style="font-family: Menlo,Consolas,monospace; color: #111827;">' . e($newPassword) . '</span>')
: '',
];
}
+7
View File
@@ -3,6 +3,7 @@
namespace App\Mail;
use App\Mail\Concerns\BuildsTemplateEnvelope;
use App\Support\AutoEmailGate;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
@@ -22,6 +23,7 @@ class GenericTemplateMail extends Mailable
public readonly string $renderedSubject,
public readonly string $renderedHtml,
public readonly array $mailConfig = [],
public readonly ?string $scenario = null,
) {}
public function envelope(): Envelope
@@ -33,4 +35,9 @@ class GenericTemplateMail extends Mailable
{
return new Content(htmlString: $this->renderedHtml);
}
public function buildViewData()
{
return [...parent::buildViewData(), AutoEmailGate::SCENARIO_DATA_KEY => $this->scenario];
}
}
+3 -4
View File
@@ -5,6 +5,7 @@ namespace App\Mail;
use App\Enums\Invoice\InvoiceStatus;
use App\Models\Invoice;
use App\Services\InvoicePaymentService;
use App\Support\EmailTemplateShell;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Mail\Mailables\Attachment;
@@ -113,10 +114,8 @@ class InvoiceNotificationMail extends TemplateMailable
return '';
}
return '<tr><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;">Đã thanh toán:</td><td style="padding: 7px 11px;"><strong style="color: #059669;">'
. number_format($paid, 0, ',', '.') . ' VNĐ</strong></td></tr>'
. '<tr bgcolor="#FFF1E6"><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;">Còn thiếu:</td><td style="padding: 7px 11px;"><strong style="color: #dc2626;">'
. number_format($outstanding, 0, ',', '.') . ' VNĐ</strong></td></tr>';
return EmailTemplateShell::row('Đã thanh toán', '<span style="color: #059669;">' . number_format($paid, 0, ',', '.') . ' VNĐ</span>')
. EmailTemplateShell::row('Còn thiếu', '<span style="color: #dc2626;">' . number_format($outstanding, 0, ',', '.') . ' VNĐ</span>');
}
private function payButton(): string
+2 -1
View File
@@ -4,6 +4,7 @@ namespace App\Mail;
use App\Models\Customer;
use App\Models\Service;
use App\Support\EmailTemplateShell;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
@@ -36,7 +37,7 @@ class ServiceRenewalReminderMail extends TemplateMailable
? \Carbon\Carbon::parse($this->service->expires_at)->format('d/m/Y')
: 'N/A',
'price_row' => $price
? '<tr><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;">Số tiền gia hạn:</td><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;"><strong>' . $price . ' VNĐ</strong></td></tr>'
? EmailTemplateShell::row('Số tiền gia hạn', $price . ' VNĐ')
: '',
'login_url' => rtrim(config('app.frontend_url', ''), '/') . '/dang-nhap',
'support_email' => 'support@tgs.com.vn',
+6
View File
@@ -6,6 +6,7 @@ use App\Mail\Concerns\BuildsTemplateEnvelope;
use App\Models\Template;
use App\Services\Email\EmailTemplateRenderer;
use App\Services\Email\EmailTemplateService;
use App\Support\AutoEmailGate;
use App\Support\MailGlobals;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
@@ -34,6 +35,11 @@ abstract class TemplateMailable extends Mailable
return new Content(htmlString: $this->rendered()['html']);
}
public function buildViewData()
{
return [...parent::buildViewData(), AutoEmailGate::SCENARIO_DATA_KEY => $this->scenario()];
}
/**
* @return array{subject: string, html: string}
*/
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Mail;
use App\Support\EmailTemplateShell;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\SerializesModels;
@@ -34,7 +35,7 @@ class TicketCreated extends TemplateMailable implements ShouldQueue
'ticket_num' => $this->ticket->ticket_num,
'subject' => $this->ticket->subject,
'room_row' => $room
? '<tr><td style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #666666; padding: 4px 0;" valign="top">Phòng ban:</td><td style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #000000; padding: 4px 0;" valign="top">' . $room . '</td></tr>'
? EmailTemplateShell::row('Phòng ban', e($room))
: '',
'ticket_url' => rtrim(config('app.frontend_url', ''), '/') . '/tickets/' . $this->ticket->ticket_num,
'app_name' => config('app.name', 'Thế Giới Số'),