commit
3330635d64
@ -2,8 +2,7 @@
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Command;
|
||||
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use RetailCrm\DeliveryModuleBundle\Exception\AbstractModuleException;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use RetailCrm\DeliveryModuleBundle\Service\AccountManager;
|
||||
use RetailCrm\DeliveryModuleBundle\Service\ModuleManagerInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
@ -16,6 +15,8 @@ class StatusesCommand extends Command
|
||||
{
|
||||
use LockableTrait;
|
||||
|
||||
const QUERY_MAX_RESULTS = 100;
|
||||
|
||||
/**
|
||||
* @var ModuleManagerInterface
|
||||
*/
|
||||
@ -26,6 +27,11 @@ class StatusesCommand extends Command
|
||||
*/
|
||||
private $accountManager;
|
||||
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -34,13 +40,15 @@ class StatusesCommand extends Command
|
||||
$this
|
||||
->setName('statuses:update')
|
||||
->setDescription('Update statuses')
|
||||
->addArgument('accountId', InputArgument::OPTIONAL, 'Choose account, or make it for all');
|
||||
->addArgument('accountId', InputArgument::OPTIONAL, 'Choose account, or make it for all')
|
||||
;
|
||||
}
|
||||
|
||||
public function __construct(ModuleManagerInterface $moduleManager, AccountManager $accountManager)
|
||||
public function __construct(ModuleManagerInterface $moduleManager, AccountManager $accountManager, ObjectManager $entityManager)
|
||||
{
|
||||
$this->moduleManager = $moduleManager;
|
||||
$this->accountManager = $accountManager;
|
||||
$this->entityManager = $entityManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@ -60,40 +68,57 @@ class StatusesCommand extends Command
|
||||
? (int) $input->getArgument('accountId')
|
||||
: null;
|
||||
|
||||
$paginator = [];
|
||||
$accountQueryBuilder = $this->accountManager->getActiveQueryBuilder()
|
||||
->andWhere('account.id > :lastId')
|
||||
->setMaxResults(static::QUERY_MAX_RESULTS)
|
||||
;
|
||||
|
||||
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);
|
||||
$accountQueryBuilder
|
||||
->andWhere('account.id = :accountId')
|
||||
->setParameter('accountId', $accountId)
|
||||
;
|
||||
}
|
||||
|
||||
$accountQuery = $accountQueryBuilder->getQuery();
|
||||
|
||||
$commandResult = 0;
|
||||
$count = 0;
|
||||
foreach ($paginator as $account) {
|
||||
try {
|
||||
$count += $this->moduleManager
|
||||
->setAccount($account)
|
||||
->updateStatuses()
|
||||
;
|
||||
} catch (AbstractModuleException $e) {
|
||||
$output->writeln(
|
||||
"<error>Failed to update statuses for account {$account->getCrmUrl()}[{$account->getId()}]</error>"
|
||||
);
|
||||
$output->writeln("<error>Error: {$e->getMessage()}</error>");
|
||||
$lastId = 0;
|
||||
while (true) {
|
||||
$accountQuery->setParameter('lastId', $lastId);
|
||||
|
||||
$result = $accountQuery->getResult();
|
||||
if (empty($result)) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($result as $account) {
|
||||
$lastId = $account->getId();
|
||||
|
||||
try {
|
||||
$count += $this->moduleManager
|
||||
->setAccount($account)
|
||||
->updateStatuses()
|
||||
;
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(
|
||||
"<error>Failed to update statuses for account {$account->getCrmUrl()}[{$account->getId()}]</error>"
|
||||
);
|
||||
$output->writeln("<error>Error: {$e->getMessage()}</error>");
|
||||
|
||||
$commandResult = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->entityManager->clear();
|
||||
gc_collect_cycles();
|
||||
}
|
||||
|
||||
$output->writeln("<info>{$count} statuses updated.</info>");
|
||||
|
||||
$this->release();
|
||||
|
||||
return 0;
|
||||
return $commandResult;
|
||||
}
|
||||
}
|
||||
|
21
Command/Traits/CommandOutputFormatterTrait.php
Normal file
21
Command/Traits/CommandOutputFormatterTrait.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Command\Traits;
|
||||
|
||||
trait CommandOutputFormatterTrait
|
||||
{
|
||||
public function getMessage(string $level, string $message): string
|
||||
{
|
||||
return sprintf('%s %s %s', date('Y-m-d H:i:s'), strtoupper($level), $message);
|
||||
}
|
||||
|
||||
public function getInfoMessage(string $message): string
|
||||
{
|
||||
return $this->getMessage('INFO', $message);
|
||||
}
|
||||
|
||||
public function getErrorMessage(string $message): string
|
||||
{
|
||||
return $this->getMessage('ERROR', $message);
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Command;
|
||||
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use RetailCrm\DeliveryModuleBundle\Service\AccountManager;
|
||||
use RetailCrm\DeliveryModuleBundle\Service\ModuleManagerInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
@ -15,6 +15,8 @@ class UpdateModuleCommand extends Command
|
||||
{
|
||||
use LockableTrait;
|
||||
|
||||
const QUERY_MAX_RESULTS = 100;
|
||||
|
||||
/**
|
||||
* @var ModuleManagerInterface
|
||||
*/
|
||||
@ -25,6 +27,11 @@ class UpdateModuleCommand extends Command
|
||||
*/
|
||||
private $accountManager;
|
||||
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -33,13 +40,15 @@ class UpdateModuleCommand extends Command
|
||||
$this
|
||||
->setName('module:update')
|
||||
->setDescription('Update module')
|
||||
->addArgument('accountId', InputArgument::OPTIONAL, 'Choose account, or make it for all');
|
||||
->addArgument('accountId', InputArgument::OPTIONAL, 'Choose account, or make it for all')
|
||||
;
|
||||
}
|
||||
|
||||
public function __construct(ModuleManagerInterface $moduleManager, AccountManager $accountManager)
|
||||
public function __construct(ModuleManagerInterface $moduleManager, AccountManager $accountManager, ObjectManager $entityManager)
|
||||
{
|
||||
$this->moduleManager = $moduleManager;
|
||||
$this->accountManager = $accountManager;
|
||||
$this->entityManager = $entityManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@ -56,44 +65,61 @@ class UpdateModuleCommand extends Command
|
||||
}
|
||||
|
||||
$accountId = $input->getArgument('accountId')
|
||||
? $input->getArgument('accountId')
|
||||
: null;
|
||||
?: null;
|
||||
|
||||
$accountQueryBuilder = $this->accountManager->getActiveQueryBuilder()
|
||||
->andWhere('account.id > :lastId')
|
||||
->setMaxResults(static::QUERY_MAX_RESULTS)
|
||||
;
|
||||
|
||||
$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);
|
||||
$accountQueryBuilder
|
||||
->andWhere('account.id = :accountId')
|
||||
->setParameter('accountId', $accountId)
|
||||
;
|
||||
}
|
||||
|
||||
$accountQuery = $accountQueryBuilder->getQuery();
|
||||
|
||||
$commandResult = 0;
|
||||
$count = 0;
|
||||
foreach ($paginator as $account) {
|
||||
try {
|
||||
$this->moduleManager
|
||||
->setAccount($account)
|
||||
->updateModuleConfiguration()
|
||||
;
|
||||
++$count;
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(
|
||||
"<error>Failed to update configuration for account {$account->getCrmUrl()}[{$account->getId()}]</error>"
|
||||
);
|
||||
$output->writeln("<error>Error: {$e->getMessage()}</error>");
|
||||
|
||||
$lastId = 0;
|
||||
while (true) {
|
||||
$accountQuery->setParameter('lastId', $lastId);
|
||||
|
||||
$result = $accountQuery->getResult();
|
||||
if (empty($result)) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($result as $account) {
|
||||
$lastId = $account->getId();
|
||||
|
||||
try {
|
||||
$this->moduleManager
|
||||
->setAccount($account)
|
||||
->updateModuleConfiguration()
|
||||
;
|
||||
++$count;
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(
|
||||
"<error>Failed to update configuration for account {$account->getCrmUrl()}[{$account->getId()}]</error>"
|
||||
);
|
||||
$output->writeln("<error>Error: {$e->getMessage()}</error>");
|
||||
|
||||
$commandResult = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->entityManager->clear();
|
||||
gc_collect_cycles();
|
||||
}
|
||||
|
||||
$output->writeln("<info>{$count} modules updated.</info>");
|
||||
|
||||
$this->release();
|
||||
|
||||
return 0;
|
||||
return $commandResult;
|
||||
}
|
||||
}
|
||||
|
26
Model/BaseStore.php
Normal file
26
Model/BaseStore.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
class BaseStore
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("code")
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("name")
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
public $name;
|
||||
}
|
@ -79,7 +79,7 @@ class Customer
|
||||
*
|
||||
* @Serializer\Groups({"get"})
|
||||
* @Serializer\SerializedName("contragent")
|
||||
* @Serializer\Type("RetailCrm\DeliveryModuleBundle\Model\Model\Contragent")
|
||||
* @Serializer\Type("RetailCrm\DeliveryModuleBundle\Model\Contragent")
|
||||
*/
|
||||
public $contragent;
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Request;
|
||||
|
||||
use Intaro\CRMBundle\Entity\Model\DeliveryTime;
|
||||
use DateTime;
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\DeliveryTime;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Traits\ExtraDataTrait;
|
||||
|
||||
class RequestCalculate
|
||||
{
|
||||
use Traits\ExtraDataTrait;
|
||||
use ExtraDataTrait;
|
||||
|
||||
/**
|
||||
* Адрес отгрузки.
|
||||
@ -23,7 +25,7 @@ class RequestCalculate
|
||||
/**
|
||||
* Адрес доставки.
|
||||
*
|
||||
* @var string
|
||||
* @var RetailCrm\DeliveryModuleBundle\Model\DeliveryAddress
|
||||
*
|
||||
* @Serializer\Groups({"request", "calculate"})
|
||||
* @Serializer\SerializedName("deliveryAddress")
|
||||
@ -34,7 +36,7 @@ class RequestCalculate
|
||||
/**
|
||||
* Набор упаковок.
|
||||
*
|
||||
* @var Intaro\CRMDeliveryBundle\Form\Model\Package[]
|
||||
* @var RetailCrm\DeliveryModuleBundle\Model\Package[]
|
||||
*
|
||||
* @Serializer\Groups({"request", "calculate"})
|
||||
* @Serializer\SerializedName("packages")
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Customer;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Manager;
|
||||
|
||||
class RequestSave
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Traits\ExtraDataTrait;
|
||||
|
||||
class RequestShipmentSave
|
||||
{
|
||||
use Traits\ExtraDataTrait;
|
||||
use ExtraDataTrait;
|
||||
|
||||
/**
|
||||
* Идентификатор отгрузки в службе доставки. Передается если требуется отредактировать уже оформленную отгрузку
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\StatusInfo;
|
||||
|
||||
class RequestStatusUpdateItem
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
|
||||
use DateTime;
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
class RequestCalculate
|
||||
@ -11,7 +12,7 @@ class RequestCalculate
|
||||
/**
|
||||
* Адрес отгрузки.
|
||||
*
|
||||
* @var RetailCrm\DeliveryModuleBundle\Model\DeliveryAddress
|
||||
* @var DeliveryAddress
|
||||
*
|
||||
* @Serializer\Groups({"request", "calculate"})
|
||||
* @Serializer\SerializedName("shipmentAddress")
|
||||
@ -22,7 +23,7 @@ class RequestCalculate
|
||||
/**
|
||||
* Адрес доставки.
|
||||
*
|
||||
* @var string
|
||||
* @var DeliveryAddress
|
||||
*
|
||||
* @Serializer\Groups({"request", "calculate"})
|
||||
* @Serializer\SerializedName("deliveryAddress")
|
||||
@ -33,7 +34,7 @@ class RequestCalculate
|
||||
/**
|
||||
* Набор упаковок.
|
||||
*
|
||||
* @var RetailCrm\DeliveryModuleBundle\Model\Package[]
|
||||
* @var Package[]
|
||||
*
|
||||
* @Serializer\Groups({"request", "calculate"})
|
||||
* @Serializer\SerializedName("packages")
|
||||
@ -74,6 +75,17 @@ class RequestCalculate
|
||||
*/
|
||||
public $payerType;
|
||||
|
||||
/**
|
||||
* Дата отгрузки.
|
||||
*
|
||||
* @var \DateTime
|
||||
*
|
||||
* @Serializer\Groups({"request", "calculate"})
|
||||
* @Serializer\SerializedName("shipmentDate")
|
||||
* @Serializer\Type("DateTime<'Y-m-d'>")
|
||||
*/
|
||||
public $shipmentDate;
|
||||
|
||||
/**
|
||||
* Дата доставки.
|
||||
*
|
||||
@ -117,4 +129,15 @@ class RequestCalculate
|
||||
* @Serializer\Type("array")
|
||||
*/
|
||||
public $extraData;
|
||||
|
||||
/**
|
||||
* Склад отгрузки.
|
||||
*
|
||||
* @var BaseStore
|
||||
*
|
||||
* @Serializer\Groups({"request", "calculate"})
|
||||
* @Serializer\SerializedName("store")
|
||||
* @Serializer\Type("RetailCrm\DeliveryModuleBundle\Model\BaseStore")
|
||||
*/
|
||||
public $store;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Response;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Response;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Response;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Terminal;
|
||||
|
||||
class ResponseCalculate
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Response;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Response;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\DeliveryAddress;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\StatusInfo;
|
||||
|
||||
class ResponseLoadDeliveryData
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Response;
|
||||
|
||||
class ResponseResult
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Response;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Response;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model\Response;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
|
@ -53,7 +53,7 @@ class ResponseLoadDeliveryData
|
||||
/**
|
||||
* Время доставки
|
||||
*
|
||||
* @var RetailCrm\DeliveryModuleBundle\Model\DeliveryTime
|
||||
* @var DeliveryTime
|
||||
*
|
||||
* @Serializer\Groups({"response"})
|
||||
* @Serializer\SerializedName("deliveryTime")
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Settings\ExtraData;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Settings\PaymentType;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Settings\ShipmentPoint;
|
||||
use RetailCrm\DeliveryModuleBundle\Model\Settings\Status;
|
||||
@ -77,7 +76,7 @@ class Settings
|
||||
public $statuses;
|
||||
|
||||
/**
|
||||
* @var array|ExtraData[]
|
||||
* @var array
|
||||
*
|
||||
* @Serializer\Groups({"set", "get"})
|
||||
* @Serializer\SerializedName("deliveryExtraData")
|
||||
@ -86,7 +85,7 @@ class Settings
|
||||
public $deliveryExtraData;
|
||||
|
||||
/**
|
||||
* @var array|ExtraData[]
|
||||
* @var array
|
||||
*
|
||||
* @Serializer\Groups({"set", "get"})
|
||||
* @Serializer\SerializedName("shipmentExtraData")
|
||||
|
@ -4,23 +4,14 @@ namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
class Store
|
||||
class Store extends BaseStore
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @var StoreWorkTime
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("code")
|
||||
* @Serializer\Type("string")
|
||||
* @Serializer\SerializedName("workTime")
|
||||
* @Serializer\Type("RetailCrm\DeliveryModuleBundle\Model\StoreWorkTime")
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("name")
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
public $name;
|
||||
public $workTime;
|
||||
}
|
||||
|
71
Model/StoreWorkTime.php
Normal file
71
Model/StoreWorkTime.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
class StoreWorkTime
|
||||
{
|
||||
/**
|
||||
* @var array<StoreWorkTimeItem>
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("mo")
|
||||
* @Serializer\Type("array<RetailCrm\DeliveryModuleBundle\Model\StoreWorkTimeItem>")
|
||||
*/
|
||||
public $monday;
|
||||
|
||||
/**
|
||||
* @var array<StoreWorkTimeItem>
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("tu")
|
||||
* @Serializer\Type("array<RetailCrm\DeliveryModuleBundle\Model\StoreWorkTimeItem>")
|
||||
*/
|
||||
public $tuesday;
|
||||
|
||||
/**
|
||||
* @var array<StoreWorkTimeItem>
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("we")
|
||||
* @Serializer\Type("array<RetailCrm\DeliveryModuleBundle\Model\StoreWorkTimeItem>")
|
||||
*/
|
||||
public $wednesday;
|
||||
|
||||
/**
|
||||
* @var array<StoreWorkTimeItem>
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("th")
|
||||
* @Serializer\Type("array<RetailCrm\DeliveryModuleBundle\Model\StoreWorkTimeItem>")
|
||||
*/
|
||||
public $thursday;
|
||||
|
||||
/**
|
||||
* @var array<StoreWorkTimeItem>
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("fr")
|
||||
* @Serializer\Type("array<RetailCrm\DeliveryModuleBundle\Model\StoreWorkTimeItem>")
|
||||
*/
|
||||
public $friday;
|
||||
|
||||
/**
|
||||
* @var array<StoreWorkTimeItem>
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("sa")
|
||||
* @Serializer\Type("array<RetailCrm\DeliveryModuleBundle\Model\StoreWorkTimeItem>")
|
||||
*/
|
||||
public $saturday;
|
||||
|
||||
/**
|
||||
* @var array<StoreWorkTimeItem>
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("su")
|
||||
* @Serializer\Type("array<RetailCrm\DeliveryModuleBundle\Model\StoreWorkTimeItem>")
|
||||
*/
|
||||
public $sunday;
|
||||
}
|
44
Model/StoreWorkTimeItem.php
Normal file
44
Model/StoreWorkTimeItem.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
class StoreWorkTimeItem
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("startTime")
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
public $startTime;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("endTime")
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
public $endTime;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("lunchStartTime")
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
public $lunchStartTime;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @Serializer\Groups({"request"})
|
||||
* @Serializer\SerializedName("lunchEndTime")
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
public $lunchEndTime;
|
||||
}
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace RetailCrm\DeliveryModuleBundle\Model;
|
||||
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
class Unit
|
||||
{
|
||||
/**
|
||||
|
@ -52,4 +52,13 @@ class AccountManager
|
||||
{
|
||||
return $this->entityManager->getRepository($this->class);
|
||||
}
|
||||
|
||||
public function getActiveQueryBuilder()
|
||||
{
|
||||
return $this->getRepository()->createQueryBuilder('account')
|
||||
->where('account.active = true')
|
||||
->andWhere('account.freeze != true')
|
||||
->orderBy('account.id')
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,16 @@ use RetailCrm\DeliveryModuleBundle\Model\Entity\DeliveryOrder;
|
||||
|
||||
class DeliveryOrderManager
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $class;
|
||||
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
public function __construct(string $deliveryOrderClass, ObjectManager $entityManager)
|
||||
{
|
||||
$this->class = $deliveryOrderClass;
|
||||
|
@ -79,7 +79,7 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
protected $logger;
|
||||
|
||||
public function __construct(
|
||||
array $moduleParameters,
|
||||
@ -157,8 +157,9 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
return true;
|
||||
} else {
|
||||
if ($this->logger) {
|
||||
$errorMsg = $response['error_msg'] ?? '';
|
||||
$this->logger->warning("Failed to update module configuration[account={$this->getAccount()->getCrmUrl()}]:{$errorMsg}");
|
||||
$errorMsg = $response['errorMsg'] ?? '';
|
||||
$errors = json_encode($response['errors'] ?? '');
|
||||
$this->logger->warning("Failed to update module configuration[account={$this->getAccount()->getCrmUrl()}]: {$errorMsg}. Detailed errors: {$errors}");
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -238,7 +239,7 @@ abstract class ModuleManager implements ModuleManagerInterface
|
||||
{
|
||||
$deliveries = $this->deliveryManager->findBy([
|
||||
'account' => $this->account,
|
||||
'externalId' => $request->deliveryIds,
|
||||
'externalId' => $request->deliveryIds[0] ?? null,
|
||||
]);
|
||||
|
||||
if (empty($deliveries)) {
|
||||
|
@ -20,15 +20,21 @@
|
||||
"jms/serializer-bundle": "^3.5",
|
||||
"ramsey/uuid": "^3.9",
|
||||
"ramsey/uuid-doctrine": "^1.5",
|
||||
"retailcrm/api-client-php": "^5.0.0",
|
||||
"symfony/framework-bundle": "^3.4|^4.0|^5.1",
|
||||
"symfony/lock": "^5.1",
|
||||
"symfony/routing": "^5.1",
|
||||
"symfony/translation": "^5.1",
|
||||
"symfony/validator": "^5.1"
|
||||
"retailcrm/api-client-php": "dev-add-logger@dev",
|
||||
"symfony/framework-bundle": "^3.4|^4.0|^5.0",
|
||||
"symfony/lock": "^5.0",
|
||||
"symfony/routing": "^5.0",
|
||||
"symfony/translation": "^5.0",
|
||||
"symfony/validator": "^5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/doctrine-fixtures-bundle": "^3.3",
|
||||
"friendsofphp/php-cs-fixer": "^2.0"
|
||||
}
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/raulleo/api-client-php.git"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user