Exemple #1
0
 /**
  * статистика по дням по площадке
  *
  * @param Platform $platform id площадки
  *
  * @Rest\Get("billing/earnings/{platform_id}", requirements={"platform_id"="\d+"})
  * @ParamConverter("platform", class="VifeedPlatformBundle:Platform",
  *                  options={"id" = "platform_id", "repository_method" = "findWithoutFilter"})
  * @ApiDoc(
  *     section="Billing statistics API",
  *     requirements={
  *       {"name"="platform_id", "dataType"="integer", "requirement"="\d+", "description"="id площадки"}
  *     },
  *     parameters={
  *       {"name"="date_from", "dataType"="date", "format"="YYYY-MM-DD", "required"=true},
  *       {"name"="date_to", "dataType"="date", "format"="YYYY-MM-DD", "required"=true}
  *     },
  *     statusCodes={
  *         200="Returned when successful",
  *         400="Returned when date_from or date_to is not correct",
  *         403="Returned when the user is not authorized to use this method",
  *         404="Returned when platform is not found"
  *     }
  * )
  *
  * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getBillingEarningsByPlatformAction(Platform $platform)
 {
     if ($this->getUser()->getType() !== User::TYPE_PUBLISHER) {
         throw new AccessDeniedHttpException();
     }
     if ($this->getUser() !== $platform->getUser()) {
         throw new AccessDeniedHttpException();
     }
     $dates = $this->getRequestedDates();
     $data = ['stats' => [], 'total' => 0];
     $paymentRepo = $this->getDoctrine()->getRepository('VifeedPaymentBundle:VideoViewPayment');
     $stats = $paymentRepo->getPlatformStatsByDay($platform, $dates['date_from'], $dates['date_to']);
     foreach ($stats as $row) {
         $data['total'] += $row['earned'];
     }
     $data['stats'] = $stats;
     $view = new View($data);
     return $this->handleView($view);
 }
Exemple #2
0
 /**
  * Паблишер отменяет бан кампании
  *
  * @param Platform $platform id площадки
  * @param Campaign $campaign id кампании
  *
  * @Rest\Delete("platforms/{id}/ban/{campaign_id}", requirements={"id"="\d+", "campaign_id"="\d+"})
  * @ParamConverter("platform", class="VifeedPlatformBundle:Platform")
  * @ParamConverter("campaign", class="VifeedCampaignBundle:Campaign", options={"id" = "campaign_id"})
  * @ApiDoc(
  *     section="Platform API",
  *     requirements={
  *       {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="id площадки"},
  *       {"name"="campaign_id", "dataType"="integer", "requirement"="\d+", "description"="id кампании"}
  *     },
  *     statusCodes={
  *         204="Returned when successful",
  *         403="Returned when the user is not authorized to use this method",
  *         404="Returned when platform or campaign not found"
  *     }
  * )
  *
  *
  * @return Response
  */
 public function deleteCampaignBanAction(Platform $platform, Campaign $campaign)
 {
     if ($this->getUser()->getType() !== User::TYPE_PUBLISHER) {
         throw new AccessDeniedHttpException('Вы не можете блокировать кампании');
     }
     if ($platform->getUser() !== $this->getUser()) {
         throw new AccessDeniedHttpException('Можно работать только со своими площадками');
     }
     try {
         $this->platformManager->unbanCampaign($platform, $campaign);
     } catch (EntityNotFoundException $e) {
         throw new NotFoundHttpException();
     }
     $view = new View('', 204);
     return $this->handleView($view);
 }