소스 검색

Nouveau PriceUtils

feature/export_comptable
Guillaume 4 년 전
부모
커밋
e20a97eb41
6개의 변경된 파일72개의 추가작업 그리고 23개의 파일을 삭제
  1. +2
    -2
      ShopBundle/Controller/ApiController.php
  2. +4
    -4
      ShopBundle/Services/DateUtils.php
  3. +4
    -3
      ShopBundle/Services/OrderUtils.php
  4. +47
    -0
      ShopBundle/Services/Price/PriceUtils.php
  5. +2
    -2
      ShopBundle/Services/Price/ProductPriceUtils.php
  6. +13
    -12
      ShopBundle/Services/ProductFamilyUtils.php

+ 2
- 2
ShopBundle/Controller/ApiController.php 파일 보기

@@ -4,9 +4,9 @@ namespace Lc\ShopBundle\Controller;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\PriceUtilsInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Services\PriceUtils;
use Lc\ShopBundle\Services\ProductFamilyUtils;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -22,7 +22,7 @@ class ApiController extends AbstractController
protected $priceUtils ;
protected $productFamilyUtils;

public function __construct(EntityManagerInterface $entityManager, PriceUtils $priceUtils, ProductFamilyUtils $productFamilyUtils)
public function __construct(EntityManagerInterface $entityManager, PriceUtilsInterface $priceUtils, ProductFamilyUtils $productFamilyUtils)
{
$this->em = $entityManager;
$this->priceUtils = $priceUtils;

+ 4
- 4
ShopBundle/Services/DateUtils.php 파일 보기

@@ -21,10 +21,10 @@ class DateUtils
}

public function getDayByNumber($number, $lang = 'fr')
{
if($lang == 'fr') {
$daysArray = [
1 => 'Lundi',
{
if($lang == 'fr') {
$daysArray = [
1 => 'Lundi',
2 => 'Mardi',
3 => 'Mercredi',
4 => 'Jeudi',

+ 4
- 3
ShopBundle/Services/OrderUtils.php 파일 보기

@@ -14,6 +14,7 @@ use Lc\ShopBundle\Context\OrderReductionCreditInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderStatusHistoryInterface;
use Lc\ShopBundle\Context\OrderStatusInterface;
use Lc\ShopBundle\Context\PriceUtilsInterface;
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
@@ -37,13 +38,13 @@ class OrderUtils
protected $orderShopRepo;
protected $reductionCreditRepo ;
protected $orderReductionCreditRepo ;
protected $orderShopPriceUtils;
protected $priceUtils;
protected $productFamilyUtils;
protected $documentUtils;
protected $session;

public function __construct(EntityManagerInterface $em, Security $security, UserUtils $userUtils,
MerchantUtilsInterface $merchantUtils, OrderShopPriceUtils $orderShopPriceUtils, ProductFamilyUtilsInterface $productFamilyUtils,
MerchantUtilsInterface $merchantUtils, PriceUtilsInterface $priceUtils, ProductFamilyUtilsInterface $productFamilyUtils,
DocumentUtils $documentUtils, SessionInterface $session)
{
$this->em = $em;
@@ -53,7 +54,7 @@ class OrderUtils
$this->orderShopRepo = $this->em->getRepository($this->em->getClassMetadata(OrderShopInterface::class)->getName());
$this->reductionCreditRepo = $this->em->getRepository($this->em->getClassMetadata(ReductionCreditInterface::class)->getName());
$this->orderReductionCreditRepo = $this->em->getRepository($this->em->getClassMetadata(OrderReductionCreditInterface::class)->getName());
$this->orderShopPriceUtils = $orderShopPriceUtils;
$this->priceUtils = $priceUtils;
$this->productFamilyUtils = $productFamilyUtils;
$this->documentUtils = $documentUtils;
$this->session = $session;

+ 47
- 0
ShopBundle/Services/Price/PriceUtils.php 파일 보기

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

namespace Lc\ShopBundle\Services\Price ;

use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderShopPriceUtilsInterface;
use Lc\ShopBundle\Context\PriceUtilsInterface;
use Lc\ShopBundle\Context\ProductPropertyInterface;

class PriceUtils implements PriceUtilsInterface
{
protected $productPriceUtils ;
protected $orderProductPriceUtils ;
protected $orderShopPriceUtils ;

public function __construct(ProductPriceUtils $productPriceUtils, OrderProductPriceUtils $orderProductPriceUtils, OrderShopPriceUtilsInterface $orderShopPriceUtils)
{
$this->productPriceUtils = $productPriceUtils ;
$this->orderProductPriceUtils = $orderProductPriceUtils ;
$this->orderShopPriceUtils = $orderShopPriceUtils ;
}

public function __call($name, $arguments)
{
$entity = $arguments[0] ;
$service = '' ;

if($entity instanceof ProductPropertyInterface) {
$service = 'productPriceUtils' ;
}

if($entity instanceof OrderProductInterface) {
$service = 'orderProductPriceUtils' ;
}

if($entity instanceof OrderShopInterface) {
$service = 'orderShopPriceUtils' ;
}

if(strlen($service) && $entity && method_exists($this->$service, $name)) {
return $this->$service->$name($entity) ;
}

return false ;
}
}

+ 2
- 2
ShopBundle/Services/Price/ProductPriceUtils.php 파일 보기

@@ -57,8 +57,8 @@ class ProductPriceUtils
{
return $this->applyReductionCatalog(
$product,
$this->getTotal($product),
$this->getTotalWithTax($product)
$this->getPrice($product),
$this->getPriceWithTax($product)
);
}


+ 13
- 12
ShopBundle/Services/ProductFamilyUtils.php 파일 보기

@@ -2,38 +2,39 @@

namespace Lc\ShopBundle\Services ;

use Lc\ShopBundle\Context\PriceUtilsInterface;
use Lc\ShopBundle\Price\Services\ProductPriceUtils;

class ProductFamilyUtils
{
protected $productPriceUtils ;
protected $priceUtils ;

public function __construct(ProductPriceUtils $productPriceUtils)
public function __construct(PriceUtilsInterface $priceUtils)
{
$this->productPriceUtils = $productPriceUtils ;
$this->priceUtils = $priceUtils ;
}

public function getCheapestProduct($productFamily)
{
$productPriceUtils = $this->productPriceUtils ;
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($productPriceUtils) {
return $productPriceUtils->getPriceWithTaxAndReduction($a) > $productPriceUtils->getPriceWithTaxAndReduction($b) ;
$priceUtils = $this->priceUtils ;
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) {
return $priceUtils->getPriceWithTaxAndReduction($a) > $priceUtils->getPriceWithTaxAndReduction($b) ;
}, true);
}

public function getCheapestProductByRefUnit($productFamily)
{
$productPriceUtils = $this->productPriceUtils ;
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($productPriceUtils) {
return $productPriceUtils->getPriceByRefUnitWithTaxAndReduction($a) > $productPriceUtils->getPriceByRefUnitWithTaxAndReduction($b) ;
$priceUtils = $this->priceUtils ;
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) {
return $priceUtils->getPriceByRefUnitWithTaxAndReduction($a) > $priceUtils->getPriceByRefUnitWithTaxAndReduction($b) ;
}, false);
}

public function getMostExpensiveProductByRefUnit($productFamily)
{
$productPriceUtils = $this->productPriceUtils ;
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($productPriceUtils) {
return $productPriceUtils->getPriceByRefUnitWithTaxAndReduction($a) < $productPriceUtils->getPriceByRefUnitWithTaxAndReduction($b) ;
$priceUtils = $this->priceUtils ;
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceUtils) {
return $priceUtils->getPriceByRefUnitWithTaxAndReduction($a) < $priceUtils->getPriceByRefUnitWithTaxAndReduction($b) ;
}, false);
}


Loading…
취소
저장