Przeglądaj źródła

Correctif

refactoring
Guillaume Bourgeois 1 rok temu
rodzic
commit
41ef7f2fe4
2 zmienionych plików z 12 dodań i 6 usunięć
  1. +5
    -1
      common/logic/Order/Order/Service/OrderSolver.php
  2. +7
    -5
      producer/controllers/OrderController.php

+ 5
- 1
common/logic/Order/Order/Service/OrderSolver.php Wyświetl plik

@@ -364,7 +364,11 @@ class OrderSolver extends AbstractService implements SolverInterface
// belongsToUser
public function isOrderBelongsToUser(Order $order, User $user = null): bool
{
return $order->id_user == $user->id;
if($user) {
return $order->id_user == $user->id;
}

return false;
}

/**

+ 7
- 5
producer/controllers/OrderController.php Wyświetl plik

@@ -140,6 +140,8 @@ class OrderController extends ProducerBaseController

$orderManager = $this->getOrderManager();
$producerManager = $this->getProducerManager();
$userManager = $this->getUserManager();

$producer = $this->getProducerCurrent();
$redirect = null;
$idProducer = $producer->id;
@@ -192,9 +194,8 @@ class OrderController extends ProducerBaseController
$user = new User;
$user->id_producer = 0;
$user->type = User::TYPE_GUEST;
$password = Password::generate();
$user->setPassword($password);
$user->generateAuthKey();
$userManager->setPassword($user, Password::generate());
$userManager->generateAuthKey($user);
$user->username = $posts['user']['email'];
$user->email = $posts['user']['email'];
$user->name = $posts['user']['firstname'];
@@ -564,10 +565,11 @@ class OrderController extends ProducerBaseController
public function actionConfirm(int $idOrder, string $returnPayment = '')
{
$orderManager = $this->getOrderManager();

$order = $orderManager->findOneOrderById($idOrder);
$producer = $this->getProducerCurrent();

if (!$order || (!$orderManager->isOrderBelongsToUser($order, GlobalParam::getCurrentUser()) && !$producer->option_allow_order_guest)) {
if (!$order || (!$producer->option_allow_order_guest && !$orderManager->isOrderBelongsToUser($order, GlobalParam::getCurrentUser()))) {
throw new \yii\base\UserException('Commande introuvable.');
}

@@ -936,7 +938,7 @@ class OrderController extends ProducerBaseController
$product['photo'] = '';
}

$product['quantity_max'] = $product['productDistribution'][0]['quantity_max'];
$product['quantity_max'] = (isset($product['productDistribution']) && isset($product['productDistribution'][0])) ? $product['productDistribution'][0]['quantity_max'] : null;
$quantityOrder = $orderManager->getProductQuantity($productObject, $ordersArray);
$product['quantity_ordered'] = $quantityOrder;
$product['quantity_remaining'] = $product['quantity_max'] - $quantityOrder;

Ładowanie…
Anuluj
Zapisz