|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
-
-
- namespace console\commands;
-
- use domain\Order\Order\OrderModule;
- use domain\Order\OrderStatus\OrderStatus;
- use domain\Producer\Producer\ProducerModule;
- use domain\User\User\UserModule;
- use yii\console\Controller;
-
- class InitOrderStatusHistoryController extends Controller
- {
-
- public function actionIndex()
- {
- ini_set('memory_limit', '-1');
-
-
-
-
- $producerModule = ProducerModule::getInstance();
- $orderModule = OrderModule::getInstance();
-
- $userSystem = UserModule::getInstance()->getRepository()->findOneUserSystem();
-
- foreach($producerModule->getRepository()->findProducers() as $producer) {
- \Yii::$app->logic->setProducerContext($producer);
-
- $ordersArray = $orderModule->getRepository()->findOrdersWithOrderStatusAliasNull();
- echo ($ordersArray ? count($ordersArray) : '0').' : '.$producer->name."\n";
-
- while ($ordersArray && count($ordersArray)) {
- foreach ($ordersArray as $order) {
- $orderModule->getManager()->changeOrderStatus(
- $order,
- OrderStatus::ALIAS_ORDERED,
- $userSystem,
- new \DateTime($order->date)
- );
- if($order->date_update) {
- $orderModule->getManager()->changeOrderStatus(
- $order,
- OrderStatus::ALIAS_UPDATED,
- $userSystem,
- new \DateTime($order->date_update)
- );
- }
- if($order->date_delete) {
- $orderModule->getManager()->changeOrderStatus(
- $order,
- OrderStatus::ALIAS_DELETED,
- $userSystem,
- new \DateTime($order->date_delete)
- );
- }
-
- echo 'Order #'.$order->id."\n";
- }
- $ordersArray = $orderModule->getRepository()->findOrdersWithOrderStatusAliasNull();
- }
- }
- }
- }
|