This commit is contained in:
aozhiwei 2019-10-23 20:43:04 +08:00
parent 3440887b98
commit f04143038a

View File

@ -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()
));
}
}