sms panel add melipayamak and complete
This commit is contained in:
parent
3c1dfd7d0d
commit
4160c9c51f
|
@ -12,6 +12,7 @@ use App\Service\Jdate;
|
|||
use App\Service\Log;
|
||||
use App\Service\Notification;
|
||||
use App\Service\Provider;
|
||||
use App\Service\registryMGR;
|
||||
use App\Service\SMS;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
@ -222,7 +223,7 @@ class SMSController extends AbstractController
|
|||
* @throws \ReflectionException
|
||||
*/
|
||||
#[Route('/api/sms/send/sell-invoice/{id}/{num}', name: 'api_sms_send_invoice')]
|
||||
public function api_sms_send_invoice(SMS $SMS,String $id,String $num,Provider $provider,Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): Response
|
||||
public function api_sms_send_invoice(registryMGR $registryMGR, SMS $SMS,String $id,String $num,Provider $provider,Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$acc = $access->hasRole('sell');
|
||||
if(!$acc)
|
||||
|
@ -245,7 +246,7 @@ class SMSController extends AbstractController
|
|||
return $this->json(['result'=>
|
||||
$SMS->sendByBalance(
|
||||
[$bid->getName(),'sell/' . $bid->getId() . '/' . $shortLink],
|
||||
168030,
|
||||
$registryMGR->get('sms','sharefaktor'),
|
||||
$num,$bid,$this->getUser(),3
|
||||
)]);
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Entity\User;
|
|||
use App\Service\Jdate;
|
||||
use App\Service\Notification;
|
||||
use App\Service\Provider;
|
||||
use App\Service\registryMGR;
|
||||
use App\Service\SMS;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
@ -49,7 +50,7 @@ class SupportController extends AbstractController
|
|||
]);
|
||||
}
|
||||
#[Route('/api/admin/support/mod/{id}', name: 'app_admin_support_mod')]
|
||||
public function app_admin_support_mod(SMS $SMS,Request $request, EntityManagerInterface $entityManager,Notification $notifi,string $id = ''): JsonResponse
|
||||
public function app_admin_support_mod(registryMGR $registryMGR, SMS $SMS,Request $request, EntityManagerInterface $entityManager,Notification $notifi,string $id = ''): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -72,8 +73,13 @@ class SupportController extends AbstractController
|
|||
$entityManager->persist($support);
|
||||
$entityManager->flush();
|
||||
//send sms to customer
|
||||
if($item->getSubmitter()->getMobile())
|
||||
$SMS->send([$item->getId()],'162251',$item->getSubmitter()->getMobile());
|
||||
if($item->getSubmitter()->getMobile()){
|
||||
$SMS->send(
|
||||
[$item->getId()],
|
||||
$registryMGR->get('sms','ticketReplay'),
|
||||
$item->getSubmitter()->getMobile()
|
||||
);
|
||||
}
|
||||
//send notification to user
|
||||
$settings = $entityManager->getRepository(Settings::class)->findAll()[0];
|
||||
$url = $settings->getAppSite() . '/profile/support-view/' . $item->getId();
|
||||
|
@ -105,7 +111,7 @@ class SupportController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/api/support/mod/{id}', name: 'app_support_mod')]
|
||||
public function app_support_mod(SMS $SMS,Request $request, EntityManagerInterface $entityManager,string $id = ''): JsonResponse
|
||||
public function app_support_mod(registryMGR $registryMGR,SMS $SMS,Request $request, EntityManagerInterface $entityManager,string $id = ''): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -123,7 +129,12 @@ class SupportController extends AbstractController
|
|||
$entityManager->persist($item);
|
||||
$entityManager->flush();
|
||||
//send sms to manager
|
||||
$SMS->send([$item->getId()],'162214','09183282405');
|
||||
$SMS->send(
|
||||
[$item->getId()],
|
||||
$registryMGR->get('sms','ticketRec'),
|
||||
$registryMGR->get('ticket','managerMobile')
|
||||
);
|
||||
|
||||
return $this->json([
|
||||
'error'=> 0,
|
||||
'message'=> 'ok',
|
||||
|
@ -149,8 +160,13 @@ class SupportController extends AbstractController
|
|||
$entityManager->flush();
|
||||
//send sms to manager
|
||||
$admins = $entityManager->getRepository(User::class)->findByRole('ROLE_ADMIN');
|
||||
foreach($admins as $admin)
|
||||
$SMS->send([$item->getId()],'162214',$admin->getMobile());
|
||||
foreach($admins as $admin){
|
||||
$SMS->send(
|
||||
[$item->getId()],
|
||||
$registryMGR->get('sms','ticketRec'),
|
||||
$admin->getMobile()
|
||||
);
|
||||
}
|
||||
return $this->json([
|
||||
'error'=> 0,
|
||||
'message'=> 'ok',
|
||||
|
|
|
@ -243,7 +243,6 @@ class UserController extends AbstractController
|
|||
$user->setActive(false);
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
$SMS->send([$user->getVerifyCode()],'162246',$user->getMobile());
|
||||
$SMS->send(
|
||||
[$user->getVerifyCode()],
|
||||
$registryMGR->get('sms','f2a'),
|
||||
|
@ -279,7 +278,7 @@ class UserController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/api/user/active/code/info/{id}', name: 'api_user_active_code_info')]
|
||||
public function api_user_active_code_info(MailerInterface $mailer,SMS $SMS,String $id,#[CurrentUser] ?User $user,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
|
||||
public function api_user_active_code_info(registryMGR $registryMGR,MailerInterface $mailer,SMS $SMS,String $id,#[CurrentUser] ?User $user,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
|
||||
{
|
||||
$send = false;
|
||||
$user = $entityManager->getRepository(User::class)->find($id);
|
||||
|
@ -314,7 +313,11 @@ class UserController extends AbstractController
|
|||
|
||||
if($send){
|
||||
//send sms and email
|
||||
$SMS->send([$user->getVerifyCode()],'162246',$user->getMobile());
|
||||
$SMS->send(
|
||||
[$user->getVerifyCode()],
|
||||
$registryMGR->get('sms','f2a'),
|
||||
$user->getMobile()
|
||||
);
|
||||
$email = (new Email())
|
||||
->to($user->getEmail())
|
||||
->priority(Email::PRIORITY_HIGH)
|
||||
|
@ -331,7 +334,7 @@ class UserController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/api/user/reset/password/send-to-sms/{id}', name: 'api_user_forget_reset_password')]
|
||||
public function api_user_forget_reset_password(MailerInterface $mailer,SMS $SMS,String $id,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
|
||||
public function api_user_forget_reset_password(registryMGR $registryMGR,MailerInterface $mailer,SMS $SMS,String $id,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -353,7 +356,12 @@ class UserController extends AbstractController
|
|||
);
|
||||
$entityManager->persist($obj);
|
||||
$entityManager->flush();
|
||||
$SMS->send([$password],163543,$obj->getMobile());
|
||||
|
||||
$SMS->send(
|
||||
[$password],
|
||||
$registryMGR->get('sms','changePassword'),
|
||||
$obj->getMobile()
|
||||
);
|
||||
$email = (new Email())
|
||||
->to($obj->getEmail())
|
||||
->priority(Email::PRIORITY_HIGH)
|
||||
|
@ -401,7 +409,7 @@ class UserController extends AbstractController
|
|||
return $this->json(['result'=>'not correct','id'=>$user->getId(),'active'=>false]);
|
||||
}
|
||||
#[Route('/api/user/forget/password/send-code', name: 'api_user_forget_password_send_code')]
|
||||
public function api_user_forget_password_send_code(#[CurrentUser] ?User $user,SMS $SMS,MailerInterface $mailer,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
|
||||
public function api_user_forget_password_send_code(registryMGR $registryMGR,#[CurrentUser] ?User $user,SMS $SMS,MailerInterface $mailer,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -422,7 +430,11 @@ class UserController extends AbstractController
|
|||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
//send sms and email
|
||||
$SMS->send([$user->getVerifyCode()],'160887',$user->getMobile());
|
||||
$SMS->send(
|
||||
[$user->getVerifyCode()],
|
||||
$registryMGR->get('sms','recPassword'),
|
||||
$user->getMobile()
|
||||
);
|
||||
$email = (new Email())
|
||||
->to($user->getEmail())
|
||||
->priority(Email::PRIORITY_HIGH)
|
||||
|
|
|
@ -11,53 +11,53 @@ class SMS
|
|||
{
|
||||
private EntityManagerInterface $entityManager;
|
||||
private Settings $settings;
|
||||
private registryMGR $registryMGR;
|
||||
|
||||
private int $smsPrice = 2500;
|
||||
|
||||
/**
|
||||
* @param EntityManagerInterface $entityManager
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager,registryMGR $registryMGR)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->registryMGR = $registryMGR;
|
||||
$this->settings = $entityManager->getRepository(Settings::class)->findAll()[0];
|
||||
|
||||
}
|
||||
|
||||
public function send(array $params,$bodyID,$to): void
|
||||
{
|
||||
$settings = $this->entityManager->getRepository(Settings::class)->findAll()[0];
|
||||
if($settings->getActiveSmsPanel() == 'melipayamak'){
|
||||
if($this->registryMGR->get('sms','plan') == 'melipayamak'){
|
||||
try{
|
||||
$username = $this->settings->getPayamakUsername();
|
||||
$password = $this->settings->getPayamakPassword();
|
||||
$username = $this->registryMGR->get('sms','username');
|
||||
$password = $this->registryMGR->get('sms','password');
|
||||
$api = new MelipayamakApi($username,$password);
|
||||
$sms = $api->sms('soap');
|
||||
$response = $sms->sendByBaseNumber($params,$to,$bodyID);
|
||||
$json = json_decode($response);
|
||||
echo $json->Value; //RecId or Error Number
|
||||
|
||||
}catch(\Exception $e){
|
||||
//echo $e->getMessage();
|
||||
echo $e->getMessage();
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
elseif($settings->getActiveSmsPanel() == 'idePayam'){
|
||||
elseif($this->registryMGR->get('sms','plan') == 'idePayam'){
|
||||
ini_set("soap.wsdl_cache_enabled", "0");
|
||||
$patternID = $this->entityManager->getRepository(Registry::class)->findOneBy([
|
||||
'root'=>'sms',
|
||||
'name'=>$bodyID
|
||||
]);
|
||||
$fromNum = $this->entityManager->getRepository(Registry::class)->findOneBy([
|
||||
'root'=>'sms',
|
||||
'name'=>'fromNum'
|
||||
]);
|
||||
|
||||
//create next
|
||||
$pt = [];
|
||||
foreach($params as $param){
|
||||
$pt['{' + array_search($param,$params) + '}'] = $param;
|
||||
}
|
||||
$soap = new \SoapClient("http://185.112.33.61/wbs/send.php?wsdl");
|
||||
$soap->token = $this->settings->getMelipayamakToken();
|
||||
$soap->fromNum = $fromNum->getValueOfKey();
|
||||
$soap->token = $this->registryMGR->get('sms','username');
|
||||
$soap->fromNum = $this->registryMGR->get('sms','fromNum');
|
||||
$soap->toNum = array($to);
|
||||
$soap->patternID = $patternID->getValueOfKey();
|
||||
$soap->Content = json_encode($pt,JSON_UNESCAPED_UNICODE);
|
||||
|
|
Loading…
Reference in a new issue