@api

@param int $idIdSalesOrder

@return \Orm\Zed\Payone\Persistence\SpyPaymentPayoneTransactionStatusLog[]
179652
public function createTransactionStatusLogsBySalesOrder($idIdSalesOrder)
    {
        $query = $this->getFactory()->createPaymentPayoneTransactionStatusLogQuery()
            ->useSpyPaymentPayoneQuery()
            ->filterByFkSalesOrder($idIdSalesOrder)
            ->endUse()
            ->orderByCreatedAt();

        return $query;
    }
154782
public function isPaymentOverpaid($idSalesOrder, $idSalesOrderItem)
    {
        $status = PayoneTransactionStatusConstants::TXACTION_PAID;
        $statusLog = $this->getFirstUnprocessedTransactionStatusLog($idSalesOrder, $idSalesOrderItem, $status);
        if ($statusLog === null) {
            return false;
        }
        if ($statusLog->getBalance() >= 0) {
            return false;
        }

        $this->saveSpyPaymentPayoneTransactionStatusLogOrderItem($idSalesOrderItem, $statusLog);

        return true;
    }
1311102
public function debitPayment($idPayment)
    {
        $paymentEntity = $this->getPaymentEntity($idPayment);
        $paymentMethodMapper = $this->getPaymentMethodMapper($paymentEntity);

        $requestContainer = $paymentMethodMapper->mapPaymentToDebit($paymentEntity);
        $this->setStandardParameter($requestContainer);

        $paymentEntity = $this->findPaymentByTransactionId($paymentEntity->getTransactionId());
        $apiLogEntity = $this->initializeApiLog($paymentEntity, $requestContainer);

        $rawResponse = $this->executionAdapter->sendRequest($requestContainer);
        $responseContainer = new DebitResponseContainer($rawResponse);

        $this->updateApiLogAfterDebit($apiLogEntity, $responseContainer);

        $responseMapper = new DebitResponseMapper();
        $responseTransfer = $responseMapper->getDebitResponseTransfer($responseContainer);

        return $responseTransfer;
    }
1175787
public function orderBy(IdentityInterface $identity = null)
    {
        if (is_null($this->identity) || !$this->identity->hasOrderBy()) {
            return [];
        }
        $sort = [];
        foreach ($this->identity->getOrderBy() as $key => $value) {
            if (strpos($key, 'random') !== false) {
                $sort["_script"] = [
                    "type"   => "number",
                    "script" => "Math.random()",
                    "order"  => "asc"
                ];
            } elseif ($key === Consts::GEO_DISTANCE_SORT) {
                $sort[$key] = $value;
            } elseif ($key !== null) {
                $sort[$key] = (strtolower($value) == Consts::DESCENDING)
                    ? \G4\DataMapper\Selection\Solr\Consts\Query::DESCENDING
                    : \G4\DataMapper\Selection\Solr\Consts\Query::ASCENDING;
            }
        }
        return $sort;
    }
894469
public function check(SpySalesOrderItem $orderItem)
    {
        return $this->getFacade()
            ->isPaymentPaid($orderItem->getFkSalesOrder(), $orderItem->getIdSalesOrderItem());
    }
365666
protected function saveSpyPaymentPayoneTransactionStatusLogOrderItem($idSalesOrderItem, SpyPaymentPayoneTransactionStatusLog $statusLog)
    {
        $entity = new SpyPaymentPayoneTransactionStatusLogOrderItem();
        $entity->setSpyPaymentPayoneTransactionStatusLog($statusLog);
        $entity->setIdSalesOrderItem($idSalesOrderItem);
        $entity->save();
    }
1021247
private function getIPNIdentifierFromOrder(TdbShopOrder $oOrder)
    {
        $sIdentifier = null;
        $query = "SELECT `shop_payment_handler_group`.*
                    FROM `shop_payment_handler_group`
              INNER JOIN `shop_payment_handler` on `shop_payment_handler_group`.`id` = `shop_payment_handler`.`shop_payment_handler_group_id`
              INNER JOIN `shop_payment_method` on `shop_payment_handler`.`id` = `shop_payment_method`.`shop_payment_handler_id`
              INNER JOIN `shop_order` on `shop_payment_method`.`id` = `shop_order`.`shop_payment_method_id`
                   WHERE `shop_order`.`id` = '".MySqlLegacySupport::getInstance()->real_escape_string($oOrder->id)."'
        ";
        if ($aGroup = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query))) {
            $sIdentifier = trim($aGroup['ipn_group_identifier']);
            if ('' === $sIdentifier) {
                $sIdentifier = trim($aGroup['system_name']);
            }
        }

        return $sIdentifier;
    }
295283
public function getPaymentLogs(ObjectCollection $orders)
    {
        $orderCollectionTransfer = new OrderCollectionTransfer();
        $orderCollectionTransfer->setOrders($orders->getData());
        return $this->getFacade()->getPaymentLogs($orderCollectionTransfer);
    }
454906
public function check(SpySalesOrderItem $orderItem)
    {
        return $this->getFacade()
            ->isPaymentUnderpaid($orderItem->getFkSalesOrder(), $orderItem->getIdSalesOrderItem());
    }
310426
public function getOrderedRequiredHits()
	{
		$hitIdentifiers = array();
		foreach($this->requiredHits as $hitIdentifier)
		{
			$hitIdentifiers[$this->hitPositions[$hitIdentifier]] = $hitIdentifier;
		}
		krsort($hitIdentifiers);
		return $hitIdentifiers;
	}
323953
public function purchase(array $productsToBuy, array $productIds, DataBaseExporter $exporter, int $internalOrderId): int
    {
        $preOrdersCount = 0;
        $order = Order::createOrder($productsToBuy, $internalOrderId, true);

        foreach ($order->getProducts() as $product) {
            $numberOfPreOrders = 0;
            $links = [];

            foreach ($product->getCodes() as $code) {

                if ($code->isPreOrder()) {
                    $numberOfPreOrders++;
                    $preOrdersCount++;
                }

                $links[] = $code->getCodeId();
            }

            $orderedCodes = [
                'cwOrderId' => $order->getOrderId(),
                'links' => $links,
                'preOrders' => $numberOfPreOrders
            ];

            $exporter->export(null, $orderedCodes, $productIds[$product->getProductId()], $internalOrderId);
        }

        return $preOrdersCount;
    }
980317
public function getRelatedCompanyIdsByIdProductList(int $idProductList): array
    {
        /** @var \Orm\Zed\ProductList\Persistence\SpyProductListCompanyQuery $productListCompanyQuery */
        $productListCompanyQuery = $this->getFactory()
            ->createProductListCompanyQuery()
            ->select(SpyProductListCompanyTableMap::COL_FK_COMPANY);

        return $productListCompanyQuery
            ->findByFkProductList($idProductList)
            ->toArray();
    }
186750
protected function isPayment($idSalesOrder, $idSalesOrderItem, $status)
    {
        $statusLog = $this->getFirstUnprocessedTransactionStatusLog($idSalesOrder, $idSalesOrderItem, $status);
        if ($statusLog === null) {
            return false;
        }

        $this->saveSpyPaymentPayoneTransactionStatusLogOrderItem($idSalesOrderItem, $statusLog);

        return true;
    }
35438
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;
    }
659600
public function isPaymentUnderpaid($idSalesOrder, $idSalesOrderItem)
    {
        $status = PayoneTransactionStatusConstants::TXACTION_UNDERPAID;

        return $this->isPayment($idSalesOrder, $idSalesOrderItem, $status);
    }
990178
public function check(SpySalesOrderItem $orderItem)
    {
        return $this->getFacade()
            ->isPaymentCapture($orderItem->getFkSalesOrder(), $orderItem->getIdSalesOrderItem());
    }
806335
public function isPaymentOther($idSalesOrder, $idSalesOrderItem)
    {
        $statusLogs = $this->getUnprocessedTransactionStatusLogs($idSalesOrder, $idSalesOrderItem);
        if (empty($statusLogs)) {
            return false;
        }

        /** @var \Orm\Zed\Payone\Persistence\SpyPaymentPayoneTransactionStatusLog $statusLog */
        $statusLog = array_shift($statusLogs);

        $statuses = [
            PayoneTransactionStatusConstants::TXACTION_PAID,
            PayoneTransactionStatusConstants::TXACTION_APPOINTED,
            PayoneTransactionStatusConstants::TXACTION_UNDERPAID,
        ];
        if (in_array($statusLog->getStatus(), $statuses)) {
            return false;
        }

        $this->saveSpyPaymentPayoneTransactionStatusLogOrderItem($idSalesOrderItem, $statusLog);

        return true;
    }