feat(domain): chỉnh ngày bắt đầu/hết hạn tên miền và điền hạn từ dữ liệu cũ

PUT administrator/domains/{id}/term, LegacyDomainTerms và migration backfill hạn cho dịch vụ domain chưa có expires_at.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-28 17:26:41 +07:00
co-authored by Claude Sonnet 5.5
parent e37106f2dc
commit 7136bec265
6 changed files with 171 additions and 2 deletions
@@ -93,9 +93,13 @@ class DomainController extends Controller
return response()->json(['error' => true, 'message' => "Không tìm thấy domain #$id"], 404);
}
$summary = DomainServiceSummary::forDomains(collect([$domain]));
return response()->json([
'error' => false,
'data' => $this->formatDomain($domain),
'data' => $this->formatDomain($domain) + [
'service' => $summary[DomainServiceSummary::key($domain->domain_name)] ?? null,
],
]);
}
@@ -194,6 +198,37 @@ class DomainController extends Controller
}
}
public function updateTerm(int $id, Request $request): JsonResponse
{
$domain = $this->domainRepository->find($id);
if (!$domain) {
return response()->json(['error' => true, 'message' => "Không tìm thấy domain #$id"], 404);
}
$data = $request->validate([
'registered_at' => 'nullable|date',
'expires_at' => 'nullable|date|after_or_equal:registered_at',
'cycle_years' => 'nullable|integer|min:1|max:10',
]);
$updated = $this->customerDomainServiceSync->applyTerm(
$domain,
$data['registered_at'] ?? null,
$data['expires_at'] ?? null,
$data['cycle_years'] ?? null,
);
if ($updated === 0) {
return response()->json([
'error' => true,
'message' => 'Tên miền chưa gắn khách hàng nên chưa có dịch vụ để lưu ngày đăng ký/hết hạn.',
], 422);
}
return $this->show($id);
}
public function provision(int $id): JsonResponse
{
$domain = $this->domainRepository->find($id);