Beispiel #1
0
 public function runAction()
 {
     $sendResult = true;
     $errInfo = '';
     // 采购交期回复批量回复
     $hourSet = array('12:00', '18:00');
     // 12点和18点各运行一次
     $timeDiff = 12;
     foreach ($hourSet as $hour) {
         if ($hour == date('H:00')) {
             $this->generatePurchseDeliveryUpdateEmail(date('Y-m-d H:00:00'), $timeDiff);
         }
     }
     $mail = new Application_Model_Log_Mail();
     $content = "[ Start " . date("Y-m-d H:i:s") . " ]\r\n";
     $dateStart = date('Y-m-d', strtotime('-3 day'));
     $data = $mail->fetchAll("state = 0 and add_date >= '" . $dateStart . "'")->toArray();
     //echo '<pre>';print_r($data);exit;
     foreach ($data as $d) {
         $mail->update(array('content' => '<div style="color:#f00;font-weight:bold;">系统任务计划重发!</div>' . $d['content']), "id = " . $d['id']);
         $result = $mail->send($d['id']);
         if (!$result['success']) {
             $sendResult = false;
             $errInfo = $result['info'];
             break;
         }
     }
     if (count($data) > 0) {
         if (!$sendResult) {
             $content .= "      " . date("Y-m-d H:i:s") . " Faild [" . $errInfo . "]\r\n";
         } else {
             $content .= "      " . date("Y-m-d H:i:s") . " Success\r\n";
         }
     }
     $content .= "[ End   " . date("Y-m-d H:i:s") . " ]\r\n";
     $this::writeLog($content, 'cron_mail');
     if ($errInfo) {
         echo iconv('utf-8', 'gbk', 'Faild! ' . $errInfo);
     } else {
         echo iconv('utf-8', 'gbk', 'Success! ');
     }
     exit;
 }