From 0ddad93c0c4965dcae3285a4652bd4a4bf2d35de Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 30 Apr 2020 10:13:15 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 6 + webapp/bootstrap/init.php | 4 + webapp/classes/AddReward.php | 75 ++++- .../controller/ActivityController.class.php | 289 ++++++++++++++++++ webapp/controller/BagController.class.php | 59 +++- webapp/controller/PassController.class.php | 157 ++++++---- webapp/controller/RoleController.class.php | 6 +- webapp/controller/ShareController.class.php | 65 ++++ webapp/controller/ShopController.class.php | 93 +++++- webapp/controller/SignController.class.php | 66 +++- 10 files changed, 752 insertions(+), 68 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 804ff74..bc06b5f 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -85,6 +85,11 @@ CREATE TABLE `user` ( `free_lot_ticket` int(11) NOT NULL DEFAULT '0' COMMENT '免费抽奖券', `free_dou_lot_ticket` int(11) NOT NULL DEFAULT '0' COMMENT '免费十倍抽奖券', + + `daily_order1` int(11) NOT NULL DEFAULT '0' COMMENT '每日免费宝箱1', + `daily_order2` int(11) NOT NULL DEFAULT '0' COMMENT '每日免费宝箱2', + `daily_order3` int(11) NOT NULL DEFAULT '0' COMMENT '每日免费宝箱3', + `first_bee` 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; @@ -103,6 +108,7 @@ CREATE TABLE `bag` ( `color_id` int(11) NOT NULL DEFAULT '0' COMMENT '颜色id', `status` int(11) NOT NULL DEFAULT '0' COMMENT '状态(0:上阵中,1:已获得,2:未获得)', `active_time` varchar(50) NOT NULL DEFAULT '' COMMENT '有效时间(体验时间)', + `num` int(11) NOT NULL DEFAULT '0' COMMENT '数量', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/bootstrap/init.php b/webapp/bootstrap/init.php index d5c15b5..06ee216 100644 --- a/webapp/bootstrap/init.php +++ b/webapp/bootstrap/init.php @@ -80,6 +80,10 @@ define('REDLIMIT', 68); //红包上限 define('RECOMMEND_FOREVER_WEIGHT',85); //精选道具概率 define('RECOMMEND_TIME', 84); //道具精选时间 define('GAMEOVER_REWARD_TIMES', 87); //战斗结束奖励倍数 +define('LOGINBOX_TIME1', 100); //登录礼包-早晨开始时间 +define('LOGINBOX_TIME2', 101); //登录礼包-中午开始时间 +define('LOGINBOX_TIME3', 102); //登录礼包-晚上开始时间 +define('LOGINBOX_TIME', 103); //登录礼包延时 require 'config_loader.php'; diff --git a/webapp/classes/AddReward.php b/webapp/classes/AddReward.php index f04068f..6f00918 100644 --- a/webapp/classes/AddReward.php +++ b/webapp/classes/AddReward.php @@ -85,6 +85,8 @@ class AddReward { $this->addticket($item['item_id'], $item['item_num'], $account_id); } else if ($i['type'] == 9){ $this->addtenticket($item['item_id'], $item['item_num'], $account_id); + } else if ($i['type'] == 10){ + $this->addweizhuang($item['item_id'], $item['item_num'], $account_id); } else { $price = $i['diamond']; if ($time != 0) { @@ -175,6 +177,73 @@ class AddReward { } } + protected function addweizhuang($item_id, $item_num, $accountid) + { + $conn = $this->getMysql($accountid); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + die(); + } + $rows = $conn->execQuery('SELECT id, status FROM bag WHERE accountid=:accountid;', + array( + ':accountid' => $accountid, + )); + $sum = 0; + foreach ($rows as $r) { + $it = $this->getItem($r['id']); + if ($r['status'] == 0 && $it['type'] == 10) { + $sum++; + } + } + $status = 0; + if ($sum >= 4) { + $status = 1; + } + $row = $conn->execQueryOne('SELECT status, num FROM bag WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $accountid, + 'id' => $item_id + )); + if (!$row && $item_id != 0) { + $ret = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, num, active_time, create_time, modify_time) ' . + ' VALUES(:account_id, :id, 0, :status, :num, :active_time, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=:status, num=:num, active_time=:active_time, modify_time=:modify_time;', + array( + ':account_id' => $accountid, + ':id' => $item_id, + ':active_time' => 0, + ':status' => $status, + ':num' => $item_num, + ':create_time' => time(), + ':modify_time' => time() + )); + if(!$ret){ + die(); + } + } else { + $status = $row['status']; + if ($row['status'] == 2) { + if ($sum >= 4) { + $status = 1; + } else { + $status = 0; + } + } + $ret = $conn->execScript('UPDATE bag SET num=:num, status=:status, modify_time=:modify_time ' . + ' WHERE accountid=:account_id AND id=:id;', + array( + ':account_id' => $accountid, + ':id' => $item_id, + ':num' => $row['num'] + $item_num, + ':status' => $status, + ':modify_time' => time() + )); + if (!$ret) { + die(); + } + } + } + protected function addticket($item_id, $item_num, $accountid) { $conn = $this->getMysql($accountid); @@ -251,9 +320,9 @@ class AddReward { $status = 0; $this->updateStatus($item_id, $accountid); } - $ret = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, active_time, create_time, modify_time) ' . - ' VALUES(:account_id, :id, 0, :status, :active_time, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=:status, active_time=:active_time, modify_time=:modify_time;', + $ret = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, num, active_time, create_time, modify_time) ' . + ' VALUES(:account_id, :id, 0, :status, 0, :active_time, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=:status, num=0, active_time=:active_time, modify_time=:modify_time;', array( ':account_id' => $accountid, ':id' => $item_id, diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index f4d8a73..369fa8c 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -30,6 +30,21 @@ class ActivityController{ return $r; } + protected function getBox($box_id) + { + $box_meta_table = require('../res/box@box.php'); + $box_meta = getBoxConfig($box_meta_table, $box_id); + $b = array( + 'box_id' => $box_meta['box_type'], + 'item_id' => $box_meta['item_id'], + 'num' => $box_meta['num'], + 'weight' => $box_meta['weight'], + 'type' => $box_meta['type'], + 'time' => $box_meta['time'], + ); + return $b; + } + protected function getParameter($para_id) { $parameter_meta_cluster = require('../res/parameter@parameter.php'); @@ -855,5 +870,279 @@ class ActivityController{ } return $key; } + + public function getBoxOrder() + { + $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; + } + $row = $conn->execQueryOne('SELECT daily_order1, daily_order2, daily_order3 FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + $item_list = array(); + $daily_order1 = $row['daily_order1']; + $daily_order2 = $row['daily_order2']; + $daily_order3 = $row['daily_order3']; + $p1 = $this->getParameter(LOGINBOX_TIME1); + $p2 = $this->getParameter(LOGINBOX_TIME2); + $p3 = $this->getParameter(LOGINBOX_TIME3); + $p = $this->getParameter(LOGINBOX_TIME); + $pt1 = $p1['value']; + $pt2 = $p2['value']; + $pt3 = $p3['value']; + $pt = $p['value']; + $nowTime = floor((time() - phpcommon\getdayseconds(time())) / 3600); + if ($nowTime < $pt1) { + $daily_order1 = 0; + $daily_order2 = 0; + $daily_order3 = 0; + } else if ($nowTime >= $pt1 && $nowTime < $pt1 + $pt) { + if ($daily_order1 == 0) { + $daily_order1 = 1; + } else { + $daily_order1 = $row['daily_order1']; + } + $daily_order2 = 0; + $daily_order3 = 0; + } else if ($nowTime >= $pt1 + $pt && $nowTime < $pt2) { + if ($daily_order1 <= 1) { + $daily_order1 = 3; + } else { + $daily_order1 = $row['daily_order1']; + } + $daily_order2 = 0; + $daily_order3 = 0; + } else if ($nowTime >= $pt2 && $nowTime < $pt2 + $pt) { + if ($daily_order1 <= 1) { + $daily_order1 = 3; + } else { + $daily_order1 = $row['daily_order1']; + } + if ($daily_order2 == 0) { + $daily_order2 = 1; + } else { + $daily_order2 = $row['daily_order2']; + } + $daily_order3 = 0; + } else if ($nowTime >= $pt2 + $pt && $nowTime < $pt3) { + if ($daily_order1 <= 1) { + $daily_order1 = 3; + } else { + $daily_order1 = $row['daily_order1']; + } + if ($daily_order2 <= 1) { + $daily_order2 = 3; + } else { + $daily_order2 = $row['daily_order2']; + } + $daily_order3 = 0; + } else if ($nowTime >= $pt3 && $nowTime < $pt3 + $pt) { + if ($daily_order1 <= 1) { + $daily_order1 = 3; + } else { + $daily_order1 = $row['daily_order1']; + } + if ($daily_order2 <= 1) { + $daily_order2 = 3; + } else { + $daily_order2 = $row['daily_order2']; + } + if ($daily_order3 == 0) { + $daily_order3 = 1; + } else { + $daily_order3 = $row['daily_order3']; + } + } else if ($nowTime > $pt3 + $pt) { + if ($daily_order1 <= 1) { + $daily_order1 = 3; + } else { + $daily_order1 = $row['daily_order1']; + } + if ($daily_order2 <= 1) { + $daily_order2 = 3; + } else { + $daily_order2 = $row['daily_order2']; + } + if ($daily_order3 <= 1) { + $daily_order3 = 3; + } else { + $daily_order3 = $row['daily_order3']; + } + } + $stauts = 0; + for ($i = 0; $i < 3; $i++) { + if ($i == 0) { + $status = $daily_order1; + } else if ($i == 1) { + $status = $daily_order2; + } else if ($i == 2) { + $status = $daily_order3; + } + array_push($item_list, array( + 'status' => $status + )); + } + $ret = $conn->execScript('UPDATE user SET daily_order1=:daily_order1, daily_order2=:daily_order2, daily_order3=:daily_order3 ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':daily_order1' => $daily_order1, + ':daily_order2' => $daily_order2, + ':daily_order3' => $daily_order3 + )); + if (!$ret) { + die(); + return; + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg'=> '', + 'item_list' => $item_list, + )); + } + + public function getOrderReward() + { + $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; + } + $id = $_REQUEST['id']; + $row = $conn->execQueryOne('SELECT daily_order1, daily_order2, daily_order3 FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + if ($id == 1) { + if ($row['daily_order1'] != 1) { + phpcommon\sendError(ERR_USER_BASE + 3, '奖励不可领'); + return; + } + $ret = $conn->execScript('UPDATE user SET daily_order1=2 ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + )); + if (!$ret) { + die(); + return; + } + } else if ($id == 2) { + if ($row['daily_order2'] != 1) { + phpcommon\sendError(ERR_USER_BASE + 3, '奖励不可领'); + return; + } + $ret = $conn->execScript('UPDATE user SET daily_order2=2 ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + )); + if (!$ret) { + die(); + return; + } + } else if ($id == 3) { + if ($row['daily_order3'] != 1) { + phpcommon\sendError(ERR_USER_BASE + 3, '奖励不可领'); + return; + } + $ret = $conn->execScript('UPDATE user SET daily_order3=2 ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + )); + if (!$ret) { + die(); + return; + } + } + $all_item_list = array(); + $item_list = $this->randBoxReward(3); + $addreward = new classes\AddReward(); + foreach ($item_list as $item) { + $items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time'], 0); + foreach($items as $i) { + array_push($all_item_list, array( + 'item_id' => $i['item_id'], + 'item_num' => $i['item_num'], + 'time' => $i['time'], + )); + } + } + $coin_num = $addreward->getCoinNum($account_id); + $num = $addreward->getDiamondNum($account_id); + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'item_list' => $item_list, + 'diamond_nums' => $num, + 'all_item_list' => $all_item_list + )); + } + + protected function randBoxReward($drop_id) + { + //随机奖励 + $item_list = array(); + + $b = $this->getbox($drop_id); + if (!$b) { + phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); + die(); + } + $item_id_array = $this->getExplode($b['item_id']); + $weight_sum = 0; + $keys = 0; + $item_num_array = $this->getExplode($b['num']); + $weight_array = $this->getExplode($b['weight']); + $time_array = $this->getExplode($b['time']); + for ($i = 0; $i < count($weight_array); $i++) { + $weight_sum += $weight_array[$i][0]; + } + $random = Rand(0, $weight_sum); + $weight = 0; + for ($i = 0; $i < count($weight_array); $i++) { + $weight += $weight_array[$i][0]; + if ($weight > $random) { + $keys = $i; + break; + } + } + $item_id = $item_id_array[$keys][0]; + $item_num = $item_num_array[$keys][0]; + $time = $time_array[$keys][0]; + array_push($item_list, array( + 'item_id' => $item_id, + 'item_num' => $item_num, + 'time' => $time + )); + + return $item_list; + } } ?> diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index 2c94bcf..6de09c4 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -107,12 +107,13 @@ class BagController{ 'active_time' => $active_time, 'status' => $status, 'color_id' => $color_id, + 'num' => $row['num'], )); } } else { - $ret = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, active_time, create_time, modify_time) ' . - ' VALUES(:account_id, :id, 0, :status, :active_time, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=:status, active_time=:active_time, modify_time=:modify_time;', + $ret = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, num, active_time, create_time, modify_time) ' . + ' VALUES(:account_id, :id, 0, :status, 0, :active_time, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=:status, num=0, active_time=:active_time, modify_time=:modify_time;', array( ':account_id' => $account_id, ':id' => 16001, @@ -130,6 +131,7 @@ class BagController{ 'active_time' => 0, 'status' => 0, 'color_id' => 0, + 'num' => 0, )); } echo json_encode(array( @@ -157,7 +159,7 @@ class BagController{ $b = $this->getBag($item_id); $bag_meta_table = require('../res/bag@bag.php'); //正在装备的道具 - if ($b['fuction'] != 5) { + if ($b['fuction'] != 5 && $b['fuction'] != 6) { foreach ($bag_meta_table as $bag_info) { $id = $bag_info['id']; $bag = $this->getBag($id); @@ -359,7 +361,6 @@ class BagController{ } else { $time = $ptime['param_value']; } - error_log(json_encode($item_multiply)); foreach ($item_multiply as $i) { array_push($item_list, array( 'item_id' => $i, @@ -384,5 +385,53 @@ class BagController{ 'all_item_list' => $all_item_list )); } + + public function updateWeizhuang() + { + $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; + } + $arr = json_decode($_REQUEST['arr'], true); + foreach ($arr as $a) { + $row = $conn->execQueryOne('SELECT status FROM bag WHERE accountid=:account_id AND id=:id;', + array( + ':account_id' => $account_id, + ':id' => $a['id'] + )); + if (!$row) { + continue; + } + $status = $row['status']; + if ($a['count'] == 0) { + $status = 2; + } + $ret = $conn->execScript('UPDATE bag SET status=:status, num=:num, modify_time=:modify_time ' . + ' WHERE accountid = :account_id AND id = :id;', + array( + ':account_id' => $account_id, + ':id' => $a['id'], + ':status' => $status, + ':num' => $a['count'], + ':modify_time' => time() + )); + if(!$ret){ + die(); + return; + } + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + )); + } } ?> diff --git a/webapp/controller/PassController.class.php b/webapp/controller/PassController.class.php index 072b4de..397b50c 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -39,6 +39,8 @@ class PassController{ 'number' => $season_meta['season_number'], 'open_time' => $season_meta['time1'], 'end_time' => $season_meta['time2'], + 'reward' => $season_meta['season_reward'], + 'weekreward' => $season_meta['week_reward'], ); return $season; } @@ -52,8 +54,8 @@ class PassController{ 'min' => $seaPoint_meta['min_point'], 'max' => $seaPoint_meta['max_point'], 'des' => $seaPoint_meta['des'], - 'reward' => $seaPoint_meta['season_reward'], - 'weekreward' => $seaPoint_meta['week_reward'], + //'reward' => $seaPoint_meta['season_reward'], + //'weekreward' => $seaPoint_meta['week_reward'], ); return $seaPoint; } @@ -76,6 +78,8 @@ class PassController{ $number = 0; $open_time = 0; $end_time = 0; + $sea_reward = array(); + $rank_status = 0; $season_meta_table = require('../res/season@season.php'); for ($i = 1; $i <= count($season_meta_table); $i++) { $season = $this->getSeason($i); @@ -94,6 +98,43 @@ class PassController{ return; } $number = $i; + $item_multiply = $this->getExplode($season['reward']); + //$ii = 0; + for($ii = 1; $ii <= count($item_multiply); $ii++) { + $rowpass = $conn->execQueryOne('SELECT active_status, honor_status ' . + ' FROM passinfo WHERE accountid=:accountid AND passid=:passid;', + array( + ':accountid' => $account_id, + ':passid' => $ii, + )); + $rank_status = 0; + if (!$rowpass) { + $ret = $conn->execScript('INSERT INTO passinfo(accountid, passid, active_status, honor_status, create_time, modify_time) ' . + ' VALUES(:accountid, :passid, 0, 0, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:accountid, passid=:passid, active_status=0, honor_status=0, modify_time=:modify_time;', + array( + ':accountid' => $account_id, + ':passid' => $ii, + ':create_time' => time(), + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + $rank_status = 0; + } else { + $rank_status = $rowpass['active_status']; + } + + $key = $ii - 1; + array_push($sea_reward, array( + 'item_id' => $item_multiply[$key][0], + 'item_num' => $item_multiply[$key][1], + 'time' => $item_multiply[$key][2], + 'status' => $rank_status + )); + } break; } } @@ -122,12 +163,25 @@ class PassController{ if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] || $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) { - $drop_multiply = $this->getExplode($seaPoint['weekreward']); - for($s = 0; $s < count($drop_multiply); $s++) { + + $delim1 = '|'; + $drop_multiply = explode($delim1, $season['weekreward']); + + $delim2 = ';'; + $mul = explode($delim2, $drop_multiply[$ii - 1]); + + $delim = ':'; + $week_array = array(); + for ($i2 = 0; $i2 < count($mul); $i2++) { + $mul1 = explode($delim, $mul[$i2]); + array_push($week_array, $mul1); + } + + for($s = 0; $s < count($week_array); $s++) { array_push($week_reward, array( - 'item_id' => $drop_multiply[$s][0], - 'item_num' => $drop_multiply[$s][1], - 'time' => $drop_multiply[$s][2], + 'item_id' => $week_array[$s][0], + 'item_num' => $week_array[$s][1], + 'time' => $week_array[$s][2], 'status' => $row['pass_status'] )); } @@ -141,39 +195,6 @@ class PassController{ $max_rank_score = $seaPoint['max'] + 1; } } - $rowpass = $conn->execQueryOne('SELECT active_status, honor_status ' . - ' FROM passinfo WHERE accountid=:accountid AND passid=:passid;', - array( - ':accountid' => $account_id, - ':passid' => $ii, - )); - $rank_status = 0; - if (!$rowpass) { - $ret = $conn->execScript('INSERT INTO passinfo(accountid, passid, active_status, honor_status, create_time, modify_time) ' . - ' VALUES(:accountid, :passid, 0, 0, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE accountid=:accountid, passid=:passid, active_status=0, honor_status=0, modify_time=:modify_time;', - array( - ':accountid' => $account_id, - ':passid' => $ii, - ':create_time' => time(), - ':modify_time' => time() - )); - if (!$ret) { - die(); - return; - } - $rank_status = 0; - } else { - $rank_status = $rowpass['active_status']; - } - $delim = ':'; - $item_multiply = explode($delim, $seaPoint['reward']); - array_push($reward, array( - 'item_id' => $item_multiply[0], - 'item_num' => $item_multiply[1], - 'time' => $item_multiply[2], - 'status' => $rank_status - )); } if ($rank == 0) { phpcommon\sendError(ERR_USER_BASE + 3, '未达到段位要求'); @@ -193,6 +214,7 @@ class PassController{ 'max_rank_score' => $max_rank_score, 'reward' => $reward, 'week' => $week_reward, + 'seareward' => $sea_reward, )); } @@ -242,17 +264,28 @@ class PassController{ $this->updateStatus($account_id, $passid); //增加奖励 - $seaPoint = $this->getSeasonPoint($passid); - $delim = ':'; - $drop_multiply = explode($delim, $seaPoint['reward']); + //$seaPoint = $this->getSeasonPoint($passid); + //$delim = ':'; + //$drop_multiply = explode($delim, $seaPoint['reward']); + $season = array(); + $season_meta_table = require('../res/season@season.php'); + for ($i = 1; $i <= count($season_meta_table); $i++) { + $season = $this->getSeason($i); + if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) { + break; + } + } + $item_multiply = $this->getExplode($season['reward']); + $items = $item_multiply[$passid - 1]; + $reward = array(); array_push($reward, array( - 'item_id' => $drop_multiply[0], - 'item_num' => $drop_multiply[1], - 'time' => $drop_multiply[2], + 'item_id' => $items[0], + 'item_num' => $items[1], + 'time' => $items[2], )); $addreward = new classes\AddReward(); - $all_item_list = $addreward->addReward($drop_multiply[0], $drop_multiply[1], $account_id, $drop_multiply[2],0); + $all_item_list = $addreward->addReward($items[0], $items[1], $account_id, $items[2],0); $coin_num = $addreward->getCoinNum($account_id); $diamond_num = $addreward->getDiamondNum($account_id); @@ -327,12 +360,32 @@ class PassController{ if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] || $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) { - $drop_multiply = $this->getExplode($seaPoint['weekreward']); - for($i = 0; $i < count($drop_multiply); $i++) { + $season = array(); + $season_meta_table = require('../res/season@season.php'); + for ($i = 1; $i <= count($season_meta_table); $i++) { + $season = $this->getSeason($i); + if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) { + break; + } + } + $delim1 = '|'; + $drop_multiply = explode($delim1, $season['weekreward']); + + $delim2 = ';'; + $mul = explode($delim2, $drop_multiply[$ii - 1]); + + $delim = ':'; + $week_array = array(); + for ($i2 = 0; $i2 < count($mul); $i2++) { + $mul1 = explode($delim, $mul[$i2]); + array_push($week_array, $mul1); + } + + for($s = 0; $s < count($week_array); $s++) { array_push($reward, array( - 'item_id' => $drop_multiply[$i][0], - 'item_num' => $drop_multiply[$i][1], - 'time' => $drop_multiply[$i][2] + 'item_id' => $week_array[$s][0], + 'item_num' => $week_array[$s][1], + 'time' => $week_array[$s][2], )); } $level = $ii; diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index 1eebaca..267ea87 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -116,9 +116,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, 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) ' . - ' 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, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,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=0, 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;', + $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) ' . + ' 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, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,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=0, 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;', array( ':accountid' => $account_id, ':user_name' => $user_name, diff --git a/webapp/controller/ShareController.class.php b/webapp/controller/ShareController.class.php index a27527a..d32fd93 100644 --- a/webapp/controller/ShareController.class.php +++ b/webapp/controller/ShareController.class.php @@ -165,6 +165,67 @@ class ShareController{ return $item_list; } + public function beeReward() + { + $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; + } + $row = $conn->execQueryOne('SELECT first_bee FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + $item_list = array(); + if ($row['first_bee'] == 0) { + array_push($item_list, array( + 'item_id' => 12119, + 'item_num' => 1, + 'time' => 1 + )); + $ret = $conn->execScript('UPDATE user SET first_bee=1, ' . + 'modify_time=:modify_time WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':modify_time' => time(), + )); + } else { + $item_list = $this->randBoxReward(4, 1); + } + $all_item_list = array(); + foreach ($item_list as $item) { + $addreward = new classes\AddReward(); + $items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time'], 0); + foreach($items as $i) { + array_push($all_item_list, array( + 'item_id' => $i['item_id'], + 'item_num' => $i['item_num'], + 'time' => $i['time'], + )); + } + } + $coin_num = $addreward->getCoinNum($account_id); + $num = $addreward->getDiamondNum($account_id); + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'item_list' => $item_list, + 'diamond_nums' => $num, + 'all_item_list' => $all_item_list + )); + } + public function keyBoxInfo() { $account_id = $_REQUEST['account_id']; @@ -186,6 +247,10 @@ class ShareController{ array( ':accountid' => $account_id )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } $item_list = array(); $diamond_num = 0; if ($free != 0) { diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 3b6bb64..364c7c0 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -39,6 +39,8 @@ class ShopController{ 'dprice' => $item_conf['diamond_price'], 'discount' => $item_conf['discount'], 'shop_type' => $item_conf['shop_type'], + 'type' => $item_conf['fuction'], + 'bug_groupnum' => $item_conf['bug_groupnum'] ); return $it; } @@ -155,6 +157,7 @@ class ShopController{ $status = 0; $coin_shop = array(); $diamond_shop = array(); + $num = 1; foreach($g_conf_item_cluster as $items) { $it = $this->getItem($items['id']); $status = 0; @@ -165,6 +168,9 @@ class ShopController{ if ($r['status'] == 2 || $r['active_time'] != 0) { continue; } + if ($it['type'] == 10) { + continue; + } $status = 1; break; } @@ -174,14 +180,51 @@ class ShopController{ 'id' => $it['id'], )); } + if ($it['type'] == 10) { + $num = 10; + } array_push($coin_shop,array( 'id' => $it['id'], 'price' => $it['price'], 'status' => $status, 'discount' => 0, 'coin_id' => 10001, + 'num' => $num )); } else if ($it['shop_type'] == 2) { + if ($status == 0) { + array_push($rand_diamondshop,array( + 'id' => $it['id'], + )); + } + if ($it['type'] == 10) { + $num = 10; + } + array_push($diamond_shop,array( + 'id' => $it['id'], + 'price' => $it['dprice'], + 'status' => $status, + 'discount' => 0, + 'coin_id' => 10003, + 'num' => $num + )); + } else if ($it['shop_type'] == 3) { + if ($status == 0) { + array_push($rand_coinshop,array( + 'id' => $it['id'], + )); + } + if ($it['type'] == 10) { + $num = 10; + } + array_push($coin_shop,array( + 'id' => $it['id'], + 'price' => $it['price'], + 'status' => $status, + 'discount' => 0, + 'coin_id' => 10001, + 'num' => $num + )); if ($status == 0) { array_push($rand_diamondshop,array( 'id' => $it['id'], @@ -193,6 +236,7 @@ class ShopController{ 'status' => $status, 'discount' => 0, 'coin_id' => 10003, + 'num' => $num )); } } @@ -317,6 +361,7 @@ class ShopController{ return; } $id = $_REQUEST['id']; + $type = $_REQUEST['type']; $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); @@ -328,7 +373,8 @@ class ShopController{ ':id' => $id )); if ($row) { - if ($row['status'] != 2 && $row['active_time'] == 0) { + $it = $this->getItem($id); + if ($row['status'] != 2 && $row['active_time'] == 0 && $it['type'] != 10) { phpcommon\sendError(ERR_USER_BASE + 4, '商品已购买'); return; } @@ -336,6 +382,7 @@ class ShopController{ //扣除货币 $i = $this->getItem($id); $price = 0; + $num = 1; if ($i['shop_type'] == 1) { $row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;', array( @@ -343,12 +390,20 @@ class ShopController{ ':id' => $id )); $price = $i['price']; + if ($it['type'] == 10) { + + $num = $i['bug_groupnum']; + } if ($row_c) { $price = round($i['price'] * $row_c['coin_discount'] / 10); } $this->SubCoin($price, $account_id, 1); } else if ($i['shop_type'] == 2) { $price = $i['dprice']; + if ($i['type'] == 10) { + + $num = $i['bug_groupnum']; + } $row_d = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND diamond_id=:id;', array( ':accountid' => $account_id, @@ -358,17 +413,47 @@ class ShopController{ $price = round($i['dprice'] * $row_d['diamond_discount'] / 10); } $this->SubCoin($price, $account_id, 2); - } + } else if ($i['shop_type'] == 3) { + if ($type == 0) { + $row_c = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND coin_id=:id;', + array( + ':accountid' => $account_id, + ':id' => $id + )); + $price = $i['price']; + if ($i['type'] == 10) { + $num = $i['bug_groupnum']; + } + if ($row_c) { + $price = round($i['price'] * $row_c['coin_discount'] / 10); + } + $this->SubCoin($price, $account_id, 1); + } else if ($type == 1) { + $price = $i['dprice']; + if ($i['type'] == 10) { + $num = $i['bug_groupnum']; + } + $row_d = $conn->execQueryOne('SELECT * FROM shop WHERE accountid=:accountid AND diamond_id=:id;', + array( + ':accountid' => $account_id, + ':id' => $id + )); + if ($row_d) { + $price = round($i['dprice'] * $row_d['diamond_discount'] / 10); + } + $this->SubCoin($price, $account_id, 2); + } + } //增加奖励 $addreward = new classes\AddReward(); - $all_item_list = $addreward->addReward($id, 1, $account_id, 0, 0); + $all_item_list = $addreward->addReward($id, $num, $account_id, 0, 0); $coin_num = $addreward->getCoinNum($account_id); $diamond_num = $addreward->getDiamondNum($account_id); $item_list = array(); array_push($item_list,array( 'item_id' => $id, - 'item_num' => 1, + 'item_num' => $num, 'time' => 0, )); echo json_encode(array( diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index d05e030..9a289f9 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -45,6 +45,22 @@ class SignController{ return $arr; } + protected function getItem($item_id) + { + $g_conf_item_cluster = require('../res/item@item.php'); + $item_conf = getItemConfig($g_conf_item_cluster, $item_id); + $it = array( + 'id' => $item_conf['id'], + 'diamond' => $item_conf['diamond'], + 'type' => $item_conf['fuction'], + 'diamond_hour' => $item_conf['diamond_hour'], + 'pool_weight' => $item_conf['pool_weight'], + 'name' => $item_conf['name'] + ); + return $it; + } + + protected function getSeason($season_id) { $season_meta_table = require('../res/season@season.php'); @@ -414,7 +430,7 @@ class SignController{ } } //刷新战斗结算奖励次数,商店刷新次数,客服, 每日免费金币钻石 - $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, free_box=0, update_time=:update_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, daily_order1=0, daily_order2=0, daily_order3=0, modify_time=:modify_time, free_box=0, update_time=:update_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, @@ -497,5 +513,53 @@ class SignController{ die(); } } + + public function getSignOrder() + { + $account_id = $_REQUEST['account_id']; + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + $rowUser = $conn->execQueryOne('SELECT sign_sum FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + )); + + if (!$rowUser) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + + $week = ceil($rowUser['sign_sum'] / 7); + $dayid = ($week - 1) * 7; + $day = $rowUser['sign_sum'] % 7; + //如果大于配置表最后一周,按最后一周奖励 + $g_conf_sign_cluster = require('../res/signDaily@signDaily.php'); + if ($dayid + 1 > count($g_conf_sign_cluster)) { + $dayid = count($g_conf_sign_cluster) - 7; + } + $sign_sum = $rowUser['sign_sum']; + $item_num = 0; + $item_name = ''; + $item = $this->getSign(90000 + $day + $dayid); + if ($rowUser['sign_sum'] == 3) { + $item_name = '咸鱼套装(永久)'; + } else if ($rowUser['sign_sum'] == 7) { + $item_name = '神秘宝箱'; + } else { + $it = $this->getItem($item['item_id']); + $item_name = $it['name']; + $item_num = $item['num']; + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'sign_sum' => $sign_sum, + 'item_name' => $item_name, + 'item_num' => $item_num + )); + } } ?>