src/Controller/Cronjob/SubTransactions/StreamMastersController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Cronjob\SubTransactions;
  3. use App\Repository\SubTransactions\StreamMastersRepository;
  4. use App\Service\SettingService;
  5. use App\Service\StreamMasterApi;
  6. use App\Service\TransactionService;
  7. use App\Service\Util\NotificationService;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Doctrine\Persistence\ManagerRegistry;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. use Symfony\Component\HttpFoundation\JsonResponse;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. class StreamMastersController extends AbstractController
  14. {
  15.     public TransactionService $transaction;
  16.     public function __construct(TransactionService $transaction)
  17.     {
  18.         $this->transaction $transaction;
  19.     }
  20.     #[Route('/cronjob/sub/transactions/stream-masters'name'app_cronjob_stream_master_cron')]
  21.     public function index(StreamMastersRepository $repository EntityManagerInterface $managerRegistry,NotificationService $notificationService)
  22.     {
  23.         $settingObject = new SettingService($managerRegistry);
  24.         $api = new StreamMasterApi();
  25.         foreach ($repository->findBy(['isPaid' => false]) as $payment4Object) {
  26.             $res =  $api->getPaymentStatus($settingObject->getSetting('streamMaster_token'),$payment4Object->getRefId());
  27.             if ($res['status'] == 'success'){
  28.                 try {
  29.                     $user $payment4Object->getOwner();
  30.                     $amount $payment4Object->getPrice();
  31.                     $setting = new SettingService($managerRegistry);
  32.                     $payment4Object->setIsPaid(true);
  33.                     $this->transaction->createTransaction($user$amount"افزایش اعتبار کیف پول  - درگاه استریم مستر-
  34.                   {$amount}
  35.                   تومان
  36.                   - پیگیری : "
  37.                         $payment4Object->getRefId(), 10null0null'StreamMaster'nullnull);
  38.                     $managerRegistry->flush();
  39.                     $managerRegistry->clear();
  40.                 } catch (\Exception $exception) {
  41.                     $notificationService->exception($exception);
  42. //                    $this->telegram->exception($exception);
  43.                 }
  44.             }
  45.         }
  46.         return $this->json(['res' => true]);
  47.     }
  48. }