|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © Getnet. All rights reserved. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Bruno Elisei <[email protected]> |
|
6
|
|
|
* See LICENSE for license details. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Getnet\PaymentMagento\Cron; |
|
10
|
|
|
|
|
11
|
|
|
use Getnet\PaymentMagento\Gateway\Config\ConfigWallet; |
|
12
|
|
|
use Magento\Payment\Model\Method\Logger; |
|
13
|
|
|
use Magento\Sales\Model\Order; |
|
14
|
|
|
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; |
|
15
|
|
|
|
|
16
|
|
|
/* |
|
17
|
|
|
* Class Fetch Transaction Order Wallet - Cron fetch order |
|
18
|
|
|
*/ |
|
19
|
|
|
class FetchTransactionOrderWallet |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var Logger |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $logger; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var Order |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $order; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var ConfigWallet |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $configWallet; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var CollectionFactory |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $collectionFactory; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param Order $order |
|
43
|
|
|
* @param Logger $logger |
|
44
|
|
|
* @param ConfigWallet $configWallet |
|
45
|
|
|
* @param CollectionFactory $collectionFactory |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct( |
|
48
|
|
|
Order $order, |
|
49
|
|
|
Logger $logger, |
|
50
|
|
|
ConfigWallet $configWallet, |
|
51
|
|
|
CollectionFactory $collectionFactory |
|
52
|
|
|
) { |
|
53
|
|
|
$this->order = $order; |
|
54
|
|
|
$this->logger = $logger; |
|
55
|
|
|
$this->configWallet = $configWallet; |
|
56
|
|
|
$this->collectionFactory = $collectionFactory; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Execute. |
|
61
|
|
|
* |
|
62
|
|
|
* @return void |
|
63
|
|
|
*/ |
|
64
|
|
|
public function execute() |
|
65
|
|
|
{ |
|
66
|
|
|
$orders = $this->collectionFactory->create() |
|
67
|
|
|
->addFieldToFilter('state', [ |
|
68
|
|
|
'in' => [ |
|
69
|
|
|
Order::STATE_NEW, |
|
70
|
|
|
], |
|
71
|
|
|
]); |
|
72
|
|
|
|
|
73
|
|
|
$orders->getSelect() |
|
74
|
|
|
->join( |
|
75
|
|
|
['sop' => 'sales_order_payment'], |
|
|
|
|
|
|
76
|
|
|
'main_table.entity_id = sop.parent_id', |
|
77
|
|
|
['method'] |
|
78
|
|
|
) |
|
79
|
|
|
->where('sop.method = ?', ConfigWallet::METHOD); |
|
80
|
|
|
|
|
81
|
|
|
foreach ($orders as $order) { |
|
82
|
|
|
if (!$order->getEntityId()) { |
|
83
|
|
|
continue; |
|
84
|
|
|
} |
|
85
|
|
|
$loadedOrder = $this->order->load($order->getEntityId()); |
|
|
|
|
|
|
86
|
|
|
$payment = $loadedOrder->getPayment(); |
|
87
|
|
|
$payment->update(); |
|
88
|
|
|
$this->logger->debug([ |
|
89
|
|
|
'cron' => 'FetchTransactionOrderWallet', |
|
90
|
|
|
'type' => ConfigWallet::METHOD, |
|
91
|
|
|
'order' => $loadedOrder->getIncrementId(), |
|
92
|
|
|
'status' => $loadedOrder->getStatus(), |
|
93
|
|
|
]); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.