1
This commit is contained in:
parent
8981641974
commit
2e47fb1ea0
@ -89,6 +89,10 @@ class ShareController{
|
|||||||
array(
|
array(
|
||||||
':accountid' => $account_id
|
':accountid' => $account_id
|
||||||
));
|
));
|
||||||
|
if (!$row) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||||
|
return;
|
||||||
|
}
|
||||||
/*if ($row['keys_num'] < 1) {
|
/*if ($row['keys_num'] < 1) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 3, '钥匙不足');
|
phpcommon\sendError(ERR_USER_BASE + 3, '钥匙不足');
|
||||||
die();
|
die();
|
||||||
@ -125,7 +129,7 @@ class ShareController{
|
|||||||
for ($i = 0; $i < count($weight_array); $i++) {
|
for ($i = 0; $i < count($weight_array); $i++) {
|
||||||
$weight_sum += $weight_array[$i][0];
|
$weight_sum += $weight_array[$i][0];
|
||||||
}
|
}
|
||||||
srand(crc32($account_id));
|
srand(crc32($account_id . $row['keys_num']));
|
||||||
$random = Rand(0, $weight_sum);
|
$random = Rand(0, $weight_sum);
|
||||||
$weight = 0;
|
$weight = 0;
|
||||||
for ($i = 0; $i < count($weight_array); $i++) {
|
for ($i = 0; $i < count($weight_array); $i++) {
|
||||||
@ -169,6 +173,14 @@ class ShareController{
|
|||||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$row = $conn->execQueryOne('SELECT keys_num FROM user WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id
|
||||||
|
));
|
||||||
|
if (!$row) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||||
|
return;
|
||||||
|
}
|
||||||
//随机奖励
|
//随机奖励
|
||||||
$free = $_REQUEST['free'];
|
$free = $_REQUEST['free'];
|
||||||
$drop_id = 0;
|
$drop_id = 0;
|
||||||
@ -190,7 +202,7 @@ class ShareController{
|
|||||||
for ($i = 0; $i < count($weight_array); $i++) {
|
for ($i = 0; $i < count($weight_array); $i++) {
|
||||||
$weight_sum += $weight_array[$i][0];
|
$weight_sum += $weight_array[$i][0];
|
||||||
}
|
}
|
||||||
srand($account_id);
|
srand(crc32($account_id . $row['keys_num']));
|
||||||
$random = Rand(0, $weight_sum);
|
$random = Rand(0, $weight_sum);
|
||||||
$weight = 0;
|
$weight = 0;
|
||||||
for ($i = 0; $i < count($weight_array); $i++) {
|
for ($i = 0; $i < count($weight_array); $i++) {
|
||||||
@ -338,7 +350,131 @@ class ShareController{
|
|||||||
'errcode' => 0,
|
'errcode' => 0,
|
||||||
'errmsg' => '',
|
'errmsg' => '',
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKefuReward()
|
||||||
|
{
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
$mail_id = $_REQUEST['mail_ids'];
|
||||||
|
|
||||||
|
$url = '';
|
||||||
|
if (SERVER_ENV == _ONLINE) {
|
||||||
|
$url = 'https://gamemail.kingsome.cn/webapp/index.php?c=Mail&a=getAttachment&';
|
||||||
|
} else {
|
||||||
|
$url = 'https://gamemail-test.kingsome.cn/webapp/index.php?c=Mail&a=getAttachment&';
|
||||||
|
}
|
||||||
|
$params = array(
|
||||||
|
'account_id' => $REQUEST['account_id'],
|
||||||
|
'mail_ids' => $mail_id,
|
||||||
|
'session_id' => $_REQUEST['session_id']
|
||||||
|
);
|
||||||
|
if (!phpcommon\HttpClient::get($url, $params, $response)) {
|
||||||
|
phpcommon\sendError(ERR_RETRY, '系统繁忙');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$item_list = array();
|
||||||
|
$item_id = 0;
|
||||||
|
$item_num = 0;
|
||||||
|
$data = json_decode($response, true);
|
||||||
|
$errcode = $data['errcode'];
|
||||||
|
$errmsg = $data['errmsg'];
|
||||||
|
if ($errcode == 0) {
|
||||||
|
$d = $this->getDrop(24005);
|
||||||
|
if (!$d) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$item_id_array = $this->getExplode($d['item_id']);
|
||||||
|
$weight_sum = 0;
|
||||||
|
$keys = 0;
|
||||||
|
$item_num_array = $this->getExplode($d['num']);
|
||||||
|
$weight_array = $this->getExplode($d['weight']);
|
||||||
|
for ($i = 0; $i < count($weight_array); $i++) {
|
||||||
|
$weight_sum += $weight_array[$i][0];
|
||||||
|
}
|
||||||
|
srand(crc32($account_id . $mail_id));
|
||||||
|
$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];
|
||||||
|
$addreward = new classes\AddReward();
|
||||||
|
$addreward->addReward($item_id, $item_num, $account_id);
|
||||||
|
array_push($item_list, array(
|
||||||
|
'item_id' => $item_id,
|
||||||
|
'item_num' => $item_num,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => $errcode,
|
||||||
|
'errmsg' => $errmsg,
|
||||||
|
'item_list' => $item_list
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function kefuDoubleReward()
|
||||||
|
{
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
$mail_id = $_REQUEST['mail_ids'];
|
||||||
|
$d = $this->getDrop(24005);
|
||||||
|
if (!$d) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$item_id_array = $this->getExplode($d['item_id']);
|
||||||
|
$weight_sum = 0;
|
||||||
|
$keys = 0;
|
||||||
|
$item_num_array = $this->getExplode($d['num']);
|
||||||
|
$weight_array = $this->getExplode($d['weight']);
|
||||||
|
for ($i = 0; $i < count($weight_array); $i++) {
|
||||||
|
$weight_sum += $weight_array[$i][0];
|
||||||
|
}
|
||||||
|
srand(crc32($account_id . $mail_id));
|
||||||
|
$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];
|
||||||
|
$addreward = new classes\AddReward();
|
||||||
|
$addreward->addReward($item_id, $item_num, $account_id);
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg' => '',
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user