643 lines
26 KiB
PHP
643 lines
26 KiB
PHP
<?php
|
|
|
|
require 'classes/Quest.php';
|
|
require 'classes/AddReward.php';
|
|
|
|
class SignController{
|
|
|
|
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' => DBNAME_PREFIX . $mysql_conf['instance_id']
|
|
));
|
|
return $conn;
|
|
}
|
|
|
|
protected function getSign($sign_id)
|
|
{
|
|
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
|
|
$sign_conf = getSignConfig($g_conf_sign_cluster, $sign_id);
|
|
$s = array(
|
|
'sign_id' => $sign_conf['sign_id'],
|
|
'condition' => $sign_conf['condition'],
|
|
'item_id' => $sign_conf['item_id'],
|
|
'num' => $sign_conf['num'],
|
|
'time' => $sign_conf['time'],
|
|
);
|
|
return $s;
|
|
}
|
|
|
|
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 getItem($item_id)
|
|
{
|
|
$g_conf_item_cluster = require('../res/item@item.php');
|
|
$item_conf = getItemConfig($g_conf_item_cluster, $item_id);
|
|
$it = array(
|
|
'id' => $item_conf['id'],
|
|
'diamond' => $item_conf['diamond'],
|
|
'type' => $item_conf['fuction'],
|
|
'diamond_hour' => $item_conf['diamond_hour'],
|
|
'pool_weight' => $item_conf['pool_weight'],
|
|
'name' => $item_conf['name']
|
|
);
|
|
return $it;
|
|
}
|
|
|
|
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'],
|
|
'type' => $share_meta['type'],
|
|
);
|
|
return $sh;
|
|
}
|
|
|
|
protected function getSeason($season_id)
|
|
{
|
|
$season_meta_table = require('../res/season@season.php');
|
|
$season_meta = getSeasonConfig($season_meta_table, $season_id);
|
|
$season = array(
|
|
'number' => $season_meta['season_number'],
|
|
'open_time' => $season_meta['time1'],
|
|
'end_time' => $season_meta['time2'],
|
|
);
|
|
return $season;
|
|
}
|
|
|
|
protected function getSeasonPoint($seaPoint_id)
|
|
{
|
|
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
|
$seaPoint_meta = getSeasonPointConfig($seaPoint_meta_table, $seaPoint_id);
|
|
$seaPoint = array(
|
|
'id' => $seaPoint_meta['id'],
|
|
'min' => $seaPoint_meta['min_point'],
|
|
'max' => $seaPoint_meta['max_point'],
|
|
'des' => $seaPoint_meta['des'],
|
|
'topoint' => $seaPoint_meta['topoint'],
|
|
//'weekreward' => $seaPoint_meta['week_reward'],
|
|
);
|
|
return $seaPoint;
|
|
}
|
|
|
|
protected function getParameter($para_id)
|
|
{
|
|
$g_conf_para_cluster = require('../res/parameter@parameter.php');
|
|
$para_conf = getParameterConfig($g_conf_para_cluster, $para_id);
|
|
$p = array(
|
|
'id' => $para_conf['id'],
|
|
'param_name' => $para_conf['param_name'],
|
|
'param_value' => $para_conf['param_value'],
|
|
);
|
|
return $p;
|
|
}
|
|
|
|
protected function insertSign($account_id, $sign_days)
|
|
{
|
|
$conn = $this->getMysql($account_id);
|
|
if (!$conn) {
|
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
|
die();
|
|
}
|
|
$ret = $conn->execScript('INSERT INTO sign(accountid, sign_id, signable, sign_time, create_time, modify_time) ' .
|
|
' VALUES(:accountid, :sign_id, 0, :sign_time, :create_time, :modify_time) ' .
|
|
' ON DUPLICATE KEY UPDATE accountid=:accountid, sign_id=:sign_id, signable=0, sign_time=:sign_time, modify_time=:modify_time;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':sign_id' => $sign_days,
|
|
':sign_time' => time(),
|
|
':create_time' => time(),
|
|
':modify_time' => time()
|
|
));
|
|
if (!$ret) {
|
|
die();
|
|
}
|
|
}
|
|
|
|
public function signInfo()
|
|
{
|
|
$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);
|
|
$last_sign_id = 0;
|
|
if (!$conn) {
|
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
|
return;
|
|
}
|
|
|
|
$rows = $conn->execQuery('SELECT sign_id, sign_time, signable FROM sign WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
$nowTime = phpcommon\getdayseconds(time());
|
|
if (!$rows) {
|
|
$last_sign_id = 1;
|
|
//插入签到列表
|
|
$this->insertSign($account_id, $last_sign_id);
|
|
//更新签到总天数
|
|
$this->updateSignSum($account_id, $last_sign_id);
|
|
//完成签到任务
|
|
$quest = new classes\Quest();
|
|
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
|
} else {
|
|
$last_sign_time = 0;
|
|
$flag = 0;
|
|
foreach ($rows as $row) {
|
|
if ($row['sign_id'] > $last_sign_id) {
|
|
$last_sign_time = $row['sign_time'];
|
|
$last_sign_id = $row['sign_id'];
|
|
}
|
|
if ($row['signable'] != 1) {
|
|
$flag = 1;
|
|
}
|
|
}
|
|
$rowuser = $conn->execQueryOne('SELECT update_time FROM user WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
//$this->updateSeasonStatus($account_id);
|
|
if ($nowTime - phpcommon\getdayseconds($rowuser['update_time']) > 0) {
|
|
//每日刷新
|
|
$this->updateDaily($account_id);
|
|
//$this->updateSeasonStatus($account_id);
|
|
if (phpcommon\getMondayseconds(time()) - phpcommon\getMondayseconds($rowuser['update_time']) > 0) {
|
|
$this->updateWeekReward($account_id);
|
|
}
|
|
}
|
|
if ($nowTime - phpcommon\getdayseconds($last_sign_time) > 0) {
|
|
$passed_days = floor(($nowTime - phpcommon\getdayseconds($last_sign_time)) / (3600 * 24));
|
|
if ($passed_days > 7 - $last_sign_id && $flag == 0 && count($rows) >= 7) {
|
|
//跨周时删除老数据
|
|
$num = 0;
|
|
$sum = 0;
|
|
$ret = $conn->execScript('DELETE from sign WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
));
|
|
if (!$ret) {
|
|
die();
|
|
return;
|
|
}
|
|
//$last_sign_id = 1;
|
|
//插入签到列表
|
|
$this->insertSign($account_id, 1);
|
|
//更新签到总天数
|
|
$this->updateSignSum($account_id, 1);
|
|
|
|
} else if ($passed_days > 7 - $last_sign_id){
|
|
for ($i = $last_sign_id + 1; $i < 8; $i++) {
|
|
//插入补签列表
|
|
$this->insertSign($account_id, $i);
|
|
}
|
|
$this->updateSignSum($account_id, 7 - $last_sign_id);
|
|
}else if ($passed_days <= 7 - $last_sign_id){
|
|
for ($i = $last_sign_id + 1; $i < $passed_days + $last_sign_id + 1; $i++) {
|
|
//插入补签列表
|
|
$this->insertSign($account_id, $i);
|
|
}
|
|
//更新签到总天数
|
|
$this->updateSignSum($account_id, $passed_days);
|
|
}
|
|
//完成签到任务
|
|
$quest = new classes\Quest();
|
|
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
|
//$quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id);
|
|
}
|
|
}
|
|
$sign_list = array();
|
|
$rows = $conn->execQuery('SELECT sign_id, signable FROM sign WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
foreach ($rows as $row) {
|
|
array_push($sign_list, array(
|
|
'sign_id' => $row['sign_id'],
|
|
'signable' => $row['signable']
|
|
));
|
|
}
|
|
$rowUser = $conn->execQueryOne('SELECT sign_sum FROM user WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
//判断当前第几周
|
|
$item_list = array();
|
|
$week = ceil($rowUser['sign_sum'] / 7);
|
|
$dayid = ($week - 1) * 7;
|
|
//如果大于配置表最后一周,按最后一周奖励
|
|
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
|
|
if ($dayid + 1 > count($g_conf_sign_cluster)) {
|
|
$dayid = count($g_conf_sign_cluster) - 7;
|
|
}
|
|
//error_log($dayid);
|
|
for ($day = $dayid + 1; $day <= $dayid + 7; $day++)
|
|
{
|
|
$s = $this->getSign($day + 90000);
|
|
array_push($item_list, array(
|
|
'item_id' => $s['item_id'],
|
|
'item_num' => $s['num'],
|
|
'time' => $s['time'],
|
|
));
|
|
}
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'sign_days' => $rowUser['sign_sum'],
|
|
'sign_list' => $sign_list,
|
|
'item_list' => $item_list
|
|
));
|
|
}
|
|
|
|
public function signReward()
|
|
{
|
|
$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 + 1, '没有这个玩家');
|
|
return;
|
|
}
|
|
$row = $conn->execQueryOne('SELECT signable FROM sign WHERE accountid=:accountid AND sign_id=:sign_id;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':sign_id' => $_REQUEST['sign_id'],
|
|
));
|
|
if (!$row || $row['signable'] == 1) {
|
|
phpcommon\sendError(ERR_USER_BASE + 2, '已签到');
|
|
return;
|
|
}
|
|
$ret = $conn->execScript('UPDATE sign SET sign_time=:sign_time, signable=1, modify_time=:modify_time ' .
|
|
' WHERE accountid=:accountid AND sign_id=:sign_id;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':sign_id' => $_REQUEST['sign_id'],
|
|
':sign_time' => time(),
|
|
':modify_time' => time()
|
|
));
|
|
if (!$ret) {
|
|
die();
|
|
return;
|
|
}
|
|
$rowUser = $conn->execQueryOne('SELECT sign_sum FROM user WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
|
|
|
|
//获得奖励
|
|
//判断当前第几周
|
|
$item_list = array();
|
|
$week = ceil($rowUser['sign_sum'] / 7);
|
|
$dayid = ($week - 1) * 7 + $_REQUEST['sign_id'];
|
|
//如果大于配置表最后一周,按最后一周奖励
|
|
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
|
|
if ($dayid > count($g_conf_sign_cluster)) {
|
|
$dayid = count($g_conf_sign_cluster) - 7;
|
|
}
|
|
//$dayid = $_REQUEST['sign_id'];
|
|
$s = $this->getSign($dayid + 90000);
|
|
$item_id_array = $this->getExplode($s['item_id']);
|
|
$num_array = $this->getExplode($s['num']);
|
|
$time_array = $this->getExplode($s['time']);
|
|
$addreward = new classes\AddReward();
|
|
$all_item_list = array();
|
|
for ($i = 0; $i < count($item_id_array); $i++) {
|
|
$item_id = $item_id_array[$i][0];
|
|
$num = $num_array[$i][0];
|
|
$time = $time_array[$i][0];
|
|
array_push($item_list, array(
|
|
'item_id' => $item_id,
|
|
'item_num' => $num,
|
|
'time' => $time,
|
|
));
|
|
$items = $addreward->addReward($item_id, $num, $account_id, $time,0);
|
|
|
|
foreach($items as $j) {
|
|
array_push($all_item_list, array(
|
|
'item_id' => $j['item_id'],
|
|
'item_num' => $j['item_num'],
|
|
'time' => $j['time'],
|
|
));
|
|
}
|
|
}
|
|
//$addreward = new classes\AddReward();
|
|
//$addreward->addReward($item_id, $num, $account_id);
|
|
$coin_num = $addreward->getCoinNum($account_id);
|
|
$diamond_num = $addreward->getDiamondNum($account_id);
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'item_list' => $item_list,
|
|
'coin_nums' => $coin_num,
|
|
'diamond_nums' => $diamond_num,
|
|
'all_item_list' => $all_item_list
|
|
));
|
|
|
|
}
|
|
|
|
public function signDoubleReward()
|
|
{
|
|
$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 + 1, '没有这个玩家');
|
|
return;
|
|
}
|
|
$row = $conn->execQueryOne('SELECT signable FROM sign WHERE accountid=:accountid AND sign_id=:sign_id;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':sign_id' => $_REQUEST['sign_id'],
|
|
));
|
|
if (!$row || $row['signable'] == 1) {
|
|
phpcommon\sendError(ERR_USER_BASE + 2, '已签到');
|
|
return;
|
|
}
|
|
$ret = $conn->execScript('UPDATE sign SET sign_time=:sign_time, signable=1, modify_time=:modify_time ' .
|
|
' WHERE accountid=:accountid AND sign_id=:sign_id;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':sign_id' => $_REQUEST['sign_id'],
|
|
':sign_time' => time(),
|
|
':modify_time' => time()
|
|
));
|
|
if (!$ret) {
|
|
die();
|
|
return;
|
|
}
|
|
$rowUser = $conn->execQueryOne('SELECT sign_sum FROM user WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
//获得奖励
|
|
//判断当前第几周
|
|
$item_list = array();
|
|
$week = ceil($rowUser['sign_sum'] / 7);
|
|
$dayid = ($week - 1) * 7 + $_REQUEST['sign_id'];
|
|
//如果大于配置表最后一周,按最后一周奖励
|
|
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
|
|
if ($dayid > count($g_conf_sign_cluster)) {
|
|
$dayid = count($g_conf_sign_cluster) - 7;
|
|
|
|
}
|
|
//$dayid = $_REQUEST['sign_id'];
|
|
$s = $this->getSign($dayid + 90000);
|
|
$item_id_array = $this->getExplode($s['item_id']);
|
|
$num_array = $this->getExplode($s['num']);
|
|
$time_array = $this->getExplode($s['time']);
|
|
$addreward = new classes\AddReward();
|
|
$all_item_list = array();
|
|
for ($addtimes = 0; $addtimes < 2; $addtimes++) {
|
|
for ($i = 0; $i < count($item_id_array); $i++) {
|
|
$item_id = $item_id_array[$i][0];
|
|
$num = $num_array[$i][0];
|
|
$time = $time_array[$i][0];
|
|
array_push($item_list, array(
|
|
'item_id' => $item_id,
|
|
'item_num' => $num,
|
|
'time' => $time,
|
|
));
|
|
$items = $addreward->addReward($item_id, $num, $account_id, $time,0);
|
|
|
|
foreach($items as $j) {
|
|
array_push($all_item_list, array(
|
|
'item_id' => $j['item_id'],
|
|
'item_num' => $j['item_num'],
|
|
'time' => $j['time'],
|
|
));
|
|
}
|
|
}
|
|
}
|
|
//$addreward = new classes\AddReward();
|
|
//$addreward->addReward($item_id, $num, $account_id);
|
|
$coin_num = $addreward->getCoinNum($account_id);
|
|
$diamond_num = $addreward->getDiamondNum($account_id);
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'item_list' => $item_list,
|
|
'coin_nums' => $coin_num,
|
|
'diamond_nums' => $diamond_num,
|
|
'all_item_list' => $all_item_list
|
|
));
|
|
}
|
|
|
|
protected function updateSignSum($account_id, $sign_num)
|
|
{
|
|
$conn = $this->getMysql($account_id);
|
|
if (!$conn) {
|
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
|
die();
|
|
}
|
|
$row = $conn->execQueryOne('SELECT sign_sum FROM user WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id
|
|
));
|
|
$ret = $conn->execScript('UPDATE user SET sign_sum=:sign_sum, modify_time=:modify_time ' .
|
|
' WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':sign_sum' => $row['sign_sum'] + $sign_num,
|
|
':modify_time' => time()
|
|
));
|
|
if (!$ret) {
|
|
die();
|
|
}
|
|
}
|
|
|
|
protected function updateDaily($account_id)
|
|
{
|
|
$conn = $this->getMysql($account_id);
|
|
if (!$conn) {
|
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
|
die();
|
|
}
|
|
//刷新每日任务和活动任务
|
|
$rowCount = $conn->execQueryRowCount('SELECT * FROM quest WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
));
|
|
if ($rowCount != 0) {
|
|
for ($i = 0; $i < $rowCount; $i++) {
|
|
$ret = $conn->execScript('UPDATE quest SET quest_state=:quest_state, quest_num=:quest_num, modify_time=:modify_time ' .
|
|
' WHERE accountid=:accountid AND quest_type=:quest_type1;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':quest_num' => 0,
|
|
':quest_type1' => 1,
|
|
':quest_state' => 0,
|
|
':modify_time' => time()
|
|
));
|
|
}
|
|
if (!$ret) {
|
|
die();
|
|
}
|
|
}
|
|
//刷新战斗结算奖励次数,商店刷新次数,客服, 每日免费金币钻石
|
|
$battle_ret = $conn->execScript('UPDATE user SET battle_re_times=0, diamond_shop_flush_times=0, shop_flush_times=0, free_coin=0, free_diamond=0, daily_order1=0, daily_order2=0, daily_order3=0, modify_time=:modify_time, free_box=0, update_time=:update_time ' .
|
|
' WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':modify_time' => time(),
|
|
':update_time' => time()
|
|
));
|
|
if (!$battle_ret) {
|
|
die();
|
|
}
|
|
|
|
//刷新邀请好友奖励
|
|
$rowShare = $conn->execQuery('SELECT ach_id, status FROM share_achievement WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
));
|
|
$order = 0;
|
|
$lastid = 0;
|
|
if (count($rowShare) != 0) {
|
|
foreach ($rowShare as $rs) {
|
|
if ($rs['status'] == 1) {
|
|
$order++;
|
|
}
|
|
$lastid = $rs['ach_id'];
|
|
}
|
|
if ($order >= count($rowShare)) {
|
|
//更新新的邀请列表
|
|
$s = $this->getShare($lastid);
|
|
if (!$s) {
|
|
die();
|
|
}
|
|
$share_meta_table = require('../res/share@share.php');
|
|
$type = $s['type'] + 1;
|
|
if ($lastid >= count($share_meta_table)) {
|
|
$type = $s['type'];
|
|
}
|
|
$count = 0;
|
|
for ($i = 1; $i <= count($share_meta_table); $i++) {
|
|
$s1 = $this->getShare($i);
|
|
if (!$s1 || $s1['type'] != $type) {
|
|
continue;
|
|
}
|
|
$id = $i;
|
|
$updateid = $rowShare[$count]['ach_id'];
|
|
$count++;
|
|
$share_ret = $conn->execScript('UPDATE share_achievement SET ach_id=:ach_id, status=0, modify_time=:modify_time ' .
|
|
' WHERE accountid=:accountid AND ach_id=:id;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':modify_time' => time(),
|
|
':ach_id' => $id,
|
|
':id' => $updateid
|
|
));
|
|
}
|
|
} else {
|
|
$share_ret = $conn->execScript('UPDATE share_achievement SET status=0, modify_time=:modify_time ' .
|
|
' WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':modify_time' => time(),
|
|
));
|
|
}
|
|
}
|
|
}
|
|
|
|
protected function updateWeekReward($account_id)
|
|
{
|
|
$conn = $this->getMysql($account_id);
|
|
if (!$conn) {
|
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
|
die();
|
|
}
|
|
$user_ret = $conn->execScript('UPDATE user SET pass_status=0, modify_time=:modify_time ' .
|
|
' WHERE accountid=:accountid;',
|
|
array(
|
|
':accountid' => $account_id,
|
|
':modify_time' => time()
|
|
));
|
|
if (!$user_ret) {
|
|
die();
|
|
}
|
|
}
|
|
|
|
public function getSignOrder()
|
|
{
|
|
$account_id = $_REQUEST['account_id'];
|
|
$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,
|
|
));
|
|
|
|
if (!$rowUser) {
|
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
|
return;
|
|
}
|
|
|
|
$week = ceil($rowUser['sign_sum'] / 7);
|
|
$dayid = ($week - 1) * 7;
|
|
$day = $rowUser['sign_sum'] % 7;
|
|
//如果大于配置表最后一周,按最后一周奖励
|
|
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
|
|
if ($dayid + 1 > count($g_conf_sign_cluster)) {
|
|
$dayid = count($g_conf_sign_cluster) - 7;
|
|
}
|
|
$sign_sum = $rowUser['sign_sum'];
|
|
$item_num = 0;
|
|
$item_name = '';
|
|
$item = $this->getSign(90000 + $day + $dayid);
|
|
if ($rowUser['sign_sum'] == 3) {
|
|
$item_name = '咸鱼套装(永久)';
|
|
} else if ($rowUser['sign_sum'] == 7) {
|
|
$item_name = '神秘宝箱';
|
|
} else {
|
|
$it = $this->getItem($item['item_id']);
|
|
$item_name = $it['name'];
|
|
$item_num = $item['num'];
|
|
}
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'sign_sum' => $sign_sum,
|
|
'item_name' => $item_name,
|
|
'item_num' => $item_num
|
|
));
|
|
}
|
|
}
|
|
?>
|