Merge branch 'hotfix/login_crontab' of wmtx/platform into release

修复登录统计问题
master
万盟天下 5 years ago committed by Gogs
commit 8e9749bacb

@ -104,7 +104,7 @@ class ConsoleController extends Think {
public function modifyLoginCheck($start_time=0, $end_time=0) public function modifyLoginCheck($start_time=0, $end_time=0)
{ {
$start_time = $start_time ? strtotime($start_time) : strtotime(date("Y-m-d")); $start_time = $start_time ? strtotime($start_time) : strtotime(date("Y-m-d"));
$end_time = $end_time ? strtotime($end_time) : $start_time + 86400; $end_time = $end_time ? strtotime($end_time) : $start_time;
$this->modifyLogin($start_time, $end_time); $this->modifyLogin($start_time, $end_time);
} }
@ -118,7 +118,7 @@ class ConsoleController extends Think {
$end_time = $i+86400; $end_time = $i+86400;
$result = M()->query("SELECT $result = M()->query("SELECT
game_id, game_id,
FROM_UNIXTIME(login_time, '%Y-%m-%d') create_time, UNIX_TIMESTAMP(FROM_UNIXTIME(login_time, '%Y-%m-%d')) create_time,
user_id, user_id,
promote_id promote_id
FROM FROM
@ -135,18 +135,24 @@ class ConsoleController extends Think {
GROUP BY GROUP BY
create_time, create_time,
game_id, game_id,
user_id"); user_id,
promote_id");
if ($result) { if ($result) {
foreach ($result as $index => $item) { foreach ($result as $index => $item) {
$item['create_time'] = strtotime($item['create_time']); if (is_null($result[$index]['promote_id']))
if ($item['create_time']) { {
$res = M("login_daily_record", "tab_")->add($item); unset($result[$index]);
echo "写入{$item['create_time']} $res \n"; }
}
$step = 500;
for ($j=0;;$j+=$step) {
$insData = array_slice($result, $j, $step);
if ($insData) {
$res = M("login_daily_record", 'tab_')->addAll($insData);
echo "写入 $res \n";
} else { } else {
echo "写入{$item['create_time']} error \n"; break;
} }
unset($result[$index]);
} }
} else { } else {
echo "写入{$item['create_time']} 无 \n"; echo "写入{$item['create_time']} 无 \n";

Loading…
Cancel
Save