diff --git a/webapp/controller/SkinController.class.php b/webapp/controller/SkinController.class.php index ec891ba..e476dab 100644 --- a/webapp/controller/SkinController.class.php +++ b/webapp/controller/SkinController.class.php @@ -490,5 +490,47 @@ class SkinController{ 'errmsg' => '', )); } + + public function getSkinReward() + { + $account_id = $_REQUEST['account_id']; + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + $skin_id = $_REQUEST['id']; + $row = $conn->execQueryOne('SELECT fragment_num FROM skin WHERE accountid=:account_id AND skin_id=:skin_id;', + array( + ':account_id' => $account_id, + ':skin_id' => $skin_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 1, '皮肤不存在'); + return; + } + $ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num, modify_time=:modify_time ' . + ' WHERE accountid=:account_id AND skin_id=:skin_id;', + array( + ':account_id' => $account_id, + ':skin_id' => $skin_id, + ':fragment_num' => $row['fragment_num'] + 20, + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + )); + } } ?>