Exemplo n.º 1
0
 /**
  * @param int $idDiscount
  *
  * @return \Generated\Shared\Transfer\DiscountVoucherTransfer|null
  */
 public function getData($idDiscount)
 {
     $discountConfiguratorTransfer = null;
     if (!$idDiscount) {
         $discountConfiguratorTransfer = new DiscountConfiguratorTransfer();
         $discountGeneralTransfer = $this->createDiscountGeneralTransferDefaults();
         $discountConfiguratorTransfer->setDiscountGeneral($discountGeneralTransfer);
         $calculatedDiscountTransfer = $this->createDiscountCalculatorTransfer();
         $discountConfiguratorTransfer->setDiscountCalculator($calculatedDiscountTransfer);
     }
     return $discountConfiguratorTransfer;
 }
Exemplo n.º 2
0
 /**
  * @return \Generated\Shared\Transfer\DiscountConfiguratorTransfer
  */
 protected function createDiscountConfiguratorTransfer()
 {
     $discountConfiguratorTransfer = new DiscountConfiguratorTransfer();
     $discountGeneralTransfer = new DiscountGeneralTransfer();
     $discountGeneralTransfer->setDiscountType(DiscountConstants::TYPE_VOUCHER);
     $discountConfiguratorTransfer->setDiscountGeneral($discountGeneralTransfer);
     $discountCalculatorTransfer = new DiscountCalculatorTransfer();
     $discountConfiguratorTransfer->setDiscountCalculator($discountCalculatorTransfer);
     $discountVoucherTransfer = new DiscountVoucherTransfer();
     $discountConfiguratorTransfer->setDiscountVoucher($discountVoucherTransfer);
     $discountConditionTransfer = new DiscountConditionTransfer();
     $discountConfiguratorTransfer->setDiscountCondition($discountConditionTransfer);
     return $discountConfiguratorTransfer;
 }
 /**
  * @param integer $idDiscount
  * @param \Orm\Zed\Discount\Persistence\SpyDiscount $discountEntity
  * @param \Generated\Shared\Transfer\DiscountConfiguratorTransfer $discountConfigurator
  *
  * @return void
  */
 protected function hydrateDiscountVoucher($idDiscount, SpyDiscount $discountEntity, DiscountConfiguratorTransfer $discountConfigurator)
 {
     if ($discountEntity->getFkDiscountVoucherPool()) {
         $discountVoucherTransfer = new DiscountVoucherTransfer();
         $discountVoucherTransfer->setIdDiscount($idDiscount);
         $discountVoucherTransfer->setFkDiscountVoucherPool($discountEntity->getFkDiscountVoucherPool());
         $discountConfigurator->setDiscountVoucher($discountVoucherTransfer);
     }
 }
Exemplo n.º 4
0
 /**
  * @param \Generated\Shared\Transfer\DiscountConfiguratorTransfer $discountConfiguratorTransfer
  *
  * @return void
  */
 protected function setFormattedCalculatorDiscountAmount(DiscountConfiguratorTransfer $discountConfiguratorTransfer)
 {
     $calculatorPlugins = $this->getFactory()->getCalculatorPlugins();
     $calculatorPluginName = $discountConfiguratorTransfer->getDiscountCalculator()->getCalculatorPlugin();
     if (!isset($calculatorPlugins[$calculatorPluginName])) {
         return;
     }
     $calculatorPlugin = $calculatorPlugins[$calculatorPluginName];
     $formatterAmount = $calculatorPlugin->getFormattedAmount($discountConfiguratorTransfer->getDiscountCalculator()->getAmount());
     $discountConfiguratorTransfer->getDiscountCalculator()->setAmount($formatterAmount);
 }
Exemplo n.º 5
0
 /**
  * @return bool
  */
 protected function isVoucherType()
 {
     return $this->discountConfiguratorTransfer && $this->discountConfiguratorTransfer->getDiscountGeneral()->getDiscountType() == DiscountConstants::TYPE_VOUCHER;
 }
Exemplo n.º 6
0
 /**
  * @param \Generated\Shared\Transfer\DiscountConfiguratorTransfer $discountConfiguratorTransfer
  * @param \Orm\Zed\Discount\Persistence\SpyDiscount $discountEntity
  *
  * @return void
  */
 protected function hydrateDiscountEntity(DiscountConfiguratorTransfer $discountConfiguratorTransfer, SpyDiscount $discountEntity)
 {
     $discountEntity->fromArray($discountConfiguratorTransfer->getDiscountGeneral()->toArray());
     $discountEntity->setAmount($discountConfiguratorTransfer->getDiscountCalculator()->getAmount());
     $discountEntity->setCalculatorPlugin($discountConfiguratorTransfer->getDiscountCalculator()->getCalculatorPlugin());
     $discountEntity->setCollectorQueryString($discountConfiguratorTransfer->getDiscountCalculator()->getCollectorQueryString());
     $discountEntity->setDecisionRuleQueryString($discountConfiguratorTransfer->getDiscountCondition()->getDecisionRuleQueryString());
 }