Browse Source

Merge branch 'develop' of https://forge.laclic.fr/Laclic/CaracoleBundle into develop

packProduct
Fab 3 years ago
parent
commit
590cf7340c
21 changed files with 383 additions and 104 deletions
  1. +36
    -2
      Builder/Credit/CreditHistoryBuilder.php
  2. +1
    -1
      Builder/Order/OrderShopBuilder.php
  3. +20
    -0
      Builder/Ticket/TicketBuilder.php
  4. +2
    -2
      Builder/User/UserBuilder.php
  5. +18
    -20
      Builder/User/UserMerchantBuilder.php
  6. +10
    -1
      Container/Address/AddressContainer.php
  7. +10
    -1
      Container/Credit/CreditHistoryContainer.php
  8. +38
    -20
      Container/Order/OrderShopContainer.php
  9. +19
    -1
      Container/User/UserMerchantContainer.php
  10. +43
    -0
      Form/Reduction/EditGiftVoucherType.php
  11. +31
    -0
      Form/Reduction/ReductionCartType.php
  12. +26
    -0
      Form/Reduction/SendGiftVoucherType.php
  13. +1
    -0
      Model/Credit/CreditHistoryModel.php
  14. +26
    -20
      Repository/Order/OrderShopStore.php
  15. +1
    -0
      Repository/Product/ProductCategoryStore.php
  16. +26
    -0
      Repository/Reduction/ReductionCreditStore.php
  17. +1
    -3
      Resolver/MerchantResolver.php
  18. +38
    -7
      Resolver/OpeningResolver.php
  19. +27
    -21
      Resolver/SectionResolver.php
  20. +1
    -1
      Statistic/Product/ProductsSalesStatistic.php
  21. +8
    -4
      Twig/StoreTwigExtension.php

+ 36
- 2
Builder/Credit/CreditHistoryBuilder.php View File

namespace Lc\CaracoleBundle\Builder\Credit; namespace Lc\CaracoleBundle\Builder\Credit;


use Lc\CaracoleBundle\Builder\User\UserMerchantBuilder; use Lc\CaracoleBundle\Builder\User\UserMerchantBuilder;
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel; use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\CaracoleBundle\Repository\User\UserMerchantStore; use Lc\CaracoleBundle\Repository\User\UserMerchantStore;


class CreditHistoryBuilder class CreditHistoryBuilder
{ {
protected CreditHistoryFactory $creditHistoryFactory;
protected UserMerchantStore $userMerchantStore; protected UserMerchantStore $userMerchantStore;
protected UserMerchantBuilder $userMerchantBuilder; protected UserMerchantBuilder $userMerchantBuilder;


public function __construct( public function __construct(
CreditHistoryFactory $creditHistoryFactory,
UserMerchantStore $userMerchantStore, UserMerchantStore $userMerchantStore,
UserMerchantBuilder $userMerchantBuilder UserMerchantBuilder $userMerchantBuilder
) { ) {
$this->creditHistoryFactory = $creditHistoryFactory;
$this->userMerchantStore = $userMerchantStore; $this->userMerchantStore = $userMerchantStore;
$this->userMerchantBuilder = $userMerchantBuilder; $this->userMerchantBuilder = $userMerchantBuilder;
} }


public function create(
string $type,
UserMerchantInterface $userMerchant,
array $params = []
): 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 ;

$creditHistory->setType($type);
$creditHistory->setUserMerchant($userMerchant);
$creditHistory->setAmount($amount);
$creditHistory->setMeanPayment($meanPayment);
$creditHistory->setReference($reference);
$creditHistory->setComment($comment);
$creditHistory->setOrderPayment($orderPayment);
$creditHistory->setOrderRefund($orderRefund);

return $creditHistory;
}

// saveCreditHistory // saveCreditHistory
public function save(CreditHistoryInterface $creditHistory) :bool
public function save(CreditHistoryInterface $creditHistory): bool
{ {
if ($creditHistory) { if ($creditHistory) {
$userMerchant = $creditHistory->getUserMerchant(); $userMerchant = $creditHistory->getUserMerchant();
$this->userMerchantBuilder->updateCredit($userMerchant, $creditHistory, $userMerchantAmount); $this->userMerchantBuilder->updateCredit($userMerchant, $creditHistory, $userMerchantAmount);
return true; return true;
} elseif ($creditHistory->getType() == CreditHistoryModel::TYPE_DEBIT) { } elseif ($creditHistory->getType() == CreditHistoryModel::TYPE_DEBIT) {
if ($this->userMerchantStore->isCreditSufficientToPay($userMerchant, $creditHistory->getAmountInherited())) {
if ($this->userMerchantStore->isCreditSufficientToPay(
$userMerchant,
$creditHistory->getAmountInherited()
)) {
$userMerchantAmount = $userMerchant->getCredit() - $creditHistory->getAmountInherited(); $userMerchantAmount = $userMerchant->getCredit() - $creditHistory->getAmountInherited();
$this->userMerchantBuilder->updateCredit($userMerchant, $creditHistory, $userMerchantAmount); $this->userMerchantBuilder->updateCredit($userMerchant, $creditHistory, $userMerchantAmount);
return true; return true;

+ 1
- 1
Builder/Order/OrderShopBuilder.php View File

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


foreach ($productFamily->getProducts() as $product) { foreach ($productFamily->getProducts() as $product) {

+ 20
- 0
Builder/Ticket/TicketBuilder.php View File

<?php

namespace Lc\CaracoleBundle\Builder\Ticket;

use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Builder\Ticket\TicketBuilder as SovTicketBuilder;

class TicketBuilder extends SovTicketBuilder
{

public function init(TicketInterface $ticket, array $params = []): void
{
parent::init($ticket, $params);

$ticket->setSection($params['section']);
if(isset($data['orderShop'])) {
$ticket->setOrderShop($data['orderShop']);
}
}
}

+ 2
- 2
Builder/User/UserBuilder.php View File



namespace Lc\CaracoleBundle\Builder\User; namespace Lc\CaracoleBundle\Builder\User;


use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Factory\User\UserPointSaleFactory; use Lc\CaracoleBundle\Factory\User\UserPointSaleFactory;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;
class UserBuilder extends SovUserBuilder class UserBuilder extends SovUserBuilder
{ {


// linkUserToPointSale
public function linkToPointSale(UserInterface $user, PointSaleInterface $pointSale):bool public function linkToPointSale(UserInterface $user, PointSaleInterface $pointSale):bool
{ {
if (!$user->isLinkedToPointSale($pointSale)) {
if (!$this->userSolver->isLinkedToPointSale($user, $pointSale)) {
$userPointSaleFactory = new UserPointSaleFactory(); $userPointSaleFactory = new UserPointSaleFactory();
$userPointSale = $userPointSaleFactory->create($user, $pointSale); $userPointSale = $userPointSaleFactory->create($user, $pointSale);



+ 18
- 20
Builder/User/UserMerchantBuilder.php View File

return $userMerchant; return $userMerchant;
} }


public function updateCreditActive(
UserInterface $user,
MerchantInterface $merchant,
$creditActive = true
): UserMerchantInterface {
$userMerchant = $this->createIfNotExist($user, $merchant);

$userMerchant->setCreditActive($creditActive);

//TODO create ou update ???
$this->entityManager->persist($userMerchant);
$this->entityManager->flush();

return $userMerchant;
}

public function activeCredit(UserInterface $user, MerchantInterface $merchant): UserMerchantInterface
public function activeCredit(UserMerchantInterface $userMerchant): UserMerchantInterface
{ {
return $this->updateCreditActive($user, $merchant, true);
return $this->updateCreditActive($userMerchant, true);
} }


public function unactiveCredit(UserInterface $user, MerchantInterface $merchant): UserMerchantInterface
public function unactiveCredit(UserMerchantInterface $userMerchant): UserMerchantInterface
{ {
return $this->updateCreditActive($user, $merchant, false);
return $this->updateCreditActive($userMerchant, false);
} }


public function updateCredit( public function updateCredit(
return $userMerchant; return $userMerchant;
} }


public function updateCreditActive(
UserMerchantInterface $userMerchant,
$creditActive = true
): UserMerchantInterface {

$userMerchant->setCreditActive($creditActive);

//TODO create ou update ???
$this->entityManager->persist($userMerchant);
$this->entityManager->flush();

return $userMerchant;
}

} }



+ 10
- 1
Container/Address/AddressContainer.php View File



namespace Lc\CaracoleBundle\Container\Address; namespace Lc\CaracoleBundle\Container\Address;


use Lc\CaracoleBundle\Builder\Address\AddressBuilder;
use Lc\CaracoleBundle\Factory\Address\AddressFactory; use Lc\CaracoleBundle\Factory\Address\AddressFactory;
use Lc\CaracoleBundle\Repository\Address\AddressRepositoryQuery; use Lc\CaracoleBundle\Repository\Address\AddressRepositoryQuery;
use Lc\CaracoleBundle\Repository\Address\AddressStore; use Lc\CaracoleBundle\Repository\Address\AddressStore;
protected AddressFactory $factory; protected AddressFactory $factory;
protected AddressRepositoryQuery $repositoryQuery; protected AddressRepositoryQuery $repositoryQuery;
protected AddressStore $store; protected AddressStore $store;
protected AddressBuilder $builder;


public function __construct( public function __construct(
AddressFactory $factory, AddressFactory $factory,
AddressRepositoryQuery $repositoryQuery, AddressRepositoryQuery $repositoryQuery,
AddressStore $store
AddressStore $store,
AddressBuilder $builder
) { ) {
$this->factory = $factory; $this->factory = $factory;
$this->repositoryQuery = $repositoryQuery; $this->repositoryQuery = $repositoryQuery;
$this->store = $store; $this->store = $store;
$this->builder = $builder;
} }


public function getFactory(): AddressFactory public function getFactory(): AddressFactory
{ {
return $this->store; return $this->store;
} }

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

+ 10
- 1
Container/Credit/CreditHistoryContainer.php View File



namespace Lc\CaracoleBundle\Container\Credit; namespace Lc\CaracoleBundle\Container\Credit;


use Lc\CaracoleBundle\Builder\Credit\CreditHistoryBuilder;
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory; use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory;
use Lc\CaracoleBundle\Repository\Credit\CreditHistoryRepositoryQuery; use Lc\CaracoleBundle\Repository\Credit\CreditHistoryRepositoryQuery;
use Lc\CaracoleBundle\Repository\Credit\CreditHistoryStore; use Lc\CaracoleBundle\Repository\Credit\CreditHistoryStore;
protected CreditHistoryFactory $factory; protected CreditHistoryFactory $factory;
protected CreditHistoryRepositoryQuery $repositoryQuery; protected CreditHistoryRepositoryQuery $repositoryQuery;
protected CreditHistoryStore $store; protected CreditHistoryStore $store;
protected CreditHistoryBuilder $builder;


public function __construct( public function __construct(
CreditHistoryFactory $factory, CreditHistoryFactory $factory,
CreditHistoryRepositoryQuery $repositoryQuery, CreditHistoryRepositoryQuery $repositoryQuery,
CreditHistoryStore $store
CreditHistoryStore $store,
CreditHistoryBuilder $builder
) { ) {
$this->factory = $factory; $this->factory = $factory;
$this->repositoryQuery = $repositoryQuery; $this->repositoryQuery = $repositoryQuery;
$this->store = $store; $this->store = $store;
$this->builder = $builder;
} }


public function getFactory(): CreditHistoryFactory public function getFactory(): CreditHistoryFactory
{ {
return $this->store; return $this->store;
} }

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

+ 38
- 20
Container/Order/OrderShopContainer.php View File



namespace Lc\CaracoleBundle\Container\Order; namespace Lc\CaracoleBundle\Container\Order;


use App\Resolver\OrderResolver;
use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder; use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder;
use Lc\CaracoleBundle\Factory\Order\OrderShopFactory; use Lc\CaracoleBundle\Factory\Order\OrderShopFactory;
use Lc\CaracoleBundle\Repository\Order\OrderShopRepositoryQuery; use Lc\CaracoleBundle\Repository\Order\OrderShopRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
use Lc\CaracoleBundle\Transformer\Order\OrderShopTransformer;


class OrderShopContainer class OrderShopContainer
{ {
protected OrderShopFactory $orderShopFactory;
protected OrderShopSolver $orderShopSolver;
protected OrderShopRepositoryQuery $orderShopRepositoryQuery;
protected OrderShopStore $orderShopStore;
protected OrderShopBuilder $orderShopBuilder;
protected OrderShopFactory $factory;
protected OrderShopSolver $solver;
protected OrderShopRepositoryQuery $repositoryQuery;
protected OrderShopStore $store;
protected OrderShopBuilder $builder;
protected OrderResolver $resolver;
protected OrderShopTransformer $transformer;


public function __construct( public function __construct(
OrderShopFactory $orderShopFactory,
OrderShopSolver $orderShopSolver,
OrderShopRepositoryQuery $orderShopRepositoryQuery,
OrderShopStore $orderShopStore,
OrderShopBuilder $orderShopBuilder
OrderShopFactory $factory,
OrderShopSolver $solver,
OrderShopRepositoryQuery $repositoryQuery,
OrderShopStore $store,
OrderResolver $resolver,
OrderShopBuilder $builder,
OrderShopTransformer $transformer
) { ) {
$this->orderShopFactory = $orderShopFactory;
$this->orderShopSolver = $orderShopSolver;
$this->orderShopRepositoryQuery = $orderShopRepositoryQuery;
$this->orderShopStore = $orderShopStore;
$this->orderShopBuilder = $orderShopBuilder;
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->resolver = $resolver;
$this->builder = $builder;
$this->transformer = $transformer;
} }


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


public function getSolver(): OrderShopSolver public function getSolver(): OrderShopSolver
{ {
return $this->orderShopSolver;
return $this->solver;
} }


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


public function getStore(): OrderShopStore public function getStore(): OrderShopStore
{ {
return $this->orderShopStore;
return $this->store;
}

public function getResolver(): OrderResolver
{
return $this->resolver;
} }


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

public function getTransformer(): OrderShopTransformer
{
return $this->transformer;
} }


} }

+ 19
- 1
Container/User/UserMerchantContainer.php View File



namespace Lc\CaracoleBundle\Container\User; namespace Lc\CaracoleBundle\Container\User;


use Lc\CaracoleBundle\Builder\User\UserMerchantBuilder;
use Lc\CaracoleBundle\Factory\User\UserMerchantFactory; use Lc\CaracoleBundle\Factory\User\UserMerchantFactory;
use Lc\CaracoleBundle\Repository\User\UserMerchantRepositoryQuery; use Lc\CaracoleBundle\Repository\User\UserMerchantRepositoryQuery;
use Lc\CaracoleBundle\Repository\User\UserMerchantStore; use Lc\CaracoleBundle\Repository\User\UserMerchantStore;
use Lc\CaracoleBundle\Solver\User\UserMerchantSolver;


class UserMerchantContainer class UserMerchantContainer
{ {
protected UserMerchantFactory $factory; protected UserMerchantFactory $factory;
protected UserMerchantSolver $solver;
protected UserMerchantRepositoryQuery $repositoryQuery; protected UserMerchantRepositoryQuery $repositoryQuery;
protected UserMerchantStore $store; protected UserMerchantStore $store;
protected UserMerchantBuilder $builder;


public function __construct( public function __construct(
UserMerchantFactory $factory, UserMerchantFactory $factory,
UserMerchantSolver $solver,
UserMerchantRepositoryQuery $repositoryQuery, UserMerchantRepositoryQuery $repositoryQuery,
UserMerchantStore $store
UserMerchantStore $store,
UserMerchantBuilder $builder
) { ) {
$this->factory = $factory; $this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery; $this->repositoryQuery = $repositoryQuery;
$this->store = $store; $this->store = $store;
$this->builder = $builder;
} }


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


public function getSolver(): UserMerchantSolver
{
return $this->solver;
}

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


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

} }

+ 43
- 0
Form/Reduction/EditGiftVoucherType.php View File

<?php

namespace Lc\CaracoleBundle\Form\Reduction;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class EditGiftVoucherType extends AbstractType
{

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('activationDate', DateType::class, [
'label' => 'Date d\'activation de votre bon cadeau :',
'widget'=> 'single_text',
'help'=> 'Date à partir de laquelle la personne pourra utiliser ce bon cadeau.'
//'format'=> 'dd/MM/yyyy'
])
->add('title', TextType::class, [
'label' => 'Message personnalisé affiché dans le bon cadeau :',
'help'=> 'Exemple "Joyeux Noël Tata Suzanne !"'
])
->add('email', EmailType::class, [
'label' => 'Email de la personne à qui vous souhaitez offrir ce bon cadeau :',
'help'=> 'Le bon ne sera utilisable qu\'avec cet adresse e-mail'
])
->add('ownerName', TextType::class,[
'label' => 'Offert par :',
'help'=> 'Sera affiché dans le bon cadeau'
]);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}

+ 31
- 0
Form/Reduction/ReductionCartType.php View File

<?php

namespace Lc\CaracoleBundle\Form\Reduction;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ReductionCartType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'code',
TextType::class,
[
'label' => 'Bon de réduction :'
]
);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[

]
);
}
}

+ 26
- 0
Form/Reduction/SendGiftVoucherType.php View File

<?php

namespace Lc\CaracoleBundle\Form\Reduction;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class SendGiftVoucherType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{

$builder->add('message', TextareaType::class, [
'label' => 'Message personnalisé',
]);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}

+ 1
- 0
Model/Credit/CreditHistoryModel.php View File

const MEAN_PAYMENT_CREDIT = 'credit'; const MEAN_PAYMENT_CREDIT = 'credit';
const MEAN_PAYMENT_TRANSFER = 'transfer'; const MEAN_PAYMENT_TRANSFER = 'transfer';
const MEAN_PAYMENT_CASH = 'cash'; const MEAN_PAYMENT_CASH = 'cash';
const MEAN_PAYMENT_GIFT = 'transfer-gift';


/** /**
* @ORM\Column(type="float", nullable=true) * @ORM\Column(type="float", nullable=true)

+ 26
- 20
Repository/Order/OrderShopStore.php View File

} }


//public $countOrderShopsOfWeek = null; //public $countOrderShopsOfWeek = null;
public function countByCurrentCycle(bool $excludeComplementaryOrderShops = true, $query = null)
// public function countByCurrentCycle(bool $excludeComplementaryOrderShops = true, $query = null)
public function countByCurrentCycle(array $params, $query = null)
{ {
return $this->getByCurrentCycle(
return $this->countBy(
[ [
'count' => true,
'excludeComplementaryOrderShops' => $excludeComplementaryOrderShops

'cycleNumber' => $this->orderShopSolver->getCycleNumberCurrentOrder($this->section),
'excludeComplementaryOrderShops' => isset($params['excludeComplementaryOrderShops']) ?? true,
], ],
$query $query
); );
// getNextWeekId // getNextWeekId
public function getNextCycleId(int $cycleNumber, $query = null): int public function getNextCycleId(int $cycleNumber, $query = null): int
{ {
$lastOrder = $this->getOneLastValidOfCycle($cycleNumber, $query);
$lastOrder = $this->getOneLastValidByCycle($cycleNumber, $query);
if ($lastOrder) { if ($lastOrder) {
return intval($lastOrder->getCycleId() + 1); return intval($lastOrder->getCycleId() + 1);
} else { } else {
public function countBy(array $params = [], $query = null) public function countBy(array $params = [], $query = null)
{ {
$query = $this->createDefaultQuery($query); $query = $this->createDefaultQuery($query);

$query
->selectCount()
->applyGetByFilters($query);

$query->selectCount();
$this->applyGetByFilters($query);
return $query->count(); return $query->count();
} }


} }


// getReductionCartUsedQuantityPerUser // getReductionCartUsedQuantityPerUser
public function getReductionCartUsedQuantityByUser(ReductionCartInterface $reductionCart, UserInterface $user): float
{
public function getReductionCartUsedQuantityByUser(
ReductionCartInterface $reductionCart,
UserInterface $user
): float {
return $this->countValidWithReductionCartByUser($reductionCart, $user); return $this->countValidWithReductionCartByUser($reductionCart, $user);
} }


} }


// getReductionCartRemainingQuantityPerUser // getReductionCartRemainingQuantityPerUser
public function getReductionCartRemainingQuantityByUser(ReductionCartInterface $reductionCart, UserInterface $user): float
{
public function getReductionCartRemainingQuantityByUser(
ReductionCartInterface $reductionCart,
UserInterface $user
): float {
if ($reductionCart->getAvailableQuantityPerUser()) { if ($reductionCart->getAvailableQuantityPerUser()) {
return $reductionCart->getAvailableQuantityPerUser(
) - $this->countValidWithReductionCartByUser($reductionCart, $user);
return $reductionCart->getAvailableQuantityPerUser() - $this->countValidWithReductionCartByUser(
$reductionCart,
$user
);
} }


return false; return false;
return $reductionCartsArray; return $reductionCartsArray;
} }


public function countValidOrderProductsOfCyclesByProducts(array $cycleNumbers, array $products, $query =null): array
{
public function countValidOrderProductsOfCyclesByProducts(
array $cycleNumbers,
array $products,
$query = null
): array {
$query = $this->createDefaultQuery($query); $query = $this->createDefaultQuery($query);


$query $query
return $query->find(); return $query->find();
} }


public function countValidOrderProductsOfCycleByProduct(int $cycleNumber, int $productId, $query =null): ?string
public function countValidOrderProductsOfCycleByProduct(int $cycleNumber, int $productId, $query = null): ?string
{ {
$query = $this->createDefaultQuery($query); $query = $this->createDefaultQuery($query);



+ 1
- 0
Repository/Product/ProductCategoryStore.php View File

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{ {
$query->orderBy('position'); $query->orderBy('position');
return $query;
} }


public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface

+ 26
- 0
Repository/Reduction/ReductionCreditStore.php View File

return $query->find(); return $query->find();
} }


// findReductionGiftToUseByUser
public function getReductionGiftToUseByUser(UserInterface $user, $query = null)
{
/// @TODO : à écrire
$query = $this->createDefaultQuery($query);
$query->filterByUser($user);
return $query->find();
}

// findReductionGiftOwnedByUser
public function getReductionGiftOwnedByUser(UserInterface $user, $query = null)
{
/// @TODO : à écrire
$query = $this->createDefaultQuery($query);
$query->filterByUser($user);
return $query->find();
}

// findReductionGiftOwnedActiveByUser
public function getReductionGiftOwnedActiveByUser(UserInterface $user, $query = null)
{
/// @TODO : à écrire
$query = $this->createDefaultQuery($query);
$query->filterByUser($user);
return $query->find();
}


} }

+ 1
- 3
Resolver/MerchantResolver.php View File

<?php <?php

/** /**
* @author La clic ! <contact@laclic.fr> * @author La clic ! <contact@laclic.fr>
*/ */



namespace Lc\CaracoleBundle\Resolver; namespace Lc\CaracoleBundle\Resolver;



use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinition; use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinitionInterface; use Lc\CaracoleBundle\Definition\MerchantSettingDefinitionInterface;
} }
} }



public function getUserMerchant( public function getUserMerchant(
UserInterface $user = null, UserInterface $user = null,
MerchantInterface $merchant = null MerchantInterface $merchant = null

+ 38
- 7
Resolver/OpeningResolver.php View File

use Lc\CaracoleBundle\Definition\SectionSettingDefinition; use Lc\CaracoleBundle\Definition\SectionSettingDefinition;
use Lc\CaracoleBundle\Model\Section\OpeningInterface; use Lc\CaracoleBundle\Model\Section\OpeningInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface; use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\Section\SectionModel;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Solver\Setting\SettingSolver; use Lc\SovBundle\Solver\Setting\SettingSolver;
} }


public function isOpenSale( public function isOpenSale(
SectionInterface $section,
SectionInterface $section = null,
UserInterface $user = null, UserInterface $user = null,
\DateTime $date = null,
string $context = null string $context = null
): bool { ): bool {
// Initialisation // Initialisation
$this->messages = []; $this->messages = [];


if (is_null($date)) {
$date = new \DateTime();
if(is_null($section)) {
$section = $this->sectionResolver->getCurrent();
} }


$date = new \DateTime();

// État des prise de commande (voir configuration de section) // État des prise de commande (voir configuration de section)
$orderState = $this->settingSolver->getSettingValue($section, SectionSettingDefinition::SETTING_ORDER_STATE); $orderState = $this->settingSolver->getSettingValue($section, SectionSettingDefinition::SETTING_ORDER_STATE);


return false; return false;
} }


public function isOpenFullTime(SectionInterface $section = null)
{
if(is_null($section)) {
$section = $this->sectionResolver->getCurrent();
}

$orderState = $this->settingSolver->getSettingValue($section, SectionSettingDefinition::SETTING_ORDER_STATE);

if($orderState == SectionSettingDefinition::VALUE_ORDER_STATE_OPEN) {
return true;
}

return false;
}

// isHolidays // isHolidays
public function isClosingPeriod(SectionInterface $section, \DateTime $date)
public function isClosingPeriod(SectionInterface $section = null)
{ {
if(is_null($section)) {
$section = $this->sectionResolver->getCurrent();
}

$date = new \DateTime();

$orderClosedStart = $this->settingSolver->getSettingValue($section, SectionSettingDefinition::SETTING_ORDER_CLOSED_START); $orderClosedStart = $this->settingSolver->getSettingValue($section, SectionSettingDefinition::SETTING_ORDER_CLOSED_START);
$orderClosedEnd = $this->settingSolver->getSettingValue($section, SectionSettingDefinition::SETTING_ORDER_CLOSED_END); $orderClosedEnd = $this->settingSolver->getSettingValue($section, SectionSettingDefinition::SETTING_ORDER_CLOSED_END);


return false; return false;
} }


public function getDateEndCurrentSale(SectionInterface $section, $formatDate = '', $delimiterDayTime = 'à')
public function getDateEndCurrentSale(SectionInterface $section = null, $formatDate = '', $delimiterDayTime = 'à')
{ {
if(is_null($section)) {
$section = $this->sectionResolver->getCurrent();
}

// @TODO : à réécrire // @TODO : à réécrire
} }


public function getDateBeginNextSale(SectionInterface $section, $formatDate = '', $delimiterDayTime = 'à')
public function getDateBeginNextSale(SectionInterface $section = null, $formatDate = '', $delimiterDayTime = 'à')
{ {
if(is_null($section)) {
$section = $this->sectionResolver->getCurrent();
}

// @TODO : à réécrire // @TODO : à réécrire
} }



+ 27
- 21
Resolver/SectionResolver.php View File

protected EntityManagerInterface $entityManager; protected EntityManagerInterface $entityManager;
protected MerchantResolver $merchantResolver; protected MerchantResolver $merchantResolver;
protected SectionStore $sectionStore; protected SectionStore $sectionStore;
protected RequestStack $requestStack;


public function __construct(EntityManagerInterface $entityManager, MerchantResolver $merchantResolver, SectionStore $sectionStore)
public function __construct(EntityManagerInterface $entityManager, MerchantResolver $merchantResolver, SectionStore $sectionStore, RequestStack $requestStack)
{ {
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->merchantResolver = $merchantResolver; $this->merchantResolver = $merchantResolver;
$this->sectionStore = $sectionStore; $this->sectionStore = $sectionStore;
$this->requestStack = $requestStack;
} }


public function getCurrentFrontend()
public function getCurrent()
{ {
return $this->sectionStore
->setMerchant($this->merchantResolver->getCurrent())
->getOneDefault();
}

public function getCurrent(): SectionInterface
{
$currentAdminSection = null;
$userMerchant = $this->merchantResolver->getUserMerchant();
$requestAttributesArray = $this->requestStack->getMainRequest()->attributes->all();


if ($userMerchant !== null) {
$currentAdminSection = $userMerchant->getCurrentAdminSection();
}
// admin
if(isset($requestAttributesArray['easyadmin_context'])) {
$currentAdminSection = null;
$userMerchant = $this->merchantResolver->getUserMerchant();


if ($currentAdminSection === null) {
$currentAdminSection = $this->sectionStore
->setMerchant($userMerchant->getMerchant())
->getOneDefault();
if ($userMerchant !== null) {
$currentAdminSection = $userMerchant->getCurrentAdminSection();
}


if ($currentAdminSection === null) { if ($currentAdminSection === null) {
throw new \ErrorException('Aucune section par défaut définie pour ce merchant');
$currentAdminSection = $this->sectionStore
->setMerchant($userMerchant->getMerchant())
->getOneDefault();

if ($currentAdminSection === null) {
throw new \ErrorException('Aucune section par défaut définie pour ce merchant');
}
} }
}


return $currentAdminSection;
return $currentAdminSection;
}
// front
else {
return $this->sectionStore
->setMerchant($this->merchantResolver->getCurrent())
->getOneDefault();
}
} }





+ 1
- 1
Statistic/Product/ProductsSalesStatistic.php View File

public function init(SectionInterface $section, OrderShopSolver $orderShopSolver, OpeningResolver $openingResolver) public function init(SectionInterface $section, OrderShopSolver $orderShopSolver, OpeningResolver $openingResolver)
{ {
$currentCycleNumber = $orderShopSolver->getCycleNumberCurrentOrder(); $currentCycleNumber = $orderShopSolver->getCycleNumberCurrentOrder();
if ($openingResolver->isOpenSale($section, null, null,OpeningResolver::OPENING_CONTEXT_BACKEND) == false && date('w') > 2) {
if ($openingResolver->isOpenSale($section, null,OpeningResolver::OPENING_CONTEXT_BACKEND) == false && date('w') > 2) {
$currentCycleNumber = $currentCycleNumber - 1; $currentCycleNumber = $currentCycleNumber - 1;
} }
$this->cycleNumbers = array(); $this->cycleNumbers = array();

+ 8
- 4
Twig/StoreTwigExtension.php View File



public function getProductCategories() public function getProductCategories()
{ {
return $this->productCategoryStore->getParent(false);
return $this->productCategoryStore
->setSection($this->sectionResolver->getCurrent())
->getParent(false);
} }


public function getSections() public function getSections()
{ {
return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOnline();
return $this->sectionStore
->setMerchant($this->merchantResolver->getCurrent())
->getOnline();
} }


public function getSectionCurrent() public function getSectionCurrent()
{ {
return $this->sectionResolver->getCurrentFrontend();
return $this->sectionResolver->getCurrent();
} }


public function getMerchants() public function getMerchants()


public function getReductionCartCodes() public function getReductionCartCodes()
{ {
//TODO mettre à jour une fois les repo fait
//TODO mettre à jour une fois les repo fait
return array(); return array();
} }



Loading…
Cancel
Save