瀏覽代碼

Merge branch 'develop'

master
Guillaume 2 年之前
父節點
當前提交
ef85afecb6
共有 9 個文件被更改,包括 226 次插入140 次删除
  1. +143
    -134
      Builder/Order/OrderShopBuilder.php
  2. +46
    -0
      EventSubscriber/Product/UpdateProductfamilyAfterFlushEventSubscriber.php
  3. +4
    -2
      EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php
  4. +1
    -1
      Repository/Order/OrderProductStore.php
  5. +7
    -0
      Repository/Product/ProductRepositoryQuery.php
  6. +2
    -2
      Repository/Product/ProductStore.php
  7. +11
    -0
      Repository/Section/OpeningRepositoryQuery.php
  8. +7
    -0
      Repository/Section/OpeningStore.php
  9. +5
    -1
      Solver/Section/OpeningSolver.php

+ 143
- 134
Builder/Order/OrderShopBuilder.php 查看文件

@@ -74,27 +74,30 @@ class OrderShopBuilder
protected DistributionBuilder $distributionBuilder;
protected MerchantResolver $merchantResolver;
protected CreditHistoryBuilder $creditHistoryBuilder;
protected FlashBagTranslator $flashBagTranslator;

public function __construct(
EntityManagerInterface $entityManager,
OrderShopStore $orderShopStore,
OrderShopSolver $orderShopSolver,
OrderStatusStore $orderStatusStore,
OrderProductStore $orderProductStore,
ProductFamilyStore $productFamilyStore,
OrderProductBuilder $orderProductBuilder,
DocumentBuilder $documentBuilder,
PriceSolver $priceSolver,
EventDispatcherInterface $eventDispatcher,
FlashBagInterface $flashBag,
OpeningResolver $openingResolver,
ProductSolver $productSolver,
OrderShopResolver $orderShopResolver,
OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver,
DistributionBuilder $distributionBuilder,
MerchantResolver $merchantResolver,
CreditHistoryBuilder $creditHistoryBuilder
) {
EntityManagerInterface $entityManager,
OrderShopStore $orderShopStore,
OrderShopSolver $orderShopSolver,
OrderStatusStore $orderStatusStore,
OrderProductStore $orderProductStore,
ProductFamilyStore $productFamilyStore,
OrderProductBuilder $orderProductBuilder,
DocumentBuilder $documentBuilder,
PriceSolver $priceSolver,
EventDispatcherInterface $eventDispatcher,
FlashBagInterface $flashBag,
OpeningResolver $openingResolver,
ProductSolver $productSolver,
OrderShopResolver $orderShopResolver,
OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver,
DistributionBuilder $distributionBuilder,
MerchantResolver $merchantResolver,
CreditHistoryBuilder $creditHistoryBuilder,
FlashBagTranslator $flashBagTranslator
)
{
$this->entityManager = $entityManager;
$this->orderShopStore = $orderShopStore;
$this->orderShopSolver = $orderShopSolver;
@@ -113,13 +116,15 @@ class OrderShopBuilder
$this->distributionBuilder = $distributionBuilder;
$this->merchantResolver = $merchantResolver;
$this->creditHistoryBuilder = $creditHistoryBuilder;
$this->flashBagTranslator = $flashBagTranslator;
}

public function create(
SectionInterface $section,
UserInterface $user = null,
VisitorInterface $visitor = null
): OrderShopInterface {
SectionInterface $section,
UserInterface $user = null,
VisitorInterface $visitor = null
): OrderShopInterface
{
$orderShopFactory = new OrderShopFactory();
$orderShop = $orderShopFactory->create($section, $user, $visitor);

@@ -135,19 +140,20 @@ class OrderShopBuilder
protected array $cacheCartCurrentBySection = [];

public function createIfNotExist(
SectionInterface $section,
UserInterface $user = null,
VisitorInterface $visitor = null,
bool $cache = false
): OrderShopInterface {
SectionInterface $section,
UserInterface $user = null,
VisitorInterface $visitor = null,
bool $cache = false
): OrderShopInterface
{

$cart = null;

// cache
$cacheIdCartCurrent = 'cart_current_'.$section->getId();
if($cache
&& isset($this->cacheCartCurrentBySection[$cacheIdCartCurrent])
&& $this->cacheCartCurrentBySection[$cacheIdCartCurrent]) {
$cacheIdCartCurrent = 'cart_current_' . $section->getId();
if ($cache
&& isset($this->cacheCartCurrentBySection[$cacheIdCartCurrent])
&& $this->cacheCartCurrentBySection[$cacheIdCartCurrent]) {

return $this->cacheCartCurrentBySection[$cacheIdCartCurrent];
}
@@ -160,12 +166,11 @@ class OrderShopBuilder
if ($cartUser && $cartVisitor && $cartUser->getId() != $cartVisitor->getId()) {
$cart = $this->merge($cartUser, $cartVisitor);
} else {
if($cartUser) {
if ($cartUser) {
$cart = $cartUser;
}
elseif($cartVisitor) {
} elseif ($cartVisitor) {

if($user && $cartVisitor && !$cartVisitor->getUser()) {
if ($user && $cartVisitor && !$cartVisitor->getUser()) {
$cartVisitor->setUser($user);
$this->entityManager->update($cartVisitor);
$this->entityManager->flush();
@@ -189,15 +194,16 @@ class OrderShopBuilder
}

public function setOrderStatus(
OrderShopInterface $orderShop,
string $alias,
bool $forceByAdmin = false
): OrderShopInterface {
OrderShopInterface $orderShop,
string $alias,
bool $forceByAdmin = false
): OrderShopInterface
{
$orderStatus = $this->orderStatusStore->getOneByAlias($alias);

if ($orderStatus) {
if ($orderShop->getOrderStatus() === null
|| $orderShop->getOrderStatus()->getNextStatusAllowed()->contains($orderStatus)) {
|| $orderShop->getOrderStatus()->getNextStatusAllowed()->contains($orderStatus)) {
$this->applyChangeOrderStatus($orderShop, $orderStatus, $forceByAdmin);
}
} else {
@@ -208,13 +214,14 @@ class OrderShopBuilder
}

public function applyChangeOrderStatus(
OrderShopInterface $orderShop,
OrderStatusInterface $orderStatus,
bool $forceByAdmin = false
): void {
OrderShopInterface $orderShop,
OrderStatusInterface $orderStatus,
bool $forceByAdmin = false
): void
{
$this->eventDispatcher->dispatch(
new OrderShopChangeStatusEvent($orderShop, $orderStatus, $forceByAdmin),
OrderShopChangeStatusEvent::PRE_CHANGE_STATUS
new OrderShopChangeStatusEvent($orderShop, $orderStatus, $forceByAdmin),
OrderShopChangeStatusEvent::PRE_CHANGE_STATUS
);

$orderShop->setOrderStatusProtected($orderStatus);
@@ -225,16 +232,17 @@ class OrderShopBuilder
$orderShop->addOrderStatusHistory($orderStatusHistory);

$this->eventDispatcher->dispatch(
new OrderShopChangeStatusEvent($orderShop, $orderStatus, $forceByAdmin),
OrderShopChangeStatusEvent::POST_CHANGE_STATUS
new OrderShopChangeStatusEvent($orderShop, $orderStatus, $forceByAdmin),
OrderShopChangeStatusEvent::POST_CHANGE_STATUS
);
}

public function addOrderProduct(
OrderShopInterface $orderShop,
OrderProductInterface $orderProductAdd,
bool $persist = true
): bool {
OrderShopInterface $orderShop,
OrderProductInterface $orderProductAdd,
bool $persist = true
): bool
{
$return = false;

if ($this->orderShopSolver->isOrderProductAvailableAddCart($orderProductAdd, $orderShop)) {
@@ -242,19 +250,19 @@ class OrderShopBuilder
$updated = false;
$this->orderProductBuilder->init($orderProductAdd);
$productFamily = $this->productFamilyStore->setSection($orderShop->getSection())->getOneBySlug(
$orderProductAdd->getProduct()->getProductFamily()->getSlug()
$orderProductAdd->getProduct()->getProductFamily()->getSlug()
);

if ($productFamily) {
$reductionCatalog = $productFamily->getReductionCatalog();

if ($reductionCatalog) {
if ($reductionCatalog && $reductionCatalog->getStatus()) {
$orderProductReductionCatalogFactory = new OrderProductReductionCatalogFactory();
$orderProductReductionCatalog = $orderProductReductionCatalogFactory->create(
$reductionCatalog->getTitle(),
$reductionCatalog->getValue(),
$reductionCatalog->getUnit(),
$reductionCatalog->getBehaviorTaxRate()
$reductionCatalog->getTitle(),
$reductionCatalog->getValue(),
$reductionCatalog->getUnit(),
$reductionCatalog->getBehaviorTaxRate()
);

$orderProductAdd->setOrderProductReductionCatalog($orderProductReductionCatalog);
@@ -263,15 +271,15 @@ class OrderShopBuilder

foreach ($orderShop->getOrderProducts() as $orderProduct) {
if ($orderProduct->getProduct()->getId() == $orderProductAdd->getProduct()->getId()
&& $orderProduct->getRedelivery() == $orderProductAdd->getRedelivery()
&& (string)$this->priceSolver->getPrice($orderProduct)
== (string)$this->priceSolver->getPrice($orderProductAdd)
&& $this->orderProductReductionCatalogSolver->compare(
$orderProduct->getOrderProductReductionCatalog(),
$orderProductAdd->getOrderProductReductionCatalog()
)) {
&& $orderProduct->getRedelivery() == $orderProductAdd->getRedelivery()
&& (string)$this->priceSolver->getPrice($orderProduct)
== (string)$this->priceSolver->getPrice($orderProductAdd)
&& $this->orderProductReductionCatalogSolver->compare(
$orderProduct->getOrderProductReductionCatalog(),
$orderProductAdd->getOrderProductReductionCatalog()
)) {
$orderProduct->setQuantityOrder(
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder()
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder()
);

if ($persist) {
@@ -335,10 +343,11 @@ class OrderShopBuilder
}

public function merge(
OrderShopInterface $orderShop1,
OrderShopInterface $orderShop2,
$persist = true
): OrderShopInterface {
OrderShopInterface $orderShop1,
OrderShopInterface $orderShop2,
$persist = true
): OrderShopInterface
{
//TODO essayer de comprendre prk on doit faire un refresh ici ???
$this->entityManager->refresh($orderShop1);
$this->entityManager->refresh($orderShop2);
@@ -377,9 +386,9 @@ class OrderShopBuilder

$orderShop->addOrderPayment($orderPayment);

if($meanPayment == OrderPaymentModel::MEAN_PAYMENT_CREDIT) {
if ($meanPayment == OrderPaymentModel::MEAN_PAYMENT_CREDIT) {
$this->creditHistoryBuilder->create(CreditHistoryModel::TYPE_DEBIT, $this->merchantResolver->getUserMerchant(), [
'orderPayment' => $orderPayment
'orderPayment' => $orderPayment
]);
}

@@ -406,17 +415,17 @@ class OrderShopBuilder
$orderShop->setStatTotal($this->priceSolver->getTotal($orderShop));
$orderShop->setStatTotalWithTax($this->priceSolver->getTotalWithTax($orderShop));
$orderShop->setStatTotalOrderProductsWithReductions(
$this->priceSolver->getTotalOrderProductsWithReductions($orderShop)
$this->priceSolver->getTotalOrderProductsWithReductions($orderShop)
);
$orderShop->setStatTotalOrderProductsWithTaxAndReductions(
$this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop)
$this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop)
);
$orderShop->setStatMarginOrderProductsWithReductions(
$this->priceSolver->getMarginOrderProductsWithReductions($orderShop)
$this->priceSolver->getMarginOrderProductsWithReductions($orderShop)
);
$orderShop->setStatDeliveryPriceWithReduction($this->priceSolver->getDeliveryPriceWithReduction($orderShop));
$orderShop->setStatDeliveryPriceWithTaxAndReduction(
$this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
$this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
);

$this->entityManager->persist($orderShop);
@@ -429,8 +438,8 @@ class OrderShopBuilder
public function initDistribution(OrderShopInterface $orderShop): void
{
$distribution = $this->distributionBuilder->guessDistributionByDeliveryDate(
$orderShop->getDeliveryDate(),
$orderShop->getSection()
$orderShop->getDeliveryDate(),
$orderShop->getSection()
);
$orderShop->setDistribution($distribution);
}
@@ -447,16 +456,17 @@ class OrderShopBuilder
}

public function addReductionCart(
OrderShopInterface $orderShop,
ReductionCartInterface $reductionCart
): ?OrderReductionCartInterface {
OrderShopInterface $orderShop,
ReductionCartInterface $reductionCart
): ?OrderReductionCartInterface
{
$orderReductionCartFactory = new OrderReductionCartFactory();
$orderReductionCart = $orderReductionCartFactory->create($orderShop, $reductionCart);

$orderShop->addOrderReductionCart($orderReductionCart);

if ($this->orderShopResolver->isPositiveAmount($orderShop)
&& $this->orderShopResolver->isPositiveAmountRemainingToBePaid($orderShop)) {
&& $this->orderShopResolver->isPositiveAmountRemainingToBePaid($orderShop)) {
$this->entityManager->create($orderReductionCart);
$this->entityManager->flush();

@@ -470,16 +480,17 @@ class OrderShopBuilder

// createOrderReductionCredit
public function addReductionCredit(
OrderShopInterface $orderShop,
ReductionCreditInterface $reductionCredit
): ?OrderReductionCreditInterface {
OrderShopInterface $orderShop,
ReductionCreditInterface $reductionCredit
): ?OrderReductionCreditInterface
{
$orderReductionCreditFactory = new OrderReductionCreditFactory();
$orderReductionCredit = $orderReductionCreditFactory->create($orderShop, $reductionCredit);

$orderShop->addOrderReductionCredit($orderReductionCredit);

if ($this->orderShopResolver->isPositiveAmount($orderShop)
&& $this->orderShopResolver->isPositiveAmountRemainingToBePaid($orderShop)) {
&& $this->orderShopResolver->isPositiveAmountRemainingToBePaid($orderShop)) {

$this->entityManager->create($orderReductionCredit);
$this->entityManager->flush();
@@ -500,16 +511,16 @@ class OrderShopBuilder
}

public function applyDeductAvailabilityProduct(
OrderShopInterface $orderShop,
OrderProductInterface $orderProduct
): void {
OrderShopInterface $orderShop,
OrderProductInterface $orderProduct
): void
{
switch ($orderProduct->getProduct()->getProductFamily()->getBehaviorCountStock()) {
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE :

//Disponibilité par unité de référence
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct());
$newAvailability = $oldAvailability - ($orderProduct->getQuantityOrder(
) * ($orderProduct->getQuantityProduct() / $orderProduct->getUnit()->getCoefficient()));
$newAvailability = $oldAvailability - ($orderProduct->getQuantityOrder() * ($orderProduct->getQuantityProduct() / $orderProduct->getUnit()->getCoefficient()));

$productFamily = $orderProduct->getProduct()->getProductFamily();
$productFamily->setAvailableQuantity($newAvailability);
@@ -548,44 +559,42 @@ class OrderShopBuilder

public function updatePriceByProductFamily(ProductFamilyInterface $productFamily)
{
// @TODO : faire la vérification isOpenSale depuis la méthode appelante
if (!$this->openingResolver->isOpenSale(
$productFamily->getSection(),
null,
OpeningResolver::OPENING_CONTEXT_BACKEND
)) {
$countOrderProductUpdated = 0;

foreach ($productFamily->getProducts() as $product) {
$orderProducts = $this->orderProductStore->getInCartsByProduct($product);

foreach ($orderProducts as $orderProduct) {
$quantityOrder = $orderProduct->getQuantityOrder();
$orderShop = $orderProduct->getOrderShop();
$orderShop->removeOrderProduct($orderProduct);
$this->entityManager->delete($orderProduct);
$this->entityManager->flush();
$this->entityManager->refresh($orderShop);

$orderProductFactory = new OrderProductFactory();
$addOrderProduct = $orderProductFactory->create($product, $quantityOrder);
$this->addOrderProduct($orderShop, $addOrderProduct);

$countOrderProductUpdated++;
foreach ($this->merchantResolver->getCurrent()->getSections() as $section) {
// @TODO : faire la vérification isOpenSale depuis la méthode appelante
if (!$this->openingResolver->isOpenSale($section)) {
$countOrderProductUpdated = 0;

foreach ($productFamily->getProducts() as $product) {
$orderProducts = $this->orderProductStore->resetContext()->setSection($section)->getInCartsByProduct($product);

foreach ($orderProducts as $orderProduct) {
$quantityOrder = $orderProduct->getQuantityOrder();
$orderShop = $orderProduct->getOrderShop();
$orderShop->removeOrderProduct($orderProduct);
$this->entityManager->delete($orderProduct);
$this->entityManager->flush();
$this->entityManager->refresh($orderShop);

$orderProductFactory = new OrderProductFactory();
$addOrderProduct = $orderProductFactory->create($product, $quantityOrder);
$this->addOrderProduct($orderShop, $addOrderProduct);

$countOrderProductUpdated++;
}
}
}
if ($countOrderProductUpdated) {
// @TODO : faire le add flash dans le controller
/*$this->utils->addFlash(
if ($countOrderProductUpdated) {
// @TODO : faire le add flash dans le controller
$this->flashBagTranslator->add(
'success',
'success.OrderShop.orderProductUpdated',
array(),
'orderProductUpdated',
'OrderShop',
array('%count%' => $countOrderProductUpdated)
);*/
$this->entityManager->flush();
}
);

return $countOrderProductUpdated;
$this->entityManager->flush();
}
return $countOrderProductUpdated;
}
}
}

@@ -595,17 +604,17 @@ class OrderShopBuilder
$orderShop->setStatTotal($this->priceSolver->getTotal($orderShop));
$orderShop->setStatTotalWithTax($this->priceSolver->getTotalWithTax($orderShop));
$orderShop->setStatTotalOrderProductsWithReductions(
$this->priceSolver->getTotalOrderProductsWithReductions($orderShop)
$this->priceSolver->getTotalOrderProductsWithReductions($orderShop)
);
$orderShop->setStatTotalOrderProductsWithTaxAndReductions(
$this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop)
$this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop)
);
$orderShop->setStatMarginOrderProductsWithReductions(
$this->priceSolver->getMarginOrderProductsWithReductions($orderShop)
$this->priceSolver->getMarginOrderProductsWithReductions($orderShop)
);
$orderShop->setStatDeliveryPriceWithReduction($this->priceSolver->getDeliveryPriceWithReduction($orderShop));
$orderShop->setStatDeliveryPriceWithTaxAndReduction(
$this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
$this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
);

$this->entityManager->update($orderShop);
@@ -656,10 +665,10 @@ class OrderShopBuilder
public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2)
{
$productsSalesStatistic = new ProductsSalesStatistic(
$this->entityManager,
$entity,
$nbWeek,
$this->productSolver
$this->entityManager,
$entity,
$nbWeek,
$this->productSolver
);

$productsSalesStatistic->init($section, $this->distributionBuilder, $this->openingResolver);

+ 46
- 0
EventSubscriber/Product/UpdateProductfamilyAfterFlushEventSubscriber.php 查看文件

@@ -0,0 +1,46 @@
<?php

namespace Lc\CaracoleBundle\EventSubscriber\Product;

use Doctrine\ORM\EntityManagerInterface;

use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityUpdatedEvent;
use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder;
use Lc\CaracoleBundle\Container\Product\ProductContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
use Lc\SovBundle\Event\EntityManager\EntityManagerEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class UpdateProductfamilyAfterFlushEventSubscriber implements EventSubscriberInterface
{
protected EntityManagerInterface $em;
protected ProductFamilyContainer $productFamilyContainer;
protected ProductContainer $productContainer;
protected OrderShopBuilder $orderShopBuilder;

public function __construct(EntityManagerInterface $entityManager, ProductFamilyContainer $productFamilyContainer, ProductContainer $productContainer, OrderShopBuilder $orderShopBuilder)
{
$this->em = $entityManager;
$this->productFamilyContainer = $productFamilyContainer;
$this->productContainer = $productContainer;
$this->orderShopBuilder = $orderShopBuilder;
}

public static function getSubscribedEvents()
{
return [
AfterEntityUpdatedEvent::class => ['processAfterFlushProductFamily'],
];
}

public function processAfterFlushProductFamily(AfterEntityUpdatedEvent $event)
{
$entity = $event->getEntityInstance();
if ($entity instanceof ProductFamilyInterface) {
$this->orderShopBuilder->updatePriceByProductFamily($entity);
}
}
}

+ 4
- 2
EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php 查看文件

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\EventSubscriber\Product;

use Doctrine\ORM\EntityManagerInterface;

use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder;
use Lc\CaracoleBundle\Container\Product\ProductContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
@@ -17,12 +18,14 @@ class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface
protected EntityManagerInterface $em;
protected ProductFamilyContainer $productFamilyContainer;
protected ProductContainer $productContainer;
protected OrderShopBuilder $orderShopBuilder;

public function __construct(EntityManagerInterface $entityManager, ProductFamilyContainer $productFamilyContainer, ProductContainer $productContainer)
public function __construct(EntityManagerInterface $entityManager, ProductFamilyContainer $productFamilyContainer, ProductContainer $productContainer, OrderShopBuilder $orderShopBuilder)
{
$this->em = $entityManager;
$this->productFamilyContainer = $productFamilyContainer;
$this->productContainer = $productContainer;
$this->orderShopBuilder = $orderShopBuilder;
}

public static function getSubscribedEvents()
@@ -41,7 +44,6 @@ class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface
$this->processPrice($entity);
$this->processReductionCatalog($entity);
}
//TODO updatePriceByProductFamily
}



+ 1
- 1
Repository/Order/OrderProductStore.php 查看文件

@@ -44,7 +44,7 @@ class OrderProductStore extends AbstractStore
{
$query = $this->createDefaultQuery($query);
$query->filterByProduct($product);
$query->filterByOrderStatus(OrderStatusModel::$statusAliasAsValid);
$query->filterByOrderStatus(OrderStatusModel::$statusAliasAsCart);
return $query->find();
}
}

+ 7
- 0
Repository/Product/ProductRepositoryQuery.php 查看文件

@@ -108,6 +108,13 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery
}


public function filterIsNotAvailableQuantitySupplierUnlimited():self
{
$this->andWhere('productFamily.availableQuantitySupplierUnlimited != 1');
return $this;
}


public function filterAvailableQuantityNegative() :self
{


+ 2
- 2
Repository/Product/ProductStore.php 查看文件

@@ -66,6 +66,7 @@ class ProductStore extends AbstractStore
$query->joinProductFamily();
$query->filterIsOnline();
$query->filterAvailableQuantitySupplierNegative();
$query->filterIsNotAvailableQuantitySupplierUnlimited();
$query->groupBy('productFamily.id');
$productListAvailableQuantityNegative = $query->find();

@@ -83,8 +84,7 @@ class ProductStore extends AbstractStore
$query = $this->createQuery();
$query->filterByProductFamily($productFamily);
$query->filterIsOriginProduct();
$query->filterIsOnlineAndOffline();
return $query->find();
return $query->find();

}
}

+ 11
- 0
Repository/Section/OpeningRepositoryQuery.php 查看文件

@@ -14,4 +14,15 @@ class OpeningRepositoryQuery extends AbstractRepositoryQuery
{
parent::__construct($repository, 'opening', $paginator);
}

public function filterByToday()
{
return $this->filterByDay(date('N'));
}

public function filterByDay(int $day)
{
return $this->andWhereEqual('day', $day);
}

}

+ 7
- 0
Repository/Section/OpeningStore.php 查看文件

@@ -33,4 +33,11 @@ class OpeningStore extends AbstractStore
{
return $query;
}

public function getOneToday($query = null)
{
$query = $this->createDefaultQuery($query);
$query->filterByToday();
return $query->findOne();
}
}

+ 5
- 1
Solver/Section/OpeningSolver.php 查看文件

@@ -49,7 +49,11 @@ class OpeningSolver
if($opening) {
$now = new \DateTime();
if($weekDay == $now->format('N')) {
if($now < $opening->getTimeEnd()) {
$timeEnd = $opening->getTimeEnd();
$timeStart = $opening->getTimeStart();

if((($timeEnd && $now < $timeEnd) || !$timeEnd)
&& (($timeStart && $now > $timeStart) || !$timeStart) ) {
return true;
}
}

Loading…
取消
儲存