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
@@ -15,7 +15,9 @@ use App\Models\OrderItem;
|
||||
use App\Models\Service;
|
||||
use App\Models\ServiceAddon;
|
||||
use App\Services\ActivityLogger;
|
||||
use App\Services\CustomerRenewalNotifier;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -94,13 +96,30 @@ trait ActivatesPaidInvoices
|
||||
: now();
|
||||
$expiresAt = Carbon::parse($baseDate)->addMonths($months);
|
||||
$previousExpiresAt = $service->expires_at;
|
||||
$previousStatus = $service->status;
|
||||
$wasCancelled = $previousStatus === 'cancelled';
|
||||
$wasScheduledCancel = (bool) $service->cancel_at_expiry;
|
||||
|
||||
$service->update([
|
||||
'status' => 'active',
|
||||
'expires_at' => $expiresAt,
|
||||
'suspended_at' => null,
|
||||
'cancel_at_expiry' => false,
|
||||
'cancelled_at' => null,
|
||||
]);
|
||||
|
||||
if ($wasCancelled || $wasScheduledCancel) {
|
||||
app(ActivityLogger::class)->log(
|
||||
event: 'cancellation_revoked',
|
||||
logName: 'Service',
|
||||
description: "Dịch vụ #{$service->id} được gia hạn nên huỷ bỏ việc hủy dịch vụ"
|
||||
.($wasCancelled ? ' (đã hủy → hoạt động lại)' : ' (hủy cuối kỳ)'),
|
||||
subject: $service,
|
||||
oldValues: ['status' => $previousStatus, 'cancel_at_expiry' => $wasScheduledCancel],
|
||||
newValues: ['status' => 'active', 'cancel_at_expiry' => false, 'invoice_number' => $invoice->invoice_number],
|
||||
);
|
||||
}
|
||||
|
||||
app(ActivityLogger::class)->log(
|
||||
event: 'renewed',
|
||||
logName: 'Service',
|
||||
@@ -119,6 +138,21 @@ trait ActivatesPaidInvoices
|
||||
if ($service->vm_id) {
|
||||
dispatch(new VMJobs((int) $service->vm_id, 'Start', false))->delay(now()->addSeconds(5));
|
||||
}
|
||||
|
||||
$this->notifyAdminsOfRenewal($service, $invoice, $months, $previousExpiresAt);
|
||||
}
|
||||
|
||||
private function notifyAdminsOfRenewal(Service $service, Invoice $invoice, int $months, ?CarbonInterface $previousExpiresAt): void
|
||||
{
|
||||
if (auth()->guard('admin')->check()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$source = auth()->guard('client')->check()
|
||||
? CustomerRenewalNotifier::SOURCE_CUSTOMER
|
||||
: CustomerRenewalNotifier::SOURCE_SYSTEM;
|
||||
|
||||
DB::afterCommit(fn () => app(CustomerRenewalNotifier::class)->notify($service->fresh(), $invoice, $months, $previousExpiresAt, $source));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user