Explorar el Código

Merge branch 'develop'

master
Guillaume hace 4 años
padre
commit
2d79d6b610
Se han modificado 17 ficheros con 227 adiciones y 53 borrados
  1. +8
    -0
      ShopBundle/Context/DeliveryUtilsInterface.php
  2. +8
    -0
      ShopBundle/Context/PriceUtilsInterface.php
  3. +2
    -2
      ShopBundle/Controller/CitiesController.php
  4. +1
    -1
      ShopBundle/Controller/Frontend/CartController.php
  5. +13
    -7
      ShopBundle/EventSubscriber/EditEventSubscriber.php
  6. +1
    -1
      ShopBundle/Model/Address.php
  7. +17
    -0
      ShopBundle/Model/OrderShop.php
  8. +9
    -0
      ShopBundle/Model/Product.php
  9. +0
    -11
      ShopBundle/Repository/PointSaleRepository.php
  10. +41
    -0
      ShopBundle/Services/AddressUtils.php
  11. +17
    -1
      ShopBundle/Services/CityUtils.php
  12. +0
    -13
      ShopBundle/Services/CustomCKFinderAuth.phpRENAME
  13. +54
    -0
      ShopBundle/Services/DateUtils.php
  14. +18
    -0
      ShopBundle/Services/DeliveryUtils.php
  15. +36
    -15
      ShopBundle/Services/PriceUtils.php
  16. +1
    -1
      ShopBundle/Services/Utils.php
  17. +1
    -1
      ShopBundle/Twig/FrontendTwigExtension.php

+ 8
- 0
ShopBundle/Context/DeliveryUtilsInterface.php Ver fichero

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

namespace Lc\ShopBundle\Context ;

interface DeliveryUtilsInterface
{

}

+ 8
- 0
ShopBundle/Context/PriceUtilsInterface.php Ver fichero

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

namespace Lc\ShopBundle\Context ;

interface PriceUtilsInterface
{

}

+ 2
- 2
ShopBundle/Controller/CitiesController.php Ver fichero

@@ -2,7 +2,7 @@

namespace Lc\ShopBundle\Controller ;

use Lc\ShopBundle\Services\Cities;
use Lc\ShopBundle\Services\CityUtils;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -11,7 +11,7 @@ class CitiesController extends AbstractController
{
protected $cities ;

public function __construct(Cities $cities)
public function __construct(CityUtils $cities)
{
$this->cities = $cities ;
}

+ 1
- 1
ShopBundle/Controller/Frontend/CartController.php Ver fichero

@@ -47,7 +47,7 @@ class CartController extends BaseController
foreach($data as $orderProduct) {
if($orderProduct instanceof OrderProductInterface) {
$this->orderUtils->addOrderProduct($orderShop, $orderProduct) ;
if($orderProduct->getQuantityorder() > 0) {
if($orderProduct->getQuantityOrder() > 0) {
$this->orderProducts[] = $orderProduct ;
}
}

+ 13
- 7
ShopBundle/EventSubscriber/EditEventSubscriber.php Ver fichero

@@ -67,12 +67,14 @@ class EditEventSubscriber implements EventSubscriberInterface
return $entity;
}

private function setSortableProperty($entity, $entityRepo){
private function setSortableProperty($entity, $entityRepo)
{
if ($entity instanceof TreeInterface) {
if ($entity->getParent()) {
$total = $entityRepo->count(array('status' => 1, 'parent' => $entity->getParent()->getId()));
$entity->setPosition($entity->getParent()->getId() . '_' . $total);
} else {
$entity->setPosition((float) $entity->getParent()->getId() . '.' . str_pad($total, 2, '0', STR_PAD_LEFT));
}
else {
if ($entity instanceof FilterMerchantInterface) {
$total = $entityRepo->count(array('status' => 1, 'parent' => null, 'merchant' => $this->merchantUtils->getMerchantCurrent()));
}else{
@@ -80,10 +82,12 @@ class EditEventSubscriber implements EventSubscriberInterface
}
$entity->setPosition($total);
}
} else {
}
else {
if ($entity instanceof FilterMerchantInterface) {
$total = $entityRepo->count(array('status' => 1, 'merchant' => $this->merchantUtils->getMerchantCurrent()));
}else{
}
else {
$total = $entityRepo->count(array('status' => 1));
}
$entity->setPosition($total);
@@ -91,11 +95,13 @@ class EditEventSubscriber implements EventSubscriberInterface
return $entity;
}

private function setMerchantProperty($entity){
private function setMerchantProperty($entity)
{
$entity->setMerchant($this->merchantUtils->getMerchantCurrent());
}

private function setMultipleMerchantProperty($entity){
private function setMultipleMerchantProperty($entity)
{
if ($entity->getMerchants()->isEmpty()) {
$entity->addMerchant($this->merchantUtils->getMerchantCurrent());
}

+ 1
- 1
ShopBundle/Model/Address.php Ver fichero

@@ -98,7 +98,7 @@ abstract class Address extends AbstractEntity

public function __toString()
{
return $this->getTitle() ;
return $this->getTitle().' - '.$this->getZip().' '.$this->getCity() ;
}

public function getUser(): ?User

+ 17
- 0
ShopBundle/Model/OrderShop.php Ver fichero

@@ -85,6 +85,11 @@ abstract class OrderShop implements FilterMerchantInterface
*/
protected $documentDeliveryNote;

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

public function __construct()
{
$this->orderStatusHistories = new ArrayCollection();
@@ -304,4 +309,16 @@ abstract class OrderShop implements FilterMerchantInterface

return $this;
}

public function getInfosDelivery(): ?string
{
return $this->infosDelivery;
}

public function setInfosDelivery(?string $infosDelivery): self
{
$this->infosDelivery = $infosDelivery;

return $this;
}
}

+ 9
- 0
ShopBundle/Model/Product.php Ver fichero

@@ -108,6 +108,15 @@ abstract class Product extends AbstractEntity implements SortableInterface, Prod
return $quantity.$unit->getWordingShort() ;
}

public function getQuantityTitle($productFamily)
{
$title = $this->getQuantityLabelInherited() ;
if($productFamily->hasProductsWithVariousWeight()) {
$title .= ', '.$this->getTitleInherited() ;
}
return $title ;
}

public function getAvailableQuantityInherited()
{
if($this->getProductFamily()->getBehaviorCountStock()) {

+ 0
- 11
ShopBundle/Repository/PointSaleRepository.php Ver fichero

@@ -19,17 +19,6 @@ class PointSaleRepository extends BaseRepository implements DefaultRepositoryInt
return PointSaleInterface::class;
}

public function findAllPublics()
{
return $this->createQueryBuilder('e')
->where(':currentMerchant MEMBER OF e.merchants')
->andWhere('e.isPublic = 1')
->andWhere('e.status = 1')
->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent())
->getQuery()
->getResult() ;
}

public function findAllByMerchant()
{
return $this->createQueryBuilder('e')

+ 41
- 0
ShopBundle/Services/AddressUtils.php Ver fichero

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

namespace Lc\ShopBundle\Services ;

use Lc\ShopBundle\Context\AddressInterface;

class AddressUtils
{
public function getSummaryShort(AddressInterface $address)
{
return $address->getAddress().' - '.$address->getZip().' '.$address->getCity() ;
}

public function getSummary(AddressInterface $address)
{
$html = '' ;

if($address->getTitle()) {
$html .= $address->getTitle().'<br />' ;
}

if($address->getLastname() || $address->getFirstname()) {
$html .= $address->getLastname().' '.$address->getFirstname().'<br />' ;
}

if($address->getAddress()) {
$html .= $address->getAddress().'<br />' ;
}

if($address->getZip() || $address->getCity()) {
$html .= $address->getZip().' '.$address->getCity().'<br />' ;
}

if($address->getPhone()) {
$html .= 'Tél. '.$address->getPhone() ;
}

return $html ;
}

}

ShopBundle/Services/Cities.php → ShopBundle/Services/CityUtils.php Ver fichero

@@ -2,7 +2,7 @@

namespace Lc\ShopBundle\Services ;

class Cities
class CityUtils
{

function callApi($method, $url, $data = false)
@@ -39,4 +39,20 @@ class Cities

return $result;
}

public function getZipByCity($city)
{
$zip = null ;
$returnCitiesSearchZip = json_decode($this->callApi('get', 'communes', ['nom' => $city, 'fields' => 'nom,codesPostaux'])) ;

if($returnCitiesSearchZip) {
foreach($returnCitiesSearchZip as $citySearchZip) {
if(strtolower(trim($city)) == strtolower(trim($citySearchZip->nom))) {
$zip = $citySearchZip->codesPostaux[0] ;
}
}
}

return $zip ;
}
}

+ 0
- 13
ShopBundle/Services/CustomCKFinderAuth.phpRENAME Ver fichero

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

namespace Lc\ShopBundle\Services;

use CKSource\Bundle\CKFinderBundle\Authentication\Authentication as AuthenticationBase;

class CustomCKFinderAuth extends AuthenticationBase
{
public function authenticate()
{
return true;
}
}

+ 54
- 0
ShopBundle/Services/DateUtils.php Ver fichero

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

namespace Lc\ShopBundle\Services ;

class DateUtils
{
public function date($format, $timestamp)
{
setlocale(LC_TIME, 'fr_FR.UTF8', 'fr.UTF8', 'fr_FR.UTF-8', 'fr.UTF-8');
return strftime($format, $timestamp) ;
}

public function getNextDay($day)
{
return new \DateTime('next '.$day) ;
}

public function getNextDayByNumber($number)
{
return $this->getNextDay($this->getDayByNumber($number, 'en')) ;
}

public function getDayByNumber($number, $lang = 'fr')
{
if($lang == 'fr') {
$daysArray = [
1 => 'Lundi',
2 => 'Mardi',
3 => 'Mercredi',
4 => 'Jeudi',
5 => 'Vendredi',
6 => 'Samedi',
7 => 'Dimanche'
] ;
}
else {
$daysArray = [
1 => 'Monday',
2 => 'Tuesday',
3 => 'Wednesday',
4 => 'Thursday',
5 => 'Friday',
6 => 'Saturday',
7 => 'Sunday',
] ;
}

if(isset($daysArray[$number])) {
return $daysArray[$number] ;
}

return '' ;
}
}

+ 18
- 0
ShopBundle/Services/DeliveryUtils.php Ver fichero

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

namespace Lc\ShopBundle\Services ;

use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Security;

class DeliveryUtils
{
protected $em ;
protected $security ;

public function __construct(EntityManagerInterface $em, Security $security)
{
$this->em = $em ;
$this->security = $security ;
}
}

+ 36
- 15
ShopBundle/Services/PriceUtils.php Ver fichero

@@ -2,6 +2,7 @@

namespace Lc\ShopBundle\Services ;

use Doctrine\Common\Collections\Collection;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
@@ -115,7 +116,7 @@ class PriceUtils
return $total ;
}
if($entity instanceof OrderShopInterface) {
return $this->getTotalWithTaxByOrderProducts($entity->getOrderProducts()) ;
return $this->getTotalOrderProducts($entity->getOrderProducts(), true) ;
}
return null ;
}
@@ -131,30 +132,50 @@ class PriceUtils
}

if($entity instanceof OrderShopInterface) {
return $this->getTotalWithTaxAndReductionByOrderProducts($entity->getOrderProducts()) ;
return $this->getTotalOrderProductsWithTaxAndReduction($entity->getOrderProducts(), true, true) ;
}
}

public function getTotalWithTaxByOrderProducts($orderProducts)
public function getTotalOrderProducts($entity)
{
$totalWithTax = 0;

foreach ($orderProducts as $orderProduct) {
$totalWithTax += $this->getTotalWithTax($orderProduct);
}
return $this->getSumOrderProductsDispatch($entity) ;
}

return $totalWithTax;
public function getTotalOrderProductsWithTax($entity)
{
return $this->getSumOrderProductsDispatch($entity, true) ;
}

public function getTotalWithTaxAndReductionByOrderProducts($orderProducts)
public function getTotalOrderProductsWithTaxAndReduction($entity)
{
$totalWithTax = 0;
return $this->getSumOrderProductsDispatch($entity, true, true) ;
}

foreach ($orderProducts as $orderProduct) {
$totalWithTax += $this->getTotalWithTaxAndReduction($orderProduct);
public function getSumOrderProductsDispatch($entity, $withTax = false, $withReduction = false)
{
if($entity instanceof OrderShopInterface) {
return $this->getSumOrderProducts($entity->getOrderProducts(), $withTax, $withReduction) ;
}
if($entity instanceof Collection || is_array($entity)) {
return $this->getSumOrderProducts($entity, $withTax, $withReduction) ;
}
}

return $totalWithTax;
public function getSumOrderProducts($orderProducts, $withTax = false, $withReduction = false)
{
$total = 0 ;
foreach($orderProducts as $orderProduct) {
if($withTax && $withReduction) {
$total += $this->getTotalWithTaxAndReduction($orderProduct) ;
}
elseif($withTax) {
$total += $this->getTotalWithTax($orderProduct) ;
}
else {
$total += $this->getTotal($orderProduct) ;
}
}
return $total ;
}

public function getPriceWithTaxAndReductionCatalog($entity, $price, $priceWithTax, $reductionCatalog = null): ?float
@@ -199,7 +220,7 @@ class PriceUtils
$price,
$reductionCatalogValue
),
$this->getTaxRateInherited()->getValue()
$entity->getTaxRateInherited()->getValue()
);
}
elseif($reductionCatalogBehaviorTaxRate == 'tax-included') {

+ 1
- 1
ShopBundle/Services/Utils.php Ver fichero

@@ -22,6 +22,7 @@ class Utils
$this->parameterBag = $parameterBag ;
}

// @todo : À supprimer et passer dans DateUtils (gérer du coup le cas du modèle DeliverySlot qui dépend de cette fonction)
public static function getDayByNumber($number, $lang = 'fr')
{
if($lang == 'fr') {
@@ -54,7 +55,6 @@ class Utils
return '' ;
}


public function getElementByDevAlias($devAlias, $class = PageInterface::class)
{
$class = $this->em->getClassMetadata($class)->getName();

+ 1
- 1
ShopBundle/Twig/FrontendTwigExtension.php Ver fichero

@@ -96,7 +96,7 @@ class FrontendTwigExtension extends AbstractExtension

public function getProductCategories()
{
$categories = $this->productCategoryRepository->findAllParents($this->merchantUtils->getMerchantCurrent());
$categories = $this->productCategoryRepository->findAllParents(false);
return $categories;
}


Cargando…
Cancelar
Guardar