1
This commit is contained in:
parent
ba4e548f83
commit
16f902d9a4
2
third_party/phpcommon
vendored
2
third_party/phpcommon
vendored
@ -1 +1 @@
|
||||
Subproject commit 5fb5d7f6fcd174b9c4ad4e30e189e90e2b8c846e
|
||||
Subproject commit 2e7067d848c09897f27e6486c38399b27126ca26
|
@ -42,6 +42,21 @@ class ActivityController{
|
||||
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 getExplode($string)
|
||||
{
|
||||
$delim = "|";
|
||||
@ -400,13 +415,23 @@ class ActivityController{
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$randreward_list = $this->getRandomReward();
|
||||
$randreward_db = array(
|
||||
'randreward_uuid' => $randreward_uuid,
|
||||
'randreward_list' => $randreward_list,
|
||||
);
|
||||
$r -> set($randreward_uuid, json_encode($randreward_db));
|
||||
$r -> pexpire($randreward_uuid, 1000 * 300);
|
||||
if (empty($user_db_str)) {
|
||||
$randreward_list = $this->getRandomReward();
|
||||
$randreward_db = array(
|
||||
'randreward_uuid' => $randreward_uuid,
|
||||
'randreward_list' => $randreward_list,
|
||||
);
|
||||
$r -> set($randreward_uuid, json_encode($randreward_db));
|
||||
$r -> pexpire($randreward_uuid, 1000 * 60);
|
||||
} else {
|
||||
$randreward_list = $this->getRandomReward();
|
||||
$randreward_db = array(
|
||||
'randreward_uuid' => $randreward_uuid,
|
||||
'randreward_list' => $randreward_list,
|
||||
);
|
||||
$r -> set($randreward_uuid, json_encode($randreward_db));
|
||||
$r -> pexpire($randreward_uuid, 1000 * 60);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
@ -440,7 +465,7 @@ class ActivityController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
foreach ($user_db['randreward_uuid'] as $randreward) {
|
||||
foreach ($user_db['randreward_list'] as $randreward) {
|
||||
//增加奖励
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($randreward['item_id'], $randreward['item_num'], $account_id);
|
||||
@ -476,7 +501,7 @@ class ActivityController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
foreach ($user_db['randreward_uuid'] as $randreward) {
|
||||
foreach ($user_db['randreward_list'] as $randreward) {
|
||||
//增加奖励
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($randreward['item_id'], $randreward['item_num'], $account_id);
|
||||
@ -495,7 +520,7 @@ class ActivityController{
|
||||
$item_id = 0;
|
||||
$item_num = 0;
|
||||
$key = 0;
|
||||
$re = $this->getrandreward($i);
|
||||
$re = $this->getreward($i);
|
||||
//确定商品id和数量
|
||||
$weight_sum = 0;
|
||||
$weight_array = $this->getExplode($re['weight']);
|
||||
@ -512,7 +537,7 @@ class ActivityController{
|
||||
}
|
||||
}
|
||||
$item_id_array = $this->getExplode($re['reward']);
|
||||
$num_array = $this->getExplode($l['number']);
|
||||
$num_array = $this->getExplode($re['number']);
|
||||
$item_id = $item_id_array[$key][0];
|
||||
$item_num = $num_array[$key][0];
|
||||
array_push($randreward_list, array(
|
||||
@ -522,5 +547,142 @@ class ActivityController{
|
||||
}
|
||||
return $randreward_list;
|
||||
}
|
||||
|
||||
public function airDropBoxReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
|
||||
$airReward_uuid = 'game2001api_airReward_uuid:' . md5($_REQUEST['account_id']);
|
||||
$airReward_list = array();
|
||||
$r = $this->getRedis($airReward_uuid);
|
||||
if (!$r) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$user_db_str = $r->get($airReward_uuid);
|
||||
if (empty($user_db_str)) {
|
||||
$airReward_list = $this->getRandomAirReward();
|
||||
$airReward_db = array(
|
||||
'airReward_uuid' => $airReward_uuid,
|
||||
'airReward_list' => $airReward_list,
|
||||
);
|
||||
$r -> set($airReward_uuid, json_encode($airReward_db));
|
||||
$r -> pexpire($airReward_uuid, 1000 * 60);
|
||||
} else {
|
||||
$airReward_list = $this->getRandomAirReward();
|
||||
$airReward_db = array(
|
||||
'airReward_uuid' => $airReward_uuid,
|
||||
'airReward_list' => $airReward_list,
|
||||
);
|
||||
$r -> set($airReward_uuid, json_encode($airReward_db));
|
||||
$r -> pexpire($airReward_uuid, 1000 * 60);
|
||||
}
|
||||
foreach ($airReward_list as $airReward) {
|
||||
//增加奖励
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($airReward['item_id'], $airReward['item_num'], $account_id);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'item_list' => $airReward_list
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public function airDoubleReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
|
||||
$airReward_uuid = 'game2001api_airReward_uuid:' . md5($_REQUEST['account_id']);
|
||||
$airReward_list = array();
|
||||
$r = $this->getRedis($airReward_uuid);
|
||||
if (!$r) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$user_db_str = $r->get($airReward_uuid);
|
||||
if (empty($user_db_str)) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
if (empty($user_db)) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
foreach ($user_db['airReward_list'] as $airReward) {
|
||||
//增加奖励
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($airReward['item_id'], $airReward['item_num'], $account_id);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'item_list' => $airReward_list
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
protected function getRandomAirReward()
|
||||
{
|
||||
$airReward_list = array();
|
||||
//随机奖励
|
||||
$d = $this->getDrop(24106);
|
||||
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']);
|
||||
if ($d['type'] == 2) {
|
||||
$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($airReward_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
));
|
||||
}
|
||||
if ($d['type'] == 1) {
|
||||
for ($i = 0; $i < count($weight_array); $i++) {
|
||||
$random = Rand(0, 10000);
|
||||
if ($weight_array[$i][0] < $random) {
|
||||
continue;
|
||||
}
|
||||
array_push($airReward_list, array(
|
||||
'item_id' => $item_id_array[$keys][0],
|
||||
'item_num' => $item_num_array[$keys][0],
|
||||
));
|
||||
}
|
||||
}
|
||||
return $airReward_list;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -303,6 +303,11 @@ class QuestController{
|
||||
}
|
||||
$quest_id = $_REQUEST['quest_id'];
|
||||
$quest_type = $_REQUEST['type'];
|
||||
$double = $_REQUEST['double'];
|
||||
$reward_times = 1;
|
||||
if ($double == 1) {
|
||||
$reward_times = 2;
|
||||
}
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
@ -364,7 +369,7 @@ class QuestController{
|
||||
$item_id_array = $this->getExplode($d['item_id']);
|
||||
$num_array = $this->getExplode($d['num']);
|
||||
$item_id = $item_id_array[$key][0];
|
||||
$item_num = $num_array[$key][0];
|
||||
$item_num = $num_array[$key][0] * $reward_times;
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
|
@ -309,7 +309,6 @@ class ShareController{
|
||||
return;
|
||||
}
|
||||
$ach_id = $_REQUEST['ach_id'];
|
||||
$double = $_REQUEST['double'];
|
||||
$row = $conn->execQueryOne('SELECT status FROM share_achievement WHERE accountid=:accountid AND ach_id=:ach_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
@ -326,20 +325,16 @@ class ShareController{
|
||||
//获取奖励信息
|
||||
$url = '';
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
$url = 'https://service.kingsome.cn/webapp/index.php?c=AchievementShare&a=getInviteeNumSvr&';
|
||||
$url = 'https://service.kingsome.cn/webapp/index.php?c=DailyMission&a=getInviteeNum&';
|
||||
} else {
|
||||
$url = 'https://service-test.kingsome.cn/webapp/index.php?c=AchievementShare&a=getInviteeNumSvr&';
|
||||
$url = 'https://service-test.kingsome.cn/webapp/index.php?c=DailyMission&a=getInviteeNum&';
|
||||
}
|
||||
$timestamp = time();
|
||||
$params = array(
|
||||
'account_id' => $_REQUEST['account_id'],
|
||||
'achievement_ids' => $ach_id,
|
||||
'session_id' => $_REQUEST['session_id'],
|
||||
'activity_param' => $_REQUEST['activity_param'],
|
||||
);
|
||||
$sign = phpcommon\md5Sign($params,
|
||||
'70e32abc60367adccaa9eb7b56ed821b',
|
||||
$timestamp);
|
||||
$params['sign'] = $sign;
|
||||
$params['timestamp'] = $timestamp;
|
||||
$response = '';
|
||||
if (!phpcommon\HttpClient::get($url, $params, $response)) {
|
||||
phpcommon\sendError(ERR_RETRY, '系统繁忙');
|
||||
@ -347,26 +342,15 @@ class ShareController{
|
||||
}
|
||||
//领取奖励
|
||||
$data = json_decode($response, true);
|
||||
$ach_list = $data['invitee_nums'];
|
||||
$peo_num = 0;
|
||||
$peo_num = $data['invitee_num'];
|
||||
$sh = $this->getShare($ach_id);
|
||||
$num = 0;
|
||||
if ($double != 0) {
|
||||
$num = 2;
|
||||
} else {
|
||||
$num = 1;
|
||||
}
|
||||
foreach($ach_list as $ach){
|
||||
$ach_id = $ach['achievement_id'];
|
||||
$peo_num = $ach['invitee_num'];
|
||||
}
|
||||
if ($peo_num == 0) {
|
||||
if ($peo_num < $sh['people']) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 4, '未达到人数要求');
|
||||
return;
|
||||
}
|
||||
$array = $this->getExplode($sh['rewards']);
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($array[0][0], $array[0][1] * $num, $account_id);
|
||||
$addreward->addReward($array[0][0], $array[0][1], $account_id);
|
||||
//更新状态
|
||||
$ret = $conn->execScript('UPDATE share_achievement SET status=1, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid AND ach_id=:ach_id;',
|
||||
@ -385,6 +369,57 @@ class ShareController{
|
||||
));
|
||||
}
|
||||
|
||||
public function shareDoubleReward()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$ach_id = $_REQUEST['ach_id'];
|
||||
//获取奖励信息
|
||||
$url = '';
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
$url = 'https://service.kingsome.cn/webapp/index.php?c=DailyMission&a=getInviteeNum&';
|
||||
} else {
|
||||
$url = 'https://service-test.kingsome.cn/webapp/index.php?c=DailyMission&a=getInviteeNum&';
|
||||
}
|
||||
$timestamp = time();
|
||||
$params = array(
|
||||
'account_id' => $_REQUEST['account_id'],
|
||||
'session_id' => $_REQUEST['session_id'],
|
||||
'activity_param' => $_REQUEST['activity_param'],
|
||||
);
|
||||
$response = '';
|
||||
if (!phpcommon\HttpClient::get($url, $params, $response)) {
|
||||
phpcommon\sendError(ERR_RETRY, '系统繁忙');
|
||||
return;
|
||||
}
|
||||
//领取奖励
|
||||
$data = json_decode($response, true);
|
||||
$peo_num = $data['invitee_num'];
|
||||
$sh = $this->getShare($ach_id);
|
||||
if ($peo_num < $sh['people']) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 4, '未达到人数要求');
|
||||
return;
|
||||
}
|
||||
$array = $this->getExplode($sh['rewards']);
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($array[0][0], $array[0][1], $account_id);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public function getKefuReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
|
@ -307,6 +307,16 @@ class SignController{
|
||||
if (!$lottery_ret) {
|
||||
die();
|
||||
}
|
||||
//刷新邀请好友奖励
|
||||
$share_ret = $conn->execScript('UPDATE share_achievement SET status=0, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$share_ret) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -280,12 +280,6 @@ class SkinController{
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
/*"skin_id" => $skin_id,
|
||||
"skin_status" => $skin_status,
|
||||
"fragment_num" => $fragment_num,
|
||||
"time" => $active_time,
|
||||
"skin_level" => 1,
|
||||
"skin_experience_type" => $skin_experience_type,*/
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ class VoiceController{
|
||||
$md5 = md5($data);
|
||||
$r = $this->getRedis($md5);
|
||||
$r->set('game2001:voice:' . $md5, $data);
|
||||
$r -> pexpire('game2001:voice:' . $md5, 1000 * 600);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
|
Loading…
x
Reference in New Issue
Block a user