Переглянути джерело

Merge branch 'develop'

master
Guillaume 2 роки тому
джерело
коміт
33f1494700
16 змінених файлів з 366 додано та 44 видалено
  1. +7
    -0
      Builder/PointSale/PointSaleSectionBuilder.php
  2. +50
    -0
      Container/PointSale/PointSaleSectionContainer.php
  3. +7
    -0
      Controller/ControllerTrait.php
  4. +24
    -0
      Factory/PointSale/PointSaleSectionFactory.php
  5. +8
    -40
      Model/PointSale/PointSaleInterface.php
  6. +36
    -2
      Model/PointSale/PointSaleModel.php
  7. +15
    -0
      Model/PointSale/PointSaleSectionInterface.php
  8. +68
    -0
      Model/PointSale/PointSaleSectionModel.php
  9. +8
    -0
      Model/Section/SectionInterface.php
  10. +36
    -0
      Model/Section/SectionModel.php
  11. +5
    -0
      Repository/PointSale/PointSaleRepositoryQuery.php
  12. +15
    -0
      Repository/PointSale/PointSaleSectionRepository.php
  13. +23
    -0
      Repository/PointSale/PointSaleSectionRepositoryQuery.php
  14. +43
    -0
      Repository/PointSale/PointSaleSectionStore.php
  15. +5
    -0
      Resources/translations/admin.fr.yaml
  16. +16
    -2
      Solver/PointSale/PointSaleSolver.php

+ 7
- 0
Builder/PointSale/PointSaleSectionBuilder.php Переглянути файл

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

namespace Lc\CaracoleBundle\Builder\PointSale;

class PointSaleSectionBuilder
{
}

+ 50
- 0
Container/PointSale/PointSaleSectionContainer.php Переглянути файл

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

namespace Lc\CaracoleBundle\Container\PointSale;

use Lc\CaracoleBundle\Builder\PointSale\PointSaleSectionBuilder;
use Lc\CaracoleBundle\Factory\PointSale\PointSaleSectionFactory;
use Lc\CaracoleBundle\Repository\PointSale\PointSaleSectionRepositoryQuery;
use Lc\CaracoleBundle\Repository\PointSale\PointSaleSectionStore;

class PointSaleSectionContainer
{
protected PointSaleSectionFactory $factory;
protected PointSaleSectionRepositoryQuery $repositoryQuery;
protected PointSaleSectionStore $store;
protected PointSaleSectionBuilder $builder;

public function __construct(
PointSaleSectionFactory $factory,
PointSaleSectionRepositoryQuery $repositoryQuery,
PointSaleSectionStore $store,
PointSaleSectionBuilder $builder
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->builder = $builder;
}

public function getFactory(): PointSaleSectionFactory
{
return $this->factory;
}

public function getRepositoryQuery(): PointSaleSectionRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): PointSaleSectionStore
{
$this->store->resetContext();

return $this->store;
}

public function getBuilder(): PointSaleSectionBuilder
{
return $this->builder;
}
}

+ 7
- 0
Controller/ControllerTrait.php Переглянути файл

@@ -20,6 +20,7 @@ use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use Lc\CaracoleBundle\Container\Order\OrderStatusContainer;
use Lc\CaracoleBundle\Container\Order\OrderStatusHistoryContainer;
use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer;
use Lc\CaracoleBundle\Container\PointSale\PointSaleSectionContainer;
use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer;
use Lc\CaracoleBundle\Container\Product\ProductContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
@@ -92,6 +93,7 @@ trait ControllerTrait
DistributionContainer::class => DistributionContainer::class,
ProductFamilySectionPropertyContainer::class => ProductFamilySectionPropertyContainer::class,
QualityLabelContainer::class => QualityLabelContainer::class,
PointSaleSectionContainer::class => PointSaleSectionContainer::class,
]
);
}
@@ -353,4 +355,9 @@ trait ControllerTrait
{
return $this->get(QualityLabelContainer::class);
}

public function getPointSaleSectionContainer(): PointSaleSectionContainer
{
return $this->get(PointSaleSectionContainer::class);
}
}

+ 24
- 0
Factory/PointSale/PointSaleSectionFactory.php Переглянути файл

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

namespace Lc\CaracoleBundle\Factory\PointSale;

use App\Entity\PointSale\PointSaleSection;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleSectionInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Factory\AbstractFactory;

class PointSaleSectionFactory extends AbstractFactory
{

public function create(PointSaleInterface $pointSale, SectionInterface $section): PointSaleSectionInterface
{
$pointSaleSection = new PointSaleSection();

$pointSaleSection->setPointSale($pointSale);
$pointSaleSection->setSection($section);

return $pointSaleSection;
}

}

+ 8
- 40
Model/PointSale/PointSaleInterface.php Переглянути файл

@@ -13,83 +13,50 @@ use Lc\SovBundle\Model\User\UserInterface;
interface PointSaleInterface
{
public function getTitle(): ?string;

public function setTitle(string $title);

public function getDescription(): ?string;

public function setDescription(?string $description);

public function getCreatedBy(): ?UserInterface;

public function setCreatedBy(?UserInterface $createdBy);

public function getUpdatedBy(): ?UserInterface;

public function setUpdatedBy(?UserInterface $updatedBy);

public function getDevAlias(): ?string;

public function setDevAlias(?string $devAlias);

public function getOrderAmountMin(): ?float;

public function setOrderAmountMin(float $orderAmountMin): PointSaleInterface;

/**
* @return Collection|MerchantInterface[]
*/
public function getMerchants(): Collection;

public function addMerchant(MerchantInterface $merchant): PointSaleInterface;

public function removeMerchant(MerchantInterface $merchant): PointSaleInterface;

public function getCode(): ?string;

public function setCode(?string $code): PointSaleInterface;

public function getDeliveryPrice(): ?float;

public function setDeliveryPrice(float $deliveryPrice): PointSaleInterface;

public function getIsPublic(): ?bool;

public function setIsPublic(bool $isPublic): PointSaleInterface;

public function getAddress(): ?AddressInterface;

public function setAddress(AddressInterface $address): PointSaleInterface;

/**
* @return Collection|UserPointSaleInterface[]
*/
public function getUserPointSales(): Collection;

public function addUserPointSale(UserPointSaleInterface $userPointSale
): PointSaleInterface;

public function removeUserPointSale(UserPointSaleInterface $userPointSale
): PointSaleInterface;

public function getImage(): ?File;

public function setImage(?File $image): PointSaleInterface;

public function getMetaTitle(): ?string;

public function setMetaTitle(?string $metaTitle);

public function getMetaDescription(): ?string;

public function setMetaDescription(?string $metaDescription);

public function setOldUrls($oldUrls);

public function getOldUrls(): ?array;

public function getSlug(): ?string;

public function setSlug(?string $slug);

/**
@@ -102,18 +69,19 @@ interface PointSaleInterface
* @return $this
*/
public function setPosition(float $position);

public function clearPosition();

public function getStatus(): ?float;

public function setStatus(float $status);

public function getCreatedAt(): ?\DateTimeInterface;

public function setCreatedAt(\DateTimeInterface $createdAt);

public function getUpdatedAt(): ?\DateTimeInterface;

public function setUpdatedAt(\DateTimeInterface $updatedAt);

/**
* @return Collection|PointSaleSectionInterface[]
*/
public function getPointSaleSections(): Collection;
public function addPointSaleSection(PointSaleSectionInterface $pointSaleSection): PointSaleInterface;
public function removePointSaleSection(PointSaleSectionInterface $pointSaleSection): PointSaleInterface;

}

+ 36
- 2
Model/PointSale/PointSaleModel.php Переглянути файл

@@ -20,7 +20,6 @@ use App\Entity\File\File;
abstract class PointSaleModel extends AbstractFullEntity implements FilterMultipleMerchantsInterface,
OrderAmountMinInterface, PointSaleInterface
{

use OrderAmountMinTrait;

/**
@@ -59,10 +58,16 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip
*/
protected $image;

/**
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\PointSale\PointSaleSectionInterface", mappedBy="pointSale", cascade={"persist"})
*/
protected $pointSaleSections;

public function __construct()
{
$this->merchants = new ArrayCollection();
$this->userPointSales = new ArrayCollection();
$this->pointSaleSections = new ArrayCollection();
}

public function __toString()
@@ -108,7 +113,6 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip
return $this;
}


public function getDeliveryPrice(): ?float
{
return $this->deliveryPrice;
@@ -187,4 +191,34 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip

return $this;
}

/**
* @return Collection|PointSaleSectionInterface[]
*/
public function getPointSaleSections(): Collection
{
return $this->pointSaleSections;
}

public function addPointSaleSection(PointSaleSectionInterface $pointSaleSection): self
{
if (!$this->pointSaleSections->contains($pointSaleSection)) {
$this->pointSaleSections[] = $pointSaleSection;
$pointSaleSection->setPointSale($this);
}

return $this;
}

public function removePointSaleSection(PointSaleSectionInterface $pointSaleSection): self
{
if ($this->pointSaleSections->removeElement($pointSaleSection)) {
// set the owning side to null (unless already changed)
if ($pointSaleSection->getPointSale() === $this) {
$pointSaleSection->setPointSale(null);
}
}

return $this;
}
}

+ 15
- 0
Model/PointSale/PointSaleSectionInterface.php Переглянути файл

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

namespace Lc\CaracoleBundle\Model\PointSale;

use Lc\CaracoleBundle\Model\Section\SectionInterface;

interface PointSaleSectionInterface
{
public function getSection(): SectionInterface;
public function setSection(SectionInterface $section): PointSaleSectionInterface;
public function getPointSale(): PointSaleInterface;
public function setPointSale(PointSaleInterface $pointSale): PointSaleSectionInterface;
public function getOrderAmountMin(): ?float;
public function setOrderAmountMin(float $orderAmountMin): self;
}

+ 68
- 0
Model/PointSale/PointSaleSectionModel.php Переглянути файл

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

namespace Lc\CaracoleBundle\Model\PointSale;

use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinTrait;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Doctrine\EntityInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class PointSaleSectionModel implements EntityInterface, PointSaleSectionInterface
{
/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pointSaleSections")
* @ORM\JoinColumn(nullable=false)
*/
protected $section;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\PointSale\PointSaleInterface", inversedBy="pointSaleSections")
* @ORM\JoinColumn(nullable=false)
*/
protected $pointSale;


/**
* @ORM\Column(type="float", nullable=true)
*/
protected $orderAmountMin;

public function getSection(): SectionInterface
{
return $this->section;
}

public function setSection(SectionInterface $section): self
{
$this->section = $section;

return $this;
}

public function getPointSale(): PointSaleInterface
{
return $this->pointSale;
}

public function setPointSale(PointSaleInterface $pointSale): self
{
$this->pointSale = $pointSale;

return $this;
}

public function getOrderAmountMin(): ?float
{
return $this->orderAmountMin;
}

public function setOrderAmountMin(?float $orderAmountMin): self
{
$this->orderAmountMin = $orderAmountMin;

return $this;
}
}

+ 8
- 0
Model/Section/SectionInterface.php Переглянути файл

@@ -6,6 +6,7 @@ namespace Lc\CaracoleBundle\Model\Section;
use Doctrine\Common\Collections\Collection;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleSectionInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface;
use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface;
@@ -163,4 +164,11 @@ interface SectionInterface
public function getUpdatedAt(): ?\DateTimeInterface;

public function setUpdatedAt(\DateTimeInterface $updatedAt);

/**
* @return Collection|PointSaleSectionInterface[]
*/
public function getPointSaleSections(): Collection;
public function addPointSaleSection(PointSaleSectionInterface $pointSaleSection): SectionInterface;
public function removePointSaleSection(PointSaleSectionInterface $pointSaleSection): SectionInterface;
}

+ 36
- 0
Model/Section/SectionModel.php Переглянути файл

@@ -9,6 +9,7 @@ use Gedmo\Mapping\Annotation as Gedmo;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleSectionInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface;
use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface;
@@ -96,6 +97,11 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant
*/
protected $productFamilySectionProperties;

/**
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\PointSale\PointSaleSectionInterface", mappedBy="section")
*/
protected $pointSaleSections;

public function __construct()
{
$this->orderShops = new ArrayCollection();
@@ -405,4 +411,34 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant

return $this;
}

/**
* @return Collection|PointSaleSectionInterface[]
*/
public function getPointSaleSections(): Collection
{
return $this->pointSaleSections;
}

public function addPointSaleSection(PointSaleSectionInterface $pointSaleSection): self
{
if (!$this->pointSaleSections->contains($pointSaleSection)) {
$this->pointSaleSections[] = $pointSaleSection;
$pointSaleSection->setSection($this);
}

return $this;
}

public function removePointSaleSection(PointSaleSectionInterface $pointSaleSection): self
{
if ($this->pointSaleSections->removeElement($pointSaleSection)) {
// set the owning side to null (unless already changed)
if ($pointSaleSection->getSection() === $this) {
$pointSaleSection->setSection(null);
}
}

return $this;
}
}

+ 5
- 0
Repository/PointSale/PointSaleRepositoryQuery.php Переглянути файл

@@ -64,4 +64,9 @@ class PointSaleRepositoryQuery extends AbstractRepositoryQuery
}
return $this;
}

public function innerJoinDeliveryAvailabilityPointSale()
{
return $this->innerJoin('.deliveryAvailabilityPointSale');
}
}

+ 15
- 0
Repository/PointSale/PointSaleSectionRepository.php Переглянути файл

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

namespace Lc\CaracoleBundle\Repository\PointSale;

use App\Entity\PointSale\PointSaleSection;
use Doctrine\Persistence\ManagerRegistry;
use Lc\SovBundle\Repository\AbstractRepository;

class PointSaleSectionRepository extends AbstractRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, PointSaleSection::class);
}
}

+ 23
- 0
Repository/PointSale/PointSaleSectionRepositoryQuery.php Переглянути файл

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

namespace Lc\CaracoleBundle\Repository\PointSale;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class PointSaleSectionRepositoryQuery extends AbstractRepositoryQuery
{
use SectionRepositoryQueryTrait;

public function __construct(PointSaleSectionRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'pointSaleSection', $paginator);
}

public function filterByPointSale(PointSaleInterface $pointSale): self
{
return $this->andWhereEqual('pointSale', $pointSale);
}
}

+ 43
- 0
Repository/PointSale/PointSaleSectionStore.php Переглянути файл

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

namespace Lc\CaracoleBundle\Repository\PointSale;

use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\CaracoleBundle\Repository\AbstractStore;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class PointSaleSectionStore extends AbstractStore
{
use SectionStoreTrait;

protected PointSaleSectionRepositoryQuery $query;

public function __construct(PointSaleSectionRepositoryQuery $query)
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$this->addFilterBySectionOptionnal($query);
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function getOneByPointSale(PointSaleInterface $pointSale, $query = null)
{
$query = $this->createDefaultQuery($query);
$query->filterByPointSale($pointSale);
return $query->findOne();
}
}

+ 5
- 0
Resources/translations/admin.fr.yaml Переглянути файл

@@ -88,6 +88,11 @@ entity:
code: Code
code_help: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse)
image: Image
pointSaleSections: Sections

PointSaleSection:
fields:
orderAmountMin: Montant minimum de commande

Address:
fields:

+ 16
- 2
Solver/PointSale/PointSaleSolver.php Переглянути файл

@@ -1,10 +1,9 @@
<?php


namespace Lc\CaracoleBundle\Solver\PointSale;


use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;

class PointSaleSolver
{
@@ -36,4 +35,19 @@ class PointSaleSolver

return $html;
}

public function getOrderAmountMin(PointSaleInterface $pointSale, SectionInterface $section)
{
foreach($pointSale->getPointSaleSections() as $pointSaleSection) {
if($pointSaleSection->getSection()->getId() == $section->getId()) {
$orderAmountMin = $pointSaleSection->getOrderAmountMin();

if(!is_null($orderAmountMin)) {
return $orderAmountMin;
}
}
}

return $pointSale->getOrderAmountMin();
}
}

Завантаження…
Відмінити
Зберегти