From 04417b0598324421e38a1d52655514f0eb2142f9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 28 Aug 2019 10:21:42 +0800 Subject: [PATCH] 1 --- .../controller/ActivityController.class.php | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index dbc5280..164e2bb 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -693,5 +693,64 @@ class ActivityController{ } return $airReward_list; } + + public function getRedBag() + { + $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; + } + //随机奖励 + $item_list = array(); + $d = $this->getDrop(24006); + if (!$d) { + phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); + return; + } + $item_id_array = $this->getExplode($d['item_id']); + $item_num_array = $this->getExplode($d['num']); + $weight_array = $this->getExplode($d['weight']); + $weight_sum = 0; + $keys = 0; + 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]; + array_push($item_list, array( + 'item_id' => $item_id, + 'item_num' => $item_num, + )); + if ($item_id != 10004) { + //增加奖励 + $addreward = new classes\AddReward(); + $addreward->addReward($item_id, $item_num, $account_id); + } else { + //红包领取现金 + + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'item_list' => $item_list + )); + } } ?>