Browse Source

Adaptations OrderShop

packProduct
Guillaume 3 years ago
parent
commit
d5597ab54d
3 changed files with 24 additions and 6 deletions
  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 View File

break; break;
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY :


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


$productFamily = $orderProduct->getProduct()->getProductFamily(); $productFamily = $orderProduct->getProduct()->getProductFamily();


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


$product = $orderProduct->getProduct(); $product = $orderProduct->getProduct();

+ 9
- 0
Repository/Order/OrderShopRepositoryQuery.php View File

use App\Entity\PointSale\PointSale; use App\Entity\PointSale\PointSale;
use Knp\Component\Pager\PaginatorInterface; use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface; use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface; use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface; use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
->select('count(r.id) as total'); ->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 public function filterByUser(UserInterface $user): self
{ {
return $this return $this
} }
return $this; return $this;
} }

} }

+ 13
- 4
Repository/Order/OrderShopStore.php View File

use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Model\User\VisitorInterface; use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore; use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore; use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
use Lc\CaracoleBundle\Repository\Section\SectionStore; use Lc\CaracoleBundle\Repository\Section\SectionStore;
class OrderShopStore extends AbstractStore class OrderShopStore extends AbstractStore
{ {
use SectionStoreTrait; use SectionStoreTrait;
use MerchantStoreTrait;


protected OrderShopRepositoryQuery $query; protected OrderShopRepositoryQuery $query;
protected EntityManagerInterface $entityManager; protected EntityManagerInterface $entityManager;


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


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

return $query; return $query;
} }




$reductionCreditsArray = []; $reductionCreditsArray = [];
foreach ($reductionCredits as $reductionCredit) { foreach ($reductionCredits as $reductionCredit) {
if (!$this->countValidWithReductionCredit($reductionCredit, $user)) {
if (!$this->countValidWithReductionCredit($reductionCredit, $user)
&& (!$this->merchant || $reductionCredit->getSection()->getMerchant() == $this->merchant)) {
$reductionCreditsArray[] = $reductionCredit; $reductionCreditsArray[] = $reductionCredit;
} }
} }
if ($this->reductionCartSolver->matchWithUser($reductionCart, $user) if ($this->reductionCartSolver->matchWithUser($reductionCart, $user)
&& $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user) && $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user)
&& $this->getReductionCartRemainingQuantityByUser($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;
} }
} }



Loading…
Cancel
Save