示例#1
0
 private function setSynchLastTime($time)
 {
     if ($time instanceof DateTime) {
         $time = (int) $time->format('U');
     }
     if (is_int($time)) {
         $oldTimezone = date_default_timezone_get();
         date_default_timezone_set('UTC');
         $time = strftime('%Y-%m-%d %H:%M:%S', $time);
         date_default_timezone_set($oldTimezone);
     }
     $this->config->setGroupValue('/play/orders/receive/', 'last_time', $time);
 }
示例#2
0
 private function executeReserveCancellationSynch()
 {
     $mode = (bool) $this->config->getGroupValue('/amazon/orders/reserve_cancellation/', 'mode');
     if (!$mode) {
         return;
     }
     $interval = $this->config->getGroupValue('/amazon/orders/reserve_cancellation/', 'interval');
     $lastAccess = $this->config->getGroupValue('/amazon/orders/reserve_cancellation/', 'last_access');
     $currentTimeStamp = Mage::helper('M2ePro')->getCurrentGmtDate(true);
     $currentGmtDate = Mage::helper('M2ePro')->getCurrentGmtDate();
     if (!is_null($lastAccess) && $currentTimeStamp < strtotime($lastAccess) + $interval) {
         return;
     }
     $this->config->setGroupValue('/amazon/orders/reserve_cancellation/', 'last_access', $currentGmtDate);
     $tempSynch = new Ess_M2ePro_Model_Amazon_Synchronization_Tasks_Orders_Reserve_Cancellation();
     $tempSynch->process();
 }
示例#3
0
 public function process()
 {
     // Check tasks config mode
     //-----------------------------
     $generalMode = $this->config->getGroupValue('/ebay/orders/', 'mode');
     $receiveMode = $this->config->getGroupValue('/ebay/orders/receive/', 'mode');
     $updateMode = $this->config->getGroupValue('/ebay/orders/update/', 'mode');
     $cancellationMode = $this->config->getGroupValue('/ebay/orders/cancellation/', 'mode');
     $reserveCancellationMode = $this->config->getGroupValue('/ebay/orders/reserve_cancellation/', 'mode');
     if (!$generalMode || !$receiveMode && !$cancellationMode && !$reserveCancellationMode) {
         return false;
     }
     //-----------------------------
     // PREPARE SYNCH
     //---------------------------
     $this->prepareSynch();
     //---------------------------
     // RUN CANCELLATION SYNCH
     //---------------------------
     $interval = $this->config->getGroupValue('/ebay/orders/cancellation/', 'interval');
     $lastAccess = $this->config->getGroupValue('/ebay/orders/cancellation/', 'last_access');
     $startDate = $this->config->getGroupValue('/ebay/orders/cancellation/', 'start_date');
     $currentTimeStamp = Mage::helper('M2ePro')->getCurrentGmtDate(true);
     $currentGmtDate = Mage::helper('M2ePro')->getCurrentGmtDate();
     $isNowTimeToRun = is_null($lastAccess) || $currentTimeStamp > strtotime($lastAccess) + $interval;
     $isNowTimeToRun && ($isNowTimeToRun = !is_null($startDate) && $currentTimeStamp > strtotime($startDate));
     if ($cancellationMode && $isNowTimeToRun) {
         $this->config->setGroupValue('/ebay/orders/cancellation/', 'last_access', $currentGmtDate);
         $tempSynch = new Ess_M2ePro_Model_Ebay_Synchronization_Tasks_Orders_Cancellation();
         $tempSynch->process();
     }
     if (is_null($startDate)) {
         $startDate = new DateTime('now', new DateTimeZone('UTC'));
         $startDate->modify('+7 days');
         $this->config->setGroupValue('/ebay/orders/cancellation/', 'start_date', $startDate->format('Y-m-d H:i:s'));
     }
     //---------------------------
     // RUN RESERVE CANCELLATION SYNCH
     //---------------------------
     $interval = $this->config->getGroupValue('/ebay/orders/reserve_cancellation/', 'interval');
     $lastAccess = $this->config->getGroupValue('/ebay/orders/reserve_cancellation/', 'last_access');
     $currentTimeStamp = Mage::helper('M2ePro')->getCurrentGmtDate(true);
     $currentGmtDate = Mage::helper('M2ePro')->getCurrentGmtDate();
     $isNowTimeToRun = is_null($lastAccess) || $currentTimeStamp > strtotime($lastAccess) + $interval;
     if ($reserveCancellationMode && $isNowTimeToRun) {
         $this->config->setGroupValue('/ebay/orders/reserve_cancellation/', 'last_access', $currentGmtDate);
         $tempSynch = new Ess_M2ePro_Model_Ebay_Synchronization_Tasks_Orders_Reserve_Cancellation();
         $tempSynch->process();
     }
     //---------------------------
     // RUN RECEIVE SYNCH
     //---------------------------
     if ($receiveMode) {
         $tempSynch = new Ess_M2ePro_Model_Ebay_Synchronization_Tasks_Orders_Receive();
         $tempSynch->process();
     }
     //---------------------------
     // RUN UPDATE SYNCH
     //------------------------------
     if ($updateMode) {
         $tempSynch = new Ess_M2ePro_Model_Ebay_Synchronization_Tasks_Orders_Update();
         $tempSynch->process();
     }
     //------------------------------
     // CANCEL SYNCH
     //---------------------------
     $this->cancelSynch();
     //---------------------------
 }