ソースを参照

Évolution OrderShop / OrderStatus / OrderShopRepository

feature/export_comptable
Guillaume 4年前
コミット
7b169dd9e5
3個のファイルの変更42行の追加10行の削除
  1. +18
    -0
      ShopBundle/Model/OrderShop.php
  2. +20
    -0
      ShopBundle/Model/OrderStatus.php
  3. +4
    -10
      ShopBundle/Repository/OrderShopRepository.php

+ 18
- 0
ShopBundle/Model/OrderShop.php ファイルの表示

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

namespace Lc\ShopBundle\Model;

use App\Entity\OrderStatus;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Gedmo\Mapping\Annotation as Gedmo;
@@ -496,4 +497,21 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
return $this;
}


public function isValid() {
if($this->getOrderStatus() && in_array($this->getOrderStatus()->getAlias(), OrderStatus::$statusAliasAsValid) > 0) {
return true ;
}

return false ;
}

public function isCart() {
if($this->getOrderStatus() && in_array($this->getOrderStatus()->getAlias(), OrderStatus::$statusAliasAsCart) > 0) {
return true ;
}

return false ;
}

}

+ 20
- 0
ShopBundle/Model/OrderStatus.php ファイルの表示

@@ -19,11 +19,31 @@ abstract class OrderStatus
const ALIAS_ERROR_PAYMENT_ONLINE = 'error-payment-online' ;
const ALIAS_PAID_BY_CREDIT = 'paid-by-credit' ;
const ALIAS_WAITING_DELIVERY = 'waiting-delivery' ;
const ALIAS_WAITING_DELIVERY_WITH_PAYMENT = 'waiting-delivery-with-payment' ;
const ALIAS_DELIVERED_WITHOUT_PAYMENT = 'delivered-without-payment' ;
const ALIAS_DONE = 'done' ;
const ALIAS_CANCELED = 'canceled' ;
const ALIAS_CANCELED_WAITING_REFUND = 'canceled-waiting-refund' ;
const ALIAS_REFUND = 'refund' ;


//TODO : AJOUTER un champ valid ds orderSTATUS
static $statusAliasAsValid = [
self::ALIAS_PAID_ONLINE,
self::ALIAS_PAID_BY_CREDIT,
self::ALIAS_WAITING_DELIVERY,
self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
self::ALIAS_DELIVERED_WITHOUT_PAYMENT,
self::ALIAS_DONE
] ;

static $statusAliasAsCart = [
self::ALIAS_CART,
self::ALIAS_WAITING_PAYMENT_ONLINE,
self::ALIAS_WAITING_PAYMENT_CREDIT,
self::ALIAS_ERROR_PAYMENT_ONLINE
];

/**
* @ORM\Column(type="string", length=255)
*/

+ 4
- 10
ShopBundle/Repository/OrderShopRepository.php ファイルの表示

@@ -5,6 +5,7 @@ namespace Lc\ShopBundle\Repository;
use Doctrine\ORM\QueryBuilder;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Model\OrderStatus;

/**
* @method OrderShopInterface|null find($id, $lockMode = null, $lockVersion = null)
@@ -20,12 +21,6 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
return OrderShopInterface::class;
}


//TODO : AJOUTER un champ valid ds orderSTATUS
protected $statusAliasAsValid = array('paid-online', 'paid-by-credit', 'waiting-delivery', 'waiting-delivery-with-payment', 'delivered-without-payment', 'done');
protected $statusAliasAsCart = array('cart', 'waiting-payment-online', 'waiting-payment-credit', 'waiting-payment-on-delivery', 'error-payment-online');


public function countValidOrderWithReductionCredit($reductionCredit, $user)
{
$query = $this->findByMerchantQuery();
@@ -68,10 +63,9 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt

public function filterOrderValid(?QueryBuilder $query): QueryBuilder
{

$query->leftJoin('e.orderStatus', 'os');
$query->andWhere('os.alias IN (:alias)');
$query->setParameter('alias', $this->statusAliasAsValid);
$query->setParameter('alias', OrderStatus::$statusAliasAsValid);

return $query;
}
@@ -80,7 +74,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
{
$query->leftJoin('e.orderStatus', 'os');
$query->andWhere('os.alias IN (:alias)');
$query->setParameter('alias', $this->statusAliasAsCart);
$query->setParameter('alias', OrderStatus::$statusAliasAsCart);

return $query;
}
@@ -164,7 +158,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt

$query->leftJoin('complementaryOrderShops.orderStatus', 'complementaryOrderStatus');
$query->andWhere('complementaryOrderShops IS NULL OR complementaryOrderStatus.alias IN (:statusAliasValid)');
$query->setParameter('statusAliasValid', $this->statusAliasAsValid);
$query->setParameter('statusAliasValid', OrderStatus::$statusAliasAsValid);
}

if (isset($params['excludeComplementaryOrderShops'])) {

読み込み中…
キャンセル
保存