settingService = $settingService; } public function convert(string $url, ?string $code = null): AffiliateResult { $startTime = microtime(true); $affiliateId = $this->settingService->get('affiliate_id'); if (!$affiliateId) { return new AffiliateResult( isSuccess: false, originalUrl: $url, errorMessage: 'Vui lòng thiết lập Affiliate ID trong phần Settings để sử dụng chuyển đổi thủ công.', executionTime: microtime(true) - $startTime, converterType: 'manual' ); } // URL encode the original URL $encodedLink = urlencode($url); // Construct the standard manual Shopee redirect URL $affiliateUrl = "https://s.shopee.vn/an_redir?origin_link={$encodedLink}&affiliate_id={$affiliateId}"; if ($code) { $affiliateUrl .= "&sub_id={$code}"; } return new AffiliateResult( isSuccess: true, originalUrl: $url, affiliateUrl: $affiliateUrl, executionTime: microtime(true) - $startTime, sessionUsed: 'manual_id_' . $affiliateId, converterType: 'manual' ); } }