Pārlūkot izejas kodu

[Backend] Classement des utilisateurs

develop
Fab pirms 3 gadiem
vecāks
revīzija
c7d98075c1
3 mainītis faili ar 79 papildinājumiem un 34 dzēšanām
  1. +33
    -0
      ShopBundle/Controller/Backend/UserController.php
  2. +1
    -1
      ShopBundle/Resources/views/backend/default/field/total.html.twig
  3. +45
    -33
      ShopBundle/Services/Price/OrderShopPriceUtils.php

+ 33
- 0
ShopBundle/Controller/Backend/UserController.php Parādīt failu

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

namespace Lc\ShopBundle\Controller\Backend;

use App\Entity\OrderShop;
use App\Form\Backend\Common\AddressType;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use FOS\UserBundle\Doctrine\UserManager;
use FOS\UserBundle\Model\UserManagerInterface ;
use Lc\ShopBundle\Context\AddressInterface;
@@ -11,6 +13,37 @@ use Lc\ShopBundle\Model\Address;
class UserController extends AdminController
{

public function showAction()
{

$id = $this->request->query->get('id');
$easyadmin = $this->request->attributes->get('easyadmin');
$entity = $easyadmin['item'];
$this->orderShoprepo = $this->em->getRepository(OrderShop::class);
$this->orderShoprepo->getRankSumCommand($entity);

$this->dispatch(EasyAdminEvents::PRE_SHOW);



$fields = $this->entity['show']['fields'];
$deleteForm = $this->createDeleteForm($this->entity['name'], $id);

$this->dispatch(EasyAdminEvents::POST_SHOW, [
'deleteForm' => $deleteForm,
'fields' => $fields,
'entity' => $entity,
]);

$parameters = [
'entity' => $entity,
'fields' => $fields,
'delete_form' => $deleteForm->createView(),
];

return $this->executeDynamicMethod('render<EntityName>Template', ['show', $this->entity['templates']['show'], $parameters]);
}

public function createNewEntity()
{
return $this->userManager->createUser();

+ 1
- 1
ShopBundle/Resources/views/backend/default/field/total.html.twig Parādīt failu

@@ -1 +1 @@
{{ priceUtils.getTotalWithTax(item)|format_price|raw }}
{{ priceUtils.getTotalWithTax(item, true)|format_price|raw }}

+ 45
- 33
ShopBundle/Services/Price/OrderShopPriceUtils.php Parādīt failu

@@ -40,22 +40,26 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
return $total;
}

public function getMarginOrderProductsWithReductions(OrderShopInterface $orderShop): float
public function getMarginOrderProductsWithReductions(OrderShopInterface $orderShop, $cache = false): float
{
$total = $this->getMarginOrderProducts($orderShop);
if ($cache && $orderShop->getStatMarginOrderProductsWithReductions() !== null) {
return $orderShop->getStatMarginOrderProductsWithReductions();
} else {
$total = $this->getMarginOrderProducts($orderShop);

$totalReductionAmount = 0;
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$totalReductionAmount += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart);
}
$totalReductionAmount = 0;
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$totalReductionAmount += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart);
}

foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$totalReductionAmount += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit);
}
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$totalReductionAmount += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit);
}

$total -= $totalReductionAmount;
$total -= $totalReductionAmount;

return $total;
return $total;
}
}

public function getMarginOrderProductsWithReductionsPercent(OrderShopInterface $orderShop): float
@@ -165,12 +169,16 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
return $this->getTotalOrderProductsWithTax($orderShop) / $this->getTotalOrderProducts($orderShop);
}

public function getTotalOrderProductsWithReductions(OrderShopInterface $orderShop)
public function getTotalOrderProductsWithReductions(OrderShopInterface $orderShop, $cache = false)
{
$total = $this->getTotalOrderProducts($orderShop);
$total -= $this->getTotalReductionCartsAmount($orderShop);
$total -= $this->getTotalReductionCreditsAmount($orderShop);
return $total;
if($cache && $orderShop->getStatTotalOrderProductsWithReductions()!==null){
return $orderShop->getStatTotalOrderProductsWithReductions();
}else {
$total = $this->getTotalOrderProducts($orderShop);
$total -= $this->getTotalReductionCartsAmount($orderShop);
$total -= $this->getTotalReductionCreditsAmount($orderShop);
return $total;
}
}

public function getTotalOrderProductsWithReductionCarts(OrderShopInterface $orderShop)
@@ -198,12 +206,16 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
return $totalReductionAmount;
}

public function getTotalOrderProductsWithTaxAndReductions(OrderShopInterface $orderShop)
public function getTotalOrderProductsWithTaxAndReductions(OrderShopInterface $orderShop, $cache = false)
{
$total = $this->getTotalOrderProductsWithTax($orderShop);
$total -= $this->getTotalReductionCartsAmountWithTax($orderShop);
$total -= $this->getTotalReductionCreditsAmountWithTax($orderShop);
return $total;
if($cache && $orderShop->getStatTotalOrderProductsWithTaxAndReductions()!==null){
return $orderShop->getStatTotalOrderProductsWithTaxAndReductions();
}else {
$total = $this->getTotalOrderProductsWithTax($orderShop);
$total -= $this->getTotalReductionCartsAmountWithTax($orderShop);
$total -= $this->getTotalReductionCreditsAmountWithTax($orderShop);
return $total;
}
}

public function getTotalOrderProductsWithTaxAndReductionCarts(OrderShopInterface $orderShop)
@@ -303,32 +315,32 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface

public function getTotalReductions(OrderShopInterface $orderShop)
{
$total = 0 ;
$total = 0;

foreach($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$total += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart) ;
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$total += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart);
}

foreach($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$total += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit) ;
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$total += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit);
}

return $total ;
return $total;
}

public function getTotalReductionsWithTax(OrderShopInterface $orderShop)
{
$total = 0 ;
$total = 0;

foreach($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$total += $this->getOrderProductsReductionCartAmountWithTax($orderShop, $orderReductionCart) ;
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$total += $this->getOrderProductsReductionCartAmountWithTax($orderShop, $orderReductionCart);
}

foreach($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$total += $this->getOrderProductsReductionCreditAmountWithTax($orderShop, $orderReductionCredit) ;
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$total += $this->getOrderProductsReductionCreditAmountWithTax($orderShop, $orderReductionCredit);
}

return $total ;
return $total;
}
}


Notiek ielāde…
Atcelt
Saglabāt