1
This commit is contained in:
parent
fef83e2ca7
commit
3ea2a3af64
@ -412,6 +412,7 @@ class ActivityController{
|
||||
$randreward_uuid = 'game2001api_randreward_uuid:' . md5($_REQUEST['account_id']);
|
||||
$randreward_list = array();
|
||||
$r = $this->getRedis($randreward_uuid);
|
||||
$user_db_str = $r->get($randreward_uuid);
|
||||
if (!$r) {
|
||||
die();
|
||||
return;
|
||||
|
@ -18,6 +18,18 @@ class ShareController{
|
||||
return $conn;
|
||||
}
|
||||
|
||||
protected function getRedis($shop_uuid)
|
||||
{
|
||||
$redis_conf = getRedisConfig(crc32($shop_uuid));
|
||||
$r = new phpcommon\Redis(array(
|
||||
'host' => $redis_conf['host'],
|
||||
'port' => $redis_conf['port'],
|
||||
'passwd' => $redis_conf['passwd']
|
||||
|
||||
));
|
||||
return $r;
|
||||
}
|
||||
|
||||
protected function getDrop($drop_id)
|
||||
{
|
||||
$drop_meta_table = require('../res/drop@drop.php');
|
||||
@ -492,6 +504,32 @@ class ShareController{
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
));
|
||||
|
||||
//保存客服奖励
|
||||
$kefureward_uuid = 'game2001api_kefureward_uuid:' . md5($_REQUEST['account_id']);
|
||||
$kefureward_list = array();
|
||||
$r = $this->getRedis($kefureward_uuid);
|
||||
$user_db_str = $r->get($kefureward_uuid);
|
||||
if (!$r) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
if (empty($user_db_str)) {
|
||||
$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);
|
||||
} 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);
|
||||
}
|
||||
|
||||
//更新状态
|
||||
$ret = $conn->execScript('UPDATE user SET kefu_status=1, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
@ -526,35 +564,29 @@ class ShareController{
|
||||
return;
|
||||
}
|
||||
$mail_id = $_REQUEST['mail_ids'];
|
||||
$d = $this->getDrop(24005);
|
||||
if (!$d) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||
|
||||
$user_db_str = $r->get($kefureward_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 . $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];
|
||||
$p = $this->getParameter(REWARD_TIMES);
|
||||
$times = $p['param_value'] - 1;
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($item_id, $item_num * $times, $account_id);
|
||||
$times = $p['value'] - 1;
|
||||
foreach ($user_db['kefureward_list'] as $kefureward) {
|
||||
//增加奖励
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($kefureward['item_id'], $kefureward['item_num'] * $times, $account_id);
|
||||
}
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
));
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
|
Loading…
x
Reference in New Issue
Block a user