/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * * @return bool */ public function check(SpySalesOrderItem $orderItem) { $b = microtime() * 1000000 % 2 ? true : false; $bS = $b ? 'true' : 'false'; Log::log('Condition PaymentRedirected for item: ' . $orderItem->getIdSalesOrderItem() . ' ' . $bS, 'statemachine.log'); return $b; }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * * @return bool */ public function check(SpySalesOrderItem $orderItem) { $orderEntity = $orderItem->getOrder(); $orderTransfer = new OrderTransfer(); $orderTransfer->fromArray($orderEntity->toArray(), true); $isSuccess = $this->callFacade($orderTransfer); return $isSuccess; }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * @return bool */ public function check(SpySalesOrderItem $orderItem) { $order = $orderItem->getOrder(); if (isset(self::$resultCache[$this->getName()][$order->getPrimaryKey()])) { return self::$resultCache[$this->getName()][$order->getPrimaryKey()]; } $isSuccess = $this->performCheck($order, $orderItem); self::$resultCache[$this->getName()][$order->getPrimaryKey()] = $isSuccess; return $isSuccess; }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * * @return bool */ public function check(SpySalesOrderItem $orderItem) { $order = $orderItem->getOrder(); if (isset(self::$resultCache[$this->getName()][$order->getPrimaryKey()])) { return self::$resultCache[$this->getName()][$order->getPrimaryKey()]; } $orderTransfer = new OrderTransfer(); $orderTransfer->fromArray($order->toArray(), true); $isSuccess = $this->callFacade($orderTransfer); self::$resultCache[$order->getPrimaryKey()] = $isSuccess; return $isSuccess; }
/** * @param \Spryker\Zed\Oms\Business\Process\ProcessInterface $process * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * @param \DateTime $currentTime * * @return void */ public function setNewTimeout(ProcessInterface $process, SpySalesOrderItem $orderItem, DateTime $currentTime) { $targetStateEntity = $orderItem->getState(); $targetState = $this->getStateFromProcess($targetStateEntity->getName(), $process); if ($targetState->hasTimeoutEvent()) { $events = $targetState->getTimeoutEvents(); $handledEvents = []; foreach ($events as $event) { if (in_array($event->getName(), $handledEvents)) { continue; } $handledEvents[] = $event->getName(); $timeoutDate = $this->calculateTimeoutDateFromEvent($currentTime, $event); (new SpyOmsEventTimeout())->setTimeout($timeoutDate)->setOrderItem($orderItem)->setState($targetStateEntity)->setEvent($event->getName())->save(); } } }
/** * @param string $processName * * @return array */ public function prepareItems($processName) { $orderItemsArray = $this->getOrderItems($processName); $orders = []; $txtArray = []; foreach ($orderItemsArray as $orderItemArray) { if (!isset($orders[$orderItemArray['orderId']])) { $order = new SpySalesOrder(); $order->setGrandTotal(10000); $order->setSubtotal(9900); $order->setIsTest(false); $address = new SpySalesOrderAddress(); $address->setLastName('Doe'); $address->setFirstName('John'); $address->setCity('Berlin'); $address->setZipCode('12345'); $address->setAddress1('Blastr 1'); $country = SpyCountryQuery::create()->findOneByIdCountry(1); $address->setCountry($country); $order->setBillingAddress($address); $order->setShippingAddress($address); $orders[$orderItemArray['orderId']] = $order; } } $states = []; $orderItems = []; foreach ($orderItemsArray as $orderItemArray) { if (isset($states[$orderItemArray['state']])) { $state = $states[$orderItemArray['state']]; } else { $state = new SpyOmsOrderItemState(); $state->setName($orderItemArray['state']); $state->save(); $states[$orderItemArray['state']] = $state; } $txtArray[] = 'State: ' . $state->getName(); $process = SpyOmsOrderProcessQuery::create()->filterByName($orderItemArray['process'])->findOneOrCreate(); $process->setName($orderItemArray['process']); $process->save(); $txtArray[] = 'Process: ' . $process->getName(); $item = new SpySalesOrderItem(); $item->setState($state); $item->setProcess($process); $item->setName('Testproduct'); $item->setSku('12345ABC'); $item->setGrossPrice(10); $orders[$orderItemArray['orderId']]->addItem($item); $orderItems[] = $item; } foreach ($orderItems as $orderItem) { $orderItem->save(); $txtArray[] = 'orderItem saved: ' . $orderItem->getIdSalesOrderItem(); } return $txtArray; }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItemOption $productOptionEntity * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $salesOrderItemEntity * * @return \Generated\Shared\Transfer\ProductOptionTransfer */ protected function hydrateProductOptionTransfer(SpySalesOrderItemOption $productOptionEntity, SpySalesOrderItem $salesOrderItemEntity) { $productOptionTransfer = new ProductOptionTransfer(); $productOptionTransfer->fromArray($productOptionEntity->toArray(), true); $productOptionTransfer->setUnitGrossPrice($productOptionEntity->getGrossPrice()); $productOptionTransfer->setQuantity($salesOrderItemEntity->getQuantity()); $refundableAmount = $this->getRefundableAmount($productOptionTransfer, $productOptionEntity); $productOptionTransfer->setRefundableAmount($refundableAmount); return $productOptionTransfer; }
/** * @return \Orm\Zed\Sales\Persistence\SpySalesOrderItem */ protected function getSalesOrderItemTwo() { $salesOrderItem = new SpySalesOrderItem(); $salesOrderItem->setIdSalesOrderItem(2); return $salesOrderItem; }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItemEntity * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer * * @return void */ protected function hydrateStateHistory(SpySalesOrderItem $orderItemEntity, ItemTransfer $itemTransfer) { foreach ($orderItemEntity->getStateHistories() as $stateHistoryEntity) { $itemStateTransfer = new ItemStateTransfer(); $itemStateTransfer->fromArray($stateHistoryEntity->toArray(), true); $itemStateTransfer->setName($stateHistoryEntity->getState()->getName()); $itemStateTransfer->setIdSalesOrder($orderItemEntity->getFkSalesOrder()); $itemTransfer->addStateHistory($itemStateTransfer); } }
/** * @param int $idSalesOrder * * @return \Orm\Zed\Sales\Persistence\SpySalesOrderItem */ private function createOrderItemEntity($idSalesOrder) { $stateEntity = $this->createOrderItemStateEntity(); $processEntity = $this->createOrderProcessEntity(); $bundleEntity = $this->createOrderItemBundleEntity(); $orderItemEntity = new SpySalesOrderItem(); $orderItemEntity->setFkSalesOrder($idSalesOrder)->setFkOmsOrderItemState($stateEntity->getIdOmsOrderItemState())->setFkOmsOrderProcess($processEntity->getIdOmsOrderProcess())->setFkSalesOrderItemBundle($bundleEntity->getIdSalesOrderItemBundle())->setName('test product')->setSku('1324354657687980')->setGrossPrice(1000)->setQuantity(1); $orderItemEntity->save(); return $orderItemEntity; }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * * @return bool */ public function check(SpySalesOrderItem $orderItem) { return $this->getFacade()->isPaymentPaid($orderItem->getFkSalesOrder(), $orderItem->getIdSalesOrderItem()); }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $salesOrderItem * * @return void */ public function save(SpySalesOrderItem $salesOrderItem) { $this->logEntities[$salesOrderItem->getIdSalesOrderItem()]->save(); }
/** * @param \Orm\Zed\Oms\Persistence\SpyOmsOrderItemState $omsStateEntity * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $salesOrderEntity * @param \Orm\Zed\Oms\Persistence\SpyOmsOrderProcess $omsOrderProcessEntity * @param int $quantity * @param int $grossPrice * @param int $taxRate * * @return \Orm\Zed\Sales\Persistence\SpySalesOrderItem */ protected function createOrderItem(SpyOmsOrderItemState $omsStateEntity, SpySalesOrder $salesOrderEntity, SpyOmsOrderProcess $omsOrderProcessEntity, $quantity, $grossPrice, $taxRate) { $salesOrderItem = new SpySalesOrderItem(); $salesOrderItem->setGrossPrice($grossPrice); $salesOrderItem->setQuantity($quantity); $salesOrderItem->setSku('123'); $salesOrderItem->setName('test1'); $salesOrderItem->setTaxRate($taxRate); $salesOrderItem->setFkOmsOrderItemState($omsStateEntity->getIdOmsOrderItemState()); $salesOrderItem->setProcess($omsOrderProcessEntity); $salesOrderItem->setFkSalesOrder($salesOrderEntity->getIdSalesOrder()); $salesOrderItem->save(); return $salesOrderItem; }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data * * @return array */ public function run(SpySalesOrderItem $orderItem, ReadOnlyArrayObject $data) { $message = sprintf('Command DecreaseStock by Item for Item %s (quantity %s)', $orderItem->getIdSalesOrderItem(), $orderItem->getQuantity()); Log::log($message, 'statemachine.log'); return []; }
/** * @api * * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * * @return \Orm\Zed\Nopayment\Persistence\SpyNopaymentPaidQuery */ public function queryOrderItem(SpySalesOrderItem $orderItem) { return $this->getFactory()->createNopaymentPaidQuery()->findByFkSalesOrderItem($orderItem->getIdSalesOrderItem()); }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * * @return string */ public function getStateDisplayName(SpySalesOrderItem $orderItem) { $processName = $orderItem->getProcess()->getName(); $builder = clone $this->builder; $process = $builder->createProcess($processName); $stateName = $orderItem->getState()->getName(); $state = $process->getState($stateName); return $state->getDisplay(); }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $salesOrderEntity * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $salesOrderItemEntity * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer * * @return void */ protected function hydrateSalesOrderItemEntity(SpySalesOrder $salesOrderEntity, QuoteTransfer $quoteTransfer, SpySalesOrderItem $salesOrderItemEntity, ItemTransfer $itemTransfer) { $processEntity = $this->getProcessEntity($quoteTransfer, $itemTransfer); $initialStateEntity = $this->omsFacade->getInitialStateEntity(); $salesOrderItemEntity->fromArray($itemTransfer->toArray()); $salesOrderItemEntity->setFkSalesOrder($salesOrderEntity->getIdSalesOrder()); $salesOrderItemEntity->setFkOmsOrderItemState($initialStateEntity->getIdOmsOrderItemState()); $salesOrderItemEntity->setGrossPrice($itemTransfer->getUnitGrossPrice()); $salesOrderItemEntity->setProcess($processEntity); }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * * @return bool */ public function check(SpySalesOrderItem $orderItem) { $result = $this->getFacade()->isPaymentNotificationAvailable($orderItem->getFkSalesOrder(), $orderItem->getIdSalesOrderItem()); return $result; }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * * @return bool */ public function check(SpySalesOrderItem $orderItem) { $res = $this->getFacade()->isPaymentAppointed($orderItem->getFkSalesOrder(), $orderItem->getIdSalesOrderItem()); return $res; }
/** * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem * @param string $stateName * * @return void */ protected function setState($orderItem, $stateName) { if (isset($this->states[$stateName])) { $state = $this->states[$stateName]; } else { $state = SpyOmsOrderItemStateQuery::create()->findOneByName($stateName); if (!isset($state)) { $state = new SpyOmsOrderItemState(); $state->setName($stateName); $state->save(); } $this->states[$stateName] = $state; } $orderItem->setState($state); }
/** * @param array $salesOrderItem * * @return \Orm\Zed\Sales\Persistence\SpySalesOrderItem */ protected function createSalesOrderItem(array $salesOrderItem) { $salesOrderItemEntity = new SpySalesOrderItem(); $salesOrderItemEntity->fromArray($salesOrderItem); if ($salesOrderItemEntity->getName() === null) { $salesOrderItemEntity->setName('name'); } if ($salesOrderItemEntity->getSku() === null) { $salesOrderItemEntity->setSku('sku'); } if ($salesOrderItemEntity->getGrossPrice() === null) { $salesOrderItemEntity->setGrossPrice(1000); } if ($salesOrderItemEntity->getTaxRate() === null) { $salesOrderItemEntity->setTaxRate(19); } if ($salesOrderItemEntity->getQuantity() === null) { $salesOrderItemEntity->setQuantity(1); } $omsOrderItemStateEntity = $this->getOrderItemState($salesOrderItem); $salesOrderItemEntity->setFkOmsOrderItemState($omsOrderItemStateEntity->getIdOmsOrderItemState()); $omsOrderProcessEntity = $this->getOrderProcess($salesOrderItem); $salesOrderItemEntity->setFkOmsOrderProcess($omsOrderProcessEntity->getIdOmsOrderProcess()); return $salesOrderItemEntity; }