Просмотр исходного кода

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

feature/souke
Guillaume Bourgeois 1 год назад
Родитель
Сommit
0e742de271
9 измененных файлов: 37 добавлений и 44 удалений
  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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл



Загрузка…
Отмена
Сохранить