diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 3ffb0a2..9ffc61c 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -74,6 +74,8 @@ CREATE TABLE `user` ( `season_status` int(11) NOT NULL DEFAULT '0' COMMENT '赛季奖励状态', `first_gift` int(11) NOT NULL DEFAULT '0' COMMENT '首充礼包领取状态', `season_time` int(11) NOT NULL DEFAULT '0' COMMENT '赛季结束时间', + `free_coin` int(11) NOT NULL DEFAULT '0' COMMENT '每日免费金币', + `free_diamond` 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/classes/AddReward.php b/webapp/classes/AddReward.php index ee0db22..87fb81f 100644 --- a/webapp/classes/AddReward.php +++ b/webapp/classes/AddReward.php @@ -61,6 +61,7 @@ class AddReward { public function addReward($item_id, $item_num, $account_id) { + error_log($item_id); $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); @@ -78,12 +79,10 @@ class AddReward { )); if ($it['type'] == 5) { $item_list = $this->addGift($it['index'], $account_id); - } else if ($it['type'] == 6) { - error_log($it['id']); - $item_list = $this->addEmoji($it['id'], $account_id, $it['dprice']); - } else if ($it['type'] == 4) { - $item_list = $this->addSkin($it['id'], $item_num, $account_id); + } else if ($it['type'] == 7) { + $this->addPass($it['id'], $item_num, $account_id); } + foreach ($item_list as $item) { $i = $this->getItem($item['itemid']); switch ($i['type']) @@ -100,9 +99,13 @@ class AddReward { //添加角色碎片 $this->addSkinFragment($item['itemid'], $item['itemnum'], $account_id); break; - case 7: - //添加通行证 - $this->addPass($item['itemid'], $item['itemnum'], $account_id); + case 4: + //添加角色 + $this->addSkin($item['itemid'], $item['itemnum'], $account_id); + break; + case 6: + //添加表情 + $this->addEmoji($item['itemid'], $account_id, $it['dprice']); break; default: break; @@ -150,6 +153,7 @@ class AddReward { $item_id = 0; $item_num = 0; $conn = $this->getMysql($accountid); + error_log($itemid); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); die(); @@ -176,6 +180,7 @@ class AddReward { $item_id = $itemid; $item_num = 1; } else { + error_log(22222222222); $item_id = 10003; $item_num = $dprice; $this->addDiamond($item_id, $item_num, $accountid); @@ -190,8 +195,6 @@ class AddReward { //添加钻石 protected function addDiamond($item_id, $item_num, $accountid) { - error_log($item_id); - error_log($item_num); $conn = $this->getMysql($accountid); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); @@ -335,7 +338,7 @@ class AddReward { $user_ret = $conn->execScript('UPDATE user SET pass_status=1, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( - ':accountid' => $account_id, + ':accountid' => $accountid, ':modify_time' => time() )); if (!$user_ret) { diff --git a/webapp/controller/PassController.class.php b/webapp/controller/PassController.class.php index e80ad92..106bc4c 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -98,7 +98,7 @@ class PassController{ $ret = $conn->execScript('UPDATE user SET season_time=:season_time, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( - ':accountid' => $accountid, + ':accountid' => $account_id, ':season_time' => $end_time, ':modify_time' => time() )); @@ -421,7 +421,7 @@ class PassController{ $ret = $conn->execScript('UPDATE user SET integral=0, season_status=1, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( - ':accountid' => $accountid, + ':accountid' => $account_id, ':modify_time' => time() )); if (!$ret) { @@ -431,6 +431,7 @@ class PassController{ echo json_encode(array( 'errcode' => 0, 'errmsg'=> '', + 'item_list' => $reward, )); } } diff --git a/webapp/controller/PayController.class.php b/webapp/controller/PayController.class.php index d52287f..dadfaea 100644 --- a/webapp/controller/PayController.class.php +++ b/webapp/controller/PayController.class.php @@ -47,6 +47,18 @@ class PayController{ return $vip; } + protected function getParameter($para_id) + { + $parameter_meta_cluster = require('../res/parameter@parameter.php'); + $parameter_meta = getParameterConfig($parameter_meta_cluster, $para_id); + $p = array( + 'id' => $parameter_meta['id'], + 'name' => $parameter_meta['param_name'], + 'value' => $parameter_meta['param_value'], + ); + return $p; + } + protected function getDiamondShop($diamond_id) { $diamond_meta_table = require('../res/diamondshop@diamondshop.php'); @@ -135,7 +147,7 @@ class PayController{ phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } - $rowUser = $conn->execQueryOne('SELECT create_time FROM user WHERE accountid=:accountid;', + $rowUser = $conn->execQueryOne('SELECT create_time, free_coin, free_diamond FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id, )); @@ -159,13 +171,27 @@ class PayController{ ':accountid' => $account_id, ':itemid' => $diamond['item_id'] )); - if ($diamond['limit_num'] == -1) { + if (!$row) { $times = $diamond['limit_num']; } else { - if (!$row) { + //无限次数 + if ($diamond['limit_num'] == -1) { $times = $diamond['limit_num']; } else { + //限定次数 $times = $diamond['limit_num'] - $row['today_times']; + if ($times < 0) { + $times = 0; + } + } + } + //免费金币钻石领取次数 + if ($diamond['coin_type'] == 0) { + if ($diamond['shop_type'] == 2) { + $times = $diamond['limit_num'] - $rowUser['free_coin']; + } + if ($diamond['shop_type'] == 1) { + $times = $diamond['limit_num'] - $rowUser['free_diamond']; } } $sub_item = array(); @@ -526,7 +552,7 @@ class PayController{ phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } - $row = $conn->execQueryOne('SELECT diamond_num, first_gift FROM user WHERE accountid=:accountid;', + $row = $conn->execQueryOne('SELECT diamond_num, first_gift, free_coin, free_diamond FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id )); @@ -583,6 +609,41 @@ class PayController{ return; } } + //每日免费金币钻石 + if ($diamond['coin_type'] == 0) { + if ($diamond['shop_type'] == 2) { + if ($row['free_coin'] == 1) { + phpcommon\sendError(ERR_USER_BASE + 4, '每日免费金币已领取'); + return; + } + $ret = $conn->execScript('UPDATE user SET free_coin=1, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + } + if ($diamond['shop_type'] == 1) { + if ($row['free_diamond'] == 1) { + phpcommon\sendError(ERR_USER_BASE + 4, '每日免费钻石已领取'); + return; + } + $ret = $conn->execScript('UPDATE user SET free_diamond=1, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + } + } } //添加道具 @@ -595,5 +656,43 @@ class PayController{ 'errmsg'=> '', )); } + + public function getDoubleCoin() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $item_id = $_REQUEST['item_id']; + $item_list = array(); + $diamond_meta_table = require('../res/diamondshop@diamondshop.php'); + for ($i = 1; $i <= count($diamond_meta_table); $i++) { + $diamond = $this->getDiamondShop($i); + if ($item_id != $diamond['item_id']) { + continue; + } + $item = $this->getItem($diamond['item_id']); + $item_list = $this->getItemInfo($item['fuctionindex']); + if (!$item_list) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具'); + return; + } + } + //添加道具 + $p = $this->getParameter(REWARD_TIMES); + $times = $p['value'] - 1; + foreach ($item_list as $item) { + $addreward = new classes\AddReward(); + $addreward->addReward($item['itemid'], $item['itemnum'] * $times, $account_id); + } + + echo json_encode(array( + 'errcode' => 0, + 'errmsg'=> '', + )); + } } ?> diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index ec34568..a0e41f6 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, recharge_times_total, first_gift, season_time) ' . - ' 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, 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=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) ' . + ' 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, 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=0, free_coin=0, free_diamond=0;', array( ':accountid' => $account_id, ':user_name' => $user_name, diff --git a/webapp/controller/ServerSwitchController.class.php b/webapp/controller/ServerSwitchController.class.php index c0c3dd6..e4066c3 100644 --- a/webapp/controller/ServerSwitchController.class.php +++ b/webapp/controller/ServerSwitchController.class.php @@ -2,12 +2,66 @@ class ServerSwitchController { + private function isForbidCity() + { + if (in_array(strtolower($_REQUEST['province']), + array( + strtolower('Shanghai'), + strtolower('Beijing'), + '上海', + '北京' + )) || + in_array(strtolower($_REQUEST['city']), + array( + strtolower('Guangzhou'), + strtolower('Shenzhen'), + strtolower('Chengdu'), + '广州', + '深圳', + '成都' + )) + ) { + return true; + } + return false; + } + public function getSwitch() { + if (SERVER_ENV != _ONLINE) { + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'payable' => 1 + )); + die(); + } + $payable = 0; + /* + 玩家第一天不开放 + 玩家进来第二天,玩了7-8次战斗后开放(非北上广并且每天重置战斗次数) + 北上广第三天开放 + */ + if (phpcommon\isValidSessionId($_REQUEST['account_id'], + $_REQUEST['session_id'])) { + $register_time = phpcommon\extractRegisterTimeSessionId($_REQUEST['session_id']); + $nowtime = time(); + if ($nowtime - $register_time > 3600 * 24) { + if ($this->isForbidCity() && $nowtime - $register_time > 3600 * 24 * 2) { + if ($_REQUEST['battle_times'] >= 8) { + $payable = 1; + } + } else { + if ($_REQUEST['battle_times'] >= 8) { + $payable = 1; + } + } + } + } echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - 'payable' => 1 + 'payable' => $payable )); } diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index 9749b65..6323778 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -176,7 +176,6 @@ class SignController{ public function signReward() { $account_id = $_REQUEST['account_id']; - $double = $_REQUEST['double']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); if (!$login) { @@ -322,8 +321,8 @@ class SignController{ die(); } } - //刷新战斗结算奖励次数,商店刷新次数,客服 - $battle_ret = $conn->execScript('UPDATE user SET battle_re_times=0, diamond_shop_flush_times=0, shop_flush_times=0, kefu_status=0, modify_time=:modify_time ' . + //刷新战斗结算奖励次数,商店刷新次数,客服, 每日免费金币钻石 + $battle_ret = $conn->execScript('UPDATE user SET battle_re_times=0, diamond_shop_flush_times=0, shop_flush_times=0, kefu_status=0, free_coin=0, free_diamond=0 modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, @@ -364,10 +363,9 @@ class SignController{ } //刷新赛季奖励状态 $rowUser = $conn->execQueryOne('SELECT season_time, pass_status ' . - ' FROM user WHERE accountid=:accountid AND passid=:passid;', + ' FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id, - ':passid' => $$passid )); if (time() > $rowUser['season_time']) {