add special sms patern to accpro plugin
This commit is contained in:
parent
c1f35dad4b
commit
2e87a61539
|
@ -223,6 +223,9 @@ class AdminController extends AbstractController
|
|||
'creating' => $registryMGR->get('sms', 'plugRepserviceStateCreating'),
|
||||
'created' => $registryMGR->get('sms', 'plugRepserviceStateCreated')
|
||||
];
|
||||
$resp['plugAccpro'] = [
|
||||
'sharefaktor' => $registryMGR->get('sms', 'plugAccproSharefaktor'),
|
||||
];
|
||||
return $this->json($resp);
|
||||
}
|
||||
|
||||
|
@ -274,7 +277,10 @@ class AdminController extends AbstractController
|
|||
if (array_key_exists('created', $params['plugRepservice']))
|
||||
$registryMGR->update('sms', 'plugRepserviceStateCreated', $params['plugRepservice']['created']);
|
||||
}
|
||||
|
||||
if (array_key_exists('plugAccpro', $params)) {
|
||||
if (array_key_exists('sharefaktor', $params['plugAccpro']))
|
||||
$registryMGR->update('sms', 'plugAccproSharefaktor', $params['plugAccpro']['sharefaktor']);
|
||||
}
|
||||
|
||||
return $this->json(JsonResp::success());
|
||||
}
|
||||
|
@ -521,4 +527,20 @@ class AdminController extends AbstractController
|
|||
}
|
||||
return $this->json(array_reverse($temps));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
#[Route('/script', name: 'script')]
|
||||
public function script(EntityManagerInterface $entitymanager): JsonResponse
|
||||
{
|
||||
$items = $entitymanager->getRepository(\App\Entity\HesabdariDoc::class)->findAll();
|
||||
foreach($items as $item){
|
||||
$item->setDate(str_replace("-","/",$item->getDate()));
|
||||
$entitymanager->persist($item);
|
||||
$entitymanager->flush();
|
||||
|
||||
}
|
||||
echo str_replace("-","/","1403-02-06");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ use App\Service\Access;
|
|||
use App\Service\Jdate;
|
||||
use App\Service\Log;
|
||||
use App\Service\Notification;
|
||||
use App\Service\PluginService;
|
||||
use App\Service\Provider;
|
||||
use App\Service\registryMGR;
|
||||
use App\Service\SMS;
|
||||
|
@ -117,7 +118,8 @@ class SMSController extends AbstractController
|
|||
|
||||
//get system settings
|
||||
$settings = $entityManager->getRepository(Settings::class)->findAll()[0];
|
||||
$data = array("merchant_id" => $settings->getZarinpalMerchant(),
|
||||
$data = array(
|
||||
"merchant_id" => $settings->getZarinpalMerchant(),
|
||||
"amount" => $params['price'],
|
||||
"callback_url" => $this->generateUrl('api_sms_buy_verify', [], UrlGeneratorInterface::ABSOLUTE_URL),
|
||||
"description" => 'افزایش اعتبار سرویس پیامک',
|
||||
|
@ -223,7 +225,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(registryMGR $registryMGR, SMS $SMS,String $id,String $num,Provider $provider,Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): Response
|
||||
public function api_sms_send_invoice(PluginService $pluginService, 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)
|
||||
|
@ -243,12 +245,38 @@ class SMSController extends AbstractController
|
|||
if ($doc->getShortlink())
|
||||
$shortLink = $doc->getShortlink();
|
||||
|
||||
return $this->json(['result'=>
|
||||
//find custommer
|
||||
$customer = null;
|
||||
foreach ($doc->getHesabdariRows() as $row) {
|
||||
if ($row->getPerson())
|
||||
$customer = $row->getPerson();
|
||||
}
|
||||
if ($pluginService->isActive('accpro', $acc['bid']) && $customer && $bid->getTel()) {
|
||||
return $this->json([
|
||||
'result' =>
|
||||
$SMS->sendByBalance(
|
||||
[$customer->getnikename(), 'sell/' . $bid->getId() . '/' . $shortLink, $bid->getTel()],
|
||||
$registryMGR->get('sms', 'plugAccproSharefaktor'),
|
||||
$num,
|
||||
$bid,
|
||||
$this->getUser(),
|
||||
3
|
||||
)
|
||||
]);
|
||||
} else {
|
||||
return $this->json([
|
||||
'result' =>
|
||||
$SMS->sendByBalance(
|
||||
[$bid->getName(), 'sell/' . $bid->getId() . '/' . $shortLink],
|
||||
$registryMGR->get('sms', 'sharefaktor'),
|
||||
$num,$bid,$this->getUser(),3
|
||||
)]);
|
||||
$num,
|
||||
$bid,
|
||||
$this->getUser(),
|
||||
3
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
38
hesabixCore/src/Service/PluginService.php
Normal file
38
hesabixCore/src/Service/PluginService.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Business;
|
||||
use App\Entity\HesabdariDoc;
|
||||
use App\Entity\Plugin;
|
||||
use App\Entity\PlugRepserviceOrder;
|
||||
use App\Entity\User;
|
||||
use App\Module\RemoteAddress;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class PluginService
|
||||
{
|
||||
|
||||
private $em;
|
||||
private $remoteAddress;
|
||||
function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->em = $entityManager;
|
||||
}
|
||||
|
||||
public function isActive(string $plugin, Business | string | null $bid = null ): bool
|
||||
{
|
||||
if(is_string($bid))
|
||||
$bid = $this->em->getRepository(Business::class)->find($bid);
|
||||
$ps = $this->em->getRepository(Plugin::class)->findBy([
|
||||
'bid' =>$bid,
|
||||
'name'=>$plugin
|
||||
]);
|
||||
foreach($ps as $p){
|
||||
if($p->getDateExpire() > time()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue