We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 73e31065 authored by Bas Maassen's avatar Bas Maassen Committed by GitHub

Set state (#287)

* Set state

* Add in constructor comments
parent b6cda614
......@@ -187,6 +187,11 @@ class Cron
*/
protected $_areaList;
/**
* @var \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory
*/
protected $_orderStatusCollection;
/**
* Cron constructor.
*
......@@ -203,7 +208,9 @@ class Cron
* @param Api\PaymentRequest $paymentRequest
* @param Order\PaymentFactory $adyenOrderPaymentFactory
* @param ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory
* @param InvoiceFactory $adyenInvoiceFactory
* @param AreaList $areaList
* @param \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
......@@ -220,8 +227,10 @@ class Cron
\Adyen\Payment\Model\Order\PaymentFactory $adyenOrderPaymentFactory,
\Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
\Adyen\Payment\Model\InvoiceFactory $adyenInvoiceFactory,
AreaList $areaList
) {
AreaList $areaList,
\Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection
)
{
$this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger;
$this->_notificationFactory = $notificationFactory;
......@@ -237,6 +246,7 @@ class Cron
$this->_adyenOrderPaymentCollectionFactory = $adyenOrderPaymentCollectionFactory;
$this->_adyenInvoiceFactory = $adyenInvoiceFactory;
$this->_areaList = $areaList;
$this->_orderStatusCollection = $orderStatusCollection;
}
/**
......@@ -1137,6 +1147,8 @@ class Cron
// only do this if status in configuration is set
if (!empty($status)) {
$this->_order->addStatusHistoryComment(__('Payment is authorised waiting for capture'), $status);
$this->_setState($status);
$this->_adyenLogger->addAdyenNotificationCronjob(
'Order status is changed to Pre-authorised status, status is ' . $status
);
......@@ -1594,14 +1606,30 @@ class Cron
$comment = "Adyen Payment is in Manual Review check the Adyen platform";
}
}
$status = (!empty($status)) ? $status : $this->_order->getStatus();
$this->_order->addStatusHistoryComment(__($comment), $status);
$this->_setState($status);
$this->_adyenLogger->addAdyenNotificationCronjob(
'Order status is changed to authorised status, status is ' . $status
);
}
/**
* Set State from Status
*/
protected function _setState($status)
{
$statusObject = $this->_orderStatusCollection->create()
->addFieldToFilter('main_table.status', $status)
->addFieldToFilter('state_table.is_default', true)
->joinStates()
->getFirstItem();
$this->_order->setState($statusObject->getState());
$this->_adyenLogger->addAdyenNotificationCronjob('State is changed to ' . $statusObject->getState());
}
/**
* Create shipment
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment