src/App/Controller/RecurrentJobsSearchController.php line 96

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\DebuggingInfoBag;
  4. use App\Entity\ExternalPartner\IntegratedExternalPartnerCustomer;
  5. use App\Entity\RecurrentJob;
  6. use App\Entity\RecurrentJobsSearch\RecurrentJobsSearchParameters;
  7. use App\Entity\RecurrentJobsSearch\RecurrentJobsSearchResultset;
  8. use App\Entity\UsageEvent;
  9. use App\Entity\User;
  10. use App\Entity\WantedJob;
  11. use App\Exception\UncallableSearchPageException;
  12. use App\Exception\UnknownZipcodeException;
  13. use App\Form\RecurrentJobsSearchParametersType;
  14. use App\Service\ConversionEventService;
  15. use App\Service\DebuggingService;
  16. use App\Service\ExternalPartner\IntegratedExternalPartnerService;
  17. use App\Service\FeatureFlagService;
  18. use App\Service\FeatureLimitationsService;
  19. use App\Service\Membership\MembershipService;
  20. use App\Service\RecurrentJobsSearchService;
  21. use App\Service\RouterHelperService;
  22. use App\Service\SearchTracingService;
  23. use App\Service\SeoService;
  24. use App\Service\SessionService;
  25. use App\Service\UsageEventService;
  26. use App\Value\GeneralApplicationSettingsValue;
  27. use App\Value\ZipcodeRadiusesValue;
  28. use Doctrine\ORM\EntityManagerInterface;
  29. use Exception;
  30. use JanusHercules\DatawarehouseIntegration\Domain\Entity\ExternalPartnerEvent;
  31. use JanusHercules\DatawarehouseIntegration\Domain\Service\ExternalPartnerEventDomainService;
  32. use Liip\ImagineBundle\Imagine\Cache\CacheManager;
  33. use Monolog\Logger;
  34. use Psr\Log\LoggerInterface;
  35. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  36. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  37. use Symfony\Component\HttpFoundation\JsonResponse;
  38. use Symfony\Component\HttpFoundation\RedirectResponse;
  39. use Symfony\Component\HttpFoundation\Request;
  40. use Symfony\Component\HttpFoundation\Response;
  41. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  42. use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
  43. use Symfony\Component\HttpKernel\Exception\HttpException;
  44. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  45. use Symfony\Contracts\Translation\TranslatorInterface;
  46. use Throwable;
  47. use UnexpectedValueException;
  48. class RecurrentJobsSearchController extends AbstractController implements DoAdditionalUserChecksControllerInterface
  49. {
  50. use SearchControllerHelper;
  51. private FeatureFlagService $featureFlagService;
  52. public function __construct(FeatureFlagService $featureFlagService)
  53. {
  54. $this->featureFlagService = $featureFlagService;
  55. }
  56. /** @throws Exception */
  57. public function formAction(
  58. Request $request,
  59. TranslatorInterface $translator,
  60. SessionService $sessionService,
  61. SessionInterface $session,
  62. RecurrentJobsSearchService $recurrentJobsSearchService,
  63. ConversionEventService $conversionEventService,
  64. FeatureLimitationsService $featureLimitationsService,
  65. UsageEventService $usageEventService,
  66. MembershipService $membershipService
  67. ) {
  68. /** @var User|null $user */
  69. $user = $this->getUser();
  70. if ($user instanceof User && $user->isJobofferer()) {
  71. $this->addFlash(
  72. 'info',
  73. $translator->trans('recurrent_jobs_search.alert_jobofferers_not_allowed')
  74. );
  75. return $this->redirectToRoute('wanted_jobs_search.form');
  76. }
  77. $conversionEventService->initiateGoalReachedConversionTrackingBasedOnRequest(
  78. $request,
  79. $user
  80. );
  81. $formPrefillOccupationalFieldSearchterm = '';
  82. if ($request->get('occupationalFieldSearchterm')) {
  83. $formPrefillOccupationalFieldSearchterm = $request->get('occupationalFieldSearchterm');
  84. }
  85. $recurrentJobsSearchParameters = $recurrentJobsSearchService->prefillForm($user, $formPrefillOccupationalFieldSearchterm);
  86. $sessionService->resetProfileIdsForMultiMessageSelection($session);
  87. $premiumRadarPrice = $membershipService->getJobseekerPremiumRadarPrice();
  88. $showMembershipModal = false;
  89. if (!is_null($user) && $user->hasJobseekerProfile()) {
  90. if ($showMembershipModal = $featureLimitationsService->jobseekerMustSeeMembershipModalInSearchForm($user->getDefaultJobseekerProfile())) {
  91. $usageEventService->eventHasOccurredForUser($user, UsageEvent::EVENT_TYPE_USER_SAW_MEMBERSHIP_MODAL);
  92. }
  93. }
  94. $queryString = '';
  95. if ($showMembershipModal) {
  96. $stepLinkCreatedConversionEvent = $conversionEventService->createStepLinkCreatedConversionEvent(
  97. $user,
  98. ConversionEventService::CAMPAIGN_ID_JOBSEEKER_MEMBERSHIP,
  99. 0,
  100. null,
  101. $request,
  102. null,
  103. json_encode(['premiumRadarPrice' => $premiumRadarPrice])
  104. );
  105. $queryString = '?' . ConversionEventService::QUERY_STRING_PARAM_NAME . '=' . $stepLinkCreatedConversionEvent->getId();
  106. }
  107. $form = $this->createForm(
  108. RecurrentJobsSearchParametersType::class,
  109. $recurrentJobsSearchParameters,
  110. [
  111. 'action' => $this->generateUrl('janus_hercules.recurrent_jobs_search.results') . '#results',
  112. 'method' => 'GET'
  113. ]
  114. );
  115. $response = $this->render('/recurrent_jobs_search/form.html.twig', [
  116. 'form' => $form->createView(),
  117. 'waitingInfo' => $recurrentJobsSearchService->getWaitingInfo($user),
  118. 'showMembershipModal' => $showMembershipModal,
  119. 'premiumRadarPrice' => $premiumRadarPrice,
  120. 'queryString' => $queryString
  121. ]
  122. );
  123. $response->setVary('Cookie');
  124. $response->setSharedMaxAge(60);
  125. return $response;
  126. }
  127. public function profileSelectionForMultipleMessageAddApiAction(Request $request, SessionService $sessionService, SessionInterface $session)
  128. {
  129. if ($request->getMethod() === Request::METHOD_OPTIONS) {
  130. return new Response('', Response::HTTP_NO_CONTENT, ['Allow' => 'OPTIONS, POST']);
  131. }
  132. if (!is_null($request->get('joboffererProfileId'))) {
  133. $sessionService->addProfileIdForMultiMessageSelection($session, $request->get('joboffererProfileId'));
  134. }
  135. return new Response('', Response::HTTP_NO_CONTENT);
  136. }
  137. public function profileSelectionForMultipleMessageDeleteApiAction(Request $request, SessionService $sessionService, SessionInterface $session)
  138. {
  139. if ($request->getMethod() !== Request::METHOD_DELETE) {
  140. return new Response('', Response::HTTP_NO_CONTENT, ['Allow' => 'DELETE']);
  141. }
  142. if (!is_null($request->get('joboffererProfileId'))) {
  143. $sessionService->deleteProfileIdForMultiMessageSelection($session, $request->get('joboffererProfileId'));
  144. }
  145. return new Response('', Response::HTTP_NO_CONTENT);
  146. }
  147. public function profileSelectionForMultipleMessageGetApiAction(Request $request, SessionService $sessionService, SessionInterface $session)
  148. {
  149. if ($request->getMethod() === Request::METHOD_OPTIONS) {
  150. return new Response('', Response::HTTP_NO_CONTENT, ['Allow' => 'OPTIONS, POST']);
  151. }
  152. return new JsonResponse($sessionService->getProfileIdsForMultiMessageSelection($session));
  153. }
  154. public function resultsAction(
  155. Request $request
  156. ): RedirectResponse {
  157. $queryString = $request->getQueryString();
  158. if (!is_null($queryString)) {
  159. $queryString = '?' . $queryString;
  160. } else {
  161. $queryString = '';
  162. }
  163. return new RedirectResponse(
  164. $this->container->get('router')->generate(
  165. 'janus_hercules.recurrent_jobs_search.results',
  166. [],
  167. UrlGeneratorInterface::ABSOLUTE_URL) . $queryString,
  168. 301
  169. );
  170. }
  171. public function allJobsAction(Request $request, TranslatorInterface $translator, ConversionEventService $conversionEventService)
  172. {
  173. /** @var User $user */
  174. $user = $this->getUser();
  175. $boostExternalJobs = $request->query->get('boostExternalJobs') === '1' ? true : false;
  176. if (($user instanceof User && $user->isJobseeker()) || is_null($user) && $boostExternalJobs) {
  177. $queryParameter = $request->query->get('recurrent_jobs_search_parameters');
  178. $filterZipcode = array_key_exists('filterZipcode', $queryParameter)
  179. ? $queryParameter['filterZipcode']
  180. : $user->getDefaultJoboffererProfile()->getZipcode();
  181. $filterRequiredExperience = array_key_exists('filterRequiredExperience', $queryParameter)
  182. ? $queryParameter['filterRequiredExperience']
  183. : RecurrentJob::EXPERIENCE_NONE;
  184. $recurrentJobsSearchParameters = new RecurrentJobsSearchParameters(
  185. RecurrentJobsSearchService::SEARCHTERM_ALL_JOBS,
  186. $filterZipcode,
  187. ZipcodeRadiusesValue::JOBSEEKER_PROFILE_DEFAULT,
  188. $filterRequiredExperience,
  189. RecurrentJob::POSSIBLE_CAREER_LEVELS,
  190. false,
  191. RecurrentJob::POSSIBLE_EMPLOYMENT_TYPES,
  192. false,
  193. true
  194. );
  195. return $this->redirectToRoute(
  196. 'janus_hercules.recurrent_jobs_search.results',
  197. [
  198. 'recurrent_jobs_search_parameters' => $recurrentJobsSearchParameters->asArray(),
  199. 'filterAllJobs' => 1,
  200. 'boostExternalJobs' => $boostExternalJobs
  201. ]
  202. );
  203. } else {
  204. $this->addFlash('info', $translator->trans('alert_jobofferers_not_allowed'));
  205. return $this->redirectToRoute('recurrent_jobs_search.form');
  206. }
  207. }
  208. /**
  209. * @ParamConverter("wantedJob", class="App\Entity\WantedJob", options={"id" = "wantedJobId"}))
  210. */
  211. public function specificWantedJobAction(WantedJob $wantedJob, Request $request)
  212. {
  213. $recurrentJobsSearchParameters = RecurrentJobsSearchParameters::fromWantedJob($wantedJob);
  214. return $this->redirectToRoute(
  215. 'janus_hercules.recurrent_jobs_search.results',
  216. [
  217. 'recurrent_jobs_search_parameters' => $recurrentJobsSearchParameters->asArray(),
  218. ]
  219. );
  220. }
  221. public function landingpageAction(Request $request, string $slug, SeoService $seoService, LoggerInterface $logger)
  222. {
  223. try {
  224. $seoParameters = $seoService->getSeoParametersFromRecurrentJobSearchSlug($slug);
  225. $filterRequiredEmploymentTypes = strtolower($seoParameters['filterSearchterm']) === 'minijobs'
  226. ? ['recurrent_jobs.new_page.employment_types.help' => RecurrentJob::EMPLOYMENT_TYPE_HELP]
  227. : null;
  228. $filterRequiredEmploymentTypes = strtolower($seoParameters['filterSearchterm']) === 'teilzeitjobs'
  229. ? ['recurrent_jobs.new_page.employment_types.part_time' => RecurrentJob::EMPLOYMENT_TYPE_PART_TIME]
  230. : $filterRequiredEmploymentTypes;
  231. $searchParameters = $seoService->getRecurrentJobSeoSearchParameters(
  232. $seoParameters['filterSearchterm'],
  233. $seoParameters['zipcode'],
  234. null,
  235. $filterRequiredEmploymentTypes
  236. );
  237. } catch (UnexpectedValueException $e) {
  238. $logger->info("Can't resolve search parameters from seo slug '{$slug}': {$e->getMessage()}");
  239. return $this->render(
  240. '/errors/notfound.html.twig',
  241. [],
  242. new Response(null, Response::HTTP_NOT_FOUND)
  243. );
  244. }
  245. return $this->forward(
  246. \JanusHercules\RecurrentJobsSearch\Presentation\Controller\RecurrentJobsSearchController::class . '::resultsAction',
  247. [
  248. '_route' => $request->attributes->get('_route'),
  249. 'seoParameters' => $seoParameters,
  250. '_route_params' => $request->attributes->get('_route_params'),
  251. 'slug' => $slug
  252. ],
  253. $searchParameters
  254. );
  255. }
  256. public function getRecurrentJobIdsForAnonymousSearchRequestAction(Request $request, RecurrentJobsSearchService $recurrentJobsSearchService, SearchTracingService $tracingService, FeatureFlagService $featureFlagService, DebuggingService $debuggingService, LoggerInterface $logger)
  257. {
  258. try {
  259. if (!is_null($this->getUser())) {
  260. throw new AccessDeniedHttpException('Not applicable for registered users');
  261. }
  262. $searchParametersFromUri = base64_decode($request->get('recurrent_jobs_search_parameters'));
  263. $searchParametersArray = json_decode($searchParametersFromUri);
  264. $returnJson = [];
  265. $searchParams = new RecurrentJobsSearchParameters(
  266. $searchParametersArray->filterSearchterm,
  267. $searchParametersArray->filterZipcode,
  268. $searchParametersArray->filterZipcodeRadius,
  269. $searchParametersArray->filterRequiredExperience,
  270. [
  271. RecurrentJob::CAREER_LEVEL_TRAINEE,
  272. RecurrentJob::CAREER_LEVEL_ASSISTANT,
  273. RecurrentJob::CAREER_LEVEL_EXPERT,
  274. RecurrentJob::CAREER_LEVEL_EXECUTIVE
  275. ],
  276. false,
  277. [
  278. RecurrentJob::EMPLOYMENT_TYPE_ONCE,
  279. RecurrentJob::EMPLOYMENT_TYPE_HELP,
  280. RecurrentJob::EMPLOYMENT_TYPE_PART_TIME,
  281. RecurrentJob::EMPLOYMENT_TYPE_FULL_TIME
  282. ]
  283. );
  284. $showAnonymousResults = false;
  285. $maximumTotalNumberOfResults = $numberOfResultsPerPage = $recurrentJobsSearchService->getMaxNumberOfResults(
  286. false,
  287. GeneralApplicationSettingsValue::RECURRENT_JOBS_SEARCH_ANONYMOUS_MAX_NUMBER_OF_RESULTS_PER_PAGE
  288. );
  289. $tracing = $tracingService->createTracing($recurrentJobsSearchService);
  290. $fullResultset = new RecurrentJobsSearchResultset($searchParams, $tracing);
  291. try {
  292. $fullResultset = $recurrentJobsSearchService->getResultset(
  293. $searchParams,
  294. $maximumTotalNumberOfResults,
  295. 0,
  296. $featureFlagService->isFeatureEnabledForUser($featureFlagService::FEATURE_EXTERNAL_PARTNERS, null),
  297. $showAnonymousResults,
  298. null
  299. );
  300. } catch (UnknownZipcodeException $e) {
  301. $debuggingInfoBag = new DebuggingInfoBag(
  302. 'unknown-zipcode-recurrent-jobs-search',
  303. 'Unknown zipcode ' . $searchParams->getFilterZipcode() . ' in recurrent jobs search', '',
  304. Logger::WARNING
  305. );
  306. $debuggingInfoBag->setRequest($request);
  307. $debuggingService->log($debuggingInfoBag);
  308. } catch (Exception $e) {
  309. throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, 'An exception occurred while getting real recurrent job ids for anonymous search.', $e);
  310. }
  311. $fullResultset->sliceResults(0, $maximumTotalNumberOfResults);
  312. try {
  313. $resultsetForCurrentPage = $fullResultset->getResultsetForPage($fullResultset, 1, $numberOfResultsPerPage);
  314. } catch (UncallableSearchPageException $e) {
  315. return new Response('', Response::HTTP_NO_CONTENT);
  316. }
  317. foreach ($resultsetForCurrentPage->getResults() as $result) {
  318. if ($result->containsRecurrentJob()) {
  319. $returnJson[] = $result->getRecurrentJob()->getId();
  320. }
  321. }
  322. } catch (Throwable $throwable) {
  323. $logger->warning($throwable->getMessage(), ['exception' => $throwable]);
  324. return new Response('', Response::HTTP_NO_CONTENT);
  325. }
  326. return new Response(json_encode($returnJson), Response::HTTP_OK);
  327. }
  328. public function getSimilarJobsApiAction(Request $request, RecurrentJobsSearchService $recurrentJobsSearchService, SearchTracingService $tracingService, DebuggingService $debuggingService, EntityManagerInterface $entityManager, RouterHelperService $routerHelperService, IntegratedExternalPartnerService $integratedExternalPartnerService, CacheManager $imagineCacheManager)
  329. {
  330. $recurrentJobId = $request->get('recurrentJobId');
  331. $recurrentJob = null;
  332. if (!is_null($recurrentJobId) && $recurrentJobId !== '') {
  333. /** @var RecurrentJob|null $recurrentJob */
  334. $recurrentJob = $entityManager->getRepository(RecurrentJob::class)->find($recurrentJobId);
  335. }
  336. if (!is_null($recurrentJob)) {
  337. $showAnonymousResults = false;
  338. $numberOfResultsPerPage = $recurrentJobsSearchService->getNumberOfResultsPerPage(false, $showAnonymousResults);
  339. $maximumTotalNumberOfResults = $recurrentJobsSearchService->getMaxNumberOfResults(false, $numberOfResultsPerPage);
  340. $searchParams = RecurrentJobsSearchParameters::fromRecurrentJob($recurrentJob);
  341. $tracing = $tracingService->createTracing($recurrentJobsSearchService);
  342. $fullResultset = new RecurrentJobsSearchResultset($searchParams, $tracing);
  343. try {
  344. $fullResultset = $recurrentJobsSearchService->getResultset(
  345. $searchParams,
  346. 5,
  347. 0,
  348. true,
  349. $showAnonymousResults,
  350. null
  351. );
  352. } catch (UnknownZipcodeException $e) {
  353. $debuggingInfoBag = new DebuggingInfoBag(
  354. 'unknown-zipcode-recurrent-jobs-search',
  355. 'Unknown zipcode ' . $searchParams->getFilterZipcode() . ' in recurrent jobs search', '',
  356. Logger::WARNING
  357. );
  358. $debuggingInfoBag->setRequest($request);
  359. $debuggingService->log($debuggingInfoBag);
  360. } catch (Exception $e) {
  361. $userId = null;
  362. throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, 'An exception occurred while trying to search for recurrent jobs. The query string is ' . $request->getQueryString() . ', and the userId is ' . $userId, $e);
  363. }
  364. }
  365. $returnArray = [];
  366. if (!is_null($fullResultset) && $fullResultset->getTotalNumberOfResults() > 0) {
  367. foreach ($fullResultset->getResults() as $result) {
  368. if ($result->containsRecurrentJob()) {
  369. if ($result->getRecurrentJob()->getJoboffererProfile()->getBusinessName() !== $recurrentJob->getJoboffererProfile()->getBusinessName()) {
  370. $returnArray[] = [
  371. 'id' => $result->getRecurrentJob()->getId(),
  372. 'businessName' => $result->getRecurrentJob()->getBusinessName(),
  373. 'searchterm' => $result->getRecurrentJob()->getOccupationalFieldSearchtermForDisplay(),
  374. 'zipcode' => $result->getRecurrentJob()->getZipcode(),
  375. 'city' => $result->getRecurrentJob()->getCity(),
  376. 'href' => $routerHelperService->generate(
  377. 'recurrent_jobs.share',
  378. [
  379. 'recurrentJobId' => $result->getRecurrentJob()->getId(),
  380. ConversionEventService::QUERY_STRING_PARAM_NAME_CONVERSION_CAMPAIGN_ID => ConversionEventService::CAMPAIGN_ID_SIMILAR_JOBS,
  381. ConversionEventService::QUERY_STRING_PARAM_NAME_CONVERSION_SUBCAMPAIGN_ID => 0
  382. ],
  383. UrlGeneratorInterface::ABSOLUTE_URL
  384. ),
  385. 'img' => ($result->getRecurrentJob()->isLinkedToExternalPartner() && $integratedExternalPartnerService->recurrentJobHasDedicatedHeaderImage($result->getRecurrentJob()))
  386. ?
  387. str_replace('https://preview4.joboo.de/', '', $integratedExternalPartnerService->getRecurrentJobDedicatedHeaderImagePath($result->getRecurrentJob()))
  388. :
  389. (($result->getRecurrentJob()->hasProfilePhoto())
  390. ? str_replace(
  391. 'https://preview4.joboo.de/media/cache/resolve/', 'https://default.cdn.www.joboo.de/',
  392. $imagineCacheManager->getBrowserPath($result->getRecurrentJob()->getProfilePhotoFileName(), $result->getRecurrentJob()->getImagineFilterNameForMaximizedProfilePhoto())
  393. )
  394. : null
  395. )
  396. ];
  397. }
  398. }
  399. }
  400. }
  401. return $this->json($returnArray);
  402. }
  403. public function resultsForOneSpecificCustomerAction(
  404. Request $request
  405. ): RedirectResponse {
  406. $customerInternalId = $request->get('customerInternalId');
  407. if (is_null($customerInternalId)) {
  408. $parameters = [];
  409. } else {
  410. $parameters = ['customerInternalId' => $customerInternalId];
  411. }
  412. $queryString = $request->getQueryString();
  413. if (!is_null($queryString)) {
  414. $queryString = '?' . $queryString;
  415. } else {
  416. $queryString = '';
  417. }
  418. return new RedirectResponse(
  419. $this->container->get('router')->generate(
  420. 'janus_hercules.recurrent_jobs_search.results.for_specific_customer',
  421. $parameters,
  422. UrlGeneratorInterface::ABSOLUTE_URL) . $queryString,
  423. 301
  424. );
  425. }
  426. /** @throws Exception */
  427. public function resultsForOneSpecificCustomerFromGoogleAction(
  428. Request $request,
  429. ConversionEventService $conversionEventService,
  430. EntityManagerInterface $entityManager
  431. ): Response {
  432. $user = $this->getUser();
  433. $customer = $entityManager
  434. ->getRepository(IntegratedExternalPartnerCustomer::class)
  435. ->findOneBy([
  436. 'internalId' => $request->get('customerInternalId')
  437. ]);
  438. $subcampaignId = 0;
  439. $currentHost = $request->getHost();
  440. if ($currentHost === 'rossmann.www.joboo.de') {
  441. $subcampaignId = 3;
  442. } elseif ($currentHost === 'deutsche-bahn.www.joboo.de') {
  443. $subcampaignId = 4;
  444. }
  445. $conversionEventService->initiateGoalReachedConversionTracking(
  446. $user,
  447. ConversionEventService::CAMPAIGN_ID_RECURRENT_JOBS_SEARCH_FOR_ONE_SPECIFIC_CUSTOMER,
  448. $subcampaignId,
  449. null,
  450. $request,
  451. null,
  452. null,
  453. $customer
  454. );
  455. return $this->redirectToRoute(
  456. 'janus_hercules.recurrent_jobs_search.results.for_specific_customer',
  457. [
  458. 'customerInternalId' => $request->get('customerInternalId'),
  459. 'conversionCampaignId' => ConversionEventService::CAMPAIGN_ID_GOOGLE_ADS
  460. ]
  461. );
  462. }
  463. public function resultsForPersomatchLandingPagesByCategoryAndCustomerAction(
  464. Request $request,
  465. ConversionEventService $conversionEventService,
  466. EntityManagerInterface $entityManager
  467. ): Response {
  468. $user = $this->getUser();
  469. $subcampaignId = 0;
  470. $customer = $entityManager
  471. ->getRepository(IntegratedExternalPartnerCustomer::class)
  472. ->findOneBy([
  473. 'internalId' => $request->get('customerInternalId')
  474. ]);
  475. $conversionEventService->initiateGoalReachedConversionTracking(
  476. $user,
  477. ConversionEventService::CAMPAIGN_ID_PERSOMATCH_LANDINGPAGES_CATEGORY_AND_CUSTOMER,
  478. $subcampaignId,
  479. null,
  480. $request,
  481. null,
  482. null,
  483. $customer
  484. );
  485. return $this->redirectToRoute(
  486. 'janus_hercules.recurrent_jobs_search.results.persomatch_landing_pages_by_category_and_customer',
  487. [
  488. 'customerInternalId' => $request->get('customerInternalId'),
  489. 'categoryTitle' => $request->get('categoryTitle'),
  490. ]
  491. );
  492. }
  493. public function resultsForPersomatchLandingPagesByCategoryAndCatalogAction(
  494. Request $request,
  495. ConversionEventService $conversionEventService,
  496. ): Response {
  497. $user = $this->getUser();
  498. $subcampaignId = 0;
  499. $customer = null;
  500. $conversionEventService->initiateGoalReachedConversionTracking(
  501. $user,
  502. ConversionEventService::CAMPAIGN_ID_PERSOMATCH_LANDINGPAGES_CATEGORY_AND_CATALOG,
  503. $subcampaignId,
  504. null,
  505. $request,
  506. null,
  507. null,
  508. $customer
  509. );
  510. return $this->redirectToRoute(
  511. 'janus_hercules.recurrent_jobs_search.results.persomatch_landing_pages_by_category_and_catalog',
  512. [
  513. 'categoryTitle' => $request->get('categoryTitle'),
  514. 'catalogName' => $request->get('catalogName'),
  515. ]
  516. );
  517. }
  518. /** @throws Exception */
  519. public function resultsForOneSpecificCustomerFromFacebookAction(
  520. Request $request,
  521. ConversionEventService $conversionEventService,
  522. EntityManagerInterface $entityManager
  523. ): Response {
  524. $user = $this->getUser();
  525. $customer = $entityManager
  526. ->getRepository(IntegratedExternalPartnerCustomer::class)
  527. ->findOneBy([
  528. 'internalId' => $request->get('customerInternalId')
  529. ]);
  530. $isLead = (bool)$request->get('lead') === true;
  531. // For an A/B Test https://trello.com/c/VGZpgnh9/3435-dpdhl-facebook-ad-a-b-testing-2-url
  532. $newCampaign = (bool)$request->get('nc') === true;
  533. $oldCampaign = (bool)$request->get('oc') === true;
  534. $conversionEventService->initiateGoalReachedConversionTracking(
  535. $user,
  536. ConversionEventService::CAMPAIGN_ID_RECURRENT_JOBS_SEARCH_FOR_ONE_SPECIFIC_CUSTOMER,
  537. $newCampaign ? 5 : ($oldCampaign ? 6 : ($isLead ? 2 : 1)),
  538. null,
  539. $request,
  540. null,
  541. null,
  542. $customer
  543. );
  544. return $this->redirectToRoute(
  545. 'janus_hercules.recurrent_jobs_search.results.for_specific_customer',
  546. [
  547. 'customerInternalId' => $request->get('customerInternalId'),
  548. 'conversionCampaignId' => ConversionEventService::CAMPAIGN_ID_FACEBOOK
  549. ]
  550. );
  551. }
  552. /** @throws Exception */
  553. public function resultsForOneSpecificCustomerFromInstagramAction(
  554. Request $request,
  555. ConversionEventService $conversionEventService,
  556. EntityManagerInterface $entityManager
  557. ): Response {
  558. $user = $this->getUser();
  559. $customer = $entityManager
  560. ->getRepository(IntegratedExternalPartnerCustomer::class)
  561. ->findOneBy([
  562. 'internalId' => $request->get('customerInternalId')
  563. ]);
  564. $conversionEventService->initiateGoalReachedConversionTracking(
  565. $user,
  566. ConversionEventService::CAMPAIGN_ID_RECURRENT_JOBS_SEARCH_FOR_ONE_SPECIFIC_CUSTOMER,
  567. 7,
  568. null,
  569. $request,
  570. null,
  571. null,
  572. $customer
  573. );
  574. $conversionEventService->initiateGoalReachedConversionTracking(
  575. $user,
  576. ConversionEventService::CAMPAIGN_ID_INSTAGRAM,
  577. 0,
  578. null,
  579. $request,
  580. null,
  581. null,
  582. $customer
  583. );
  584. return $this->redirectToRoute(
  585. 'janus_hercules.recurrent_jobs_search.results.for_specific_customer',
  586. [
  587. 'customerInternalId' => $request->get('customerInternalId'),
  588. 'conversionCampaignId' => ConversionEventService::CAMPAIGN_ID_INSTAGRAM
  589. ]
  590. );
  591. }
  592. /**
  593. * @throws Exception
  594. */
  595. public function resultsForOneSpecificCustomerFromPersomatchGoogleAction(
  596. Request $request,
  597. ConversionEventService $conversionEventService,
  598. EntityManagerInterface $entityManager,
  599. ExternalPartnerEventDomainService $externalPartnerEventDomainService
  600. ): Response {
  601. $user = $this->getUser();
  602. $customer = $entityManager
  603. ->getRepository(IntegratedExternalPartnerCustomer::class)
  604. ->findOneBy([
  605. 'internalId' => $request->get('customerInternalId')
  606. ]);
  607. $conversionEventService->initiateGoalReachedConversionTracking(
  608. $user,
  609. ConversionEventService::CAMPAIGN_ID_RECURRENT_JOBS_SEARCH_FOR_ONE_SPECIFIC_CUSTOMER,
  610. 8,
  611. null,
  612. $request,
  613. null,
  614. null,
  615. $customer
  616. );
  617. $externalPartnerEventDomainService->writeEvent(
  618. ExternalPartnerEvent::EVENT_TYPE_USER_HAS_BEEN_FORWARDED_TO_CUSTOMER_SPECIFIC_SEARCH_RESULTS_PAGE_VIA_PERSOMATCH_GOOGLE,
  619. $customer->getExternalPartner(),
  620. null,
  621. null,
  622. null,
  623. null,
  624. null,
  625. null,
  626. null,
  627. $request
  628. );
  629. return $this->redirectToRoute(
  630. 'janus_hercules.recurrent_jobs_search.results.for_specific_customer',
  631. [
  632. 'customerInternalId' => $request->get('customerInternalId'),
  633. 'conversionCampaignId' => ConversionEventService::CAMPAIGN_ID_PERSOMATCH_FEED
  634. ]
  635. );
  636. }
  637. }