feat(service): huỷ dịch vụ, SSL, đổi mật khẩu hosting, lịch sử thanh toán theo hình thức
- Lịch sử thanh toán hoá đơn trả thêm `method` (tự động gia hạn / số dư / admin / chuyển khoản / hoàn tiền), bỏ đuôi `(method)` khỏi ghi chú - `DnsServer::panelUrl()` = https://<domain>/ dùng cho email cấp hosting và nút Plesk của khách - Order item trả thêm `uuid`/`type` của dịch vụ để FE dẫn tới trang quản lý - Yêu cầu huỷ dịch vụ, chứng chỉ SSL, lịch sử gia hạn, đổi mật khẩu hosting cho khách Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
a6b641015e
commit
b44a88bb52
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Mail\Admin\ServiceCancellationRequestMail;
|
||||
use App\Models\Notification;
|
||||
use App\Models\ServiceCancellationRequest;
|
||||
use App\Models\Setting;
|
||||
use App\Support\AutoEmailGate;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class ServiceCancellationNotifier
|
||||
{
|
||||
public function notify(ServiceCancellationRequest $request, ?string $clientIp): void
|
||||
{
|
||||
$request->loadMissing(['service.product', 'customer']);
|
||||
$service = $request->service;
|
||||
$customer = $request->customer;
|
||||
$serviceName = $service->server_name ?: ($service->product?->name ?? 'Dịch vụ');
|
||||
|
||||
Notification::notifyAdmins([
|
||||
'type' => 'service_cancellation_request',
|
||||
'title' => 'Khách hàng yêu cầu hủy dịch vụ',
|
||||
'body' => "{$customer->fullname} yêu cầu hủy dịch vụ {$serviceName}. Lý do: {$request->reason}",
|
||||
'link' => '/services/' . $service->id,
|
||||
'data' => ['service_id' => $service->id, 'request_id' => $request->id],
|
||||
]);
|
||||
|
||||
$adminEmail = json_decode((string) Setting::where('key', 'setting')->value('value'), true)['admin_email'] ?? null;
|
||||
if (! $adminEmail || ! AutoEmailGate::allows('admin_service_cancellation_request')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Mail::to($adminEmail)->queue(new ServiceCancellationRequestMail([
|
||||
'customer_name' => (string) $customer->fullname,
|
||||
'customer_email' => (string) $customer->email,
|
||||
'product_name' => (string) ($service->product?->name ?? 'Dịch vụ'),
|
||||
'server_name' => (string) $service->server_name,
|
||||
'expires_at' => $service->expires_at?->format('d/m/Y') ?? 'N/A',
|
||||
'cancel_reason' => $request->reason,
|
||||
'client_ip' => (string) $clientIp,
|
||||
'created_at' => $request->created_at->format('d/m/Y H:i:s'),
|
||||
'admin_url' => rtrim(env('ADMIN_URL', config('app.url')), '/') . '/services/' . $service->id,
|
||||
]));
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Không gửi được email yêu cầu hủy dịch vụ', ['service_id' => $service->id, 'error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user