]; | ]; | ||||
} | } | ||||
/** | |||||
* Initialise le compte de démonstration. | |||||
* | |||||
* @param string $key | |||||
*/ | |||||
public function actionInitDemo($key = '') | |||||
{ | |||||
if ($key == '45432df6e842ac71aa0b5bb6b9f25d44') { | |||||
$producerManager = $this->getProducerManager(); | |||||
$distributionManager = $this->getDistributionManager(); | |||||
$producer = $producerManager->findOneProducerDemoAccount(); | |||||
$producerManager->setProducerContext($producer); | |||||
$distributionManager->setProducerContext($producer); | |||||
if ($producer) { | |||||
// initialisation de la distribution à J+7 | |||||
$dateTime = strtotime("+7 day"); | |||||
$dayStr = strtolower(date('l', $dateTime)); | |||||
$fieldDeliveryDay = 'delivery_' . $dayStr; | |||||
$pointsSaleArray = PointSale::searchAll(['point_sale.id_producer' => $producer->id]); | |||||
$activeDistribution = false; | |||||
foreach ($pointsSaleArray as $pointSale) { | |||||
if ($pointSale->$fieldDeliveryDay) { | |||||
$activeDistribution = true; | |||||
} | |||||
} | |||||
if ($activeDistribution) { | |||||
$distribution = $distributionManager->createDistributionIfNotExist(date('Y-m-d', $dateTime)); | |||||
$distributionManager->activeDistribution($distribution); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
public function actionPayOrders($date) | public function actionPayOrders($date) | ||||
{ | { | ||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; |
// active | // active | ||||
public function activeDistribution(Distribution $distribution, bool $active = true): void | public function activeDistribution(Distribution $distribution, bool $active = true): void | ||||
{ | { | ||||
$this->pointSaleDistributionBuilder->createAllPointSaleDistributions($distribution, true); | |||||
$distribution->active = (int) $active; | $distribution->active = (int) $active; | ||||
$this->saveUpdate($distribution); | |||||
$this->update($distribution); | |||||
$this->pointSaleDistributionBuilder->createAllPointSaleDistributions($distribution, true); | |||||
if ($active) { | if ($active) { | ||||
$distributionActiveEvent = new DistributionActiveEvent(); | $distributionActiveEvent = new DistributionActiveEvent(); |
public function afterFind() | public function afterFind() | ||||
{ | { | ||||
if ($this->taxRate == null) { | if ($this->taxRate == null) { | ||||
$producer = Producer::searchOne(['id' => GlobalParam::getCurrentProducerId()]); | |||||
$producer = Producer::searchOne(['id' => $this->id_producer]); | |||||
if ($producer) { | if ($producer) { | ||||
$this->populateRelation('taxRate', $producer->taxRate); | $this->populateRelation('taxRate', $producer->taxRate); | ||||
} | } |
"yidas/yii2-bower-asset": "2.0.13.1", | "yidas/yii2-bower-asset": "2.0.13.1", | ||||
"stripe/stripe-php": "^7.95", | "stripe/stripe-php": "^7.95", | ||||
"loveorigami/yii2-bootstrap-toggle": "*", | "loveorigami/yii2-bootstrap-toggle": "*", | ||||
"justcoded/yii2-event-listener": "*" | |||||
"justcoded/yii2-event-listener": "*", | |||||
"ext-pdo": "*" | |||||
}, | }, | ||||
"require-dev": { | "require-dev": { | ||||
"yiisoft/yii2-codeception": "*", | "yiisoft/yii2-codeception": "*", |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | ||||
"This file is @generated automatically" | "This file is @generated automatically" | ||||
], | ], | ||||
"content-hash": "a48eac3c3b38a39f09914e9a706604ce", | |||||
"content-hash": "7da17be4685def1e9635cc5ab5e5a7d9", | |||||
"packages": [ | "packages": [ | ||||
{ | { | ||||
"name": "2amigos/yii2-chartjs-widget", | "name": "2amigos/yii2-chartjs-widget", | ||||
"prefer-stable": false, | "prefer-stable": false, | ||||
"prefer-lowest": false, | "prefer-lowest": false, | ||||
"platform": { | "platform": { | ||||
"php": ">=7.4" | |||||
"php": ">=7.4", | |||||
"ext-pdo": "*" | |||||
}, | }, | ||||
"platform-dev": [], | "platform-dev": [], | ||||
"plugin-api-version": "2.3.0" | "plugin-api-version": "2.3.0" |
<?php | |||||
namespace console\commands; | |||||
use common\logic\Distribution\Distribution\Wrapper\DistributionManager; | |||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||||
use yii\console\Controller; | |||||
class DemoAccountController extends Controller | |||||
{ | |||||
public function actionIndex() | |||||
{ | |||||
$producerManager = ProducerManager::getInstance(); | |||||
$distributionManager = DistributionManager::getInstance(); | |||||
$producerDemo = $producerManager->findOneProducerDemoAccount(); | |||||
\Yii::$app->logic->setProducerContext($producerDemo); | |||||
if ($producerDemo) { | |||||
$dateTime = strtotime("+7 day"); | |||||
$distribution = $distributionManager->createDistributionIfNotExist(date('Y-m-d', $dateTime)); | |||||
$distributionManager->activeDistribution($distribution); | |||||
} | |||||
} | |||||
} | |||||
?> |
'id' => 'app-console', | 'id' => 'app-console', | ||||
'basePath' => dirname(__DIR__), | 'basePath' => dirname(__DIR__), | ||||
'bootstrap' => ['log'], | 'bootstrap' => ['log'], | ||||
'controllerNamespace' => 'console\controllers', | |||||
'controllerNamespace' => 'console\commands', | |||||
'components' => [ | 'components' => [ | ||||
'log' => [ | 'log' => [ | ||||
'targets' => [ | 'targets' => [ |