1
This commit is contained in:
parent
cd24f5155d
commit
04417b0598
@ -693,5 +693,64 @@ class ActivityController{
|
|||||||
}
|
}
|
||||||
return $airReward_list;
|
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
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user