whereRaw('LOWER(domain_name) = ?', [mb_strtolower($name)])->exists(); $status = $liveInDns ? 1 : 2; if (! $liveInDns) { $notes[] = 'Không tìm thấy domain này trong DNS manager (dns_manager_domain).'; } if ($row['registrar'] && ! $this->registrars->resolve($row['registrar'])) { $notes[] = "Registrar WHMCS chưa map: {$row['registrar']}"; } if ($row['additionalnotes']) { $notes[] = $row['additionalnotes']; } return new CustomerDomainData( legacyId: (int) $row['id'], customerId: $this->customers->resolveDomainOwner($name, (int) $row['userid']), orderId: $this->orders->resolve((int) $row['orderid']) ?? 0, name: $name, firstPayment: (int) round((float) $row['firstpaymentamount']), nextPayment: (int) round((float) $row['recurringamount']), nextDueDate: $this->toTimestamp($row['nextduedate'] ?? null), nextInvoiceDate: $this->toTimestamp($row['nextinvoicedate'] ?? null), registrarId: $row['registrar'] ? $this->registrars->resolve($row['registrar']) : null, status: $status, note: implode(' | ', $notes), ); } private function toTimestamp(?string $date): ?int { if (! $date || str_starts_with($date, '0000-00-00')) { return null; } return strtotime($date) ?: null; } }