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
@@ -69,4 +69,28 @@ class CustomerDomainServiceSyncTest extends TestCase
'user_id' => $customer->id,
]);
}
public function test_apply_term_sets_dates_and_cycle_for_domain_services(): void
{
$customer = Customer::factory()->create();
$serverId = DB::table('dns_manager_servers')->insertGetId(['ip_address' => '10.0.0.1', 'password' => 'x']);
$domain = DnsDomain::create([
'domain_name' => 'devro-tech.com',
'dns_manager_server_id' => $serverId,
'is_created' => DnsDomain::STATUS_CREATED,
]);
Product::factory()->create(['product_type' => 'domain', 'is_active' => true]);
$sync = app(CustomerDomainServiceSync::class);
$sync->syncCustomers($domain, [$customer->id]);
$updated = $sync->applyTerm($domain, '2025-06-17', '2027-06-17', 2);
$service = Service::where('customer_id', $customer->id)->where('type', 'domain')->firstOrFail();
$this->assertSame(1, $updated);
$this->assertSame('2025-06-17', $service->started_at->toDateString());
$this->assertSame('2027-06-17', $service->expires_at->toDateString());
$this->assertSame(24, (int) $service->orderItem->months);
$this->assertSame('biennially', $service->orderItem->billing_cycle);
$this->assertSame(0, $sync->applyTerm(DnsDomain::create(['domain_name' => 'solo.vn', 'dns_manager_server_id' => $serverId]), null, null, 1));
}
}