From 75ed033bebef1e44ffd1ddb6fc3b3bed0cb43c6a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 18 Mar 2020 17:23:33 +0800 Subject: [PATCH] 1 --- boundle.sh | 10 + res | 1 + webapp/controller/BagController.class.php | 314 +++++++++++++++++++++ webapp/controller/PassController.class.php | 9 +- webapp/controller/SignController.class.php | 5 +- 5 files changed, 333 insertions(+), 6 deletions(-) create mode 100755 boundle.sh create mode 120000 res create mode 100644 webapp/controller/BagController.class.php diff --git a/boundle.sh b/boundle.sh new file mode 100755 index 0000000..6e96dd6 --- /dev/null +++ b/boundle.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +tag_name=`git status |grep '# On branch '|sed 's/# On branch //g'` +dir_name=`basename $PWD` +package_name=${dir_name}.tar.gz +#echo $tag_name +#echo $dir_name +#echo $package_name + +tar --exclude=*.git -chzf target/${package_name} webapp config res reload.sh restart.sh reloadres.sh diff --git a/res b/res new file mode 120000 index 0000000..30fa1ce --- /dev/null +++ b/res @@ -0,0 +1 @@ +config \ No newline at end of file diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php new file mode 100644 index 0000000..c7ace60 --- /dev/null +++ b/webapp/controller/BagController.class.php @@ -0,0 +1,314 @@ + $mysql_conf['host'], + 'port' => $mysql_conf['port'], + 'user' => $mysql_conf['user'], + 'passwd' => $mysql_conf['passwd'], + 'dbname' => 'gamedb2004_' . $mysql_conf['instance_id'] + )); + return $conn; + } + + protected function getBag($bag_id) + { + $g_conf_bag_cluster = require('../res/bag@bag.php'); + $bag_conf = getBagConfig($g_conf_bag_cluster, $bag_id); + $b = array( + 'id' => $bag_conf['id'], + 'name' => $bag_conf['name'], + 'fuction' => $bag_conf['fuction'], + ); + return $b; + } + + 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'], + 'dprice' => $item_conf['dprice'], + 'type' => $item_conf['fuction'], + 'diamond_hour' => $item_conf['diamond_hour'] + ); + return $it; + } + + protected function getParameter($para_id) + { + $g_conf_para_cluster = require('../res/parameter@parameter.php'); + $para_conf = getParameterConfig($g_conf_para_cluster, $para_id); + $p = array( + 'id' => $para_conf['id'], + 'param_name' => $para_conf['param_name'], + 'param_value' => $para_conf['param_value'], + ); + return $p; + } + + public function getBagInfo() + { + $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; + } + $bag_list = array(); + $rows = $conn->execQuery('SELECT * FROM bag WHERE accountid=:account_id;', + array( + ':account_id' => $account_id + )); + if ($rows) { + foreach ($rows as $row){ + $active_time = 0; + $color_id = 0; + if (time() >= $row['active_time'] && $row['active_time'] != 0) { + $ret = $conn->execScript('UPDATE bag SET active_time=0, color_id=0, modify_time=:modify_time ' . + ' WHERE accountid=:account_id AND id=:id;', + array( + ':account_id' => $account_id, + ':id' => $row['id'], + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + $active_time = 0; + $color_id = 0; + } else { + if ($row['active_time'] != 0) { + $active_time = $row['active_time']; + } + $color_id = $row['color_id']; + } + array_push($bag_list, array( + 'id' => $row['id'], + 'active_time' => $active_time, + 'status' => $row['status'], + 'color_id' => $color_id, + )); + } + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'bag_list' => $bag_list + )); + } + + public function exchangeBagItem() { + $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']; + $color_id = $_REQUEST['color_id']; + $conn = $this->getMysql($account_id); + if(!$conn){ + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + $b = $this->getBag($item_id); + $bag_meta_table = require('../res/bag@bag.php'); + //正在装备的道具 + if ($b['fuction'] != 5) { + foreach ($bag_meta_table as $bag_info) { + $id = $bag_info['id']; + $bag = $this->getBag($id); + if ($bag['fuction'] != $b['fuction']) { + continue; + } + $row = $conn->execQueryOne('SELECT status, active_time FROM bag WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $account_id, + ':id' => $id, + )); + if ($row['status'] != 0 || !$row) { + continue; + } + $status = 2; + if ($row['active_time'] == 0) { + $status = 1; + } + $using_ret = $conn->execScript('UPDATE bag SET status=:status, color_id=0, modify_time=:modify_time ' . + ' WHERE accountid = :account_id AND id = :id;', + array( + ':account_id' => $account_id, + ':id' => $id, + ':status' => $status, + ':modify_time' => time() + )); + if(!$using_ret){ + die(); + return; + } + } + } + //要装备的道具 + $row = $conn->execQueryOne('SELECT status FROM bag WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $account_id, + ':id' => $item_id, + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); + return; + } + + $exchange_ret = $conn->execScript('UPDATE bag SET status=0, color_id=:color_id, modify_time=:modify_time ' . + ' WHERE accountid = :account_id AND id = :id;', + array( + ':account_id' => $account_id, + ':id' => $item_id, + ':color_id' => $color_id, + ':modify_time' => time() + )); + if(!$exchange_ret){ + die(); + return; + } + + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'item_id' => $item_id, + 'color_id' => $color_id + )); + } + + public function downItem() + { + $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']; + $conn = $this->getMysql($account_id); + if(!$conn){ + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + $b = $this->getBag($item_id); + + $row = $conn->execQueryOne('SELECT status,active_time FROM bag WHERE accountid=:accountid AND id=:id;', + array( + ':accountid' => $account_id, + ':id' => $item_id, + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); + return; + } + $status = 2; + if ($row['active_time'] == 0) { + $status = 1; + } + $exchange_ret = $conn->execScript('UPDATE bag SET status=:status, color_id=0, modify_time=:modify_time ' . + ' WHERE accountid = :account_id AND id = :id;', + array( + ':account_id' => $account_id, + ':id' => $item_id, + ':status' => $status, + ':modify_time' => time() + )); + if(!$exchange_ret){ + die(); + return; + } + + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'item_id' => $item_id, + 'color_id' => 0 + )); + } + + public function downItemColor() + { + $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']; + $conn = $this->getMysql($account_id); + if(!$conn){ + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + + $exchange_ret = $conn->execScript('UPDATE bag SET status=:status, color_id=0, modify_time=:modify_time ' . + ' WHERE accountid = :account_id AND id = :id;', + array( + ':account_id' => $account_id, + ':id' => $item_id, + ':status' => $status, + ':modify_time' => time() + )); + if(!$exchange_ret){ + die(); + return; + } + + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'item_id' => $item_id, + 'color_id' => 0 + )); + } + + public function tryItem() + { + $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']; + error_log($item_id); + $conn = $this->getMysql($account_id); + if(!$conn){ + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + $addreward = new classes\AddReward(); + $addreward->addReward($item_id, 1, $account_id, 1); + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'item_id' => $item_id, + 'color_id' => 0 + )); + } +} +?> diff --git a/webapp/controller/PassController.class.php b/webapp/controller/PassController.class.php index a873ddf..b3f24f0 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -244,13 +244,14 @@ class PassController{ $seaPoint = $this->getSeasonPoint($passid); $delim = ':'; $drop_multiply = explode($delim, $seaPoint['reward']); + $reward = array(); array_push($reward, array( 'item_id' => $drop_multiply[0], 'item_num' => $drop_multiply[1], 'time' => $drop_multiply[2], )); $addreward = new classes\AddReward(); - $all_item_list = $addreward->addReward($r['item_id'], $r['item_num'], $account_id, $r['time']); + $all_item_list = $addreward->addReward($drop_multiply[0], $drop_multiply[1], $account_id, $drop_multiply[2]); $coin_num = $addreward->getCoinNum($account_id); $diamond_num = $addreward->getDiamondNum($account_id); @@ -320,7 +321,7 @@ class PassController{ if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] || $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) { - $drop_multiply = $this->getExplode($seaPoint['reward']); + $drop_multiply = $this->getExplode($seaPoint['weekreward']); for($i = 0; $i < count($drop_multiply); $i++) { array_push($reward, array( 'item_id' => $drop_multiply[$i][0], @@ -332,9 +333,9 @@ class PassController{ } } $addreward = new classes\AddReward(); + $all_item_list = array(); foreach ($reward as $r) { - $addreward->addReward($r['item_id'], $r['item_num'], $account_id, $r['time']); - $items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time']); + $items = $addreward->addReward($r['item_id'], $r['item_num'], $account_id, $r['time']); foreach($items as $i) { array_push($all_item_list, array( 'item_id' => $i['item_id'], diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index 891a2b8..0246c94 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -274,6 +274,7 @@ class SignController{ $num_array = $this->getExplode($s['num']); $time_array = $this->getExplode($s['time']); $addreward = new classes\AddReward(); + $all_item_list = array(); for ($i = 0; $i < count($item_id_array); $i++) { $item_id = $item_id_array[$i][0]; error_log(json_encode($item_id_array)); @@ -285,8 +286,8 @@ class SignController{ 'item_num' => $num, 'time' => $time, )); - $addreward->addReward($item_id, $num, $account_id, $time); - $items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time']); + $items = $addreward->addReward($item_id, $num, $account_id, $time); + foreach($items as $i) { array_push($all_item_list, array( 'item_id' => $i['item_id'],