Quellcode durchsuchen

[Backend] Commande initialisation espace de démo #1167

feature/souke
Guillaume Bourgeois vor 1 Jahr
Ursprung
Commit
0e742de271
9 geänderte Dateien mit 37 neuen und 44 gelöschten Zeilen
  1. +0
    -37
      backend/controllers/CronController.php
  2. +3
    -2
      common/logic/Distribution/Distribution/Service/DistributionBuilder.php
  3. +1
    -1
      common/logic/Product/Product/Model/Product.php
  4. +2
    -1
      composer.json
  5. +3
    -2
      composer.lock
  6. +27
    -0
      console/commands/DemoAccountController.php
  7. +1
    -1
      console/config/main.php
  8. +0
    -0
      console/controllers/.gitkeep
  9. +0
    -0
      yii

+ 0
- 37
backend/controllers/CronController.php Datei anzeigen

@@ -78,43 +78,6 @@ class CronController extends BackendController
];
}

/**
* 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)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

+ 3
- 2
common/logic/Distribution/Distribution/Service/DistributionBuilder.php Datei anzeigen

@@ -185,9 +185,10 @@ class DistributionBuilder extends AbstractBuilder
// active
public function activeDistribution(Distribution $distribution, bool $active = true): void
{
$this->pointSaleDistributionBuilder->createAllPointSaleDistributions($distribution, true);
$distribution->active = (int) $active;
$this->saveUpdate($distribution);
$this->update($distribution);

$this->pointSaleDistributionBuilder->createAllPointSaleDistributions($distribution, true);

if ($active) {
$distributionActiveEvent = new DistributionActiveEvent();

+ 1
- 1
common/logic/Product/Product/Model/Product.php Datei anzeigen

@@ -178,7 +178,7 @@ class Product extends ActiveRecordCommon
public function afterFind()
{
if ($this->taxRate == null) {
$producer = Producer::searchOne(['id' => GlobalParam::getCurrentProducerId()]);
$producer = Producer::searchOne(['id' => $this->id_producer]);
if ($producer) {
$this->populateRelation('taxRate', $producer->taxRate);
}

+ 2
- 1
composer.json Datei anzeigen

@@ -32,7 +32,8 @@
"yidas/yii2-bower-asset": "2.0.13.1",
"stripe/stripe-php": "^7.95",
"loveorigami/yii2-bootstrap-toggle": "*",
"justcoded/yii2-event-listener": "*"
"justcoded/yii2-event-listener": "*",
"ext-pdo": "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",

+ 3
- 2
composer.lock Datei anzeigen

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a48eac3c3b38a39f09914e9a706604ce",
"content-hash": "7da17be4685def1e9635cc5ab5e5a7d9",
"packages": [
{
"name": "2amigos/yii2-chartjs-widget",
@@ -6482,7 +6482,8 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7.4"
"php": ">=7.4",
"ext-pdo": "*"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"

+ 27
- 0
console/commands/DemoAccountController.php Datei anzeigen

@@ -0,0 +1,27 @@
<?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);
}
}
}

?>

+ 1
- 1
console/config/main.php Datei anzeigen

@@ -47,7 +47,7 @@ return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'controllerNamespace' => 'console\commands',
'components' => [
'log' => [
'targets' => [

+ 0
- 0
console/controllers/.gitkeep Datei anzeigen


+ 0
- 0
yii Datei anzeigen


Laden…
Abbrechen
Speichern