Browse Source

[Boutique] Abonnements : correctif problème points de vente à accès restreint affichés

feature/souke
Guillaume Bourgeois 11 months ago
parent
commit
fc013849a8
3 changed files with 19 additions and 2 deletions
  1. +8
    -0
      common/logic/PointSale/PointSale/Repository/PointSaleRepository.php
  2. +9
    -0
      common/logic/PointSale/PointSale/Repository/PointSaleRepositoryQuery.php
  3. +2
    -2
      producer/controllers/SubscriptionController.php

+ 8
- 0
common/logic/PointSale/PointSale/Repository/PointSaleRepository.php View File

->find(); ->find();
} }


public function findPointSalesByUserAccess(User $user)
{
return $this->createDefaultQuery()
->filterIsOnline()
->filterByUserAccess($user)
->find();
}

public function queryPointSalesPublic(Producer $producer) public function queryPointSalesPublic(Producer $producer)
{ {
return $this->createDefaultQuery() return $this->createDefaultQuery()

+ 9
- 0
common/logic/PointSale/PointSale/Repository/PointSaleRepositoryQuery.php View File

use common\logic\PointSale\PointSale\Model\PointSale; use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\PointSale\PointSale\Service\PointSaleDefinition; use common\logic\PointSale\PointSale\Service\PointSaleDefinition;
use common\logic\StatusInterface; use common\logic\StatusInterface;
use common\logic\User\User\Model\User;
use yii\db\ActiveQuery; use yii\db\ActiveQuery;


class PointSaleRepositoryQuery extends AbstractRepositoryQuery class PointSaleRepositoryQuery extends AbstractRepositoryQuery


return $this; return $this;
} }

public function filterByUserAccess(User $user): self
{
$this->andWhere('status = 1 AND (restricted_access = 0 OR (restricted_access = 1 AND (SELECT COUNT(*) FROM user_point_sale WHERE point_sale.id = user_point_sale.id_point_sale AND user_point_sale.id_user = :id_user) > 0))');
$this->addParams([':id_user' => $user->id]);

return $this;
}
} }

+ 2
- 2
producer/controllers/SubscriptionController.php View File

$params = []; $params = [];
$productModule = $this->getProductModule(); $productModule = $this->getProductModule();
$subscriptionModule = $this->getSubscriptionModule(); $subscriptionModule = $this->getSubscriptionModule();
$user = GlobalParam::getCurrentUser();
$user = $this->getUserCurrent();
$userProducer = $this->getUserProducerModule()->findOneUserProducer($this->getUserCurrent()); $userProducer = $this->getUserProducerModule()->findOneUserProducer($this->getUserCurrent());
$pointSale = null; $pointSale = null;




$params['products'] = $productsArray; $params['products'] = $productsArray;
$pointsSaleArray = $this->getPointSaleModule()->findPointSales();
$pointsSaleArray = $this->getPointSaleModule()->findPointSalesByUserAccess($user);
foreach ($pointsSaleArray as &$pointSale) { foreach ($pointsSaleArray as &$pointSale) {
$pointSale = array_merge($pointSale->getAttributes(), [ $pointSale = array_merge($pointSale->getAttributes(), [
'userPointSale' => ($pointSale->userPointSale ? $pointSale->userPointSale[0] : '') 'userPointSale' => ($pointSale->userPointSale ? $pointSale->userPointSale[0] : '')

Loading…
Cancel
Save