Exemplo n.º 1
0
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId);
     // 跨年
     if (date('Y') != $this->year) {
         $this->year = date('Y');
         $this->lastLogId = 0;
     }
     // 获取任务 获取解冻失败列表
     $tasks = Model_Payment_ABidUnfreeze::getList(array(array('id', '>', $this->lastLogId), array('status', '=', 2)), $this->limit, $this->year, array('id', 'asc'));
     if ($tasks === false) {
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '获取数据失败');
         exit;
     }
     if (empty($tasks)) {
         // 任务完成
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '任务执行完成');
         $this->setStop();
         $this->setShStopFlag();
         $this->setFlag(array('lastLogId' => $this->lastLogId, 'year' => $this->year));
         exit;
     }
     // 循环任务处理
     foreach ($tasks as $task) {
         $this->dealTask($task);
         $this->lastLogId = $task['id'];
     }
     //记录游标
     $this->setFlag(array('lastLogId' => $this->lastLogId, 'year' => $this->year));
     // 发邮件提醒
     if (count($this->failInfos) > 0) {
         printf('[%s] 有%d条错误,发送报警邮件中ing' . PHP_EOL, date('Y-m-d H:i:s'), count($this->failInfos));
         $str = '<table border="1"><tr><td>错误信息</td></tr>';
         foreach ($this->failInfos as $info) {
             $str .= '<tr><td>' . $info . '</td></tr>';
         }
         $str .= '</table>';
         Bll_House_UpDown_Worker_MailBll::getInstance()->setRecipient(array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'))->setSubject('房源尝试多次解冻,依然失败。请及时跟进,谢谢!')->send(array('message' => $str));
     }
 }