namespace Lc\CaracoleBundle\Builder\Order; | namespace Lc\CaracoleBundle\Builder\Order; | ||||
use App\Builder\Distribution\DistributionBuilder; | use App\Builder\Distribution\DistributionBuilder; | ||||
use App\Entity\Order\OrderStatus; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\CaracoleBundle\Builder\Credit\CreditHistoryBuilder; | use Lc\CaracoleBundle\Builder\Credit\CreditHistoryBuilder; | ||||
use Lc\CaracoleBundle\Builder\File\DocumentBuilder; | use Lc\CaracoleBundle\Builder\File\DocumentBuilder; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusHistoryModel; | use Lc\CaracoleBundle\Model\Order\OrderStatusHistoryModel; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | use Lc\CaracoleBundle\Model\Product\ProductInterface; | ||||
): OrderShopInterface { | ): OrderShopInterface { | ||||
$orderShop = $this->orderShopFactory->create($section, $user, $visitor); | $orderShop = $this->orderShopFactory->create($section, $user, $visitor); | ||||
$this->setOrderStatus($orderShop, OrderStatusModel::ALIAS_CART); | |||||
$this->setOrderStatus($orderShop, OrderStatus::ALIAS_CART); | |||||
$this->entityManager->create($orderShop); | $this->entityManager->create($orderShop); | ||||
$this->entityManager->flush(); | $this->entityManager->flush(); | ||||
} | } | ||||
if ($this->orderShopResolver->isPaid($orderShop)) { | if ($this->orderShopResolver->isPaid($orderShop)) { | ||||
$nextStatus = OrderStatusModel::ALIAS_PAID; | |||||
$nextStatus = OrderStatus::ALIAS_PAID; | |||||
} else { | } else { | ||||
$nextStatus = OrderStatusModel::ALIAS_PARTIAL_PAYMENT; | |||||
$nextStatus = OrderStatus::ALIAS_PARTIAL_PAYMENT; | |||||
} | } | ||||
if ($orderShop->getOrderStatus()->getAlias() != $nextStatus) { | if ($orderShop->getOrderStatus()->getAlias() != $nextStatus) { |
namespace Lc\CaracoleBundle\Repository\Order; | namespace Lc\CaracoleBundle\Repository\Order; | ||||
use App\Entity\Order\OrderStatus; | |||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | use Lc\CaracoleBundle\Model\Product\ProductInterface; | ||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | use Lc\CaracoleBundle\Repository\SectionStoreTrait; | ||||
use Lc\CaracoleBundle\Repository\AbstractStore; | use Lc\CaracoleBundle\Repository\AbstractStore; | ||||
{ | { | ||||
$query = $this->createDefaultQuery($query); | $query = $this->createDefaultQuery($query); | ||||
$query->filterByProduct($product); | $query->filterByProduct($product); | ||||
$query->filterByOrderStatus(OrderStatusModel::$statusAliasAsCart); | |||||
$query->filterByOrderStatus(OrderStatus::$statusAliasAsCart); | |||||
return $query->find(); | return $query->find(); | ||||
} | } | ||||
} | } |
use App\Builder\Distribution\DistributionBuilder; | use App\Builder\Distribution\DistributionBuilder; | ||||
use App\Entity\Distribution\Distribution; | use App\Entity\Distribution\Distribution; | ||||
use App\Entity\User\User; | |||||
use App\Entity\Order\OrderStatus; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\CaracoleBundle\Builder\File\DocumentBuilder; | use Lc\CaracoleBundle\Builder\File\DocumentBuilder; | ||||
use Lc\CaracoleBundle\Model\Distribution\DistributionInterface; | use Lc\CaracoleBundle\Model\Distribution\DistributionInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | use Lc\CaracoleBundle\Model\Product\ProductInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | ||||
$query | $query | ||||
->selectCount() | ->selectCount() | ||||
->filterByReductionCredit($reductionCredit) | ->filterByReductionCredit($reductionCredit) | ||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid); | |||||
->filterByStatus(OrderStatus::$statusAliasAsValid); | |||||
return $query->count(); | return $query->count(); | ||||
} | } | ||||
$query | $query | ||||
->selectCount() | ->selectCount() | ||||
->filterByReductionCart($reductionCart) | ->filterByReductionCart($reductionCart) | ||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid); | |||||
->filterByStatus(OrderStatus::$statusAliasAsValid); | |||||
return $query->count(); | return $query->count(); | ||||
} | } | ||||
->selectCount() | ->selectCount() | ||||
->filterByUser($user) | ->filterByUser($user) | ||||
->filterByReductionCart($reductionCart) | ->filterByReductionCart($reductionCart) | ||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid); | |||||
->filterByStatus(OrderStatus::$statusAliasAsValid); | |||||
return $query->count(); | return $query->count(); | ||||
} | } | ||||
$query | $query | ||||
->selectOrderReductionCarts() | ->selectOrderReductionCarts() | ||||
->filterByStatus(OrderStatusModel::$statusAliasAsCart); | |||||
->filterByStatus(OrderStatus::$statusAliasAsCart); | |||||
return $query->findOne(); | return $query->findOne(); | ||||
} | } | ||||
$query | $query | ||||
->filterByDistribution($distribution) | ->filterByDistribution($distribution) | ||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid) | |||||
->filterByStatus(OrderStatus::$statusAliasAsValid) | |||||
->filterIsNotComplementaryOrderShop() | ->filterIsNotComplementaryOrderShop() | ||||
->orderBy('.cycleId', 'DESC'); | ->orderBy('.cycleId', 'DESC'); | ||||
$query | $query | ||||
->filterByDistribution($distribution) | ->filterByDistribution($distribution) | ||||
->filterByUser($user) | ->filterByUser($user) | ||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid) | |||||
->filterByStatus(OrderStatus::$statusAliasAsValid) | |||||
->filterIsNotComplementaryOrderShop() | ->filterIsNotComplementaryOrderShop() | ||||
->orderBy('.cycleId', 'DESC'); | ->orderBy('.cycleId', 'DESC'); | ||||
$query = $this->createDefaultQuery($query); | $query = $this->createDefaultQuery($query); | ||||
$query | $query | ||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid) | |||||
->filterByStatus(OrderStatus::$statusAliasAsValid) | |||||
->filterIsNotComplementaryOrderShop() | ->filterIsNotComplementaryOrderShop() | ||||
->orderBy('.idValidOrder', 'DESC'); | ->orderBy('.idValidOrder', 'DESC'); | ||||
} | } | ||||
if (isset($params['isCart'])) { | if (isset($params['isCart'])) { | ||||
$query->filterByStatus(OrderStatusModel::$statusAliasAsCart); | |||||
$query->filterByStatus(OrderStatus::$statusAliasAsCart); | |||||
} | } | ||||
if (isset($params['isValid'])) { | if (isset($params['isValid'])) { | ||||
$query->filterByStatus(OrderStatusModel::$statusAliasAsValid); | |||||
$query->filterByStatus(OrderStatus::$statusAliasAsValid); | |||||
} | } | ||||
if (isset($params['isWaitingDelivery'])) { | if (isset($params['isWaitingDelivery'])) { | ||||
$query->filterByStatus(OrderStatusModel::$statusAliasWaitingDelivery); | |||||
$query->filterByStatus(OrderStatus::$statusAliasWaitingDelivery); | |||||
} | } | ||||
if (isset($params['orderStatus'])) { | if (isset($params['orderStatus'])) { | ||||
{ | { | ||||
$query = $this->createDefaultQuery($query); | $query = $this->createDefaultQuery($query); | ||||
$query | $query | ||||
->filterByAlias(OrderStatusModel::$statusAliasAsValid) | |||||
->filterByAlias(OrderStatus::$statusAliasAsValid) | |||||
->filterByDistributions($distributions) | ->filterByDistributions($distributions) | ||||
->filterByProducts($products) | ->filterByProducts($products) | ||||
->selectSum() | ->selectSum() | ||||
$query = $this->createQuery($query); | $query = $this->createQuery($query); | ||||
$query | $query | ||||
->filterByAlias(OrderStatusModel::$statusAliasAsValid) | |||||
->filterByAlias(OrderStatus::$statusAliasAsValid) | |||||
->filterByDistribution($distribution) | ->filterByDistribution($distribution) | ||||
->filterByProduct($product) | ->filterByProduct($product) | ||||
->selectSumQuantityOrder() | ->selectSumQuantityOrder() | ||||
$query = $this->createQuery($query); | $query = $this->createQuery($query); | ||||
$query->filterByAlias(OrderStatusModel::$statusAliasAsCart); | |||||
$query->filterByAlias(OrderStatus::$statusAliasAsCart); | |||||
$query->filterByUserIsNull(); | $query->filterByUserIsNull(); | ||||
$query->filterByVisitorIsNull(); | $query->filterByVisitorIsNull(); | ||||
namespace Lc\CaracoleBundle\Solver\Order; | namespace Lc\CaracoleBundle\Solver\Order; | ||||
use App\Entity\Order\OrderShop; | use App\Entity\Order\OrderShop; | ||||
use App\Entity\Order\OrderStatus; | |||||
use Doctrine\Common\Collections\ArrayCollection; | use Doctrine\Common\Collections\ArrayCollection; | ||||
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopModel; | use Lc\CaracoleBundle\Model\Order\OrderShopModel; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | use Lc\CaracoleBundle\Model\Product\ProductInterface; | ||||
{ | { | ||||
if ($orderShop->getOrderStatus() && in_array( | if ($orderShop->getOrderStatus() && in_array( | ||||
$orderShop->getOrderStatus()->getAlias(), | $orderShop->getOrderStatus()->getAlias(), | ||||
OrderStatusModel::$statusAliasAsValid | |||||
OrderStatus::$statusAliasAsValid | |||||
) > 0) { | ) > 0) { | ||||
return true; | return true; | ||||
} | } | ||||
{ | { | ||||
if ($orderShop->getOrderStatus() && in_array( | if ($orderShop->getOrderStatus() && in_array( | ||||
$orderShop->getOrderStatus()->getAlias(), | $orderShop->getOrderStatus()->getAlias(), | ||||
OrderStatusModel::$statusAliasAsCart | |||||
OrderStatus::$statusAliasAsCart | |||||
) > 0) { | ) > 0) { | ||||
return true; | return true; | ||||
} | } | ||||
public function isDone(OrderShopInterface $orderShop): bool | public function isDone(OrderShopInterface $orderShop): bool | ||||
{ | { | ||||
if ($orderShop->getOrderStatus() && $orderShop->getOrderStatus()->getAlias() == OrderStatusModel::ALIAS_DONE) { | |||||
if ($orderShop->getOrderStatus() && $orderShop->getOrderStatus()->getAlias() == OrderStatus::ALIAS_DONE) { | |||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; |