1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- /**
- * Created by PhpStorm.
- * User: PHP
- * Date: 2016/11/23
- * Time: 9:11
- */
- class GetKennelDetailWorkCommand extends CConsoleCommand {
- public function run($args){
- //error_reporting(E_ERROR);
- ini_set('memory_limit', '256M');
- //ini_set('mongo.long_as_object',1);
- set_time_limit(0);
- self::getKennel();
- }
- public function getKennel()
- {
- $end_time = date("Y-m-d 14:00:00");
- $start_time = date("Y-m-d 14:00:00",strtotime("-1 day"));
- $criteria = new EMongoCriteria();
- $criteria->addCond('time','>=',strtotime(date('Y-m-d H:i:s',strtotime($start_time))));
- $criteria->addCond('time','<=',strtotime(date('Y-m-d H:i:s',strtotime($end_time))));
- $cursor = JRecord::model()->findAll($criteria);
- $rows = CommonFn::getRowsFromCursor($cursor);
- $parsedRows = JRecord::model()->parse($rows);
- foreach ($cursor as $item) {
- $item->status = 2;
- $item->save();
- }
- $type_name = '全部';
- $res=Service::factory('JRecordService')->push($parsedRows,$type_name,['start' => $start_time, 'end' => $end_time],1);
- $mail = Yii::app()->mailer;
- try {
- $mail->SMTPDebug = 2; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.qq.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = '1340652578@qq.com'; // SMTP username
- $mail->Password = 'iaycligvfccmjdcf'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- $mail->setFrom('1340652578@qq.com', 'Mailer');
- $mail->AddAddress('1340652578@qq.com');
- $mail->addAttachment(Yii::app()->basePath.'/export/'.$res); // Add attachments
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = '提货记录';
- $mail->Body = $res;
- $mail->AltBody = $res;
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- }
- }
|