瀏覽代碼

[Command] Activation de distributions à l'avance #1381

feature/souke
Guillaume Bourgeois 1 年之前
父節點
當前提交
4723c0f991
共有 5 個檔案被更改,包括 39 行新增30 行删除
  1. +10
    -0
      common/components/BusinessLogic.php
  2. +5
    -1
      common/helpers/GlobalParam.php
  3. +3
    -2
      console/commands/ActiveDistributionsInAdvanceController.php
  4. +21
    -0
      console/commands/ClosingOrdersController.php
  5. +0
    -27
      console/commands/DemoAccountController.php

+ 10
- 0
common/components/BusinessLogic.php 查看文件

@@ -3,10 +3,13 @@
namespace common\components;

use common\logic\Producer\Producer\Model\Producer;
use common\logic\ProducerContextTrait;
use yii\base\ErrorException;

class BusinessLogic
{
protected ?Producer $producerContext = null;

use BusinessLogicTrait;

public function getModules()
@@ -44,8 +47,15 @@ class BusinessLogic
];
}

public function getProducerContext(): ?Producer
{
return $this->producerContext;
}

public function setProducerContext(Producer $producer)
{
$this->producerContext = $producer;

foreach($this->getModules() as $module) {
foreach($module->getServices() as $serviceClass) {
$instanceService = $serviceClass::getInstance();

+ 5
- 1
common/helpers/GlobalParam.php 查看文件

@@ -80,7 +80,11 @@ class GlobalParam
if (!\Yii::$app->user->isGuest) {
return \Yii::$app->user->identity->id_producer;
}
} else {
}
elseif(\Yii::$app->controller->module->id == 'app-console') {
return \Yii::$app->logic->getProducerContext()->id;
}
else {
return \Yii::$app->controller->getProducerCurrent()->id;
}


+ 3
- 2
console/commands/ActiveDistributionsInAdvanceController.php 查看文件

@@ -16,10 +16,11 @@ class ActiveDistributionsInAdvanceController extends Controller
$producersArray = $producerModule->findProducersActive();
foreach($producersArray as $producer) {
\Yii::$app->logic->setProducerContext($producer);
$weeksDistributionsActivatedInAdvance = $producerModule->getConfig('option_weeks_distributions_activated_in_advance');
$weeksDistributionsActivatedInAdvance = $producerModule->getSolver()->getConfig('option_weeks_distributions_activated_in_advance');
if($weeksDistributionsActivatedInAdvance) {
$date = new \DateTime('+'.$weeksDistributionsActivatedInAdvance.' weeks');
$distributionModule->activeDistributionByDate($date);
$distributionModule->getBuilder()->activeDistributionByDate($date);
echo $producer->name. ' : distribution du ' . $date->format('d/m/Y') .' activée' ."\n";
}
}
}

+ 21
- 0
console/commands/ClosingOrdersController.php 查看文件

@@ -0,0 +1,21 @@
<?php

namespace console\commands;

use common\logic\Producer\Producer\Module\ProducerModule;
use yii\console\Controller;

class ClosingOrdersController extends Controller
{
public function actionIndex()
{
$producerModule = ProducerModule::getInstance();
$arrayProducers = $producerModule->getRepository()->findProducers();

foreach($arrayProducers as $producer) {

}
}
}

?>

+ 0
- 27
console/commands/DemoAccountController.php 查看文件

@@ -1,27 +0,0 @@
<?php

namespace console\commands;

use common\logic\Distribution\Distribution\Module\DistributionModule;
use common\logic\Producer\Producer\Module\ProducerModule;
use yii\console\Controller;

class DemoAccountController extends Controller
{
public function actionIndex()
{
$producerModule = ProducerModule::getInstance();
$distributionModule =DistributionModule::getInstance();

$producerDemo = $producerModule->findOneProducerDemoAccount();
\Yii::$app->logic->setProducerContext($producerDemo);

if ($producerDemo) {
$dateTime = strtotime("+7 day");
$distribution = $distributionModule->createDistributionIfNotExist(date('Y-m-d', $dateTime));
$distributionModule->activeDistribution($distribution);
}
}
}

?>

Loading…
取消
儲存