瀏覽代碼

Merge branch 'feature/section_export' into develop

develop
Guillaume Bourgeois 1 月之前
父節點
當前提交
8370302ca3
共有 5 個檔案被更改,包括 70 行新增60 行删除
  1. +36
    -27
      Builder/Order/OrderShopBuilder.php
  2. +14
    -12
      Model/Order/OrderStatusModel.php
  3. +2
    -2
      Repository/Order/OrderProductStore.php
  4. +14
    -15
      Repository/Order/OrderShopStore.php
  5. +4
    -4
      Solver/Order/OrderShopSolver.php

+ 36
- 27
Builder/Order/OrderShopBuilder.php 查看文件

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Builder\Order;

use App\Builder\Distribution\DistributionBuilder;
use App\Entity\Order\OrderStatus;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Builder\Credit\CreditHistoryBuilder;
use Lc\CaracoleBundle\Builder\File\DocumentBuilder;
@@ -27,7 +28,6 @@ use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusHistoryModel;
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
@@ -124,7 +124,7 @@ class OrderShopBuilder
): OrderShopInterface {
$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->flush();
@@ -378,9 +378,9 @@ class OrderShopBuilder
}

if ($this->orderShopResolver->isPaid($orderShop)) {
$nextStatus = OrderStatusModel::ALIAS_PAID;
$nextStatus = OrderStatus::ALIAS_PAID;
} else {
$nextStatus = OrderStatusModel::ALIAS_PARTIAL_PAYMENT;
$nextStatus = OrderStatus::ALIAS_PARTIAL_PAYMENT;
}

if ($orderShop->getOrderStatus()->getAlias() != $nextStatus) {
@@ -412,6 +412,9 @@ class OrderShopBuilder
$orderShop->setStatDeliveryPriceWithTaxAndReduction(
$this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
);
$orderShop->setStatMarginDeliveryWithReductions(
$this->priceSolver->getMarginDeliveryWithReductions($orderShop)
);

$this->entityManager->persist($orderShop);
if ($flush) {
@@ -573,29 +576,35 @@ class OrderShopBuilder
}


public function setStatsInfo(OrderShopInterface $orderShop, $flush = true)
{
$orderShop->setStatTotal($this->priceSolver->getTotal($orderShop));
$orderShop->setStatTotalWithTax($this->priceSolver->getTotalWithTax($orderShop));
$orderShop->setStatTotalOrderProductsWithReductions(
$this->priceSolver->getTotalOrderProductsWithReductions($orderShop)
);
$orderShop->setStatTotalOrderProductsWithTaxAndReductions(
$this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop)
);
$orderShop->setStatMarginOrderProductsWithReductions(
$this->priceSolver->getMarginOrderProductsWithReductions($orderShop)
);
$orderShop->setStatDeliveryPriceWithReduction($this->priceSolver->getDeliveryPriceWithReduction($orderShop));
$orderShop->setStatDeliveryPriceWithTaxAndReduction(
$this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
);

$this->entityManager->update($orderShop);
if ($flush) {
$this->entityManager->flush();
}
}
//Semble ne jamais être utilisé
//TODO : à supprimer si pas d'erreur arpès 1/01/2025
// public function setStatsInfo(OrderShopInterface $orderShop, $flush = true)
// {
// $orderShop->setStatTotal($this->priceSolver->getTotal($orderShop));
// $orderShop->setStatTotalWithTax($this->priceSolver->getTotalWithTax($orderShop));
// $orderShop->setStatTotalOrderProductsWithReductions(
// $this->priceSolver->getTotalOrderProductsWithReductions($orderShop)
// );
// $orderShop->setStatTotalOrderProductsWithTaxAndReductions(
// $this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop)
// );
// $orderShop->setStatMarginOrderProductsWithReductions(
// $this->priceSolver->getMarginOrderProductsWithReductions($orderShop)
// );
// $orderShop->setStatDeliveryPriceWithReduction($this->priceSolver->getDeliveryPriceWithReduction($orderShop));
// $orderShop->setStatDeliveryPriceWithTaxAndReduction(
// $this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
// );
// $orderShop->setStatMarginDeliveryWithReductions(
// $this->priceSolver->getMarginDeliveryWithReductions($orderShop)
// );
//
//
// $this->entityManager->update($orderShop);
// if ($flush) {
// $this->entityManager->flush();
// }
// }


public function setHasReach(int $reachStep, OrderShopInterface $orderShop)

+ 14
- 12
Model/Order/OrderStatusModel.php 查看文件

@@ -27,26 +27,28 @@ abstract class OrderStatusModel implements EntityInterface, OrderStatusInterface
const ALIAS_CANCELED_WAITING_REFUND = 'canceled-waiting-refund';
const ALIAS_REFUND = 'refund';


//TODO : AJOUTER un champ valid ds orderSTATUS
static $statusAliasAsValid = [
self::ALIAS_PAID,
self::ALIAS_WAITING_DELIVERY,
self::ALIAS_WAITING_BANK_RETURN,
self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
self::ALIAS_DELIVERED_WITHOUT_PAYMENT,
self::ALIAS_DONE
self::ALIAS_PAID,
self::ALIAS_WAITING_DELIVERY,
self::ALIAS_WAITING_BANK_RETURN,
self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
self::ALIAS_DELIVERED_WITHOUT_PAYMENT,
self::ALIAS_DONE

];

static $statusAliasWaitingDelivery = [
self::ALIAS_WAITING_DELIVERY,
self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
self::ALIAS_WAITING_DELIVERY,
self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
];

static $statusAliasAsCart = [
self::ALIAS_CART,
self::ALIAS_PARTIAL_PAYMENT,
self::ALIAS_WAITING_PAYMENT_ONLINE,
self::ALIAS_ERROR_PAYMENT_ONLINE
self::ALIAS_CART,
self::ALIAS_PARTIAL_PAYMENT,
self::ALIAS_WAITING_PAYMENT_ONLINE,
self::ALIAS_ERROR_PAYMENT_ONLINE
];

/**

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

@@ -2,8 +2,8 @@

namespace Lc\CaracoleBundle\Repository\Order;

use App\Entity\Order\OrderStatus;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Repository\AbstractStore;
@@ -43,7 +43,7 @@ class OrderProductStore extends AbstractStore
{
$query = $this->createDefaultQuery($query);
$query->filterByProduct($product);
$query->filterByOrderStatus(OrderStatusModel::$statusAliasAsCart);
$query->filterByOrderStatus(OrderStatus::$statusAliasAsCart);
return $query->find();
}
}

+ 14
- 15
Repository/Order/OrderShopStore.php 查看文件

@@ -4,12 +4,11 @@ namespace Lc\CaracoleBundle\Repository\Order;

use App\Builder\Distribution\DistributionBuilder;
use App\Entity\Distribution\Distribution;
use App\Entity\User\User;
use App\Entity\Order\OrderStatus;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Builder\File\DocumentBuilder;
use Lc\CaracoleBundle\Model\Distribution\DistributionInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
@@ -272,7 +271,7 @@ class OrderShopStore extends AbstractStore
$query
->selectCount()
->filterByReductionCredit($reductionCredit)
->filterByStatus(OrderStatusModel::$statusAliasAsValid);
->filterByStatus(OrderStatus::$statusAliasAsValid);

return $query->count();
}
@@ -288,7 +287,7 @@ class OrderShopStore extends AbstractStore
$query
->selectCount()
->filterByReductionCart($reductionCart)
->filterByStatus(OrderStatusModel::$statusAliasAsValid);
->filterByStatus(OrderStatus::$statusAliasAsValid);

return $query->count();
}
@@ -306,7 +305,7 @@ class OrderShopStore extends AbstractStore
->selectCount()
->filterByUser($user)
->filterByReductionCart($reductionCart)
->filterByStatus(OrderStatusModel::$statusAliasAsValid);
->filterByStatus(OrderStatus::$statusAliasAsValid);

return $query->count();
}
@@ -343,7 +342,7 @@ class OrderShopStore extends AbstractStore

$query
->selectOrderReductionCarts()
->filterByStatus(OrderStatusModel::$statusAliasAsCart);
->filterByStatus(OrderStatus::$statusAliasAsCart);

return $query->findOne();
}
@@ -359,7 +358,7 @@ class OrderShopStore extends AbstractStore

$query
->filterByDistribution($distribution)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterByStatus(OrderStatus::$statusAliasAsValid)
->filterIsNotComplementaryOrderShop()
->orderBy('.cycleId', 'DESC');

@@ -377,7 +376,7 @@ class OrderShopStore extends AbstractStore
$query
->filterByDistribution($distribution)
->filterByUser($user)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterByStatus(OrderStatus::$statusAliasAsValid)
->filterIsNotComplementaryOrderShop()
->orderBy('.cycleId', 'DESC');

@@ -390,7 +389,7 @@ class OrderShopStore extends AbstractStore
$query = $this->createDefaultQuery($query);

$query
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterByStatus(OrderStatus::$statusAliasAsValid)
->filterIsNotComplementaryOrderShop()
->orderBy('.idValidOrder', 'DESC');

@@ -466,15 +465,15 @@ class OrderShopStore extends AbstractStore
}

if (isset($params['isCart'])) {
$query->filterByStatus(OrderStatusModel::$statusAliasAsCart);
$query->filterByStatus(OrderStatus::$statusAliasAsCart);
}

if (isset($params['isValid'])) {
$query->filterByStatus(OrderStatusModel::$statusAliasAsValid);
$query->filterByStatus(OrderStatus::$statusAliasAsValid);
}

if (isset($params['isWaitingDelivery'])) {
$query->filterByStatus(OrderStatusModel::$statusAliasWaitingDelivery);
$query->filterByStatus(OrderStatus::$statusAliasWaitingDelivery);
}

if (isset($params['orderStatus'])) {
@@ -656,7 +655,7 @@ class OrderShopStore extends AbstractStore
{
$query = $this->createDefaultQuery($query);
$query
->filterByAlias(OrderStatusModel::$statusAliasAsValid)
->filterByAlias(OrderStatus::$statusAliasAsValid)
->filterByDistributions($distributions)
->filterByProducts($products)
->selectSum()
@@ -678,7 +677,7 @@ class OrderShopStore extends AbstractStore
$query = $this->createQuery($query);

$query
->filterByAlias(OrderStatusModel::$statusAliasAsValid)
->filterByAlias(OrderStatus::$statusAliasAsValid)
->filterByDistribution($distribution)
->filterByProduct($product)
->selectSumQuantityOrder()
@@ -730,7 +729,7 @@ class OrderShopStore extends AbstractStore

$query = $this->createQuery($query);

$query->filterByAlias(OrderStatusModel::$statusAliasAsCart);
$query->filterByAlias(OrderStatus::$statusAliasAsCart);
$query->filterByUserIsNull();
$query->filterByVisitorIsNull();


+ 4
- 4
Solver/Order/OrderShopSolver.php 查看文件

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Solver\Order;

use App\Entity\Order\OrderShop;
use App\Entity\Order\OrderStatus;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManagerInterface;
@@ -12,7 +13,6 @@ use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopModel;
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
@@ -377,7 +377,7 @@ class OrderShopSolver
{
if ($orderShop->getOrderStatus() && in_array(
$orderShop->getOrderStatus()->getAlias(),
OrderStatusModel::$statusAliasAsValid
OrderStatus::$statusAliasAsValid
) > 0) {
return true;
}
@@ -389,7 +389,7 @@ class OrderShopSolver
{
if ($orderShop->getOrderStatus() && in_array(
$orderShop->getOrderStatus()->getAlias(),
OrderStatusModel::$statusAliasAsCart
OrderStatus::$statusAliasAsCart
) > 0) {
return true;
}
@@ -399,7 +399,7 @@ class OrderShopSolver

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 false;

Loading…
取消
儲存