|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* |
|
5
|
|
|
* |
|
6
|
|
|
* @category Mygento |
|
7
|
|
|
* @package Mygento_Payture |
|
8
|
|
|
* @copyright Copyright © 2017 NKS LLC. (http://www.mygento.ru) |
|
9
|
|
|
*/ |
|
10
|
|
|
class Mygento_Payture_Model_Cron |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
View Code Duplication |
public function fivemin() |
|
|
|
|
|
|
14
|
|
|
{ |
|
15
|
|
|
Mage::helper('payture')->addLog('Start of cron run'); |
|
16
|
|
|
$collection = Mage::getModel('payture/keys')->getCollection(); |
|
17
|
|
|
$collection->addFieldToFilter('sessionid', array('neq' => null)); |
|
18
|
|
|
$collection->addFieldToFilter('state', array('neq' => 'Complete')); |
|
19
|
|
|
$collection->addFieldToFilter('date', array('gteq' => Mage::getModel('core/date')->date('Y-m-d H:i:s', strtotime('-1 hour', time())))); |
|
20
|
|
|
Mage::helper('payture')->addLog('Checking ' . count($collection) . ' order tickets'); |
|
21
|
|
|
foreach ($collection as $_ticket) { |
|
22
|
|
|
Mage::helper('payture')->checkTicket($_ticket); |
|
23
|
|
|
} |
|
24
|
|
|
Mage::helper('payture')->addLog('End of cron run'); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
View Code Duplication |
public function completeOrders() |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
Mage::helper('payture')->addLog('Start of cron run'); |
|
30
|
|
|
$collection = Mage::getModel('payture/keys')->getCollection(); |
|
31
|
|
|
$collection->addFieldToFilter('sessionid', array('neq' => null)); |
|
32
|
|
|
$collection->addFieldToFilter('state', array('eq' => 'Authorized')); |
|
33
|
|
|
$collection->addFieldToFilter('date', array('gteq' => Mage::getModel('core/date')->date('Y-m-d H:i:s', strtotime('-48 hours', time())))); |
|
34
|
|
|
Mage::helper('payture')->addLog('Checking ' . count($collection) . ' authorized tickets'); |
|
35
|
|
|
foreach ($collection as $_ticket) { |
|
36
|
|
|
Mage::helper('payture')->checkTicket($_ticket); |
|
37
|
|
|
} |
|
38
|
|
|
Mage::helper('payture')->addLog('End of cron run'); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.