|
|
@@ -7,6 +7,8 @@ use Lc\ShopBundle\Context\OrderReductionCreditInterface; |
|
|
|
use Lc\ShopBundle\Context\OrderShopInterface; |
|
|
|
use Lc\ShopBundle\Context\ReductionCartInterface; |
|
|
|
use Lc\ShopBundle\Context\ReductionCreditInterface; |
|
|
|
use Lc\ShopBundle\Model\ReductionCredit; |
|
|
|
use function Matrix\trace; |
|
|
|
|
|
|
|
trait OrderUtilsReductionTrait |
|
|
|
{ |
|
|
@@ -91,9 +93,17 @@ trait OrderUtilsReductionTrait |
|
|
|
} |
|
|
|
|
|
|
|
// n'a pas été utilisé |
|
|
|
if ($this->orderShopRepo->countValidOrderWithReductionCredit($reductionCredit, $user) > 0) { |
|
|
|
$this->utils->addFlash('error', 'error.reductionCredit.alreadyUse'); |
|
|
|
return false; |
|
|
|
if($reductionCredit->getType()== ReductionCredit::TYPE_CREDIT){ |
|
|
|
if ($this->orderShopRepo->countValidOrderWithReductionCredit($reductionCredit, $user) > 0) { |
|
|
|
$this->utils->addFlash('error', 'error.reductionCredit.alreadyUse'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if ($this->orderShopRepo->countValidOrderWithReductionCredit($reductionCredit) > 0) { |
|
|
|
$this->utils->addFlash('error', 'error.reductionCredit.alreadyUse'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
@@ -164,7 +174,7 @@ trait OrderUtilsReductionTrait |
|
|
|
|
|
|
|
$reductionGiftsArray = [] ; |
|
|
|
foreach($reductionGifts as $reductionGift) { |
|
|
|
if(!$this->orderShopRepo->countValidOrderWithReductionCredit($reductionGift, $user)) { |
|
|
|
if(!$this->orderShopRepo->countValidOrderWithReductionCredit($reductionGift)) { |
|
|
|
$reductionGiftsArray[] = $reductionGift ; |
|
|
|
} |
|
|
|
} |
|
|
@@ -172,6 +182,13 @@ trait OrderUtilsReductionTrait |
|
|
|
return $reductionGiftsArray ; |
|
|
|
} |
|
|
|
|
|
|
|
public function isReductionGiftUsed($reductionGift){ |
|
|
|
if(!$this->orderShopRepo->countValidOrderWithReductionCredit($reductionGift)) { |
|
|
|
return true; |
|
|
|
}else{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
public function isReductionCreditAddedToOrder($orderShop, $reductionCredit) |
|
|
|
{ |
|
|
|
foreach($orderShop->getOrderReductionCredits() as $orderReductionCredit) { |