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

Adaptations OrderShop

packProduct
Guillaume 3 лет назад
Родитель
Сommit
d5597ab54d
3 измененных файлов: 24 добавлений и 6 удалений
  1. +2
    -2
      Builder/Order/OrderShopBuilder.php
  2. +9
    -0
      Repository/Order/OrderShopRepositoryQuery.php
  3. +13
    -4
      Repository/Order/OrderShopStore.php

+ 2
- 2
Builder/Order/OrderShopBuilder.php Просмотреть файл

@@ -450,7 +450,7 @@ class OrderShopBuilder
break;
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY :

$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited();
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct());
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder();

$productFamily = $orderProduct->getProduct()->getProductFamily();
@@ -461,7 +461,7 @@ class OrderShopBuilder

break;
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT :
$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited();
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct());
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder();

$product = $orderProduct->getProduct();

+ 9
- 0
Repository/Order/OrderShopRepositoryQuery.php Просмотреть файл

@@ -7,6 +7,7 @@ use App\Entity\Delivery\DeliveryAvailabilityZone;
use App\Entity\PointSale\PointSale;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
@@ -49,6 +50,13 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->select('count(r.id) as total');
}

public function filterByMerchant(MerchantInterface $merchant)
{
$this->joinMerchant();
return $this->andWhere('s.merchant = :merchant')
->setParameter('merchant', $merchant);
}

public function filterByUser(UserInterface $user): self
{
return $this
@@ -233,4 +241,5 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
}
return $this;
}

}

+ 13
- 4
Repository/Order/OrderShopStore.php Просмотреть файл

@@ -11,6 +11,7 @@ use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
@@ -29,6 +30,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class OrderShopStore extends AbstractStore
{
use SectionStoreTrait;
use MerchantStoreTrait;

protected OrderShopRepositoryQuery $query;
protected EntityManagerInterface $entityManager;
@@ -86,10 +88,14 @@ class OrderShopStore extends AbstractStore

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
if($this->section) {
if(isset($this->section) && $this->section) {
$query->filterBySection($this->section);
}

if(isset($this->merchant) && $this->merchant) {
$query->filterByMerchant($this->merchant);
}

return $query;
}

@@ -445,7 +451,8 @@ class OrderShopStore extends AbstractStore

$reductionCreditsArray = [];
foreach ($reductionCredits as $reductionCredit) {
if (!$this->countValidWithReductionCredit($reductionCredit, $user)) {
if (!$this->countValidWithReductionCredit($reductionCredit, $user)
&& (!$this->merchant || $reductionCredit->getSection()->getMerchant() == $this->merchant)) {
$reductionCreditsArray[] = $reductionCredit;
}
}
@@ -514,8 +521,10 @@ class OrderShopStore extends AbstractStore
if ($this->reductionCartSolver->matchWithUser($reductionCart, $user)
&& $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user)
&& $this->getReductionCartRemainingQuantityByUser($reductionCart, $user)
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) {
$reductionCartsArray[] = $reductionCart;
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)
&& (!$this->merchant || $reductionCart->getSection()->getMerchant() == $this->merchant)) {

$reductionCartsArray[] = $reductionCart;
}
}


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