public function handle(CreateProductQuantityDiscountCommand $command)
 {
     $product = $this->productService->findOneById($command->getProductId());
     $productQuantityDiscount = new ProductQuantityDiscount($product, $command->getProductQuantityDiscountId());
     $productQuantityDiscount->setType(PromotionType::createById($command->getPromotionTypeId()));
     $productQuantityDiscount->setValue($command->getValue());
     $productQuantityDiscount->setReducesTaxSubtotal($command->getReducesTaxSubtotal());
     $productQuantityDiscount->setMaxRedemptions($command->getMaxRedemptions());
     $productQuantityDiscount->setStart($command->getStartDate());
     $productQuantityDiscount->setEnd($command->getEndDate());
     $productQuantityDiscount->setQuantity($command->getQuantity());
     $productQuantityDiscount->setFlagApplyCatalogPromotions($command->getFlagApplyCatalogPromotions());
     $this->productService->createProductQuantityDiscount($productQuantityDiscount);
 }
예제 #2
0
 public function handle(CreateCouponCommand $command)
 {
     $coupon = new Coupon($command->getCode(), $command->getCouponId());
     $coupon->setFlagFreeShipping($command->getFlagFreeShipping());
     $coupon->setMinOrderValue($command->getMinOrderValue());
     $coupon->setMaxOrderValue($command->getMaxOrderValue());
     $coupon->setCanCombineWithOtherCoupons($command->canCombineWithOtherCoupons());
     $coupon->setName($command->getName());
     $coupon->setType(PromotionType::createById($command->getPromotionTypeId()));
     $coupon->setValue($command->getValue());
     $coupon->setReducesTaxSubtotal($command->getReducesTaxSubtotal());
     $coupon->setMaxRedemptions($command->getMaxRedemptions());
     $coupon->setStart($command->getStartDate());
     $coupon->setEnd($command->getEndDate());
     $this->couponService->create($coupon);
 }
 public function handle(CreateCatalogPromotionCommand $command)
 {
     $catalogPromotion = new CatalogPromotion($command->getCatalogPromotionId());
     $catalogPromotion->setName($command->getName());
     $catalogPromotion->setType(PromotionType::createById($command->getPromotionTypeId()));
     $catalogPromotion->setValue($command->getValue());
     $catalogPromotion->setReducesTaxSubtotal($command->getReducesTaxSubtotal());
     $catalogPromotion->setMaxRedemptions($command->getMaxRedemptions());
     $catalogPromotion->setStart($command->getStartDate());
     $catalogPromotion->setEnd($command->getEndDate());
     if ($command->getTagId() !== null) {
         $tag = $this->tagService->findOneById($command->getTagId());
         $catalogPromotion->setTag($tag);
     }
     $this->catalogPromotionService->create($catalogPromotion);
 }
예제 #4
0
 public function testCreateByIdThrowsExceptionWhenInvalid()
 {
     $this->setExpectedException(InvalidArgumentException::class);
     PromotionType::createById(999);
 }