680 lines
25 KiB
PHP
680 lines
25 KiB
PHP
<?php
|
|
|
|
require 'classes/AddReward.php';
|
|
require 'classes/Quest.php';
|
|
|
|
class ShareController{
|
|
|
|
protected function getMysql($account_id)
|
|
{
|
|
$mysql_conf = getMysqlConfig(crc32($account_id));
|
|
$conn = new phpcommon\Mysql(array(
|
|
'host' => $mysql_conf['host'],
|
|
'port' => $mysql_conf['port'],
|
|
'user' => $mysql_conf['user'],
|
|
'passwd' => $mysql_conf['passwd'],
|
|
'dbname' => 'gamedb2004_' . $mysql_conf['instance_id']
|
|
));
|
|
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');
|
|
$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 getBox($box_id)
|
|
{
|
|
$box_meta_table = require('../res/box@box.php');
|
|
$box_meta = getBoxConfig($box_meta_table, $box_id);
|
|
$b = array(
|
|
'box_id' => $box_meta['box_type'],
|
|
'item_id' => $box_meta['item_id'],
|
|
'num' => $box_meta['num'],
|
|
'weight' => $box_meta['weight'],
|
|
'type' => $box_meta['type'],
|
|
'time' => $box_meta['time'],
|
|
);
|
|
return $b;
|
|
}
|
|
|
|
protected function getShare($share_id)
|
|
{
|
|
$share_meta_table = require('../res/share@share.php');
|
|
$share_meta = getShareConfig($share_meta_table, $share_id);
|
|
$sh = array(
|
|
'id' => $share_meta['id'],
|
|
'rewards' => $share_meta['rewards'],
|
|
'people' => $share_meta['people'],
|
|
);
|
|
return $sh;
|
|
}
|
|
|
|
protected function getExplode($string)
|
|
{
|
|
$delim = "|";
|
|
$drop_multiply = explode($delim, $string);
|
|
$delim1 = ":";
|
|
$arr = array();
|
|
for ($i = 0; $i < count($drop_multiply); $i++) {
|
|
$mul = explode($delim1, $drop_multiply[$i]);
|
|
array_push($arr, $mul);
|
|
}
|
|
return $arr;
|
|
}
|
|
|
|
|
|
protected function getParameter($para_id)
|
|
{
|
|
$parameter_meta_cluster = require('../res/parameter@parameter.php');
|
|
$parameter_meta = getParameterConfig($parameter_meta_cluster, $para_id);
|
|
$p = array(
|
|
'id' => $parameter_meta['id'],
|
|
'param_name' => $parameter_meta['param_name'],
|
|
'param_value' => $parameter_meta['param_value'],
|
|
);
|
|
return $p;
|
|
}
|
|
|
|
protected function subCoin($num, $account_id, $diamond_num)
|
|
{
|
|
$conn = $this->getMysql($account_id);
|
|
if (!$conn) {
|
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
|
die();
|
|
}
|
|
if ($diamond_num < $num) {
|
|
phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足');
|
|
die();
|
|
}
|
|
$ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' .
|
|
' WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':diamond_num' => $diamond_num - $num,
|
|
':modify_time' => time()
|
|
));
|
|
if (!$ret) {
|
|
die();
|
|
}
|
|
}
|
|
|
|
protected function randBoxReward($drop_id, $times)
|
|
{
|
|
//随机奖励
|
|
$item_list = array();
|
|
if ($times == 0) {
|
|
$b = $this->getbox($drop_id);
|
|
$item_id_array = $this->getExplode($b['item_id']);
|
|
$times = count($item_id_array);
|
|
error_log($times);
|
|
}
|
|
for ($j = 0; $j < $times; $j++) {
|
|
$b = $this->getbox($drop_id);
|
|
if (!$b) {
|
|
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
|
die();
|
|
}
|
|
$item_id_array = $this->getExplode($b['item_id']);
|
|
$weight_sum = 0;
|
|
$keys = 0;
|
|
$item_num_array = $this->getExplode($b['num']);
|
|
$weight_array = $this->getExplode($b['weight']);
|
|
$time_array = $this->getExplode($b['time']);
|
|
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];
|
|
$time = $time_array[$keys][0];
|
|
array_push($item_list, array(
|
|
'item_id' => $item_id,
|
|
'item_num' => $item_num,
|
|
'time' => $time
|
|
));
|
|
}
|
|
return $item_list;
|
|
}
|
|
|
|
public function keyBoxInfo()
|
|
{
|
|
$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;
|
|
}
|
|
$free = $_REQUEST['free'];
|
|
$drop_id = 0;
|
|
//随机奖励
|
|
$item_list = array();
|
|
if ($free != 0) {
|
|
$p = $this->getParameter(DIAMONDBOX10);
|
|
$diamond_num = $p['param_value'];
|
|
$item_list = $this->randBoxReward(2, 0);
|
|
} else {
|
|
$diamond_num = 0;
|
|
$item_list = $this->randBoxReward(1, 1);
|
|
$row = $conn->execQueryOne('SELECT free_box FROM user WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
if ($row['free_box'] >= 5) {
|
|
phpcommon\sendError(ERR_USER_BASE + 2, '今日免费次数已达上限');
|
|
die();
|
|
return;
|
|
}
|
|
$ret = $conn->execScript('UPDATE user SET free_box=:free_box, ' .
|
|
'modify_time=:modify_time WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':modify_time' => time(),
|
|
':free_box' => $row['free_box'] + 1,
|
|
));
|
|
|
|
}
|
|
$row = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
if (!$row) {
|
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
|
die();
|
|
}
|
|
//扣除钻石
|
|
$this->subCoin($diamond_num, $account_id, $row['diamond_num']);
|
|
$num = $row['diamond_num'] - $diamond_num;
|
|
//保存开宝箱奖励
|
|
$boxreward_uuid = 'game2004api_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);
|
|
foreach ($item_list as $item) {
|
|
$addreward = new classes\AddReward();
|
|
$addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time']);
|
|
}
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'item_list' => $item_list,
|
|
'diamond_nums' => $num,
|
|
));
|
|
}
|
|
|
|
public function keyBoxDoubleReward()
|
|
{
|
|
$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;
|
|
}
|
|
$row = $conn->execQueryOne('SELECT keys_num FROM user WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
if (!$row) {
|
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
|
return;
|
|
}
|
|
|
|
$boxreward_uuid = 'game2004api_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;
|
|
}
|
|
$user_db = json_decode($user_db_str, true);
|
|
if (empty($user_db)) {
|
|
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
|
return;
|
|
}
|
|
$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);
|
|
}
|
|
$r->del($boxreward_uuid, json_encode($user_db));
|
|
$addreward = new classes\AddReward();
|
|
$coin_num = $addreward->getCoinNum($account_id);
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'coin_nums' => $coin_num,
|
|
));
|
|
}
|
|
|
|
public function shareFriendInfo()
|
|
{
|
|
$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;
|
|
}
|
|
$info_list = array();
|
|
$rows = $conn->execQuery('SELECT ach_id, status FROM share_achievement WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
$share_meta_table = require('../res/share@share.php');
|
|
if (count($rows) < count($share_meta_table)) {
|
|
$num = count($rows) + 1;
|
|
for ($i = $num; $i <= count($share_meta_table); $i++) {
|
|
$id = $i;
|
|
$ret = $conn->execScript('INSERT INTO share_achievement(accountid, ach_id, status, create_time, modify_time) ' .
|
|
' VALUES(:account_id, :ach_id, :status, :create_time, :modify_time) ' .
|
|
' ON DUPLICATE KEY UPDATE accountid=:account_id, ach_id=:ach_id, status=:status, modify_time=:modify_time;',
|
|
array(
|
|
':account_id' => $account_id,
|
|
':ach_id' => $id,
|
|
':status' => 0,
|
|
':create_time' => time(),
|
|
':modify_time' => time()
|
|
));
|
|
if(!$ret){
|
|
die();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
$rows = $conn->execQuery('SELECT ach_id, status FROM share_achievement WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
foreach ($rows as $row) {
|
|
$sh = $this->getShare($row['ach_id']);
|
|
$array = $this->getExplode($sh['rewards']);
|
|
array_push($info_list, array(
|
|
'achivement_id' => $row['ach_id'],
|
|
'status' => $row['status'],
|
|
'item_id' => $array[0][0],
|
|
'num' => $array[0][1],
|
|
'people_num' => $sh['people'],
|
|
));
|
|
}
|
|
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'info_list' => $info_list
|
|
));
|
|
}
|
|
|
|
public function shareFriendReward()
|
|
{
|
|
$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'];
|
|
$row = $conn->execQueryOne('SELECT status FROM share_achievement WHERE accountid=:accountid AND ach_id=:ach_id;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':ach_id' => $ach_id,
|
|
));
|
|
if (!$row) {
|
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
|
return;
|
|
}
|
|
if ($row['status'] != 0) {
|
|
phpcommon\sendError(ERR_USER_BASE + 3, '奖励已领取');
|
|
return;
|
|
}
|
|
//获取奖励信息
|
|
$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;
|
|
}
|
|
$item_list = array();
|
|
$addreward = new classes\AddReward();
|
|
if ($ach_id != 6) {
|
|
$array = $this->getExplode($sh['rewards']);
|
|
array_push($item_list, array(
|
|
'item_id' => $array[0][0],
|
|
'item_num' => $array[0][1],
|
|
));
|
|
$addreward->addReward($array[0][0], $array[0][1], $account_id);
|
|
} else if ($ach_id == 6) {
|
|
array_push($item_list, array(
|
|
'item_id' => 10003,
|
|
'item_num' => 50,
|
|
));
|
|
$addreward->addReward(10003, 50, $account_id);
|
|
}
|
|
//更新状态
|
|
$ret = $conn->execScript('UPDATE share_achievement SET status=1, modify_time=:modify_time ' .
|
|
' WHERE accountid=:accountid AND ach_id=:ach_id;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':modify_time' => time(),
|
|
':ach_id' => $ach_id
|
|
));
|
|
if (!$ret) {
|
|
die();
|
|
return;
|
|
}
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'item_list' => $item_list
|
|
));
|
|
}
|
|
|
|
public function shareDobleReward()
|
|
{
|
|
$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;
|
|
}
|
|
$p = $this->getParameter(REWARD_TIMES);
|
|
$times = $p['param_value'] - 1;
|
|
$addreward = new classes\AddReward();
|
|
if ($ach_id != 6) {
|
|
$array = $this->getExplode($sh['rewards']);
|
|
$addreward->addReward($array[0][0], $array[0][1] * $times, $account_id);
|
|
} else if ($ach_id == 6) {
|
|
$addreward->addReward(10003, 50 * $times, $account_id);
|
|
}
|
|
$coin_num = $addreward->getCoinNum($account_id);
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'coin_nums' => $coin_num,
|
|
));
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
$row = $conn->execQueryOne('SELECT kefu_status FROM user WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
if (!$row) {
|
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
|
return;
|
|
}
|
|
if ($row['kefu_status'] != 0) {
|
|
phpcommon\sendError(ERR_USER_BASE + 3, '客服奖励已领取');
|
|
die();
|
|
return;
|
|
}
|
|
$item_list = array();
|
|
$item_id = 0;
|
|
$item_num = 0;
|
|
$data = json_decode($response, true);
|
|
$errcode = $data['errcode'];
|
|
$errmsg = $data['errmsg'];
|
|
if ($errcode == 0) {
|
|
foreach($data['attachments'] as $kefu){
|
|
$item_id = $kefu['itemid'];
|
|
$item_num = $kefu['itemnum'];
|
|
}
|
|
$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,
|
|
));
|
|
|
|
//保存客服奖励
|
|
$kefureward_uuid = 'game2004api_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 * 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 * 7200);
|
|
}
|
|
|
|
//更新状态
|
|
$ret = $conn->execScript('UPDATE user SET kefu_status=1, modify_time=:modify_time ' .
|
|
' WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':modify_time' => time(),
|
|
));
|
|
if (!$ret) {
|
|
die();
|
|
return;
|
|
}
|
|
}
|
|
$addreward = new classes\AddReward();
|
|
$coin_num = $addreward->getCoinNum($account_id);
|
|
$diamond_num = $addreward->getDiamondNum($account_id);
|
|
echo json_encode(array(
|
|
'errcode' => $errcode,
|
|
'errmsg' => $errmsg,
|
|
'item_list' => $item_list,
|
|
'coin_nums' => $coin_num,
|
|
'diamond_nums' => $diamond_num
|
|
));
|
|
}
|
|
|
|
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'];
|
|
$kefureward_uuid = 'game2004api_kefureward_uuid:' . md5($_REQUEST['account_id']);
|
|
$r = $this->getRedis($kefureward_uuid);
|
|
$user_db_str = $r->get($kefureward_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;
|
|
}
|
|
$p = $this->getParameter(REWARD_TIMES);
|
|
$times = $p['param_value'] - 1;
|
|
foreach ($user_db['kefureward_list'] as $kefureward) {
|
|
//增加奖励
|
|
$addreward = new classes\AddReward();
|
|
$addreward->addReward($kefureward['item_id'], $kefureward['item_num'] * $times, $account_id);
|
|
}
|
|
$r->del($kefureward_uuid, json_encode($user_db));
|
|
$addreward = new classes\AddReward();
|
|
$coin_num = $addreward->getCoinNum($account_id);
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'coin_nums' => $coin_num,
|
|
));
|
|
}
|
|
}
|
|
?>
|