batch(50) as $merchantList) { if (!empty($merchantList)) { foreach ($merchantList as $merchant) { $merchant = $merchant->toArray(); $merchantId = $merchant['id']; $name = $merchant['name']; $visitData = StatVisitService::saveYesterdayNum($merchantId);//访问量 if (!empty($visitData)) { $log = "商家:{$name}({$merchantId}):"; $time = date("Y-m-d", $visitData['time']); $log .= "访问量:date:{$time} num:{$visitData['riseNum']}\r\n"; stringUtil::log($log, '/opt/shell/log/merchant_visit_log_' . date("Ymd") . '.txt'); } } } } } /** * 每天邮件通知 */ public function actionWeekNotice($ip = '') { $open = []; if (empty($open)) { util::stop('取平台信息错误'); } $name = $open['name']; $mail = Yii::$app->mailer->compose(); $errFile = '/opt/shell/log/week_err_' . date("Ymd") . '.txt'; $infoFile = '/opt/shell/log/week_info_' . date("Ymd") . '.txt'; $mail->setTo('479439056@qq.com'); $mail->setSubject("【{$name}】《每周》脚本执行 SUCCESS(" . $ip . ")"); $mail->setTextBody('详细情况请查看附件哦'); if (file_exists($errFile) && filesize($errFile) > 0) { $content = trim(file_get_contents($errFile)); if ($content != "Warning: Using a password on the command line interface can be insecure.") { $mail->setSubject("【{$name}】《每周》脚本执行 出错了(" . $ip . ")"); $mail->attach($errFile); } } if (file_exists($infoFile) && filesize($infoFile) > 0) { $mail->attach($infoFile); } $mail->send(); } /** * 每天邮件通知 */ public function actionDayNotice($ip = '') { $openId = dict::getConfig('openId'); $open = []; if (empty($open)) { util::stop('取平台信息错误'); } $name = $open['name']; $mail = Yii::$app->mailer->compose(); $errFile = '/opt/shell/log/day_err_' . date("Ymd") . '.txt'; $infoFile = '/opt/shell/log/day_info_' . date("Ymd") . '.txt'; $mail->setTo('479439056@qq.com'); $mail->setSubject("【{$name}】【每天】脚本执行 SUCCESS(" . $ip . ")"); $mail->setTextBody('具体请看附件哦'); if (file_exists($errFile) && filesize($errFile) > 0) { $mail->setSubject("【{$name}】【每天】脚本执行 出错了(" . $ip . ")"); $mail->attach($errFile); } if (file_exists($infoFile) && filesize($infoFile) > 0) { $mail->attach($infoFile); } $mail->send(); } //将缓存放入数据库 ssh public function actionPutCacheToSave() { //商家层面 //guaguaka $arr = ['guaguacard-visit-12358-1170']; GuaGuaService::putGuaCacheToSave(); //choujiang $arr = ['draw-visit-12358-1170']; //goods $arr = ['goods-visit-12358-5521']; GoodsService::putGoodsCacheToSave(); //批发商层面 //平台层面 } }