Преглед на файлове

ManyToMany on ProductFamily/Section + gestion stock + adaptation import

packProduct
Fabien Normand преди 3 години
родител
ревизия
f0e78a2e2d
променени са 11 файла, в които са добавени 75 реда и са изтрити 23 реда
  1. +8
    -6
      Builder/Credit/CreditHistoryBuilder.php
  2. +34
    -6
      Builder/Order/OrderShopBuilder.php
  3. +2
    -2
      Controller/ControllerTrait.php
  4. +1
    -1
      Controller/PointSale/PointSaleAdminController.php
  5. +1
    -1
      Controller/Site/PageAdminController.php
  6. +7
    -5
      Definition/Field/PointSale/PointSaleFieldDefinition.php
  7. +12
    -0
      Field/AssociationField.php
  8. +1
    -1
      Repository/Product/ProductCategoryRepositoryQuery.php
  9. +7
    -0
      Repository/Product/ProductCategoryStore.php
  10. +1
    -0
      Resources/translations/admin.fr.yaml
  11. +1
    -1
      Twig/StoreTwigExtension.php

+ 8
- 6
Builder/Credit/CreditHistoryBuilder.php Целия файл

@@ -40,12 +40,12 @@ class CreditHistoryBuilder
): CreditHistoryInterface {
$creditHistory = $this->creditHistoryFactory->create($type, $userMerchant);

$amount = isset($params['amount']) ?? null ;
$meanPayment = isset($params['meanPayment']) ?? null ;
$reference = isset($params['reference']) ?? null ;
$comment = isset($params['comment']) ?? null ;
$orderPayment = isset($params['orderPayment']) ?? null ;
$orderRefund = isset($params['orderRefund']) ?? null ;
$amount = isset($params['amount']) ? $params['amount'] : null ;
$meanPayment = isset($params['meanPayment']) ? $params['meanPayment'] : null ;
$reference = isset($params['reference']) ? $params['reference'] : null ;
$comment = isset($params['comment']) ? $params['comment'] : null ;
$orderPayment = isset($params['orderPayment']) ? $params['orderPayment'] : null ;
$orderRefund = isset($params['orderRefund']) ? $params['orderRefund'] : null ;

$creditHistory->setType($type);
$creditHistory->setUserMerchant($userMerchant);
@@ -56,6 +56,8 @@ class CreditHistoryBuilder
$creditHistory->setOrderPayment($orderPayment);
$creditHistory->setOrderRefund($orderRefund);

$this->save($creditHistory);

return $creditHistory;
}


+ 34
- 6
Builder/Order/OrderShopBuilder.php Целия файл

@@ -4,8 +4,10 @@ namespace Lc\CaracoleBundle\Builder\Order;

use App\Builder\Distribution\DistributionBuilder;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Builder\Credit\CreditHistoryBuilder;
use Lc\CaracoleBundle\Builder\File\DocumentBuilder;
use Lc\CaracoleBundle\Event\Order\OrderShopChangeStatusEvent;
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory;
use Lc\CaracoleBundle\Factory\File\DocumentFactory;
use Lc\CaracoleBundle\Factory\Order\OrderPaymentFactory;
use Lc\CaracoleBundle\Factory\Order\OrderProductFactory;
@@ -15,8 +17,10 @@ use Lc\CaracoleBundle\Factory\Order\OrderReductionCreditFactory;
use Lc\CaracoleBundle\Factory\Order\OrderShopFactory;
use Lc\CaracoleBundle\Factory\Order\OrderStatusHistoryFactory;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
use Lc\CaracoleBundle\Model\Order\OrderPaymentModel;
use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
@@ -34,6 +38,7 @@ use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Repository\Order\OrderStatusStore;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\OpeningResolver;
use Lc\CaracoleBundle\Resolver\OrderShopResolver;
use Lc\CaracoleBundle\Solver\Order\OrderProductReductionCatalogSolver;
@@ -42,6 +47,7 @@ use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\CaracoleBundle\Solver\Product\ProductSolver;
use Lc\CaracoleBundle\Statistic\Product\ProductsSalesStatistic;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Translation\FlashBagTranslator;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;

@@ -63,6 +69,8 @@ class OrderShopBuilder
protected OrderShopResolver $orderShopResolver;
protected OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver;
protected DistributionBuilder $distributionBuilder;
protected MerchantResolver $merchantResolver;
protected CreditHistoryBuilder $creditHistoryBuilder;

public function __construct(
EntityManagerInterface $entityManager,
@@ -80,7 +88,9 @@ class OrderShopBuilder
ProductSolver $productSolver,
OrderShopResolver $orderShopResolver,
OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver,
DistributionBuilder $distributionBuilder
DistributionBuilder $distributionBuilder,
MerchantResolver $merchantResolver,
CreditHistoryBuilder $creditHistoryBuilder
) {
$this->entityManager = $entityManager;
$this->orderShopStore = $orderShopStore;
@@ -98,6 +108,8 @@ class OrderShopBuilder
$this->orderShopResolver = $orderShopResolver;
$this->orderProductReductionCatalogSolver = $orderProductReductionCatalogSolver;
$this->distributionBuilder = $distributionBuilder;
$this->merchantResolver = $merchantResolver;
$this->creditHistoryBuilder = $creditHistoryBuilder;
}

public function create(
@@ -121,14 +133,24 @@ class OrderShopBuilder
UserInterface $user = null,
VisitorInterface $visitor = null
): OrderShopInterface {
$cart = $this->orderShopStore
->setSection($section)
->getOneCartCurrent($user, $visitor);
$this->orderShopStore->setSection($section);

$cartUser = $this->orderShopStore->getOneCartCurrent($user);
$cartVisitor = $this->orderShopStore->getOneCartCurrent(null, $visitor);

if ($cartUser && $cartVisitor && $cartUser->getId() != $cartVisitor->getId()) {
$cart = $this->merge($cartUser, $cartVisitor);
} else {
$cart = $cartUser ?: $cartVisitor;
}

if (!$cart) {
$cart = $this->create($section, $user, $visitor);
}

// @TODO : obligé de faire ça sinon le panier ne se met pas à jour quand on ajoute des produits. Pourquoi ?
$this->entityManager->refresh($cart);

return $cart;
}

@@ -221,7 +243,7 @@ class OrderShopBuilder
);

if ($persist) {
$this->entityManager->persist($orderProduct);
$this->entityManager->update($orderProduct);
}

$updated = true;
@@ -287,7 +309,7 @@ class OrderShopBuilder
): OrderShopInterface {
if ($orderShop1 && $orderShop2) {
foreach ($orderShop2->getOrderProducts() as $orderProduct) {
$orderProductAlreadyInCart = $orderShop1->hasOrderProductAlreadyInCart($orderProduct);
$orderProductAlreadyInCart = $this->orderShopSolver->hasOrderProductAlreadyInCart($orderShop1, $orderProduct);

if ($orderProductAlreadyInCart) {
if ($orderProduct->getQuantityOrder() > $orderProductAlreadyInCart->getQuantityOrder()) {
@@ -320,6 +342,12 @@ class OrderShopBuilder

$orderShop->addOrderPayment($orderPayment);

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

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

+ 2
- 2
Controller/ControllerTrait.php Целия файл

@@ -145,9 +145,9 @@ trait ControllerTrait
return $this->get(SectionResolver::class)->getCurrent();
}

public function getSectionCurrentDevAlias(): string
public function getSectionCurrentSlug(): string
{
return $this->getSectionCurrent()->getDevAlias();
return $this->getSectionCurrent()->getSlug();
}

public function getCartCurrent(): OrderShopInterface

+ 1
- 1
Controller/PointSale/PointSaleAdminController.php Целия файл

@@ -14,7 +14,7 @@ abstract class PointSaleAdminController extends AbstractAdminController
{
return $this->getPointSaleContainer()
->getFieldDefinition()
->getFieldList($pageName);
->getFields($pageName);
}

public function createEntity(string $entityFqcn)

+ 1
- 1
Controller/Site/PageAdminController.php Целия файл

@@ -14,7 +14,7 @@ abstract class PageAdminController extends SovPageAdminController

public function createEntity(string $entityFqcn)
{
return $this->get(PageContainer::class)
return $this->getPageContainer()
->getFactory()
->setSection($this->get(SectionResolver::class)->getCurrent())
->create();

+ 7
- 5
Definition/Field/PointSale/PointSaleFieldDefinition.php Целия файл

@@ -12,7 +12,7 @@ use Lc\SovBundle\Field\StatusField;
class PointSaleFieldDefinition extends AbstractFieldDefinition
{

public function configureFieldsIndex(): array
public function configureIndex(): array
{
return [
'id',
@@ -27,11 +27,11 @@ class PointSaleFieldDefinition extends AbstractFieldDefinition
'main',
'address',
'seo',
'conf'
'conf',
];
}

public function configureFieldsPanelMain(): array
public function configurePanelMain(): array
{
return [
'title',
@@ -40,9 +40,11 @@ class PointSaleFieldDefinition extends AbstractFieldDefinition
];
}

public function configureFieldsPanelAddress(): array
public function configurePanelAddress(): array
{
return ['address'];
return [
'address'
];
}

public function configureFields(): array

+ 12
- 0
Field/AssociationField.php Целия файл

@@ -71,6 +71,13 @@ final class AssociationField implements FieldInterface
return $this;
}

public function setFilterOnMerchantViaSection(MerchantInterface $merchant): self
{
$this->queryBuilderParameters['merchantViaSection'] = $merchant;

return $this;
}

public function setFilterOnDevAlias(string $devAlias): self
{
$this->queryBuilderParameters['devAlias'] = $devAlias;
@@ -130,6 +137,11 @@ final class AssociationField implements FieldInterface
$qb->andWhereMerchantManyToMany('e', $param['merchantManyToMany']);
}

if (isset($param['merchantViaSection'])) {
$qb->leftJoin('e.section', 's');
$qb->andWhereMerchant('s', $param['merchantViaSection']);
}

if (isset($param['status'])) {
$qb->andWhere('e.status = :status')->setParameter('status', $param['status']);
}

+ 1
- 1
Repository/Product/ProductCategoryRepositoryQuery.php Целия файл

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

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Doctrine\EntityInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery
@@ -35,5 +36,4 @@ class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery
return $this->andWhere('pf.status = 1');
}


}

+ 7
- 0
Repository/Product/ProductCategoryStore.php Целия файл

@@ -34,4 +34,11 @@ class ProductCategoryStore extends AbstractStore
{
return $query;
}

public function getOneParent(): ?ProductCategoryInterface
{
$query = $this->createDefaultQuery();
$query->filterIsParent();
return $query->findOne();
}
}

+ 1
- 0
Resources/translations/admin.fr.yaml Целия файл

@@ -105,6 +105,7 @@ entity:
fields:
cycle: Cycle de vente
isDefault: Section par défaut
cycleType: Cycle
TaxRate:
label: Règle de taxe
label_plurial: Règles de taxes

+ 1
- 1
Twig/StoreTwigExtension.php Целия файл

@@ -144,7 +144,7 @@ class StoreTwigExtension extends AbstractExtension
return $this->settingSolver->getSettingValue($this->getMerchantCurrent(), $settingName);
}

public function getSectionSetting(SectionInterface $section, string $settingName): string
public function getSectionSetting(SectionInterface $section, string $settingName): ?string
{
return $this->settingSolver->getSettingValue($section, $settingName);
}

Loading…
Отказ
Запис