diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 191e2f0..1346fbb 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -72,6 +72,7 @@ CREATE TABLE `user` ( `pass_status` int(11) NOT NULL DEFAULT '0' COMMENT '通行证购买状态', `score` int(11) NOT NULL DEFAULT '0' COMMENT '通行证积分', `season_status` int(11) NOT NULL DEFAULT '0' COMMENT '赛季奖励状态', + `first_gift` 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/PassController.class.php b/webapp/controller/PassController.class.php index d136a50..749ae52 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -52,6 +52,7 @@ class PassController{ 'point' => $seaReward_meta['point'], 'active' => $seaReward_meta['reward1'], 'honor' => $seaReward_meta['reward2'], + 'level' => $seaReward_meta['level'] ); return $seaReward; } @@ -144,16 +145,19 @@ class PassController{ } $drop_multiply = array(); $status = 0; - $seaReward = $this->getSeasonReward($j + $number * 100); - if ($row['score'] >= $seaReward['point']) { + $seaReward = $this->getSeasonReward($id - 1); + if ($row['score'] >= $seaReward['point'] && $seaReward['point'] != -1) { $level = $seaReward['level']; $pass_score = $row['score'] - $seaReward['point']; $max_pass_score = $seaReward['point']; } - if ($row['score'] < $seaReward_meta_table[1]['point']) { - $max_rank_score = $seaReward['point']; + //如果是最大等级,则返回上一级的最大值 + if ($seaReward['point'] == -1) { + $seaReward = $this->getSeasonReward($id - 2); + $sum_score = $seaReward['point']; + } else { + $sum_score = $seaReward['point']; } - $sum_score = $seaReward['point']; $rowPass = $conn->execQueryOne('SELECT active_status, honor_status ' . ' FROM passinfo WHERE accountid=:accountid AND passid=:passid;', array( diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index ef4a0b1..669f9ff 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -100,9 +100,9 @@ class RoleController{ ':accountid' => $account_id )); if (!$row) { - $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) ' . - ' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) ' . - ' 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;', + $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) ' . + ' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 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) ' . + ' 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;', array( ':accountid' => $account_id, ':user_name' => $user_name, @@ -134,6 +134,7 @@ class RoleController{ 'diamond_num' => 0, 'pass_status' => 0, 'season_status' => 1, + 'first_gift' => 0, )); } else { echo json_encode(array( @@ -155,7 +156,8 @@ class RoleController{ 'box_num' => $row['box_num'], 'diamond_num' => $row['diamond_num'], 'pass_status' => $row['pass_status'], - 'season_status' => $row['season_status'] + 'season_status' => $row['season_status'], + 'first_gift' => $row['first_gift'], )); } } diff --git a/webapp/controller/ShareController.class.php b/webapp/controller/ShareController.class.php index 9ea8385..1b5389b 100644 --- a/webapp/controller/ShareController.class.php +++ b/webapp/controller/ShareController.class.php @@ -82,22 +82,14 @@ class ShareController{ return $p; } - protected function subCoin($coin_num, $account_id) + protected function subCoin($num, $account_id, $diamond_num) { $conn = $this->getMysql($account_id); if (!$conn) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); - return; - } - $row = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - )); - if (!$row) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); die(); } - if ($row['diamond_num'] < $diamond_num) { + if ($diamond_num < $num) { phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足'); die(); } @@ -105,7 +97,7 @@ class ShareController{ ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, - ':diamond_num' => $row['diamond_num'] - $diamond_num, + ':diamond_num' => $diamond_num - $num, ':modify_time' => time() )); if (!$ret) { @@ -129,6 +121,7 @@ class ShareController{ return; } $free = $_REQUEST['free']; + $drop_id = 0; if ($free != 0) { $drop_id = 24002; $p = $this->getParameter(DIAMONDBOX10); @@ -136,11 +129,19 @@ class ShareController{ $drop_id = 24001; $p = $this->getParameter(DIAMONDBOX); } + $row = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + die(); + } //扣除钻石 $diamond_num = $p['param_value']; - $this->subCoin($diamond_num, $account_id); + $this->subCoin($diamond_num, $account_id, $row['diamond_num']); + $num = $row['diamond_num'] - $diamond_num; //随机奖励 - $drop_id = 0; $d = $this->getDrop($drop_id); if (!$d) { phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); @@ -154,8 +155,7 @@ class ShareController{ for ($i = 0; $i < count($weight_array); $i++) { $weight_sum += $weight_array[$i][0]; } - $keys = $row['keys_num'] - 1; - srand(crc32($account_id . $keys)); + srand(crc32($account_id . $num)); $random = Rand(0, $weight_sum); $weight = 0; for ($i = 0; $i < count($weight_array); $i++) { @@ -205,7 +205,7 @@ class ShareController{ 'errcode' => 0, 'errmsg' => '', 'item_list' => $item_list, - 'keys_num' => $row['keys_num'] - 1 + 'diamond_num' => $num, )); }