1
This commit is contained in:
parent
72b1ab09ec
commit
699eb277eb
@ -424,7 +424,7 @@ class ActivityController{
|
||||
'randreward_list' => $randreward_list,
|
||||
);
|
||||
$r -> set($randreward_uuid, json_encode($randreward_db));
|
||||
$r -> pexpire($randreward_uuid, 1000 * 60);
|
||||
$r -> pexpire($randreward_uuid, 1000 * 7200);
|
||||
} else {
|
||||
$randreward_list = $this->getRandomReward();
|
||||
$randreward_db = array(
|
||||
@ -432,41 +432,11 @@ class ActivityController{
|
||||
'randreward_list' => $randreward_list,
|
||||
);
|
||||
$r -> set($randreward_uuid, json_encode($randreward_db));
|
||||
$r -> pexpire($randreward_uuid, 1000 * 60);
|
||||
$r -> pexpire($randreward_uuid, 1000 * 7200);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'randreward_uuid' => $randreward_uuid,
|
||||
'item_list' => $randreward_list,
|
||||
));
|
||||
}
|
||||
|
||||
public function getRandReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
$randreward_uuid = $_REQUEST['randreward_uuid'];
|
||||
$r = $this->getRedis($randreward_uuid);
|
||||
if (!$r) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$user_db_str = $r->get($randreward_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['randreward_list'] as $randreward) {
|
||||
//增加奖励
|
||||
error_log($randreward['item_num']);
|
||||
@ -476,6 +446,8 @@ class ActivityController{
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'randreward_uuid' => $randreward_uuid,
|
||||
'item_list' => $randreward_list,
|
||||
));
|
||||
}
|
||||
|
||||
@ -511,6 +483,7 @@ class ActivityController{
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($randreward['item_id'], $randreward['item_num'] * $times, $account_id);
|
||||
}
|
||||
$r->del($randreward_uuid, json_encode($user_db));
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
@ -596,7 +569,7 @@ class ActivityController{
|
||||
'airReward_list' => $airReward_list,
|
||||
);
|
||||
$r -> set($airReward_uuid, json_encode($airReward_db));
|
||||
$r -> pexpire($airReward_uuid, 1000 * 60);
|
||||
$r -> pexpire($airReward_uuid, 1000 * 7200);
|
||||
} else {
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
unset($user_db['airReward_list']);
|
||||
@ -606,7 +579,7 @@ class ActivityController{
|
||||
'airReward_list' => $airReward_list,
|
||||
);
|
||||
$r -> set($airReward_uuid, json_encode($airReward_db));
|
||||
$r -> pexpire($airReward_uuid, 1000 * 60);
|
||||
$r -> pexpire($airReward_uuid, 1000 * 7200);
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE user SET box_num=:box_num, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
@ -650,12 +623,12 @@ class ActivityController{
|
||||
}
|
||||
$user_db_str = $r->get($airReward_uuid);
|
||||
if (empty($user_db_str)) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
phpcommon\sendError(ERR_USER_BASE + 2,'session失效');
|
||||
return;
|
||||
}
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
if (empty($user_db)) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
phpcommon\sendError(ERR_USER_BASE + 3,'session失效');
|
||||
return;
|
||||
}
|
||||
$p = $this->getParameter(REWARD_TIMES);
|
||||
@ -665,6 +638,7 @@ class ActivityController{
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($airReward['item_id'], $airReward['item_num'] * $times, $account_id);
|
||||
}
|
||||
$r->del($airReward_uuid, json_encode($user_db));
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
|
@ -155,16 +155,40 @@ class ShareController{
|
||||
}
|
||||
$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);
|
||||
$item_list = array();
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
));
|
||||
//保存开宝箱奖励
|
||||
$boxreward_uuid = 'game2001api_boxreward_uuid:' . md5($_REQUEST['account_id']);
|
||||
$boxreward_list = array();
|
||||
$r = $this->getRedis($boxreward_uuid);
|
||||
$user_db_str = $r->get($boxreward_uuid);
|
||||
if (!$r) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
if (empty($user_db_str)) {
|
||||
$boxreward_db = array(
|
||||
'boxreward_uuid' => $boxreward_uuid,
|
||||
'boxreward_list' => $item_list,
|
||||
);
|
||||
$r -> set($boxreward_uuid, json_encode($boxreward_db));
|
||||
$r -> pexpire($boxreward_uuid, 1000 * 7200);
|
||||
} else {
|
||||
$boxreward_db = array(
|
||||
'boxreward_uuid' => $boxreward_uuid,
|
||||
'boxreward_list' => $item_list,
|
||||
);
|
||||
$r -> set($boxreward_uuid, json_encode($boxreward_db));
|
||||
$r -> pexpire($boxreward_uuid, 1000 * 7200);
|
||||
}
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(71004, 1, 1, $account_id);
|
||||
$quest->triggerQuest(72004, 2, 1, $account_id);
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($item_id, $item_num, $account_id);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
@ -173,7 +197,7 @@ class ShareController{
|
||||
));
|
||||
}
|
||||
|
||||
public function keyBoxReward()
|
||||
public function keyBoxDoubleReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
@ -187,7 +211,6 @@ class ShareController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$double = $_REQUEST['double'];
|
||||
$row = $conn->execQueryOne('SELECT keys_num FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
@ -196,47 +219,27 @@ class ShareController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
//随机奖励
|
||||
$p = $this->getParameter(REWARD_TIMES);
|
||||
$times = 1;
|
||||
if ($double == 1) {
|
||||
$times = $p['param_value'] - 1;
|
||||
|
||||
}
|
||||
$free = $_REQUEST['free'];
|
||||
$drop_id = 0;
|
||||
if ($free != 0) {
|
||||
$drop_id = 24002;
|
||||
} else {
|
||||
$drop_id = 24001;
|
||||
}
|
||||
$d = $this->getDrop($drop_id);
|
||||
if (!$d) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||
$boxreward_uuid = 'game2001api_boxreward_uuid:' . md5($_REQUEST['account_id']);
|
||||
$r = $this->getRedis($boxreward_uuid);
|
||||
$user_db_str = $r->get($boxreward_uuid);
|
||||
if (empty($user_db_str)) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
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];
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
if (empty($user_db)) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
srand(crc32($account_id . $row['keys_num']));
|
||||
$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;
|
||||
}
|
||||
$p = $this->getParameter(REWARD_TIMES);
|
||||
$times = $p['param_value'] - 1;
|
||||
foreach ($user_db['boxreward_list'] as $boxreward) {
|
||||
//增加奖励
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($boxreward['item_id'], $boxreward['item_num'] * $times, $account_id);
|
||||
}
|
||||
$item_id = $item_id_array[$keys][0];
|
||||
$item_num = $item_num_array[$keys][0];
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($item_id, $item_num * $times, $account_id);
|
||||
$r->del($boxreward_uuid, json_encode($user_db));
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
@ -519,14 +522,14 @@ class ShareController{
|
||||
'kefureward_list' => $item_list,
|
||||
);
|
||||
$r -> set($kefureward_uuid, json_encode($kefureward_db));
|
||||
$r -> pexpire($kefureward_uuid, 1000 * 300);
|
||||
$r -> pexpire($kefureward_uuid, 1000 * 7200);
|
||||
} else {
|
||||
$kefureward_db = array(
|
||||
'kefureward_uuid' => $kefureward_uuid,
|
||||
'kefureward_list' => $item_list,
|
||||
);
|
||||
$r -> set($kefureward_uuid, json_encode($kefureward_db));
|
||||
$r -> pexpire($kefureward_uuid, 1000 * 300);
|
||||
$r -> pexpire($kefureward_uuid, 1000 * 7200);
|
||||
}
|
||||
|
||||
//更新状态
|
||||
@ -582,7 +585,7 @@ class ShareController{
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($kefureward['item_id'], $kefureward['item_num'] * $times, $account_id);
|
||||
}
|
||||
|
||||
$r->del($kefureward_uuid, json_encode($user_db));
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
|
@ -222,11 +222,6 @@ class SignController{
|
||||
$s = $this->getSign($day + 90000);
|
||||
$item_id = $s['item_id'];
|
||||
$num = $s['num'];
|
||||
$p = $this->getParameter(REWARD_TIMES);
|
||||
$times = $p['param_value'];
|
||||
if ($double == 1) {
|
||||
$num = $num * $times;
|
||||
}
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($item_id, $num, $account_id);
|
||||
echo json_encode(array(
|
||||
@ -235,6 +230,46 @@ class SignController{
|
||||
));
|
||||
}
|
||||
|
||||
public function signDoubleReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$double = $_REQUEST['double'];
|
||||
//登录校验
|
||||
$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;
|
||||
}
|
||||
$rowUser = $conn->execQueryOne('SELECT sign_sum FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
//获得奖励
|
||||
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
|
||||
$day = ($rowUser['sign_sum'] / 7 + $_REQUEST['sign_id']) % count($g_conf_sign_cluster);
|
||||
if ($day == 0) {
|
||||
$day = count($g_conf_sign_cluster);
|
||||
}
|
||||
$s = $this->getSign($day + 90000);
|
||||
$item_id = $s['item_id'];
|
||||
$num = $s['num'];
|
||||
$p = $this->getParameter(REWARD_TIMES);
|
||||
$times = $p['param_value'] - 1;
|
||||
$num = $num * $times;
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($item_id, $num, $account_id);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
protected function updateSignSum($account_id, $sign_num)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user