From 18f6b98e587630eb3b64b49080f74929a4f4b254 Mon Sep 17 00:00:00 2001 From: wangwei01 Date: Tue, 9 Jul 2019 14:50:57 +0800 Subject: [PATCH] 1 --- .../controller/DouRewardController.class.php | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 webapp/controller/DouRewardController.class.php diff --git a/webapp/controller/DouRewardController.class.php b/webapp/controller/DouRewardController.class.php new file mode 100644 index 0000000..63eb94a --- /dev/null +++ b/webapp/controller/DouRewardController.class.php @@ -0,0 +1,137 @@ + $mysql_conf['host'], + 'port' => $mysql_conf['port'], + 'user' => $mysql_conf['user'], + 'passwd' => $mysql_conf['passwd'], + 'dbname' => 'gamedb2001_' . $mysql_conf['instance_id'] + )); + return $conn; + } + + protected function getExplode($string) + { + $delim = "|"; + $drop_multiply = explode($delim, $string); + $delim1 = ":"; + $arr = array(); + for ($i = 0; $i < count($drop_multiply); $i++) { + $mul = explode($delim1, $drop_multiply[$i]); + array_push($arr, $mul); + } + return $arr; + } + + + 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'], + 'param_name' => $parameter_meta['param_name'], + 'param_value' => $parameter_meta['param_value'], + ); + return $p; + } + + protected function getDrop($drop_id) + { + $drop_meta_table = require('../res/drop@drop.php'); + $drop_meta = getDropConfig($drop_meta_table, $drop_id); + $d = array( + 'drop_id' => $drop_meta['drop_id'], + 'item_id' => $drop_meta['item_id'], + 'num' => $drop_meta['num'], + 'weight' => $drop_meta['weight'], + 'type' => $drop_meta['type'] + ); + return $d; + } + + protected function getRewardTimes($coin_num) + { + $reward_meta_table = require('../res/rewardTimes@rewardTimes.php'); + $times = 1; + $reward_meta = array(); + for ($i = 0; $i < 4; $i++) { + $reward_id = $i + 91000; + $reward_meta = getRewardTimesConfig($reward_meta_table, $reward_id); + if ((int)$coin_num >= $reward_meta['minGold'] && (int)$coin_num <= $reward_meta['maxGold']) { + $times = $reward_meta['times']; + break; + } + } + return $times; + } + + + public function doubleReward() + { + $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; + } + $row = $conn->execQueryOne('SELECT item_id, item_num FROM sign WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + $item_id = $row['item_id']; + $num = $row['num']; + switch ($_REQUEST['type']) + { + //签到双倍奖励 + case 1: + { + $p_gold = $this->getParameter(DOUBLE_SIGN_IN); + $num = $num * ($p_gold['param_value'] - 1); + break; + } + //挂机金币多倍奖励 + case 2: + { + $times = $this->getRewardTimes($num); + $num = $num * ($times - 1); + break; + } + //开宝箱双倍奖励 + case 3: + { + $p_gold = $this->getParameter(DOUBLE_BOX); + $num = $num * ($p_gold['param_value'] - 1); + break; + } + default: + break; + } + $addreward = new classes\AddReward(); + $addreward->addReward($item_id, $num, $account_id); + $addreward->updateReward(0, 0, $account_id); + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + )); + } +} +?>