|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © Wirecard Brasil. All rights reserved. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Bruno Elisei <[email protected]> |
|
6
|
|
|
* See COPYING.txt for license details. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Moip\Magento2\Cron; |
|
10
|
|
|
|
|
11
|
|
|
use Magento\Payment\Model\Method\Logger; |
|
|
|
|
|
|
12
|
|
|
use Magento\Sales\Model\Order; |
|
|
|
|
|
|
13
|
|
|
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; |
|
|
|
|
|
|
14
|
|
|
use Moip\Magento2\Gateway\Config\ConfigBoleto; |
|
15
|
|
|
|
|
16
|
|
|
/* |
|
17
|
|
|
* Class StatusUpdateOrderBoleto |
|
18
|
|
|
*/ |
|
19
|
|
|
class StatusUpdateOrderBoleto |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var Logger |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $logger; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var Order |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $order; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var CollectionFactory |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $collectionFactory; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var ConfigBoleto |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $configBoleto; |
|
40
|
|
|
|
|
41
|
|
|
/* |
|
42
|
|
|
* @param order |
|
43
|
|
|
* @param logger |
|
44
|
|
|
* @param configBoleto |
|
45
|
|
|
* @param collectionFactory |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct( |
|
48
|
|
|
Order $order, |
|
49
|
|
|
Logger $logger, |
|
50
|
|
|
ConfigBoleto $configBoleto, |
|
51
|
|
|
CollectionFactory $collectionFactory |
|
52
|
|
|
) { |
|
53
|
|
|
$this->order = $order; |
|
54
|
|
|
$this->logger = $logger; |
|
55
|
|
|
$this->configBoleto = $configBoleto; |
|
56
|
|
|
$this->collectionFactory = $collectionFactory; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function execute() |
|
60
|
|
|
{ |
|
61
|
|
|
$orders = $this->collectionFactory->create() |
|
62
|
|
|
->addFieldToFilter('status', [ |
|
63
|
|
|
'in' => [ |
|
64
|
|
|
Order::STATE_PAYMENT_REVIEW, |
|
65
|
|
|
], |
|
66
|
|
|
]); |
|
67
|
|
|
|
|
68
|
|
|
$orders->getSelect() |
|
69
|
|
|
->join( |
|
70
|
|
|
['sop' => 'sales_order_payment'], |
|
71
|
|
|
'main_table.entity_id = sop.parent_id', |
|
72
|
|
|
['method'] |
|
73
|
|
|
) |
|
74
|
|
|
->where('sop.method = ?', ConfigBoleto::METHOD); |
|
75
|
|
|
|
|
76
|
|
|
foreach ($orders as $order) { |
|
77
|
|
|
if (!$order->getEntityId()) { |
|
78
|
|
|
continue; |
|
79
|
|
|
} |
|
80
|
|
|
$loadedOrder = $this->order->load($order->getEntityId()); |
|
81
|
|
|
|
|
82
|
|
|
if ($loadedOrder->canFetchPaymentReviewUpdate()) { |
|
83
|
|
|
$payment = $loadedOrder->getPayment(); |
|
84
|
|
|
|
|
85
|
|
|
try { |
|
86
|
|
|
$payment->update(true); |
|
87
|
|
|
$loadedOrder->save(); |
|
88
|
|
|
$this->logger->debug([ |
|
89
|
|
|
'cron' => 'boleto', |
|
90
|
|
|
'type' => 'updateStatus', |
|
91
|
|
|
'order' => $loadedOrder->getIncrementId(), |
|
92
|
|
|
'new_state' => $loadedOrder->getStatus(), |
|
93
|
|
|
]); |
|
94
|
|
|
} catch (\Exception $exc) { |
|
95
|
|
|
$this->logger->debug([ |
|
96
|
|
|
'cron' => 'boleto', |
|
97
|
|
|
'type' => 'updateStatus', |
|
98
|
|
|
'order' => $loadedOrder->getIncrementId(), |
|
99
|
|
|
'error' => $exc->getMessage(), |
|
100
|
|
|
]); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths