Common refactoring in bundle
This commit is contained in:
parent
db9e8d788d
commit
b55b0cf46b
@ -2,7 +2,7 @@
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Command;
|
||||
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use RetailCrm\DeliveryModuleBundle\Command\Traits\AccountAwareTrait;
|
||||
use RetailCrm\DeliveryModuleBundle\Exception\AbstractModuleException;
|
||||
use RetailCrm\DeliveryModuleBundle\Service\AccountManager;
|
||||
use RetailCrm\DeliveryModuleBundle\Service\ModuleManagerInterface;
|
||||
@ -15,6 +15,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
class StatusesCommand extends Command
|
||||
{
|
||||
use LockableTrait;
|
||||
use AccountAwareTrait;
|
||||
|
||||
/**
|
||||
* @var ModuleManagerInterface
|
||||
@ -60,23 +61,10 @@ class StatusesCommand extends Command
|
||||
? (int) $input->getArgument('accountId')
|
||||
: null;
|
||||
|
||||
$paginator = [];
|
||||
if (null !== $accountId) {
|
||||
$paginator = [$this->accountManager - find($accountId)];
|
||||
} else {
|
||||
$accountQuery = $this->accountManager->getRepository()
|
||||
->createQueryBuilder('account')
|
||||
->where('account.active = true')
|
||||
->andWhere('account.freeze != true')
|
||||
->addOrderBy('account.id')
|
||||
->getQuery()
|
||||
->setFirstResult(0)
|
||||
->setMaxResults(100);
|
||||
$paginator = new Paginator($accountQuery);
|
||||
}
|
||||
$accounts = $this->getAccounts($accountId);
|
||||
|
||||
$count = 0;
|
||||
foreach ($paginator as $account) {
|
||||
foreach ($accounts as $account) {
|
||||
try {
|
||||
$count += $this->moduleManager
|
||||
->setAccount($account)
|
||||
|
25
Command/Traits/AccountAwareTrait.php
Normal file
25
Command/Traits/AccountAwareTrait.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Command\Traits;
|
||||
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
|
||||
trait AccountAwareTrait
|
||||
{
|
||||
protected function getAccounts(int $accountId = null): \ArrayIterator
|
||||
{
|
||||
if (null === $accountId) {
|
||||
return new \ArrayIterator([$this->accountManager->find($accountId)]);
|
||||
}
|
||||
|
||||
$accountQuery = $this->accountManager->getRepository()->createQueryBuilder('account')
|
||||
->where('account.active = true')
|
||||
->andWhere('account.freeze != true')
|
||||
->addOrderBy('account.id')
|
||||
->getQuery()
|
||||
->setFirstResult(0)
|
||||
->setMaxResults(100)
|
||||
;
|
||||
return (new Paginator($accountQuery))->getIterator();
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Command;
|
||||
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use RetailCrm\DeliveryModuleBundle\Command\Traits\AccountAwareTrait;
|
||||
use RetailCrm\DeliveryModuleBundle\Service\AccountManager;
|
||||
use RetailCrm\DeliveryModuleBundle\Service\ModuleManagerInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
@ -14,6 +14,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
class UpdateModuleCommand extends Command
|
||||
{
|
||||
use LockableTrait;
|
||||
use AccountAwareTrait;
|
||||
|
||||
/**
|
||||
* @var ModuleManagerInterface
|
||||
@ -55,27 +56,14 @@ class UpdateModuleCommand extends Command
|
||||
return 0;
|
||||
}
|
||||
|
||||
$accountId = $input->getArgument('accountId')
|
||||
? $input->getArgument('accountId')
|
||||
$accountId = $input->hasArgument('accountId')
|
||||
? (int) $input->getArgument('accountId')
|
||||
: null;
|
||||
|
||||
$paginator = [];
|
||||
if (null !== $accountId) {
|
||||
$paginator = [$this->accountManager->find($accountId)];
|
||||
} else {
|
||||
$accountQuery = $this->accountManager->getRepository()
|
||||
->createQueryBuilder('account')
|
||||
->where('account.active = true')
|
||||
->andWhere('account.freeze != true')
|
||||
->addOrderBy('account.id')
|
||||
->getQuery()
|
||||
->setFirstResult(0)
|
||||
->setMaxResults(100);
|
||||
$paginator = new Paginator($accountQuery);
|
||||
}
|
||||
$accounts = $this->getAccounts($accountId);
|
||||
|
||||
$count = 0;
|
||||
foreach ($paginator as $account) {
|
||||
foreach ($accounts as $account) {
|
||||
try {
|
||||
$this->moduleManager
|
||||
->setAccount($account)
|
||||
|
@ -1,394 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Controller;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Knp\Component\Pager\PaginatorInterface;
|
||||
use RetailCrm\DeliveryModuleBundle\Entity\Connection;
|
||||
use RetailCrm\DeliveryModuleBundle\Service;
|
||||
use RetailCrm\DeliveryModuleBundle\Service\BaseDelivery;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
||||
|
||||
abstract class AdminController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Базовый роут
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getRoute();
|
||||
|
||||
/**
|
||||
* Сервис для работы с апи службы доставки.
|
||||
*
|
||||
* @return BaseDelivery
|
||||
*/
|
||||
abstract protected function getDeliveryApi();
|
||||
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* @var PaginatorInterface
|
||||
*/
|
||||
protected $knpPaginator;
|
||||
|
||||
/**
|
||||
* @var Service\OpenSsl
|
||||
*/
|
||||
protected $openSsl;
|
||||
|
||||
/**
|
||||
* @var FlashBagInterface
|
||||
*/
|
||||
protected $flashBag;
|
||||
|
||||
/**
|
||||
* AdminController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ObjectManager $entityManager,
|
||||
PaginatorInterface $knpPaginator,
|
||||
Service\OpenSsl $openSsl,
|
||||
FlashBagInterface $flashBag
|
||||
) {
|
||||
$this->entityManager = $entityManager;
|
||||
$this->knpPaginator = $knpPaginator;
|
||||
$this->openSsl = $openSsl;
|
||||
$this->flashBag = $flashBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getShortBundle()
|
||||
{
|
||||
return strtr('Intaro\DeliveryModuleBundle', ['\\' => '']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getNameService()
|
||||
{
|
||||
$bundle = explode('\\', 'Intaro\DeliveryModuleBundle');
|
||||
|
||||
return strtr(end($bundle), ['Bundle' => '']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function listAction(Request $request)
|
||||
{
|
||||
$clientsQuery = $this->entityManager->createQuery('
|
||||
SELECT connection
|
||||
FROM ' . $this->getConnectionClass() . ' connection
|
||||
');
|
||||
|
||||
$pagination = $this->knpPaginator->paginate(
|
||||
$clientsQuery,
|
||||
$request->query->getInt('page', 1),
|
||||
20
|
||||
);
|
||||
|
||||
return $this->render(
|
||||
$this->getShortBundle() . ':Connection:list.html.twig',
|
||||
['pagination' => $pagination, 'route' => $this->getRoute()]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function newAction(Request $request)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_DEVELOPER');
|
||||
|
||||
$connectionClass = $this->getConnectionClass();
|
||||
$connection = new $connectionClass();
|
||||
$connection->setEncoder($this->openSsl);
|
||||
$connectionTypeClass = 'Intaro\DeliveryModuleBundle\Form\ConnectionType';
|
||||
$form = $this->createForm($connectionTypeClass, $connection, [
|
||||
'container' => $this->container,
|
||||
'is_admin' => true,
|
||||
]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$connection->generateClientId();
|
||||
$this->actualizeWebhooks($connection);
|
||||
$this->entityManager->persist($connection);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute($this->getRoute() . '_admin_edit', [
|
||||
'connectionId' => $connection->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
$this->getShortBundle() . ':Connection:edit.html.twig',
|
||||
['route' => $this->getRoute(), 'form' => $form->createView()]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $connectionId
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function editAction(Request $request, $connectionId)
|
||||
{
|
||||
$connection = $this->entityManager
|
||||
->getRepository($this->getConnectionClass())
|
||||
->find($connectionId);
|
||||
if (null === $connection) {
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
$connectionTypeClass = 'Intaro\DeliveryModuleBundle\Form\ConnectionType';
|
||||
$form = $this->createForm($connectionTypeClass, $connection, [
|
||||
'container' => $this->container,
|
||||
'is_admin' => true,
|
||||
]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->actualizeWebhooks($connection);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute($this->getRoute() . '_admin_edit', [
|
||||
'connectionId' => $connection->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
$this->getShortBundle() . ':Connection:edit.html.twig',
|
||||
[
|
||||
'route' => $this->getRoute(),
|
||||
'connection' => $connection,
|
||||
'form' => $form->createView(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $connectionId
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function updateConfigurationAction(Request $request, $connectionId)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_DEVELOPER');
|
||||
|
||||
$api = $this->getDeliveryApi();
|
||||
|
||||
$connection = $this->entityManager
|
||||
->getRepository($this->getConnectionClass())
|
||||
->find($connectionId);
|
||||
|
||||
$api->setConnection($connection);
|
||||
$result = $api->updateConfiguration();
|
||||
|
||||
if (isset($result['success']) && $result['success']) {
|
||||
$this->flashBag->add('notice', 'ChangesWereSaved');
|
||||
} else {
|
||||
$this->flashBag->add('error', 'ChangesWereNotSaved');
|
||||
}
|
||||
|
||||
return $this->redirectToRoute($this->getRoute() . '_admin_edit', [
|
||||
'connectionId' => $connection->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function parcelListAction(Request $request)
|
||||
{
|
||||
$parcelsQuery = $this->entityManager->createQuery('
|
||||
SELECT parcel
|
||||
FROM ' . $this->getParcelClass() . ' parcel
|
||||
');
|
||||
|
||||
$pagination = $this->knpPaginator->paginate(
|
||||
$parcelsQuery,
|
||||
$request->query->getInt('page', 1),
|
||||
20
|
||||
);
|
||||
|
||||
return $this->render(
|
||||
$this->getShortBundle() . ':Parcel:list.html.twig',
|
||||
['route' => $this->getRoute(), 'pagination' => $pagination]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function parcelNewAction(Request $request)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_DEVELOPER');
|
||||
|
||||
$parcelClass = $this->getParcelClass();
|
||||
$parcel = new $parcelClass();
|
||||
$parcelTypeClass = 'Intaro\DeliveryModuleBundle\Form\ParcelType';
|
||||
$form = $this->createForm($parcelTypeClass, $parcel, [
|
||||
'connection_class' => $this->getConnectionClass(),
|
||||
]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->persist($parcel);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute($this->getRoute() . '_admin_parcel_list');
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
$this->getShortBundle() . ':Parcel:edit.html.twig',
|
||||
['form' => $form->createView(), 'parcel' => $parcel]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $parcelId
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function parcelEditAction(Request $request, $parcelId)
|
||||
{
|
||||
$parcel = $this->entityManager
|
||||
->getRepository($this->getParcelClass())
|
||||
->find(['id' => $parcelId]);
|
||||
|
||||
$parcelTypeClass = 'Intaro\DeliveryModuleBundle\Form\ParcelType';
|
||||
$form = $this->createForm($parcelTypeClass, $parcel, [
|
||||
'connection_class' => $this->getConnectionClass(),
|
||||
]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute($this->getRoute() . '_admin_parcel_list');
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
$this->getShortBundle() . ':Parcel:edit.html.twig',
|
||||
['form' => $form->createView(), 'parcel' => $parcel]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function connectAction(Request $request)
|
||||
{
|
||||
$api = $this->getDeliveryApi();
|
||||
|
||||
$referer = $request->headers->get('referer');
|
||||
$account = $request->query->get('account');
|
||||
$accountUrl = null;
|
||||
if (!empty($account)) {
|
||||
$accountUrl = null === parse_url($account, PHP_URL_HOST)
|
||||
? null : 'https://' . parse_url($account, PHP_URL_HOST);
|
||||
}
|
||||
|
||||
if (
|
||||
!empty($request->request->get('clientId'))
|
||||
|| !empty($request->attributes->get('clientId'))
|
||||
) {
|
||||
if (!empty($request->request->get('clientId'))) {
|
||||
$clientId = $request->request->get('clientId');
|
||||
} else {
|
||||
$clientId = $request->attributes->get('clientId');
|
||||
}
|
||||
|
||||
$connection = $this->entityManager
|
||||
->getRepository($this->getConnectionClass())
|
||||
->findOneBy([
|
||||
'clientId' => $clientId,
|
||||
]);
|
||||
$accountUrl = $connection->getCrmUrl();
|
||||
} else {
|
||||
$class = $this->getConnectionClass();
|
||||
$connection = new $class();
|
||||
$connection
|
||||
->setLanguage($request->getLocale())
|
||||
->setEncoder($this->openSsl);
|
||||
}
|
||||
|
||||
$connectionTypeClass = 'Intaro\DeliveryModuleBundle\Form\ConnectionType';
|
||||
$form = $this->createForm($connectionTypeClass, $connection, [
|
||||
'container' => $this->container,
|
||||
'is_admin' => false,
|
||||
]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$connectionIsCreated = true;
|
||||
if (empty($connection->getClientId())) {
|
||||
$connection->generateClientId();
|
||||
$connectionIsCreated = false;
|
||||
}
|
||||
|
||||
$api->setConnection($connection);
|
||||
$this->actualizeWebhooks($connection);
|
||||
$result = $api->updateConfiguration();
|
||||
if (isset($result['success']) && $result['success']) {
|
||||
if (!$connectionIsCreated) {
|
||||
$this->entityManager->persist($connection);
|
||||
}
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirect($connection->getCrmUrl() . '/admin/integration/list');
|
||||
} else {
|
||||
$srcLogo = $request->getUriForPath(
|
||||
'/bundles/delivery'
|
||||
. strtolower($this->getNameService())
|
||||
. '/images/'
|
||||
. strtolower($this->getNameService())
|
||||
. '.svg'
|
||||
);
|
||||
|
||||
return $this->render(
|
||||
'DeliveryCoreBundle:Connection:configure_error.html.twig',
|
||||
[
|
||||
'referer' => $referer,
|
||||
'errors' => $result,
|
||||
'title_delivery' => $this->getNameService(),
|
||||
'src_logo_delivery' => $srcLogo,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
$this->getShortBundle() . ':Connection:configure.html.twig',
|
||||
[
|
||||
'route' => $this->getRoute(),
|
||||
'form' => $form->createView(),
|
||||
'account' => $accountUrl,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualize webhooks.
|
||||
*/
|
||||
protected function actualizeWebhooks(Connection $connection)
|
||||
{
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@ use JMS\Serializer\SerializationContext;
|
||||
use JMS\Serializer\SerializerInterface;
|
||||
use RetailCrm\DeliveryModuleBundle\Exception;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\AbstractResponseSuccessful;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Calculate;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Entity\DeliveryOrder;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\IntegrationModule;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\RequestCalculate;
|
||||
@ -31,7 +30,6 @@ use RetailCrm\DeliveryModuleBundle\Service\ModuleManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception as SymfonyException;
|
||||
|
||||
@ -61,8 +59,7 @@ class ApiController extends AbstractController implements ClientIdSecuredControl
|
||||
SerializerInterface $jmsSerializer,
|
||||
ModuleManagerInterface $moduleManager,
|
||||
AccountManager $accountManager,
|
||||
DeliveryOrderManager $deliveryOrderManager,
|
||||
RequestStack $requestStack
|
||||
DeliveryOrderManager $deliveryOrderManager
|
||||
) {
|
||||
$this->jmsSerializer = $jmsSerializer;
|
||||
$this->moduleManager = $moduleManager;
|
||||
@ -72,14 +69,14 @@ class ApiController extends AbstractController implements ClientIdSecuredControl
|
||||
|
||||
public function activity(Request $request): JsonResponse
|
||||
{
|
||||
if (!is_string($request->request->get('activity'))) {
|
||||
$requestData = $request->request->get('activity');
|
||||
if (!is_string($requestData)) {
|
||||
return $this->getInvalidResponse('Parameter "activity" must be json', 400);
|
||||
}
|
||||
$activity = $request->request->get('activity');
|
||||
|
||||
try {
|
||||
$requestModel = $this->jmsSerializer->deserialize(
|
||||
$activity,
|
||||
$requestData,
|
||||
IntegrationModule::class,
|
||||
'json',
|
||||
DeserializationContext::create()->setGroups(['activity'])
|
||||
@ -90,9 +87,7 @@ class ApiController extends AbstractController implements ClientIdSecuredControl
|
||||
|
||||
$this->moduleManager->getAccount()->setActive($requestModel->active);
|
||||
$this->moduleManager->getAccount()->setFreeze($requestModel->freeze);
|
||||
|
||||
$systemUrl = $request->request->get('systemUrl');
|
||||
$this->moduleManager->getAccount()->setCrmUrl($systemUrl);
|
||||
$this->moduleManager->getAccount()->setCrmUrl($request->request->get('systemUrl'));
|
||||
|
||||
$this->accountManager->flush();
|
||||
|
||||
@ -101,10 +96,11 @@ class ApiController extends AbstractController implements ClientIdSecuredControl
|
||||
|
||||
public function calculate(Request $request): JsonResponse
|
||||
{
|
||||
if (!is_string($request->request->get('calculate'))) {
|
||||
$requestData = $request->request->get('calculate');
|
||||
if (!is_string($requestData)) {
|
||||
return $this->getInvalidResponse('Parameter "calculate" must be json', 400);
|
||||
}
|
||||
$requestData = $request->request->get('calculate');
|
||||
|
||||
try {
|
||||
$requestModel = $this->jmsSerializer->deserialize(
|
||||
$requestData,
|
||||
@ -132,10 +128,11 @@ class ApiController extends AbstractController implements ClientIdSecuredControl
|
||||
|
||||
public function save(Request $request): JsonResponse
|
||||
{
|
||||
if (!is_string($request->request->get('save'))) {
|
||||
$requestData = $request->request->get('save');
|
||||
if (!is_string($requestData)) {
|
||||
return $this->getInvalidResponse('Parameter "save" must be json', 400);
|
||||
}
|
||||
$requestData = $request->request->get('save');
|
||||
|
||||
try {
|
||||
$requestModel = $this->jmsSerializer->deserialize(
|
||||
$requestData,
|
||||
@ -222,10 +219,11 @@ class ApiController extends AbstractController implements ClientIdSecuredControl
|
||||
|
||||
public function delete(Request $request): JsonResponse
|
||||
{
|
||||
if (!is_string($request->request->get('delete'))) {
|
||||
$requestData = $request->request->get('delete');
|
||||
if (!is_string($requestData)) {
|
||||
return $this->getInvalidResponse('Parameter "delete" must be json', 400);
|
||||
}
|
||||
$requestData = $request->request->get('delete');
|
||||
|
||||
try {
|
||||
$requestModel = $this->jmsSerializer->deserialize(
|
||||
$requestData,
|
||||
@ -290,10 +288,11 @@ class ApiController extends AbstractController implements ClientIdSecuredControl
|
||||
|
||||
public function print(Request $request): Response
|
||||
{
|
||||
if (!is_string($request->request->get('print'))) {
|
||||
$requestData = $request->request->get('print');
|
||||
if (!is_string($requestData)) {
|
||||
return $this->getInvalidResponse('Parameter "print" must be json', 400);
|
||||
}
|
||||
$requestData = $request->request->get('print');
|
||||
|
||||
try {
|
||||
$requestModel = $this->jmsSerializer->deserialize(
|
||||
$requestData,
|
||||
@ -338,10 +337,11 @@ class ApiController extends AbstractController implements ClientIdSecuredControl
|
||||
|
||||
public function shipmentSave(Request $request): JsonResponse
|
||||
{
|
||||
if (!is_string($request->request->get('shipmentSave'))) {
|
||||
$requestData = $request->request->get('shipmentSave');
|
||||
if (!is_string($requestData)) {
|
||||
return $this->getInvalidResponse('Parameter "shipmentSave" must be json', 400);
|
||||
}
|
||||
$requestData = $request->request->get('shipmentSave');
|
||||
|
||||
try {
|
||||
$requestModel = $this->jmsSerializer->deserialize(
|
||||
$requestData,
|
||||
@ -366,10 +366,11 @@ class ApiController extends AbstractController implements ClientIdSecuredControl
|
||||
|
||||
public function shipmentDelete(Request $request): JsonResponse
|
||||
{
|
||||
if (!is_string($request->request->get('shipmentDelete'))) {
|
||||
$requestData = $request->request->get('shipmentDelete');
|
||||
if (!is_string($requestData)) {
|
||||
return $this->getInvalidResponse('Parameter "shipmentDelete" must be json', 400);
|
||||
}
|
||||
$requestData = $request->request->get('shipmentDelete');
|
||||
|
||||
try {
|
||||
$requestModel = $this->jmsSerializer->deserialize(
|
||||
$requestData,
|
||||
@ -442,7 +443,7 @@ class ApiController extends AbstractController implements ClientIdSecuredControl
|
||||
|
||||
protected function doShipmentPointList(RequestShipmentPointList $requestModel): array
|
||||
{
|
||||
return $this->moduleManager->shipmentPointList($requestModel);
|
||||
return $this->moduleManager->getShipmentPointList($requestModel);
|
||||
}
|
||||
|
||||
protected function doShipmentSave(RequestShipmentSave $requestModel): ResponseShipmentSave
|
||||
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\EventListener;
|
||||
|
||||
use JMS\Serializer\EventDispatcher\Events;
|
||||
use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
|
||||
use JMS\Serializer\EventDispatcher\PreSerializeEvent;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\ResponseResult;
|
||||
|
||||
class SerializeListener implements EventSubscriberInterface
|
||||
{
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
['event' => Events::PRE_SERIALIZE, 'method' => 'onPreSerialize', 'class' => ResponseResult::class],
|
||||
];
|
||||
}
|
||||
|
||||
public function onPreSerialize(PreSerializeEvent $event)
|
||||
{
|
||||
if (is_object($event->getObject())) {
|
||||
$event->setType(get_class($event->getObject()));
|
||||
} else {
|
||||
$event->setType('string');
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ConfigureEditType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('connectionId', null, [
|
||||
'label' => 'label.connectionId',
|
||||
'required' => true,
|
||||
'attr' => [
|
||||
'placeholder' => 'label.connectionId'
|
||||
]
|
||||
])
|
||||
->add('crmKey', null, [
|
||||
'label' => 'label.crmKey',
|
||||
'required' => true,
|
||||
'attr' => [
|
||||
'placeholder' => 'label.crmKey'
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ConnectionType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('crmUrl', TextType::class, [
|
||||
'label' => 'label.crmUrl',
|
||||
'required' => true,
|
||||
'attr' => [
|
||||
'placeholder' => 'label.crmUrl',
|
||||
'pattern' => '^(https?:\/\/)?([\da-z0-9\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$',
|
||||
],
|
||||
'translation_domain' => 'messages'
|
||||
])
|
||||
->add('crmKey', TextType::class, [
|
||||
'label' => 'label.crmKey',
|
||||
'required' => true,
|
||||
'attr' => [
|
||||
'placeholder' => 'label.crmKey'
|
||||
],
|
||||
'translation_domain' => 'messages'
|
||||
])
|
||||
->add('isActive', CheckboxType::class, [
|
||||
'label' => 'label.isActive',
|
||||
'required' => false,
|
||||
'translation_domain' => 'messages'
|
||||
])
|
||||
->add('language', ChoiceType::class, [
|
||||
'label' => 'label.language',
|
||||
'choices' => [
|
||||
'RU' => 'ru',
|
||||
'EN' => 'en',
|
||||
'ES' => 'es'
|
||||
],
|
||||
'required' => true,
|
||||
'translation_domain' => 'messages'
|
||||
])
|
||||
->add('isFreeze', CheckboxType::class, [
|
||||
'label' => 'label.isFreeze',
|
||||
'required' => false,
|
||||
'translation_domain' => 'messages'
|
||||
]);
|
||||
|
||||
if ($options['is_admin']) {
|
||||
$builder
|
||||
->add('debug', CheckboxType::class, [
|
||||
'label' => 'label.debug',
|
||||
'required' => false,
|
||||
'translation_domain' => 'messages'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setRequired(['container', 'is_admin']);
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Form;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
abstract class ParcelType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add(
|
||||
'connection',
|
||||
EntityType::class,
|
||||
[
|
||||
'class' => $options['connection_class'],
|
||||
'label' => 'label.connection',
|
||||
'translation_domain' => 'messages'
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'orderId',
|
||||
TextType::class,
|
||||
[
|
||||
'label' => 'label.orderId',
|
||||
'translation_domain' => 'messages'
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'trackId',
|
||||
TextType::class,
|
||||
[
|
||||
'label' => 'label.trackId',
|
||||
'translation_domain' => 'messages'
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'isClosed',
|
||||
CheckboxType::class,
|
||||
[
|
||||
'required' => false,
|
||||
'label' => 'label.isClosed',
|
||||
'translation_domain' => 'messages'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setRequired(['connection_class']);
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
{% form_theme form 'DeliveryCoreBundle:Form:configure.html.twig' %}
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>
|
||||
{% block title %}{% endblock %}
|
||||
</title>
|
||||
<link rel="stylesheet" href="{{ asset('bundles/coreautomate/css/connect.css') }}" />
|
||||
<link rel="shortcut icon" href="{{ asset('favicon.ico') }}" type="image/x-icon">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper" style="width:100%;">
|
||||
<div class="top">
|
||||
<div class="header">
|
||||
<div>
|
||||
{% block logo %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="blue_line"></div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="form-style-5">
|
||||
{% block form %}
|
||||
<div style="text-align: justify; margin-bottom: 10px;">
|
||||
{{ form_errors(form) }}
|
||||
</div>
|
||||
|
||||
<form name="connection" method="post" {{ form.vars.data.clientId is not empty ? ('action="' ~ path(route ~ '_configure_edit', {'clientId': form.vars.data.clientId}) ~ '"')|raw }} >
|
||||
{{ form_start(form) }}
|
||||
|
||||
{% block form_delivery %}
|
||||
{% endblock %}
|
||||
|
||||
<fieldset>
|
||||
<legend class="header_form_text">{{ 'header.configureConnection'|trans }}</legend>
|
||||
{{ form_widget(form.crmUrl, {'attr': {'value': account}}) }}
|
||||
{{ form_errors(form.crmUrl) }}
|
||||
|
||||
{{ form_widget(form.crmKey) }}
|
||||
{{ form_errors(form.crmKey) }}
|
||||
|
||||
{{ form_widget(form.language) }}
|
||||
{{ form_errors(form.language) }}
|
||||
</fieldset>
|
||||
|
||||
{% block form_delivery_after %}
|
||||
{% endblock %}
|
||||
|
||||
<div style="display: none">
|
||||
{{ form_rest(form) }}
|
||||
</div>
|
||||
<input type="submit" value="{{ (form.vars.data.clientId is not empty ? 'button.save' : 'button.activate')|trans }}" />
|
||||
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,13 +0,0 @@
|
||||
{% extends 'CoreAutomateBundle:Layout:connect.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{{ 'header.serviceConnect'|trans({'%delivery%': title_delivery})|raw }}
|
||||
{% endblock %}
|
||||
|
||||
{% block logo %}
|
||||
<img style="height: 60px" src="{{ src_logo_delivery }}" alt="{{ title_delivery }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block form %}
|
||||
{{ 'error.connect.failed'|trans({'%delivery%': title_delivery, '%href%': referer})|raw }}
|
||||
{% endblock %}
|
@ -1,60 +0,0 @@
|
||||
{% extends 'CoreOmegaBundle:Layout:base.html.twig' %}
|
||||
{% form_theme form 'DeliveryCoreBundle:Form:admin.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="header-main">
|
||||
<h1 style="margin: 10px 0 10px 0;">
|
||||
{% if connection is defined %}
|
||||
{{ 'header.adminConnectionEdit'|trans({'%uid%': '<a target="_blank" href="'~connection.crmUrl~'">'~connection.crmUrl~'</a>'})|raw }}
|
||||
{% else %}
|
||||
{{ 'header.adminConnectionCreate'|trans()|raw }}
|
||||
{% endif %}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="main">
|
||||
<div class="m-box mn-or-info">
|
||||
{{ form_start(form) }}
|
||||
{{ form_errors(form) }}
|
||||
|
||||
<div class="field-for-group cleared">
|
||||
{{ form_row(form.crmUrl) }}
|
||||
{{ form_row(form.crmKey) }}
|
||||
|
||||
{{ form_row(form.isActive) }}
|
||||
|
||||
{% if form.language is defined %}
|
||||
{{ form_row(form.language) }}
|
||||
{% endif %}
|
||||
|
||||
{{ form_row(form.isFreeze) }}
|
||||
</div>
|
||||
|
||||
{% block form_appendix %}
|
||||
{% endblock %}
|
||||
|
||||
<div class="field-for-group cleared">
|
||||
{{ form_row(form.debug) }}
|
||||
</div>
|
||||
|
||||
<div class="field-for-group cleared">
|
||||
<div class="input-group cleared">
|
||||
<input type="submit" name="submit" value="{{ 'button.save'|trans()|raw }}" class="btn small btn-save"/>
|
||||
</div>
|
||||
{% if is_granted('ROLE_DEVELOPER') %}
|
||||
{% if connection is defined %}
|
||||
<div class="input-group cleared">
|
||||
<a href="{{ path(route ~ '_admin_update_configuration', {'connectionId': connection.id}) }}" class="btn small btn-save">
|
||||
{{ 'button.updateConfiguration'|trans()|raw }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{{ form_end(form) }}
|
||||
</div>
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -1,61 +0,0 @@
|
||||
{% extends 'CoreOmegaBundle:Layout:base.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="header-main">
|
||||
<h1 style="margin: 10px 0 10px 0;">{{ 'header.listConnection'|trans()|raw }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="main">
|
||||
<div style="margin: 5px 0 15px 0;">
|
||||
{% if is_granted('ROLE_DEVELOPER') %}
|
||||
<a href="{{ path(route ~ '_admin_new') }}" class="btn small btn-save">
|
||||
{{ 'button.add'|trans()|raw }}
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{{ path(route ~ '_admin_parcel_list') }}" class="btn small btn-save">
|
||||
{{ 'button.listTracking'|trans()|raw }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<table class="modern-table">
|
||||
<tr>
|
||||
<th style="text-align: left">{{ 'label.id'|trans()|raw }}</th>
|
||||
<th>{{ 'label.crmUrl'|trans()|raw }}</th>
|
||||
<th style="text-align: center">{{ 'label.isActive'|trans()|raw }}</th>
|
||||
</tr>
|
||||
{% for client in pagination %}
|
||||
<tr>
|
||||
<td style="text-align: left">
|
||||
<a href="{{ path(route ~ '_admin_edit', {'connectionId': client.id}) }}">{{ client.clientId }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if client.crmUrl is not empty %}
|
||||
<a target="_blank" href="{{ client.crmUrl }}">
|
||||
{{ client.crmUrl }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td style="text-align: center">
|
||||
{% if client.isActive %}
|
||||
<img src="{{ asset('bundles/coreomega/images/mark-yes.svg') }}" style="width: 20px; height: 20px;"/>
|
||||
{% else %}
|
||||
<img src="{{ asset('bundles/coreomega/images/mark-no.svg') }}" style="width: 20px; height: 20px;" />
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<div class="list-bottom">
|
||||
<div class="list-total-stripe">
|
||||
<span id="list-total-count">
|
||||
{{ pagination.getTotalItemCount }} <span>{{ 'pagination.items.name'|trans()|raw }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="paginator">
|
||||
{{ knp_pagination_render(pagination) }}
|
||||
</div>
|
||||
</div>
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -1,18 +0,0 @@
|
||||
{% extends "form_div_layout.html.twig" %}
|
||||
|
||||
{% block form_row %}
|
||||
{% spaceless %}
|
||||
<div class="input-group cleared">
|
||||
{{ form_label(form, null, {'label_attr' : {'class': 'label-common'}}) }}
|
||||
{{ form_errors(form) }}
|
||||
|
||||
{% if not attr or not attr.class|default(null) %}
|
||||
{% set attr = attr|default({})|merge({
|
||||
'class': 'input-field',
|
||||
'style': 'max-width: 320px;'
|
||||
}) %}
|
||||
{% endif %}
|
||||
{{ form_widget(form, { 'attr': attr }) }}
|
||||
</div>
|
||||
{% endspaceless %}
|
||||
{% endblock form_row %}
|
@ -1,13 +0,0 @@
|
||||
{% extends "form_div_layout.html.twig" %}
|
||||
|
||||
{% block form_errors %}
|
||||
{% spaceless %}
|
||||
{% if errors|length > 0 %}
|
||||
{% for error in errors %}
|
||||
<div class="form_error_message">
|
||||
<span style="color: #ff0000;">{{ error.message }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endspaceless %}
|
||||
{% endblock form_errors %}
|
@ -1,61 +0,0 @@
|
||||
{% extends 'CoreOmegaBundle:Layout:base.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="header-main">
|
||||
<h1 style="margin: 10px 0 10px 0;">
|
||||
{% if parcel.id is not empty %}
|
||||
{{ 'header.adminParcelEdit' |trans({'%trackId%': parcel.trackId})|raw }}
|
||||
{% else %}
|
||||
{{ 'header.adminParcelCreate' |trans()|raw }}
|
||||
{% endif %}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="main">
|
||||
<div class="m-box mn-or-info">
|
||||
{{ form_start(form) }}
|
||||
{{ form_errors(form) }}
|
||||
|
||||
<div class="field-for-group cleared">
|
||||
<div class="input-group cleared">
|
||||
{{ form_label(form.connection, null, {'label_attr' : {'class': 'label-common'}}) }}
|
||||
{{ form_errors(form.connection) }}
|
||||
{{ form_widget(form.connection, {'attr': {'class': 'input-field', 'style': 'width: 320px;'}}) }}
|
||||
</div>
|
||||
|
||||
<div class="input-group cleared">
|
||||
{{ form_label(form.orderId, null, {'label_attr' : {'class': 'label-common'}}) }}
|
||||
{{ form_errors(form.orderId) }}
|
||||
{{ form_widget(form.orderId, {'attr': {'class': 'input-field', 'style': 'width: 320px;'}}) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field-for-group cleared">
|
||||
<div class="input-group cleared">
|
||||
{{ form_label(form.trackId, null, {'label_attr' : {'class': 'label-common'}}) }}
|
||||
{{ form_errors(form.trackId) }}
|
||||
{{ form_widget(form.trackId, {'attr': {'class': 'input-field', 'style': 'width: 320px;'}}) }}
|
||||
</div>
|
||||
|
||||
<div class="input-group cleared">
|
||||
{{ form_label(form.isClosed, null, {'label_attr' : {'class': 'label-common'}}) }}
|
||||
{{ form_errors(form.isClosed) }}
|
||||
{{ form_widget(form.isClosed) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% block form_appendix %}
|
||||
{% endblock %}
|
||||
|
||||
<div class="field-for-group cleared">
|
||||
<div class="input-group cleared">
|
||||
<input type="submit" name="submit" value="{{ 'button.save' |trans()|raw }}" class="btn small btn-save"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ form_end(form) }}
|
||||
</div>
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
{% endblock%}
|
@ -1,60 +0,0 @@
|
||||
{% extends 'CoreOmegaBundle:Layout:base.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="header-main">
|
||||
<h1 style="margin: 10px 0 10px 0;">{{ 'header.listConnection'|trans()|raw }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="main">
|
||||
<div style="margin: 5px 0 15px 0;">
|
||||
<a href="{{ path(route ~ '_admin_list') }}" class="btn small btn-save">
|
||||
{{ 'button.listConnection'|trans()|raw }}
|
||||
</a>
|
||||
{% if is_granted('ROLE_DEVELOPER') %}
|
||||
<a href="{{ path(route ~ '_admin_parcel_new') }}" class="btn small btn-save">
|
||||
{{ 'button.addTracking'|trans()|raw }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<table class="modern-table">
|
||||
<tr>
|
||||
<th style="text-align: left">{{ 'label.trackId'|trans()|raw }}</th>
|
||||
<th style="text-align: left">{{ 'label.orderId'|trans()|raw }}</th>
|
||||
<th style="text-align: left">{{ 'label.connection'|trans()|raw }}</th>
|
||||
<th style="text-align: center">{{ 'label.isClosed'|trans()|raw }}</th>
|
||||
</tr>
|
||||
{% for track in pagination %}
|
||||
<tr>
|
||||
<td style="text-align: left">
|
||||
<a href="{{ path(route ~ '_admin_parcel_edit', {'parcelId': track.id}) }}">{{ track.trackId}}</a>
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
{{ track.orderId}}
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
<a href="{{ path(route ~ '_admin_edit', {'connectionId': track.connection.id}) }}">{{ track.clientId}}</a>
|
||||
</td>
|
||||
<td style="text-align: center">
|
||||
{% if track.isClosed %}
|
||||
<img src="{{ asset('bundles/coreomega/images/mark-yes.svg') }}" style="width: 20px; height: 20px;"/>
|
||||
{% else %}
|
||||
<img src="{{ asset('bundles/coreomega/images/mark-no.svg') }}" style="width: 20px; height: 20px;" />
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<div class="list-bottom">
|
||||
<div class="list-total-stripe">
|
||||
<span id="list-total-count">
|
||||
{{ pagination.getTotalItemCount }} <span>{{ 'pagination.items.name'|trans()|raw }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="paginator">
|
||||
{{ knp_pagination_render(pagination) }}
|
||||
</div>
|
||||
</div>
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
{% endblock%}
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Service;
|
||||
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use JMS\Serializer\SerializationContext;
|
||||
use JMS\Serializer\SerializerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -19,19 +18,16 @@ use RetailCrm\DeliveryModuleBundle\Model\RequestSave;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\RequestShipmentDelete;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\RequestShipmentPointList;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\RequestShipmentSave;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\RequestStatusUpdateItem;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\ResponseLoadDeliveryData;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\ResponseSave;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\ResponseShipmentSave;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Terminal;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
abstract class ModuleManager implements ModuleManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $integrationCode;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -47,11 +43,6 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
*/
|
||||
protected $account;
|
||||
|
||||
/**
|
||||
* @var MockHandler
|
||||
*/
|
||||
protected $mockHandler;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
@ -95,7 +86,6 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
TranslatorInterface $translator,
|
||||
UrlGeneratorInterface $router
|
||||
) {
|
||||
$this->integrationCode = $moduleParameters['integration_code'];
|
||||
$this->moduleParameters = $moduleParameters;
|
||||
$this->retailCrmClientFactory = $retailCrmClientFactory;
|
||||
$this->deliveryManager = $deliveryManager;
|
||||
@ -105,13 +95,18 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
$this->pinbaService = new PinbaService();
|
||||
}
|
||||
|
||||
public function getIntegrationCode(): string
|
||||
{
|
||||
return $this->moduleParameters['integration_code'];
|
||||
}
|
||||
|
||||
public function getAccountCode(): string
|
||||
{
|
||||
if (null === $this->account) {
|
||||
throw new \LogicException('Account is not selected');
|
||||
}
|
||||
|
||||
return sprintf('%s-%s', $this->integrationCode, $this->account->getId());
|
||||
return sprintf('%s-%s', $this->getIntegrationCode(), $this->account->getId());
|
||||
}
|
||||
|
||||
public function getAccount(): ?Account
|
||||
@ -138,10 +133,9 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
throw new \LogicException('Account is not selected');
|
||||
}
|
||||
|
||||
$integrationModule = $this->buildIntegrationModule();
|
||||
$integrationModule = $this->jmsSerializer
|
||||
->serialize(
|
||||
$integrationModule,
|
||||
$this->buildIntegrationModule(),
|
||||
'json',
|
||||
SerializationContext::create()->setGroups(['get', 'request'])->setSerializeNull(true)
|
||||
);
|
||||
@ -176,7 +170,7 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
$integrationModule = new IntegrationModule();
|
||||
|
||||
$integrationModule->code = $this->getAccountCode();
|
||||
$integrationModule->integrationCode = $this->integrationCode;
|
||||
$integrationModule->integrationCode = $this->getIntegrationCode();
|
||||
$integrationModule->active = $this->account->isActive();
|
||||
$integrationModule->name = $this->moduleParameters['locales'][$this->translator->getLocale()]['name'];
|
||||
$integrationModule->logo = $this->moduleParameters['locales'][$this->translator->getLocale()]['logo'];
|
||||
@ -223,9 +217,9 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\DeliveryModuleBundle\Model\Terminal[]
|
||||
* @return Terminal[]
|
||||
*/
|
||||
public function shipmentPointList(RequestShipmentPointList $request): array
|
||||
public function getShipmentPointList(RequestShipmentPointList $request): array
|
||||
{
|
||||
throw new \LogicException('Method should be implemented');
|
||||
}
|
||||
@ -314,9 +308,9 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
/**
|
||||
* Получение актуальных статусов доставки от службы доставки.
|
||||
*
|
||||
* @param \RetailCrm\DeliveryModuleBundle\Entity\Parcel[] $deliveries
|
||||
* @param array $deliveries
|
||||
*
|
||||
* @return \RetailCrm\DeliveryModuleBundle\Model\RequestStatusUpdateItem[]
|
||||
* @return RequestStatusUpdateItem[]
|
||||
*/
|
||||
protected function doUpdateStatuses(array $deliveries): array
|
||||
{
|
||||
@ -326,7 +320,7 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
/**
|
||||
* Обновление статусов в CRM.
|
||||
*
|
||||
* @param \RetailCrm\DeliveryModuleBundle\Model\RequestStatusUpdateItem[] $deliveriesHistory
|
||||
* @param RequestStatusUpdateItem[] $deliveriesHistory
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
@ -344,7 +338,7 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
|
||||
$client = $this->retailCrmClient;
|
||||
$moduleCode = $this->getAccountCode();
|
||||
$response = $this->pinbaService->timerHandler(
|
||||
$this->pinbaService->timerHandler(
|
||||
[
|
||||
'api' => 'retailCrm',
|
||||
'method' => 'deliveryTracking',
|
||||
|
@ -12,8 +12,10 @@ use RetailCrm\DeliveryModuleBundle\Model\RequestSave;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\RequestShipmentDelete;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\RequestShipmentPointList;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\RequestShipmentSave;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\ResponseLoadDeliveryData;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\ResponseSave;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\ResponseShipmentSave;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Terminal;
|
||||
|
||||
interface ModuleManagerInterface
|
||||
{
|
||||
@ -31,12 +33,14 @@ interface ModuleManagerInterface
|
||||
|
||||
public function saveDelivery(RequestSave $data, DeliveryOrder $delivery = null): ResponseSave;
|
||||
|
||||
public function getDelivery(string $externalId): ResponseLoadDeliveryData;
|
||||
|
||||
public function deleteDelivery(RequestDelete $request, DeliveryOrder $delivery): bool;
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\DeliveryModuleBundle\Model\Terminal[]
|
||||
* @return Terminal[]
|
||||
*/
|
||||
public function shipmentPointList(RequestShipmentPointList $request): array;
|
||||
public function getShipmentPointList(RequestShipmentPointList $request): array;
|
||||
|
||||
public function saveShipment(RequestShipmentSave $data): ResponseShipmentSave;
|
||||
|
||||
|
@ -12,7 +12,7 @@ class PinbaService
|
||||
*/
|
||||
public function timerHandler(array $tags, \Closure $handler)
|
||||
{
|
||||
if (function_exists('pinba_timer_start')) {
|
||||
if (function_exists('pinba_timer_start') && function_exists('pinba_timer_stop')) {
|
||||
$timer = pinba_timer_start($tags);
|
||||
$response = $handler();
|
||||
pinba_timer_stop($timer);
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Service;
|
||||
|
||||
use App\Entity\Account;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RetailCrm\ApiClient;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Entity\Account;
|
||||
|
||||
class RetailCrmClientFactory implements RetailCrmClientFactoryInterface
|
||||
{
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Service;
|
||||
|
||||
use App\Entity\Account;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RetailCrm\ApiClient;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Entity\Account;
|
||||
|
||||
interface RetailCrmClientFactoryInterface
|
||||
{
|
||||
|
@ -8,18 +8,23 @@
|
||||
"RetailCrm\\DeliveryModuleBundle\\": ""
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.3",
|
||||
"ramsey/uuid": "^3.9",
|
||||
"ramsey/uuid-doctrine": "^1.5",
|
||||
"symfony/framework-bundle": "^3.4|^4.0|^5.0",
|
||||
"ext-json": "*",
|
||||
"ext-zip": "*",
|
||||
"doctrine/orm": "^2.7",
|
||||
"jms/serializer": "^3.4",
|
||||
"jms/serializer-bundle": "^3.5",
|
||||
"doctrine/orm": "^2.7",
|
||||
"symfony/lock": "^5.0",
|
||||
"ramsey/uuid": "^3.9",
|
||||
"ramsey/uuid-doctrine": "^1.5",
|
||||
"retailcrm/api-client-php": "dev-add-logger@dev",
|
||||
"symfony/translation": "^5.0",
|
||||
"symfony/routing": "^5.0"
|
||||
"symfony/framework-bundle": "^3.4|^4.0|^5.0",
|
||||
"symfony/lock": "^5.0",
|
||||
"symfony/routing": "^5.0",
|
||||
"symfony/translation": "^5.0"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
|
2638
composer.lock
generated
2638
composer.lock
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user