diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 9f2f720..0f8602f 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -97,6 +97,7 @@ CREATE TABLE `user` ( `share_video_sums` int(11) NOT NULL DEFAULT '0' COMMENT '分享录频次数', `biogame_times` int(11) NOT NULL DEFAULT '0' COMMENT '生化模式场次', + `create_user` int(11) NOT NULL DEFAULT '0' COMMENT '是否创角', PRIMARY KEY (`idx`), UNIQUE KEY `accountid` (`accountid`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; diff --git a/webapp/controller/FriendController.class.php b/webapp/controller/FriendController.class.php index e85b3be..1a5a6bd 100644 --- a/webapp/controller/FriendController.class.php +++ b/webapp/controller/FriendController.class.php @@ -84,7 +84,7 @@ class FriendController{ public function selectUser() { $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); + $conn = $this->getMysql(); if(!$conn){ phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在'); return; @@ -104,6 +104,31 @@ class FriendController{ )); } + public function selectUserByName() + { + $account_id = $_REQUEST['account_id']; + $conn = $this->getMysql(); + if(!$conn){ + phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在'); + return; + } + $user_name = $_REQUEST['user_name']; + $row = $conn->execQueryOne('SELECT accountid FROM user WHERE user_name=:user_name;', + array( + ':user_name' => $user_name, + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '玩家不存在'); + return; + } + + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'fri_accountid' => $row['accountid'], + )); + } + public function changeRoleInfo() { $account_id = $_REQUEST['account_id']; @@ -120,7 +145,7 @@ class FriendController{ } $user_name = $_REQUEST['user_name']; $avatar_url = $_REQUEST['avatar_url']; - $ret = $conn->execScript('UPDATE user SET user_name=:user_name, avatar_url=:avatar_url, modify_time=:modify_time ' . + $ret = $conn->execScript('UPDATE user SET user_name=:user_name, avatar_url=:avatar_url, modify_time=:modify_time, create_user=1 ' . ' WHERE accountid=:accountid;', array( ':user_name' => $user_name, @@ -137,6 +162,38 @@ class FriendController{ 'errmsg' => '', 'user_name' => $user_name, 'avatar_url' => $avatar_url, + 'create_user' => 1, + )); + } + + public function selRepeatName() + { + $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 + 1, '没有这个玩家'); + return; + } + $user_name = $_REQUEST['user_name']; + $row = $conn->execQueryOne('SELECT accountid FROM user WHERE accountid!=:account_id AND user_name=:user_name;', + array( + ':account_id' => $account_id, + ':user_name' => $user_name, + )); + if ($row) { + phpcommon\sendError(ERR_USER_BASE + 2, '名字重名'); + return; + } + + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', )); } diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index a5d6d29..e307f10 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -148,7 +148,7 @@ class RoleController{ $account_id = $_REQUEST['account_id']; //$user_name = $_REQUEST['name']; //$avatar_url = $_REQUEST['avatar_url']; - $user_name = '突击队员'; + $user_name = '游客'; $avatar_url = '1'; $switch_id = 1; $switch_id = isset($_REQUEST['switch_id']); @@ -186,9 +186,9 @@ class RoleController{ break; } } - $ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo, first_day_ad, share_video_times, share_video_sums, act_video_status, act_ad_status, biogame_times) ' . - ' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0) ' . - ' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo, first_day_ad=0, share_video_times=0, share_video_sums=0, act_video_status=0, act_ad_status=0, biogame_times=0;', + $ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo, first_day_ad, share_video_times, share_video_sums, act_video_status, act_ad_status, biogame_times, create_user) ' . + ' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0,0) ' . + ' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo, first_day_ad=0, share_video_times=0, share_video_sums=0, act_video_status=0, act_ad_status=0, biogame_times=0, create_user=0;', array( ':accountid' => $account_id, ':user_name' => $user_name, @@ -251,28 +251,9 @@ class RoleController{ 'biogame_times' => 0, 'user_name' => $user_name, 'avatar_url' => $avatar_url, + 'create_user' => 0, )); } else { - if ($avatar_url != '') { - if ($user_name != $row['user_name']) { - $ret = $conn->execScript('UPDATE user SET user_name=:user_name, modify_time=:modify_time ' . - ' WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':user_name' => $user_name, - ':modify_time' => time() - )); - } - if ($avatar_url != $row['avatar_url']) { - $ret = $conn->execScript('UPDATE user SET avatar_url=:avatar_url, modify_time=:modify_time ' . - ' WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':avatar_url' => $avatar_url, - ':modify_time' => time() - )); - } - } $nowTime = phpcommon\getdayseconds(time()); $daily_first_login = $row['daily_first_login']; $coin_times = $row['coin_times']; @@ -365,6 +346,7 @@ class RoleController{ 'biogame_times' => $row['biogame_times'], 'user_name' => $row['user_name'], 'avatar_url' => $row['avatar_url'], + 'create_user' => $row['create_user'], )); } } @@ -658,7 +640,7 @@ class RoleController{ if ($daily_time == 0 || ($nowTime - phpcommon\getdayseconds($daily_time) > 0)) { $daily_time = time(); } - $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time, daily_time=:daily_time, biogame_times=:biogame_times, integral=:integral, game_times=:game_times ' . + $ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time, daily_time=:daily_time, biogame_times=:biogame_times, integral=:integral, game_times=:game_times, kill_modifytime=:kill_modifytime ' . 'WHERE accountid=:accountid;', array( ':accountid' => $account_id, diff --git a/webapp/index.php b/webapp/index.php index 7ed1cb9..f06f3d1 100644 --- a/webapp/index.php +++ b/webapp/index.php @@ -1,5 +1,6 @@