From f04143038aca043d433831d81db010c52716f61c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 23 Oct 2019 20:43:04 +0800 Subject: [PATCH] 1 --- webapp/controller/KefuController.class.php | 44 +++++++++++++--------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/webapp/controller/KefuController.class.php b/webapp/controller/KefuController.class.php index 1f53d1f..975affe 100644 --- a/webapp/controller/KefuController.class.php +++ b/webapp/controller/KefuController.class.php @@ -276,29 +276,28 @@ class KefuController { $share_conf = require('../config/kefu.share.config.php'); while (true) { $rows = $conn->execQuery('SELECT idx, accountid, openid, awardtime, gameid, activetime ' . - ' FROM accounts WHERE idx > :last_idx LIMIT 0, 1000;', + ' FROM accounts WHERE activetime > :time AND idx > :last_idx LIMIT 0, 1000;', array( ':last_idx' => $last_idx, + ':time' => time() - 3600 * 24 )); if (!$rows || count($rows) <= 0) { break; } foreach ($rows as $row) { - if (time() - $row['activetime'] < 3600) { - if (isset($share_conf[$row['gameid']])) { - $game_conf = $share_conf[$row['gameid']]; - if (!isset($media_conf[$row['gameid']])) { - $media_conf[$row['gameid']] = $this->getMediaId($row['gameid']); - } - $game_conf['thumb_media_id'] = $media_conf[$row['gameid']]; - $this->sendKefuMsg($row['accountid'], - array ( - "touser" => $row['openid'], - "msgtype" => "miniprogrampage", - "miniprogrampage" => $game_conf - )); - + if (isset($share_conf[$row['gameid']])) { + $game_conf = $share_conf[$row['gameid']]; + if (!isset($media_conf[$row['gameid']])) { + $media_conf[$row['gameid']] = $this->getMediaId($row['gameid']); } + $game_conf['thumb_media_id'] = $media_conf[$row['gameid']]; + $this->sendKefuMsg($row['accountid'], + array ( + "touser" => $row['openid'], + "msgtype" => "miniprogrampage", + "miniprogrampage" => $game_conf + )); + } if ($row['idx'] > $last_idx) { $last_idx = $row['idx']; @@ -352,14 +351,14 @@ class KefuController { )); return; } + $this->updateActiveTime($conn); if ($this->sendAwardMail($accountid, $awardConfig)) { $ret = $conn->execScript('UPDATE accounts SET ' . - ' awardtime=:awardtime, activetime=:activetime ' . + ' awardtime=:awardtime ' . ' WHERE accountid=:accountid; ', array( ':accountid' => $accountid, ':awardtime' => time(), - ':activetime' => time() )); if ($ret) { $this->sendKefuMsg($accountid, array ( @@ -453,4 +452,15 @@ class KefuController { } } + protected function updateActiveTime($conn) + { + $ret = $conn->execScript('UPDATE accounts SET ' . + ' activetime=:activetime ' . + ' WHERE accountid=:accountid; ', + array( + ':accountid' => $accountid, + ':activetime' => time() + )); + } + }