diff --git a/webapp/controller/HangController.class.php b/webapp/controller/HangController.class.php index 572aeaf..44f7319 100644 --- a/webapp/controller/HangController.class.php +++ b/webapp/controller/HangController.class.php @@ -30,18 +30,7 @@ class HangController{ array( ':accountid' => $account_id )); - if (!$row) { - $ret = $conn->execScript('INSERT INTO hang(accountid, hang_time) ' . - ' VALUES(:accountid, :hang_time);', - array( - ':accountid' => $account_id, - ':hang_time' => time() - )); - if (!$ret) { - die(); - return; - } - } else { + if ($row) { $ret = $conn->execScript('UPDATE hang SET hang_time=:hang_time ' . ' WHERE accountid=:accountid;', array( @@ -52,7 +41,7 @@ class HangController{ die(); return; } - $item_id = 1; + $item_id = 10001; $num = time() - $row['hang_time']; if ($num >= 4 * 3600) { $num = 4 * 3600; @@ -84,10 +73,31 @@ class HangController{ phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } + $num = 0; + $row = $conn->execQueryOne('SELECT * FROM hang WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + $ret = $conn->execScript('INSERT INTO hang(accountid, hang_time) ' . + ' VALUES(:accountid, :hang_time);', + array( + ':accountid' => $account_id, + ':hang_time' => time() + )); + if (!$ret) { + die(); + return; + } + } else { + $num = time() - $row['hang_time']; + } + echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - 'time' => time() + 'time' => time(), + 'num' => $num )); } }