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