$user = $orderShop->getUser(); | $user = $orderShop->getUser(); | ||||
$orderProductsGiftVouchers = $this->orderProductStore->getGiftVouchersByOrder($orderShop); | $orderProductsGiftVouchers = $this->orderProductStore->getGiftVouchersByOrder($orderShop); | ||||
$sectionMarket = $this->sectionStore | |||||
->setMerchant($orderShop->getSection()->getMerchant()) | |||||
->getOneMarket(); | |||||
foreach ($orderProductsGiftVouchers as $orderProductsGiftVoucher) { | foreach ($orderProductsGiftVouchers as $orderProductsGiftVoucher) { | ||||
$i = 1; | $i = 1; | ||||
// création de la reductionCredit | // création de la reductionCredit | ||||
while ($i <= $orderProductsGiftVoucher->getQuantityOrder()) { | while ($i <= $orderProductsGiftVoucher->getQuantityOrder()) { | ||||
$reductionGift = $this->reductionCreditFactory->create($sectionMarket, ReductionCreditModel::TYPE_GIFT); | |||||
$reductionGift = $this->reductionCreditFactory->create($orderShop->getSection()->getMerchant(), ReductionCreditModel::TYPE_GIFT); | |||||
$reductionGift->setTitle($orderProductsGiftVoucher->getTitle()); | $reductionGift->setTitle($orderProductsGiftVoucher->getTitle()); | ||||
$reductionGift->setOwner($user); | $reductionGift->setOwner($user); | ||||
$reductionGift->setCreatedBy($user); | $reductionGift->setCreatedBy($user); | ||||
$reductionGift->setUpdatedBy($user); | $reductionGift->setUpdatedBy($user); | ||||
$reductionGift->setValue($this->priceSolver->getPriceWithTax($orderProductsGiftVoucher->getProduct())); | $reductionGift->setValue($this->priceSolver->getPriceWithTax($orderProductsGiftVoucher->getProduct())); | ||||
$reductionGift->setBehaviorTaxRate(TaxRateModel::BEHAVIOR_TAX_RATE_INCLUDED); | $reductionGift->setBehaviorTaxRate(TaxRateModel::BEHAVIOR_TAX_RATE_INCLUDED); | ||||
$this->entityManager->persist($reductionGift); | |||||
$this->entityManager->create($reductionGift); | |||||
$i++; | $i++; | ||||
} | } |
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
return $this->getReductionCartContainer()->getFactory()->create($this->getSectionCurrent()); | |||||
return $this->getReductionCartContainer()->getFactory()->create($this->getMerchantCurrent()); | |||||
} | } | ||||
} | } |
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
return $this->getReductionCatalogContainer()->getFactory()->create($this->getSectionCurrent()); | |||||
return $this->getReductionCatalogContainer()->getFactory()->create($this->getMerchantCurrent()); | |||||
} | } | ||||
} | } |
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
return $this->getReductionCreditContainer()->getFactory()->create($this->getSectionCurrent()); | |||||
return $this->getReductionCreditContainer()->getFactory()->create($this->getMerchantCurrent()); | |||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Factory\Reduction; | namespace Lc\CaracoleBundle\Factory\Reduction; | ||||
use App\Entity\Reduction\ReductionCart; | use App\Entity\Reduction\ReductionCart; | ||||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | |||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
class ReductionCartFactory extends AbstractFactory | class ReductionCartFactory extends AbstractFactory | ||||
{ | { | ||||
public function create(SectionInterface $section): ReductionCartInterface | |||||
public function create(MerchantInterface $merchant): ReductionCartInterface | |||||
{ | { | ||||
$reductionCart = new ReductionCart(); | $reductionCart = new ReductionCart(); | ||||
$reductionCart->setSection($section); | |||||
$reductionCart->setMerchant($merchant); | |||||
$reductionCart->setStatus(1); | $reductionCart->setStatus(1); | ||||
return $reductionCart; | return $reductionCart; |
namespace Lc\CaracoleBundle\Factory\Reduction; | namespace Lc\CaracoleBundle\Factory\Reduction; | ||||
use App\Entity\Reduction\ReductionCatalog; | use App\Entity\Reduction\ReductionCatalog; | ||||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | |||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
class ReductionCatalogFactory extends AbstractFactory | class ReductionCatalogFactory extends AbstractFactory | ||||
{ | { | ||||
public function create(SectionInterface $section): ReductionCatalogInterface | |||||
public function create(MerchantInterface $merchant): ReductionCatalogInterface | |||||
{ | { | ||||
$reductionCatalog = new ReductionCatalog(); | $reductionCatalog = new ReductionCatalog(); | ||||
$reductionCatalog->setSection($section); | |||||
$reductionCatalog->setMerchant($merchant); | |||||
$reductionCatalog->setStatus(1); | $reductionCatalog->setStatus(1); | ||||
return $reductionCatalog; | return $reductionCatalog; |
namespace Lc\CaracoleBundle\Factory\Reduction; | namespace Lc\CaracoleBundle\Factory\Reduction; | ||||
use App\Entity\Reduction\ReductionCredit; | use App\Entity\Reduction\ReductionCredit; | ||||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | |||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
class ReductionCreditFactory extends AbstractFactory | class ReductionCreditFactory extends AbstractFactory | ||||
{ | { | ||||
public function create(SectionInterface $section, string $type = ReductionCreditModel::TYPE_CREDIT): ReductionCreditInterface | |||||
public function create(MerchantInterface $merchant, string $type = ReductionCreditModel::TYPE_CREDIT): ReductionCreditInterface | |||||
{ | { | ||||
$reductionCredit = new ReductionCredit(); | $reductionCredit = new ReductionCredit(); | ||||
$reductionCredit->setSection($section); | |||||
$reductionCredit->setMerchant($merchant); | |||||
$reductionCredit->setType($type); | $reductionCredit->setType($type); | ||||
$reductionCredit->setStatus(1); | $reductionCredit->setStatus(1); | ||||
} | } | ||||
$section = ' ['.$category->getSection()->getTitle().']' ;; | $section = ' ['.$category->getSection()->getTitle().']' ;; | ||||
return $category . $section. $isOffline; | return $category . $section. $isOffline; | ||||
} | } | ||||
) | ) | ||||
); | ); |
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinInterface; | use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinTrait; | use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinTrait; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionCartPropertyInterface; | use Lc\CaracoleBundle\Doctrine\Extension\ReductionCartPropertyInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyInterface; | use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\StatusInterface; | use Lc\SovBundle\Doctrine\Extension\StatusInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\StatusTrait; | use Lc\SovBundle\Doctrine\Extension\StatusTrait; | ||||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | ||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class ReductionCartModel extends AbstractLightEntity implements ReductionPropertyInterface, ReductionInterface, | abstract class ReductionCartModel extends AbstractLightEntity implements ReductionPropertyInterface, ReductionInterface, | ||||
ReductionCartPropertyInterface, | ReductionCartPropertyInterface, | ||||
FilterSectionInterface, | |||||
OrderAmountMinInterface, StatusInterface | |||||
FilterMerchantInterface, | |||||
OrderAmountMinInterface, | |||||
StatusInterface | |||||
{ | { | ||||
use StatusTrait; | use StatusTrait; | ||||
use OrderAmountMinTrait; | use OrderAmountMinTrait; | ||||
protected $title; | protected $title; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | |||||
* @ORM\JoinColumn(nullable=false) | * @ORM\JoinColumn(nullable=false) | ||||
*/ | */ | ||||
protected $section; | |||||
protected $merchant; | |||||
/** | /** | ||||
* @ORM\Column(type="array", nullable=true) | * @ORM\Column(type="array", nullable=true) | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getSection(): SectionInterface | |||||
public function getMerchant(): MerchantInterface | |||||
{ | { | ||||
return $this->section; | |||||
return $this->merchant; | |||||
} | } | ||||
public function setSection(SectionInterface $section): self | |||||
public function setMerchant(MerchantInterface $merchant): self | |||||
{ | { | ||||
$this->section = $section; | |||||
$this->merchant = $merchant; | |||||
return $this; | return $this; | ||||
} | } | ||||
public function getCodes(): ?array | public function getCodes(): ?array | ||||
{ | { | ||||
return $this->codes; | return $this->codes; |
use Doctrine\Common\Collections\ArrayCollection; | use Doctrine\Common\Collections\ArrayCollection; | ||||
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyTrait; | use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyTrait; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyInterface; | use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\StatusInterface; | use Lc\SovBundle\Doctrine\Extension\StatusInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\StatusTrait; | use Lc\SovBundle\Doctrine\Extension\StatusTrait; | ||||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | ||||
*/ | */ | ||||
abstract class ReductionCatalogModel extends AbstractLightEntity implements ReductionCatalogInterface, | abstract class ReductionCatalogModel extends AbstractLightEntity implements ReductionCatalogInterface, | ||||
ReductionPropertyInterface, | ReductionPropertyInterface, | ||||
FilterSectionInterface, StatusInterface | |||||
FilterMerchantInterface, | |||||
StatusInterface | |||||
{ | { | ||||
use StatusTrait; | use StatusTrait; | ||||
use ReductionTrait; | use ReductionTrait; | ||||
protected $title; | protected $title; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | |||||
* @ORM\JoinColumn(nullable=false) | * @ORM\JoinColumn(nullable=false) | ||||
*/ | */ | ||||
protected $section; | |||||
protected $merchant; | |||||
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface") | * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface") | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getSection(): SectionInterface | |||||
public function getMerchant(): MerchantInterface | |||||
{ | { | ||||
return $this->section; | |||||
return $this->merchant; | |||||
} | } | ||||
public function setSection(SectionInterface $section): self | |||||
public function setMerchant(MerchantInterface $merchant): self | |||||
{ | { | ||||
$this->section = $section; | |||||
$this->merchant = $merchant; | |||||
return $this; | return $this; | ||||
} | } |
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface; | use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | ||||
use Lc\CaracoleBundle\Model\Config\UnitModel; | use Lc\CaracoleBundle\Model\Config\UnitModel; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\SovBundle\Doctrine\Extension\StatusInterface; | use Lc\SovBundle\Doctrine\Extension\StatusInterface; | ||||
use Lc\SovBundle\Doctrine\Extension\StatusTrait; | use Lc\SovBundle\Doctrine\Extension\StatusTrait; | ||||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | ||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class ReductionCreditModel extends AbstractLightEntity implements ReductionInterface, FilterSectionInterface, | |||||
abstract class ReductionCreditModel extends AbstractLightEntity implements ReductionInterface, | |||||
FilterMerchantInterface, | |||||
StatusInterface | StatusInterface | ||||
{ | { | ||||
const TYPE_CREDIT = 'credit'; | const TYPE_CREDIT = 'credit'; | ||||
protected $users; | protected $users; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | |||||
* @ORM\JoinColumn(nullable=false) | * @ORM\JoinColumn(nullable=false) | ||||
*/ | */ | ||||
protected $section; | |||||
protected $merchant; | |||||
/** | /** | ||||
* @ORM\Column(type="string", length=255) | * @ORM\Column(type="string", length=255) | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getSection(): SectionInterface | |||||
public function getMerchant(): MerchantInterface | |||||
{ | { | ||||
return $this->section; | |||||
return $this->merchant; | |||||
} | } | ||||
public function setSection(SectionInterface $section): self | |||||
public function setMerchant(MerchantInterface $merchant): self | |||||
{ | { | ||||
$this->section = $section; | |||||
$this->merchant = $merchant; | |||||
return $this; | return $this; | ||||
} | } |
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 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; | ||||
//TODO vérifier que ne pas utiliser createDefaultQuery est pertinent | //TODO vérifier que ne pas utiliser createDefaultQuery est pertinent | ||||
$query = $this->createQuery($query); | $query = $this->createQuery($query); | ||||
if ($user) { | if ($user) { | ||||
$query->filterByUser($user); | $query->filterByUser($user); | ||||
} | } | ||||
public function getReductionCreditsAvailableByUser(UserInterface $user): array | public function getReductionCreditsAvailableByUser(UserInterface $user): array | ||||
{ | { | ||||
$reductionCredits = $this->reductionCreditStore->getByTypeAndUser(ReductionCreditModel::TYPE_CREDIT, $user); | |||||
$reductionCredits = $this->reductionCreditStore | |||||
->setMerchant($this->merchant) | |||||
->getByTypeAndUser(ReductionCreditModel::TYPE_CREDIT, $user); | |||||
$reductionCreditsArray = []; | $reductionCreditsArray = []; | ||||
foreach ($reductionCredits as $reductionCredit) { | foreach ($reductionCredits as $reductionCredit) { | ||||
if (!$this->countValidWithReductionCredit($reductionCredit, $user) | |||||
&& ($reductionCredit->getSection()->getMerchant() == $this->merchant)) { | |||||
if (!$this->countValidWithReductionCredit($reductionCredit, $user)) { | |||||
$reductionCreditsArray[] = $reductionCredit; | $reductionCreditsArray[] = $reductionCredit; | ||||
} | } | ||||
} | } | ||||
return $reductionCreditsArray; | return $reductionCreditsArray; | ||||
} | } | ||||
public function getReductionGiftsAvailableByUser($user): array | |||||
public function getReductionGiftsAvailableByUser(UserInterface $user): array | |||||
{ | { | ||||
$reductionGifts = $this->reductionCreditStore->getByTypeAndUser(ReductionCreditModel::TYPE_GIFT, $user); | |||||
$reductionGifts = $this->reductionCreditStore | |||||
->setMerchant($this->merchant) | |||||
->getByTypeAndUser(ReductionCreditModel::TYPE_GIFT, $user); | |||||
$reductionGiftsArray = []; | $reductionGiftsArray = []; | ||||
foreach ($reductionGifts as $reductionGift) { | foreach ($reductionGifts as $reductionGift) { | ||||
if (!$this->countValidWithReductionCredit($reductionGift)) { | |||||
if (!$this->countValidWithReductionCredit($reductionGift, $user)) { | |||||
$reductionGiftsArray[] = $reductionGift; | $reductionGiftsArray[] = $reductionGift; | ||||
} | } | ||||
} | } | ||||
// findAllAvailableForUser / getReductionCartsAvailableByUser | // findAllAvailableForUser / getReductionCartsAvailableByUser | ||||
public function getReductionCartAvailableByUser(UserInterface $user, $query = null) | public function getReductionCartAvailableByUser(UserInterface $user, $query = null) | ||||
{ | { | ||||
$reductionCarts = $this->reductionCartStore->getOnline(); | |||||
$reductionCarts = $this->reductionCartStore | |||||
->setMerchant($this->merchant) | |||||
->getOnline(); | |||||
$reductionCartsArray = []; | $reductionCartsArray = []; | ||||
foreach ($reductionCarts as $reductionCart) { | foreach ($reductionCarts as $reductionCart) { | ||||
&& $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user) | && $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user) | ||||
&& $this->getReductionCartRemainingQuantityByUser($reductionCart, $user) | && $this->getReductionCartRemainingQuantityByUser($reductionCart, $user) | ||||
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0) | && ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0) | ||||
&& (!$this->merchant || $reductionCart->getSection()->getMerchant() == $this->merchant)) { | |||||
&& (!$this->merchant || $reductionCart->getMerchant() == $this->merchant)) { | |||||
$reductionCartsArray[] = $reductionCart; | $reductionCartsArray[] = $reductionCart; | ||||
} | } |
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | ||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class ReductionCartRepositoryQuery extends AbstractRepositoryQuery | class ReductionCartRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
use SectionRepositoryQueryTrait; | |||||
use MerchantRepositoryQueryTrait; | |||||
public function __construct(ReductionCartRepository $repository, PaginatorInterface $paginator) | public function __construct(ReductionCartRepository $repository, PaginatorInterface $paginator) | ||||
{ | { |
namespace Lc\CaracoleBundle\Repository\Reduction; | namespace Lc\CaracoleBundle\Repository\Reduction; | ||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver; | use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver; | ||||
use Lc\CaracoleBundle\Repository\AbstractStore; | use Lc\CaracoleBundle\Repository\AbstractStore; | ||||
class ReductionCartStore extends AbstractStore | class ReductionCartStore extends AbstractStore | ||||
{ | { | ||||
use SectionStoreTrait; | |||||
use MerchantStoreTrait; | |||||
protected ReductionCartRepositoryQuery $query; | protected ReductionCartRepositoryQuery $query; | ||||
protected ReductionCartSolver $reductionCartSolver; | protected ReductionCartSolver $reductionCartSolver; | ||||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
if($this->section) { | |||||
$query->filterBySection($this->section); | |||||
} | |||||
$this->addFilterByMerchantRequired($query); | |||||
$query->filterIsOnlineAndOffline(); | $query->filterIsOnlineAndOffline(); | ||||
return $query; | return $query; | ||||
} | } | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | ||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | |||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
protected bool $isJoinUsers = false; | protected bool $isJoinUsers = false; | ||||
protected bool $isJoinGroupUsers = false; | protected bool $isJoinGroupUsers = false; | ||||
use SectionRepositoryQueryTrait; | |||||
use MerchantRepositoryQueryTrait; | |||||
public function __construct(ReductionCatalogRepository $repository, PaginatorInterface $paginator) | public function __construct(ReductionCatalogRepository $repository, PaginatorInterface $paginator) | ||||
{ | { |
namespace Lc\CaracoleBundle\Repository\Reduction; | namespace Lc\CaracoleBundle\Repository\Reduction; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||||
use Lc\CaracoleBundle\Repository\AbstractStore; | use Lc\CaracoleBundle\Repository\AbstractStore; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
class ReductionCatalogStore extends AbstractStore | class ReductionCatalogStore extends AbstractStore | ||||
{ | { | ||||
use SectionStoreTrait; | |||||
use MerchantStoreTrait; | |||||
protected ReductionCatalogRepositoryQuery $query; | protected ReductionCatalogRepositoryQuery $query; | ||||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$this->addFilterBySectionOptionnal($query); | |||||
$this->addFilterByMerchantRequired($query); | |||||
$query->filterIsOnlineAndOffline(); | $query->filterIsOnlineAndOffline(); | ||||
return $query; | return $query; | ||||
} | } |
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | ||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | |||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class ReductionCreditRepositoryQuery extends AbstractRepositoryQuery | class ReductionCreditRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
use SectionRepositoryQueryTrait; | |||||
use MerchantRepositoryQueryTrait; | |||||
// @TODO : à utiliser | |||||
protected $isJoinUsers = false; | protected $isJoinUsers = false; | ||||
public function __construct(ReductionCreditRepository $repository, PaginatorInterface $paginator) | public function __construct(ReductionCreditRepository $repository, PaginatorInterface $paginator) |
class ReductionCreditStore extends AbstractStore | class ReductionCreditStore extends AbstractStore | ||||
{ | { | ||||
use SectionStoreTrait; | |||||
use MerchantStoreTrait; | use MerchantStoreTrait; | ||||
protected ReductionCreditRepositoryQuery $query; | protected ReductionCreditRepositoryQuery $query; | ||||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$this->addFilterBySectionOptionnal($query); | |||||
$this->addFilterByMerchantViaSectionOptionnal($query); | |||||
$this->addFilterByMerchantRequired($query); | |||||
$query->filterIsOnlineAndOffline(); | $query->filterIsOnlineAndOffline(); | ||||
return $query; | return $query; |
use App\Entity\Order\OrderShop; | use App\Entity\Order\OrderShop; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore; | |||||
use Lc\CaracoleBundle\Resolver\OrderShopResolver; | use Lc\CaracoleBundle\Resolver\OrderShopResolver; | ||||
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | ||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
protected TranslatorAdmin $translatorAdmin; | protected TranslatorAdmin $translatorAdmin; | ||||
protected UrlGeneratorInterface $urlGenerator; | protected UrlGeneratorInterface $urlGenerator; | ||||
public function __construct(PriceSolver $priceSolver, OrderShopSolver $orderShopSolver, OrderShopResolver $orderShopResolver, TranslatorAdmin $translatorAdmin, UrlGeneratorInterface $urlGenerator) | |||||
{ | |||||
public function __construct( | |||||
PriceSolver $priceSolver, | |||||
OrderShopSolver $orderShopSolver, | |||||
OrderShopResolver $orderShopResolver, | |||||
TranslatorAdmin $translatorAdmin, | |||||
UrlGeneratorInterface $urlGenerator | |||||
) { | |||||
$this->priceSolver = $priceSolver; | $this->priceSolver = $priceSolver; | ||||
$this->orderShopSolver = $orderShopSolver; | $this->orderShopSolver = $orderShopSolver; | ||||
$this->orderShopResolver = $orderShopResolver; | $this->orderShopResolver = $orderShopResolver; | ||||
public function getDatas(OrderShopInterface $orderShop, UserInterface $user = null): array | public function getDatas(OrderShopInterface $orderShop, UserInterface $user = null): array | ||||
{ | { | ||||
$data = []; | $data = []; | ||||
$data['order'] = $orderShop; | $data['order'] = $orderShop; | ||||
$data['count'] = $this->orderShopSolver->countQuantities($orderShop); | |||||
$data['total_with_tax'] = $this->priceSolver->getTotalWithTax($orderShop); | |||||
$data['order_products_by_category'] = $this->orderShopSolver->getOrderProductsByParentCategory($orderShop); | |||||
$data['total_remaining_to_be_paid'] = $this->orderShopResolver->getTotalRemainingToBePaid($orderShop); | |||||
if ($orderShop) { | |||||
$data['count'] = $this->orderShopSolver->countQuantities($orderShop); | |||||
$data['total_with_tax'] = $this->priceSolver->getTotalWithTax($orderShop); | |||||
$data['order_products_by_category'] = $this->orderShopSolver->getOrderProductsByParentCategory($orderShop); | |||||
$data['total_remaining_to_be_paid'] = $this->orderShopResolver->getTotalRemainingToBePaid($orderShop); | |||||
} | |||||
return $data; | return $data; | ||||
} | } | ||||
{ | { | ||||
$data = array(); | $data = array(); | ||||
foreach ($order->getOrderPayments() as $orderPayment) { | foreach ($order->getOrderPayments() as $orderPayment) { | ||||
$data[$orderPayment->getId()] = array( | $data[$orderPayment->getId()] = array( | ||||
'id' => $orderPayment->getId(), | 'id' => $orderPayment->getId(), | ||||
'reference' => $orderPayment->getReference(), | 'reference' => $orderPayment->getReference(), | ||||
'comment' => $orderPayment->getComment(), | 'comment' => $orderPayment->getComment(), | ||||
'meanPayment' => $orderPayment->getMeanPayment(), | 'meanPayment' => $orderPayment->getMeanPayment(), | ||||
'meanPaymentText' => $this->translatorAdmin->transChoice( | 'meanPaymentText' => $this->translatorAdmin->transChoice( | ||||
'OrderPayment', 'meanPayment',$orderPayment->getMeanPayment() | |||||
'OrderPayment', | |||||
'meanPayment', | |||||
$orderPayment->getMeanPayment() | |||||
), | ), | ||||
'paidAtText' => $orderPayment->getPaidAt()->format('d/m/Y'), | 'paidAtText' => $orderPayment->getPaidAt()->format('d/m/Y'), | ||||
'paidAt' => $orderPayment->getPaidAt()->format('Y-m-d'), | 'paidAt' => $orderPayment->getPaidAt()->format('Y-m-d'), | ||||
'type' => $orderDocument->getType(), | 'type' => $orderDocument->getType(), | ||||
'isSent' => $orderDocument->getIsSent(), | 'isSent' => $orderDocument->getIsSent(), | ||||
'orderReference' => $order->getReference(), | 'orderReference' => $order->getReference(), | ||||
'link' => $this->urlGenerator->generate('document_download', ['id'=> $orderDocument->getId()]) | |||||
'link' => $this->urlGenerator->generate('document_download', ['id' => $orderDocument->getId()]) | |||||
); | ); | ||||
} | } | ||||
return $data; | return $data; |