From 3c1dfd7d0dce63329383bed3d49c505f9736bb1f Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Wed, 10 Apr 2024 19:20:32 +0000 Subject: [PATCH] some progress in sms panel changes --- .../src/Controller/AdminController.php | 47 ++++++++++++++++++- hesabixCore/src/Controller/UserController.php | 8 +++- hesabixCore/src/Entity/Settings.php | 44 ----------------- hesabixCore/src/Service/JsonResp.php | 4 ++ 4 files changed, 56 insertions(+), 47 deletions(-) diff --git a/hesabixCore/src/Controller/AdminController.php b/hesabixCore/src/Controller/AdminController.php index cfec9ca..022ab66 100644 --- a/hesabixCore/src/Controller/AdminController.php +++ b/hesabixCore/src/Controller/AdminController.php @@ -14,6 +14,7 @@ use App\Entity\StoreroomTicket; use App\Entity\User; use App\Entity\WalletTransaction; use App\Service\Jdate; +use App\Service\JsonResp; use App\Service\Notification; use App\Service\Provider; use App\Service\registryMGR; @@ -199,6 +200,9 @@ class AdminController extends AbstractController { $resp = []; + $resp['username'] = $registryMGR->get('sms','username'); + $resp['password'] = $registryMGR->get('sms','password'); + $resp['token'] = $registryMGR->get('sms','token'); $resp['walletpay'] = $registryMGR->get('sms','walletPay'); $resp['changePassword'] = $registryMGR->get('sms','changePassword'); $resp['f2a'] = $registryMGR->get('sms','f2a'); @@ -210,6 +214,41 @@ class AdminController extends AbstractController return $this->json($resp); } + #[Route('/api/admin/sms/plan/info/save', name: 'admin_sms_plan_info_save')] + public function admin_sms_plan_info_save(registryMGR $registryMGR,Jdate $jdate,#[CurrentUser] ?User $user,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + if(array_key_exists('username',$params)) + $registryMGR->update('sms','username',$params['username']); + if(array_key_exists('password',$params)) + $registryMGR->update('sms','password',$params['password']); + if(array_key_exists('token',$params)) + $registryMGR->update('sms','token',$params['token']); + + if(array_key_exists('walletpay',$params)) + $registryMGR->update('sms','walletpay',$params['walletpay']); + if(array_key_exists('changePassword',$params)) + $registryMGR->update('sms','changePassword',$params['changePassword']); + if(array_key_exists('f2a',$params)) + $registryMGR->update('sms','f2a',$params['f2a']); + if(array_key_exists('ticketReplay',$params)) + $registryMGR->update('sms','ticketReplay',$params['ticketReplay']); + if(array_key_exists('ticketRec',$params)) + $registryMGR->update('sms','ticketRec',$params['ticketRec']); + if(array_key_exists('fromNum',$params)) + $registryMGR->update('sms','fromNum',$params['fromNum']); + if(array_key_exists('sharefaktor',$params)) + $registryMGR->update('sms','sharefaktor',$params['sharefaktor']); + if(array_key_exists('plan',$params)) + $registryMGR->update('sms','plan',$params['plan']); + + return $this->json(JsonResp::success()); + } + #[Route('/api/admin/settings/system/info', name: 'admin_settings_system_info')] public function admin_settings_system_info(Jdate $jdate,#[CurrentUser] ?User $user,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response { @@ -370,7 +409,7 @@ class AdminController extends AbstractController } #[Route('/api/admin/wallets/transactions/insert', name: 'app_admin_wallets_transactions_insert')] - public function app_admin_wallets_transactions_insert(SMS $SMS,Jdate $jdate,Notification $notification,Request $request,EntityManagerInterface $entityManager): JsonResponse + public function app_admin_wallets_transactions_insert(registryMGR $registryMGR, SMS $SMS,Jdate $jdate,Notification $notification,Request $request,EntityManagerInterface $entityManager): JsonResponse { $params = []; if ($content = $request->getContent()) { @@ -394,7 +433,11 @@ class AdminController extends AbstractController $entityManager->persist($item); $entityManager->flush(); $notification->insert('تسویه کیف پول انجام شد.','/acc/wallet/view',$bid,$bid->getOwner()); - $SMS->send([$bid->getName()],174225,$bid->getOwner()->getMobile()); + $SMS->send( + [$bid->getName()], + $registryMGR->get('sms','walletpay'), + $bid->getOwner()->getMobile() + ); return $this->json(['result' => 1]); } diff --git a/hesabixCore/src/Controller/UserController.php b/hesabixCore/src/Controller/UserController.php index f093035..2de0922 100644 --- a/hesabixCore/src/Controller/UserController.php +++ b/hesabixCore/src/Controller/UserController.php @@ -20,6 +20,7 @@ use Symfony\Component\Security\Core\Exception\UserNotFoundException; use Symfony\Component\Security\Http\Attribute\CurrentUser; use App\Entity\User; use App\Security\EmailVerifier; +use App\Service\registryMGR; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bridge\Twig\Mime\TemplatedEmail; use Symfony\Component\Form\FormError; @@ -206,7 +207,7 @@ class UserController extends AbstractController } #[Route('/api/user/register', name: 'api_user_register')] - public function api_user_register(SMS $SMS,MailerInterface $mailer,Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager): Response + public function api_user_register(registryMGR $registryMGR,SMS $SMS,MailerInterface $mailer,Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager): Response { $params = []; if ($content = $request->getContent()) { @@ -243,6 +244,11 @@ class UserController extends AbstractController $entityManager->persist($user); $entityManager->flush(); $SMS->send([$user->getVerifyCode()],'162246',$user->getMobile()); + $SMS->send( + [$user->getVerifyCode()], + $registryMGR->get('sms','f2a'), + $user->getMobile() + ); try { $email = (new Email()) ->to($user->getEmail()) diff --git a/hesabixCore/src/Entity/Settings.php b/hesabixCore/src/Entity/Settings.php index 98993f7..c20ee98 100644 --- a/hesabixCore/src/Entity/Settings.php +++ b/hesabixCore/src/Entity/Settings.php @@ -14,11 +14,6 @@ class Settings #[ORM\Column] private ?int $id = null; - #[ORM\Column(length: 255, nullable: true)] - private ?string $payamakUsername = null; - - #[ORM\Column(length: 255, nullable: true)] - private ?string $payamakPassword = null; #[ORM\Column(nullable: true)] private ?bool $activeSendSms = null; @@ -32,9 +27,6 @@ class Settings #[ORM\Column(length: 255, nullable: true)] private ?string $storagePrice = null; - #[ORM\Column(length: 255, nullable: true)] - private ?string $melipayamakToken = null; - #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $siteKeywords = null; @@ -58,30 +50,6 @@ class Settings return $this->id; } - public function getPayamakUsername(): ?string - { - return $this->payamakUsername; - } - - public function setPayamakUsername(?string $payamakUsername): static - { - $this->payamakUsername = $payamakUsername; - - return $this; - } - - public function getPayamakPassword(): ?string - { - return $this->payamakPassword; - } - - public function setPayamakPassword(?string $payamakPassword): static - { - $this->payamakPassword = $payamakPassword; - - return $this; - } - public function isActiveSendSms(): ?bool { return $this->activeSendSms; @@ -130,18 +98,6 @@ class Settings return $this; } - public function getMelipayamakToken(): ?string - { - return $this->melipayamakToken; - } - - public function setMelipayamakToken(?string $melipayamakToken): static - { - $this->melipayamakToken = $melipayamakToken; - - return $this; - } - public function getSiteKeywords(): ?string { return $this->siteKeywords; diff --git a/hesabixCore/src/Service/JsonResp.php b/hesabixCore/src/Service/JsonResp.php index 395b881..85cf8db 100644 --- a/hesabixCore/src/Service/JsonResp.php +++ b/hesabixCore/src/Service/JsonResp.php @@ -27,4 +27,8 @@ class JsonResp 'tempStatus' => $hesabdariDoc->getTempStatus(), ]; } + + public static function success(){ + return ['error'=>0]; + } } \ No newline at end of file