vendor/launchpad/backend/src/Admin/Api/Controller/TransactionController.php line 80

Open in your IDE?
  1. <?php
  2. namespace LaunchPad\Bundle\LaunchPadBundle\Admin\Api\Controller;
  3. use Doctrine\Common\Annotations\AnnotationException;
  4. use LaunchPad\Bundle\LaunchPadBundle\Base\Entity\Transaction\Transaction;
  5. use LaunchPad\Bundle\LaunchPadBundle\Base\Exception\MissingApiParamsException;
  6. use LaunchPad\Bundle\LaunchPadBundle\Base\Service\McApiService;
  7. use LaunchPad\Bundle\LaunchPadBundle\Base\Service\TransactionService;
  8. use LaunchPad\Bundle\LaunchPadBundle\Base\Service\Translation\TranslationService;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\Serializer\Exception\ExceptionInterface;
  11. use OpenApi\Annotations as OA;
  12. use LaunchPad\Bundle\LaunchPadBundle\Base\Service\TransactionWithThisIdDoesNotExist;
  13. use Symfony\Component\HttpFoundation\JsonResponse;
  14. /**
  15.  * Class TransactionController
  16.  * @package BoBoFin\Admin\Api\Controller
  17.  * @Route("/transaction", name="admin_")
  18.  */
  19. class TransactionController extends BaseAdminApiController
  20. {
  21.     /** @var McApiService  */
  22.     private $mcApiService;
  23.     /** @var TransactionService  */
  24.     private $transactionService;
  25.     /**
  26.      * TransactionController constructor.
  27.      *
  28.      * @param TranslationService $translationService
  29.      * @param TransactionService $transactionService
  30.      * @param McApiService $mcApiService
  31.      */
  32.     public function __construct(
  33.         TranslationService $translationService,
  34.         TransactionService $transactionService,
  35.         McApiService $mcApiService
  36.     ) {
  37.         parent::__construct($translationService);
  38.         $this->mcApiService $mcApiService;
  39.         $this->transactionService $transactionService;
  40.     }
  41.     /**
  42.      * @Route("/mastercard/test", name="mc_api_test")
  43.      * @return JsonResponse
  44.      * @throws AnnotationException
  45.      * @throws ExceptionInterface
  46.      */
  47.     public function testAction()
  48.     {
  49.         $test $this->mcApiService->test();
  50.        // dump($test);die;
  51.         return $this->success();
  52.     }
  53.     /**
  54.      * @Route("/list", name="transaction_list")
  55.      * @return \Symfony\Component\HttpFoundation\JsonResponse
  56.      * @throws \Doctrine\Common\Annotations\AnnotationException
  57.      * @return JsonResponse
  58.      * @throws AnnotationException
  59.      * @throws ExceptionInterface
  60.      */
  61.     public function getPaymentTransactionListAction()
  62.     {
  63.         $list $this->paginatorService->getPaginated(
  64.             Transaction::class,
  65.             $this->data
  66.         );
  67.         return $this->success($listnull, ['transaction_data']);
  68.     }
  69.     /**
  70.      * @Route("/save", name="transaction_save")
  71.      * @param TransactionService $transactionService
  72.      * @return JsonResponse
  73.      * @throws AnnotationException
  74.      * @throws MissingApiParamsException
  75.      * @throws ExceptionInterface
  76.      */
  77.     public function addOrEditTransaction(TransactionService $transactionService)
  78.     {
  79.         $this->requirePostParams(['account_id''user_id''category_id''merchant_id''country_id''payment_card_id''card_id''currency_id''original_currency_id''title''address''city''amount''original_amount''gps_latitude''gps_longitude''transaction_date''post_date']);
  80.         $this->transactionService->saveTransactionFromAdmin(
  81.             @$this->data['id'],
  82.             $this->data['account_id'],
  83.             $this->data['user_id'],
  84.             $this->data['category_id'],
  85.             $this->data['merchant_id'],
  86.             $this->data['country_id'],
  87.             $this->data['payment_card_id'],
  88.             $this->data['card_id'],
  89.             $this->data['currency_id'],
  90.             $this->data['original_currency_id'],
  91.             $this->data['title'],
  92.             $this->data['address'],
  93.             $this->data['city'],
  94.             $this->data['amount'],
  95.             $this->data['original_amount'],
  96.             $this->data['gps_latitude'],
  97.             $this->data['gps_longitude'],
  98.             $this->data['transaction_date'],
  99.             $this->data['post_date']
  100.         );
  101.         return $this->success();
  102.     }
  103.     /**
  104.      * @Route("/delete/{id}", name="transaction_delete")
  105.      * @param $id
  106.      * @return JsonResponse
  107.      * @throws AnnotationException
  108.      * @throws ExceptionInterface
  109.      */
  110.     public function deleteTransactionAction($idTransactionService $transactionService)
  111.     {
  112.         die('DISABLED');
  113.         $this->transactionService->deleteTransaction($id);
  114.         return $this->success();
  115.     }
  116.     /**
  117.      * @Route("/details", name="admin_transactions_details")
  118.      * @param TransactionService $transactionService
  119.      * @return JsonResponse
  120.      * @throws ExceptionInterface
  121.      * @throws AnnotationException
  122.      * @throws MissingApiParamsException
  123.      * @throws TransactionWithThisIdDoesNotExist
  124.      */
  125.     public function getTransactionsDetailsAction(TransactionService $transactionService)
  126.     {
  127.         $this->requirePostParams(['id']);
  128.         $user $this->transactionService->getTransactionByIdFromAdmin($this->data['id']);
  129.         return $this->success($usernull, ['transaction_data']);
  130.         $user $transactionService->getTransactionByIdFromAdmin($this->data['id']);
  131.         return $this->success($usernull,
  132.             ['transaction_data''user_data''account_data''payment_device_data''transaction_category_data''transaction_merchant_data''country_data''payment_card_data']
  133.         );
  134.     }
  135.     /**
  136.      * @Route("/mc-mandate/fx", name="transactions_mc_mandate_fx")
  137.      *
  138.      * @OA\Post(
  139.      *      path="/transaction/mc-mandate/fx",
  140.      *      operationId="getUserTransactionExport",
  141.      *      tags={"Transaction"},
  142.      *      summary="Get user transactions export",
  143.      *      description="Export all user transactions",
  144.      *      @OA\RequestBody(
  145.      *          required=true,
  146.      *          @OA\JsonContent(
  147.      *              type="object",
  148.      *              @OA\Property(property="id", type="integer")
  149.      *          )
  150.      *      ),
  151.      *      @OA\Response(
  152.      *          response=200,
  153.      *          description="Success Response",
  154.      *          @OA\JsonContent(ref="#/components/schemas/SuccessResponse")
  155.      *       )
  156.      * )
  157.      * @param Request $request
  158.      * @return \Symfony\Component\HttpFoundation\JsonResponse
  159.      * @throws \Doctrine\Common\Annotations\AnnotationException
  160.      * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
  161.      */
  162.     public function getExchangeForFXTransaction()
  163.     {
  164.         $this->requirePostParams(['id']);
  165.         $response $this->transactionService->getFxExchangeForTransaction($this->data['id']);
  166.         return $this->success($responsenull, ['transaction_data''mc_fx_data''fx_fee_data']);
  167.     }
  168.     /**
  169.      * Get All Transactions
  170.      *
  171.      * @param TransactionService $transactionService
  172.      * @return mixed
  173.      * @throws \Doctrine\Common\Annotations\AnnotationException
  174.      * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
  175.      * @throws \Doctrine\ORM\NonUniqueResultException
  176.      * @Route("/all", name="transaction_all_admin")
  177.      *
  178.      * @OA\Post(
  179.      *      path="/transaction/all",
  180.      *      operationId="getTransactionsAction",
  181.      *      tags={"Transaction "},
  182.      *      summary="Transaction",
  183.      *      description="Returns all number transaction",
  184.      *      @OA\Response(
  185.      *          response=200,
  186.      *          description="Successful operation",
  187.      *          @OA\JsonContent(ref="#/components/schemas/SuccessResponse")
  188.      *      ),
  189.      *      security={
  190.      *          {"Bearer": {}}
  191.      *      }
  192.      * )
  193.      */
  194.     public function getTransactionsAction()
  195.     {
  196.         $transactions $this->transactionService->getTransactions();
  197.         return $this->success($transactionsnull, ['transaction_data']);
  198.     }
  199.     /**
  200.      * Get All Overtime Transactions Trend
  201.      *
  202.      * @param TransactionService $transactionService
  203.      * @return mixed
  204.      * @throws \Doctrine\Common\Annotations\AnnotationException
  205.      * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
  206.      * @throws \Doctrine\ORM\NonUniqueResultException
  207.      * @Route("/over-time/trend", name="transaction_overtime_trend")
  208.      *
  209.      * @OA\Post(
  210.      *      path="/transaction/over-time/trend",
  211.      *      operationId="getNumberOfTransactionsOverTimeTrendAction",
  212.      *      tags={"Transaction "},
  213.      *      summary="Transaction",
  214.      *      description="Returns all number overtime transaction",
  215.      *      @OA\Response(
  216.      *          response=200,
  217.      *          description="Successful operation",
  218.      *          @OA\JsonContent(ref="#/components/schemas/SuccessResponse")
  219.      *      ),
  220.      *      security={
  221.      *          {"Bearer": {}}
  222.      *      }
  223.      * )
  224.      */
  225.     public function getNumberOfTransactionsOverTimeTrendAction()
  226.     {
  227.         $transactions $this->transactionService->getTotalNumberOvertimeTransactions(
  228.             @$this->data['startDate'], @$this->data['endDate']);
  229.         return $this->success($transactionsnull, ['transaction_data']);
  230.     }
  231.     /**
  232.      * Get All  Transactions By Category Trend
  233.      *
  234.      * @param TransactionService $transactionService
  235.      * @return mixed
  236.      * @throws \Doctrine\Common\Annotations\AnnotationException
  237.      * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
  238.      * @throws \Doctrine\ORM\NonUniqueResultException
  239.      * @Route("/category/trend", name="transaction_category_trend")
  240.      *
  241.      * @OA\Post(
  242.      *      path="/transaction/category/trend",
  243.      *      operationId="getTransactionsByCategoryAction",
  244.      *      tags={"Transaction "},
  245.      *      summary="Transaction",
  246.      *      description="Returns all number transactions by category",
  247.      *      @OA\Response(
  248.      *          response=200,
  249.      *          description="Successful operation",
  250.      *          @OA\JsonContent(ref="#/components/schemas/SuccessResponse")
  251.      *      ),
  252.      *      security={
  253.      *          {"Bearer": {}}
  254.      *      }
  255.      * )
  256.      */
  257.     public function getTransactionsByCategoryAction()
  258.     {
  259.         $transactions $this->transactionService->getTransactionsByCategory(
  260.             @$this->data['startDate'],
  261.             @$this->data['endDate']);
  262.         return $this->success($transactionsnull, ['transaction_data']);
  263.     }
  264.     /**
  265.      * Get All  Transactions By Country Trend
  266.      *
  267.      * @param TransactionService $transactionService
  268.      * @return mixed
  269.      * @throws \Doctrine\Common\Annotations\AnnotationException
  270.      * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
  271.      * @throws \Doctrine\ORM\NonUniqueResultException
  272.      * @Route("/country/trend", name="transaction_country_trend")
  273.      *
  274.      * @OA\Post(
  275.      *      path="/transaction/country/trend",
  276.      *      operationId="getTransactionsPerCountryAction",
  277.      *      tags={"Transaction "},
  278.      *      summary="Transaction",
  279.      *      description="Returns all number overtime transaction by country",
  280.      *      @OA\Response(
  281.      *          response=200,
  282.      *          description="Successful operation",
  283.      *          @OA\JsonContent(ref="#/components/schemas/SuccessResponse")
  284.      *      ),
  285.      *      security={
  286.      *          {"Bearer": {}}
  287.      *      }
  288.      * )
  289.      */
  290.     public function getTransactionsPerCountryAction()
  291.     {
  292.         $transactions $this->transactionService->getTransactionsByCountry(
  293.             @$this->data['startDate'],
  294.             @$this->data['endDate']);
  295.         return $this->success($transactionsnull, ['transaction_data']);
  296.     }
  297.     /**
  298.      * Get Average Transactions Trend
  299.      *
  300.      * @param TransactionService $transactionService
  301.      * @return mixed
  302.      * @throws \Doctrine\Common\Annotations\AnnotationException
  303.      * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
  304.      * @throws \Doctrine\ORM\NonUniqueResultException
  305.      * @Route("/average/trend", name="transaction_average_trend")
  306.      *
  307.      * @OA\Post(
  308.      *      path="/transaction/average/trend",
  309.      *      operationId="getAverageTransactionsForPeriodsAction",
  310.      *      tags={"Transaction "},
  311.      *      summary="Transaction",
  312.      *      description="Returns all avearge transaction",
  313.      *      @OA\Response(
  314.      *          response=200,
  315.      *          description="Successful operation",
  316.      *          @OA\JsonContent(ref="#/components/schemas/SuccessResponse")
  317.      *      ),
  318.      *      security={
  319.      *          {"Bearer": {}}
  320.      *      }
  321.      * )
  322.      */
  323.     public function getAverageTransactionsForPeriodsAction()
  324.     {
  325.         $transactions $this->transactionService->getAverageTransactionForPeriod(
  326.             @$this->data['startDate'],
  327.             @$this->data['endDate']);
  328.         return $this->success($transactionsnull, ['transaction_data']);
  329.     }
  330. }