gamedb.sql
This commit is contained in:
parent
e6c845004a
commit
6e159539cc
@ -63,6 +63,7 @@ CREATE TABLE `user` (
|
|||||||
`battle_re_times` int(11) NOT NULL DEFAULT '0' COMMENT '每日战斗奖励次数',
|
`battle_re_times` int(11) NOT NULL DEFAULT '0' COMMENT '每日战斗奖励次数',
|
||||||
`shop_flush_times` int(11) NOT NULL DEFAULT '0' COMMENT '每日商店刷新次数',
|
`shop_flush_times` int(11) NOT NULL DEFAULT '0' COMMENT '每日商店刷新次数',
|
||||||
`kefu_status` int(11) NOT NULL DEFAULT '0' COMMENT '客服奖励状态(0:未领取,1:已领取)',
|
`kefu_status` int(11) NOT NULL DEFAULT '0' COMMENT '客服奖励状态(0:未领取,1:已领取)',
|
||||||
|
`sign_sum` int(11) NOT NULL DEFAULT '0' COMMENT '签到总天数',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `accountid` (`accountid`)
|
UNIQUE KEY `accountid` (`accountid`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
@ -146,12 +147,13 @@ DROP TABLE IF EXISTS `sign`;
|
|||||||
CREATE TABLE `sign` (
|
CREATE TABLE `sign` (
|
||||||
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||||
`sign_days` int(11) NOT NULL COMMENT '已签天数',
|
`sign_id` int(11) NOT NULL DEFAULT '0' COMMENT '补签id',
|
||||||
`sign_time` varchar(50) NOT NULL DEFAULT '签到时间',
|
`signable` int(11) NOT NULL DEFAULT '0' COMMENT '是否签到',
|
||||||
`create_time` int(11) NOT NULL COMMENT '创建时间',
|
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modify_time` int(11) NOT NULL COMMENT '修改时间',
|
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
`sign_time` int(11) NOT NULL DEFAULT '0' COMMENT '签到时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `accountid` (`accountid`)
|
UNIQUE KEY `account_sign_id` (`accountid`, `sign_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
|
||||||
@ -261,6 +263,22 @@ CREATE TABLE `share_achievement` (
|
|||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `activity`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client*/;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `activity` (
|
||||||
|
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||||
|
`free_times` int(11) NOT NULL DEFAULT '0' COMMENT '免费抽奖次数',
|
||||||
|
`video_times` int(11) NOT NULL DEFAULT '0' COMMENT '视频抽奖次数',
|
||||||
|
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品id',
|
||||||
|
`item_num` int(11) NOT NULL DEFAULT '0' COMMENT '物品数量',
|
||||||
|
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
UNIQUE KEY `accountid` (`accountid`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||||
|
@ -257,7 +257,7 @@ if __name__ == "__main__":
|
|||||||
lambda : readMysqlData(conf['rushtime'])
|
lambda : readMysqlData(conf['rushtime'])
|
||||||
)
|
)
|
||||||
|
|
||||||
conf['rushtime'] = 3600 * 17
|
conf['rushtime'] = 17 * 3600
|
||||||
tornado.ioloop.IOLoop.current().call_later(getDaySeconds(time.time(), 1) + conf['rushtime'],
|
tornado.ioloop.IOLoop.current().call_later(getDaySeconds(time.time(), 1) + conf['rushtime'],
|
||||||
lambda : dayReadMysqlData(conf['rushtime'])
|
lambda : dayReadMysqlData(conf['rushtime'])
|
||||||
)
|
)
|
||||||
|
@ -141,5 +141,16 @@ function getShareConfig($share_table, $share_id)
|
|||||||
return array_key_exists($share_id, $share_table) ? $share_table[$share_id] : null;
|
return array_key_exists($share_id, $share_table) ? $share_table[$share_id] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLotteryConfig($lot_table, $lot_id)
|
||||||
|
{
|
||||||
|
$lot_id = (int)$lot_id;
|
||||||
|
return array_key_exists($lot_id, $lot_table) ? $lot_table[$lot_id] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRandrewardConfig($re_table, $re_id)
|
||||||
|
{
|
||||||
|
$re_id = (int)$re_id;
|
||||||
|
return array_key_exists($re_id, $re_table) ? $re_table[$re_id] : null;
|
||||||
|
}
|
||||||
checkMysqlConfig();
|
checkMysqlConfig();
|
||||||
checkRedisConfig();
|
checkRedisConfig();
|
||||||
|
@ -69,6 +69,8 @@ define('FREE_DRESS_MAX_TIME', 30); //免费获取皮肤次数上限
|
|||||||
define('RAND_SHOP_GOLD', 39); //商店金币刷新价格
|
define('RAND_SHOP_GOLD', 39); //商店金币刷新价格
|
||||||
define('MAX_BATTLE_REWARD', 40); //战斗额外奖励次数
|
define('MAX_BATTLE_REWARD', 40); //战斗额外奖励次数
|
||||||
define('MAX_SHOP_REFRESH', 41); //每日商店刷新次数
|
define('MAX_SHOP_REFRESH', 41); //每日商店刷新次数
|
||||||
|
define('FREELOTTERY_TIME', 45); //免费抽奖次数
|
||||||
|
define('VIDEOLOTTERY_TIME', 46); //视频抽奖次数
|
||||||
require 'config_loader.php';
|
require 'config_loader.php';
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require 'classes/Quest.php';
|
require 'classes/Quest.php';
|
||||||
|
require 'classes/AddReward.php';
|
||||||
|
|
||||||
class ActivityController{
|
class ActivityController{
|
||||||
|
|
||||||
@ -17,36 +18,28 @@ class ActivityController{
|
|||||||
return $conn;
|
return $conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getRedis($shop_uuid)
|
||||||
protected function getActivityConfig($activity_id)
|
|
||||||
{
|
{
|
||||||
$g_conf_activity_cluster = require('../res/activity@activity.php');
|
$redis_conf = getRedisConfig(crc32($shop_uuid));
|
||||||
$activity_conf = getActivityConfig($g_conf_activity_cluster, $activity_id);
|
$r = new phpcommon\Redis(array(
|
||||||
$a = array(
|
'host' => $redis_conf['host'],
|
||||||
'id' => $activity_conf['id'],
|
'port' => $redis_conf['port'],
|
||||||
'name' => $activity_conf['name'],
|
'passwd' => $redis_conf['passwd']
|
||||||
'des' => $activity_conf['des'],
|
|
||||||
'start_date' => $activity_conf['start_date'],
|
));
|
||||||
'end_date' => $activity_conf['end_date'],
|
return $r;
|
||||||
);
|
|
||||||
return $a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getActivityRewardConfig($activityReward_id)
|
protected function getParameter($para_id)
|
||||||
{
|
{
|
||||||
$g_conf_activityReward_cluster = require('../res/activityReward@activityReward.php');
|
$parameter_meta_cluster = require('../res/parameter@parameter.php');
|
||||||
$activityReward_conf = getActivityRewardConfig($g_conf_activityReward_cluster, $activityReward_id);
|
$parameter_meta = getParameterConfig($parameter_meta_cluster, $para_id);
|
||||||
$act = array(
|
$p = array(
|
||||||
'id' => $activityReward_conf['id'],
|
'id' => $parameter_meta['id'],
|
||||||
'activity_id' => $activityReward_conf['activity_id'],
|
'name' => $parameter_meta['param_name'],
|
||||||
'condition' => $activityReward_conf['condition'],
|
'value' => $parameter_meta['param_value'],
|
||||||
'parameter' => $activityReward_conf['parameter'],
|
|
||||||
'start_end_time' => $activityReward_conf['start_end_time'],
|
|
||||||
'activity_reward' => $activityReward_conf['activity_reward'],
|
|
||||||
'exchange_num' => $activityReward_conf['exchange_num'],
|
|
||||||
'exchange_item' => $activityReward_conf['exchange_item']
|
|
||||||
);
|
);
|
||||||
return $act;
|
return $p;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getExplode($string)
|
protected function getExplode($string)
|
||||||
@ -62,7 +55,34 @@ class ActivityController{
|
|||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activityInfo()
|
protected function getLottery($lot_id)
|
||||||
|
{
|
||||||
|
$g_conf_lot_cluster = require('../res/lottery@lottery.php');
|
||||||
|
$lot_conf = getLotteryConfig($g_conf_lot_cluster, $lot_id);
|
||||||
|
$l = array(
|
||||||
|
'id' => $lot_conf['id'],
|
||||||
|
'item_id' => $lot_conf['item_id'],
|
||||||
|
'num' => $lot_conf['num'],
|
||||||
|
'weight' => $lot_conf['weight'],
|
||||||
|
'jilv' => $lot_conf['jilv'],
|
||||||
|
);
|
||||||
|
return $l;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getreward($re_id)
|
||||||
|
{
|
||||||
|
$g_conf_re_cluster = require('../res/randreward@randreward.php');
|
||||||
|
$re_conf = getRandrewardConfig($g_conf_re_cluster, $re_id);
|
||||||
|
$re = array(
|
||||||
|
'id' => $re_conf['id'],
|
||||||
|
'reward' => $re_conf['reward'],
|
||||||
|
'number' => $re_conf['number'],
|
||||||
|
'weight' => $re_conf['weight'],
|
||||||
|
);
|
||||||
|
return $re;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function luckDrawInfo()
|
||||||
{
|
{
|
||||||
$account_id = $_REQUEST['account_id'];
|
$account_id = $_REQUEST['account_id'];
|
||||||
//登录校验
|
//登录校验
|
||||||
@ -71,222 +91,35 @@ class ActivityController{
|
|||||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = $this->getMysql($account_id);
|
$conn = $this->getMysql($account_id);
|
||||||
$activity_list = array();
|
|
||||||
$activity_skin_list = array();
|
|
||||||
$activity_quest_list = array();
|
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//活动列表
|
|
||||||
$g_conf_activity_cluster = require('../res/activity@activity.php');
|
$draw_uuid = 'game2001api_draw_uuid:' . md5($_REQUEST['account_id']);
|
||||||
for ($i = 1; $i <= count($g_conf_activity_cluster); $i++) {
|
$draw_list = array();
|
||||||
$start_status = 0;
|
$r = $this->getRedis($draw_uuid);
|
||||||
$a = $this->getActivityConfig($i);
|
if (!$r) {
|
||||||
if (time() >= $a['start_date'] && time() < $a['end_date']) {
|
|
||||||
$start_status = 1;
|
|
||||||
} else {
|
|
||||||
$ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num, modify_time=:modify_time ' .
|
|
||||||
' WHERE accountid=:accountid AND skin_type=2;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':fragment_num' => 0,
|
|
||||||
':modify_time' => time()
|
|
||||||
));
|
|
||||||
if(!$ret){
|
|
||||||
die();
|
die();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
//刷新次数
|
||||||
array_push($activity_list, array(
|
$p_free = $this->getParameter(FREELOTTERY_TIME);
|
||||||
'activity_id' => $a['id'],
|
$p_video = $this->getParameter(VIDEOLOTTERY_TIME);
|
||||||
'start_time' => $a['start_date'],
|
$free_times = $p_free['value'];
|
||||||
'end_time' => $a['end_date'],
|
$video_times = $p_video['value'];
|
||||||
'status' => $start_status
|
$row = $conn->execQueryOne('SELECT free_times, video_times FROM activity WHERE accountid=:accountid;',
|
||||||
));
|
|
||||||
}
|
|
||||||
//求生庆典活动
|
|
||||||
$rowSkin = $conn->execQuery('SELECT * FROM skin WHERE accountid=:accountid AND skin_type=:skin_type;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':skin_type' => 2
|
|
||||||
));
|
|
||||||
foreach ($rowSkin as $skin) {
|
|
||||||
array_push($activity_skin_list, array(
|
|
||||||
'id' => $skin['skin_id'],
|
|
||||||
'num' => $skin['fragment_num'],
|
|
||||||
'exchange_status' => $skin['skin_status'],
|
|
||||||
'collect_status' => $skin['fragment_status']
|
|
||||||
));
|
|
||||||
}
|
|
||||||
//分享好礼活动
|
|
||||||
$row = $conn->execQueryOne('SELECT act_share_status, act_share_time FROM user WHERE accountid=:accountid;',
|
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id
|
':accountid' => $account_id
|
||||||
));
|
));
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
$ret = $conn->execScript('INSERT INTO activity(accountid, free_times, video_times, item_id, item_num, create_time, modify_time) ' .
|
||||||
return;
|
' VALUES(:accountid, 0, 0, 0, 0, :create_time, :modify_time) ' .
|
||||||
}
|
' ON DUPLICATE KEY UPDATE accountid=:accountid, free_times=0, video_times=0, item_id=0, item_num=0, modify_time=:modify_time;',
|
||||||
$receive_status = $row['act_share_status'];
|
|
||||||
if (phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($row['act_share_time']) > 0
|
|
||||||
&& $row['act_share_status'] == 1)
|
|
||||||
{
|
|
||||||
$receive_status = 0;
|
|
||||||
$ret = $conn->execScript('UPDATE user SET act_share_status=:act_share_status, modify_time=:modify_time ' .
|
|
||||||
' WHERE accountid=:accountid;',
|
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id,
|
':accountid' => $account_id,
|
||||||
':act_share_status' => $receive_status,
|
|
||||||
':modify_time' => time()
|
|
||||||
));
|
|
||||||
if (!$ret) {
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//任务活动
|
|
||||||
$rows = $conn->execQuery('SELECT * FROM quest WHERE accountid=:accountid AND quest_type=:quest_type;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':quest_type' => 3
|
|
||||||
));
|
|
||||||
foreach ($rows as $r) {
|
|
||||||
array_push($activity_quest_list, array(
|
|
||||||
'id' => $r['quest_id'],
|
|
||||||
'num' => $r['quest_num'],
|
|
||||||
'status' => $r['quest_state']
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode(array(
|
|
||||||
'errcode' => 0,
|
|
||||||
'errmsg' => '',
|
|
||||||
'activity_list' => $activity_list,
|
|
||||||
'activity_id1' => 1,
|
|
||||||
'activity_skin_list' => $activity_skin_list,
|
|
||||||
'activity_id2' => 2,
|
|
||||||
'receive_status' => $receive_status,
|
|
||||||
'activity_id3' => 3,
|
|
||||||
'activity_quest_list' => $activity_quest_list
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function triggerActivity()
|
|
||||||
{
|
|
||||||
$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);
|
|
||||||
$activity_id = $_REQUEST['activity_id'];
|
|
||||||
$type = $_REQUEST['type'];
|
|
||||||
if (!$conn) {
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$act = $this->getActivityRewardConfig($activity_id);
|
|
||||||
$array = $this->getExplode($act['activity_reward']);
|
|
||||||
switch ($type)
|
|
||||||
{
|
|
||||||
case 1: //活动皮肤碎片收集
|
|
||||||
{
|
|
||||||
$item_id = $array[0][0];
|
|
||||||
$item_num = $array[0][1];
|
|
||||||
$rowSkin = $conn->execQueryOne('SELECT * FROM skin WHERE accountid=:accountid AND fragment_id=:fragment_id;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':fragment_id' => $item_id
|
|
||||||
));
|
|
||||||
if ($rowSkin['fragment_status'] != 0) {
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 2, '今天已收集');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($rowSkin['fragment_num'] + $item_num >= $act['exchange_num']) {
|
|
||||||
$skin_status = 2;
|
|
||||||
} else {
|
|
||||||
$skin_status = 3;
|
|
||||||
}
|
|
||||||
$ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num, skin_status=:skin_status, fragment_status=1, modify_time=:modify_time ' .
|
|
||||||
' WHERE accountid=:accountid AND fragment_id=:fragment_id;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':skin_status' => $skin_status,
|
|
||||||
':fragment_id' => $item_id,
|
|
||||||
':fragment_num' => $item_num + $rowSkin['fragment_num'],
|
|
||||||
':modify_time' => time()
|
|
||||||
));
|
|
||||||
if (!$ret) {
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2: //活动皮肤兑换
|
|
||||||
{
|
|
||||||
$arr = $this->getExplode($act['exchange_item']);
|
|
||||||
$row = $conn->execQueryOne('SELECT * FROM skin WHERE accountid = :account_id AND skin_id = :skin_id;',
|
|
||||||
array(
|
|
||||||
':account_id' => $account_id,
|
|
||||||
':skin_id' => $arr[0][0]
|
|
||||||
));
|
|
||||||
if(!$row){
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个皮肤');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($row['skin_status'] == 2) {
|
|
||||||
$fragment_num = $row['fragment_num'] - $act['exchange_num'];
|
|
||||||
$time = time();
|
|
||||||
$ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num, skin_status=1, active_time=:active_time, modify_time=:modify_time ' .
|
|
||||||
' WHERE accountid=:account_id AND skin_id=:skin_id;',
|
|
||||||
array(
|
|
||||||
':account_id' => $account_id,
|
|
||||||
':skin_id' => $arr[0][0],
|
|
||||||
':active_time' => $time,
|
|
||||||
':fragment_num' => $fragment_num,
|
|
||||||
':modify_time' => time()
|
|
||||||
));
|
|
||||||
if(!$ret){
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3: //活动补给箱领取
|
|
||||||
{
|
|
||||||
$ret = $conn->execScript('UPDATE user SET act_share_status=1, act_share_time=:act_share_time, modify_time=:modify_time ' .
|
|
||||||
' WHERE accountid=:accountid;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':act_share_time' => time(),
|
|
||||||
':modify_time' => time()
|
|
||||||
));
|
|
||||||
if (!$ret) {
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for ($i = 0; $i < count($array); $i++) {
|
|
||||||
$item_id = $array[$i][0];
|
|
||||||
$item_num = $array[$i][1];
|
|
||||||
$row = $conn->execQueryOne('SELECT * FROM supplybox WHERE accountid=:account_id AND box_id=:box_id;',
|
|
||||||
array(
|
|
||||||
':account_id' => $account_id,
|
|
||||||
':box_id' => $item_id
|
|
||||||
));
|
|
||||||
if (!$row) {
|
|
||||||
$ret = $conn->execScript('INSERT INTO supplybox(accountid, box_id, box_num, buy_times, last_buy_time, create_time, modify_time) ' .
|
|
||||||
' VALUES(:accountid, :box_id, :box_num, 0, 0, :create_time, :modify_time) ' .
|
|
||||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, box_id=:box_id, box_num=:box_num, buy_times=0, last_buy_time=0, modify_time=:modify_time;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':box_id' => $item_id,
|
|
||||||
':box_num' => 1,
|
|
||||||
':create_time' => time(),
|
':create_time' => time(),
|
||||||
':modify_time' => time()
|
':modify_time' => time()
|
||||||
));
|
));
|
||||||
@ -294,77 +127,400 @@ class ActivityController{
|
|||||||
die();
|
die();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$free_times = $p_free['value'];
|
||||||
|
$video_times = $p_video['value'];
|
||||||
} else {
|
} else {
|
||||||
$ret = $conn->execScript('UPDATE supplybox SET box_num=:box_num, modify_time=:modify_time ' .
|
$free_times = $p_free['value'] - $row['free_times'];
|
||||||
' WHERE accountid=:accountid AND box_id=:box_id;',
|
$video_times = $p_video['value'] - $row['video_times'];
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':box_id' => $item_id,
|
|
||||||
':box_num' => $row['box_num'] + $item_num,
|
|
||||||
':modify_time' => time()
|
|
||||||
));
|
|
||||||
if (!$ret) {
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
//道具物品
|
||||||
break;
|
$user_db_str = $r->get($draw_uuid);
|
||||||
}
|
if (empty($user_db_str)) {
|
||||||
case 4: //活动任务奖励
|
$draw_list = $this->randomReward();
|
||||||
{
|
$draw_db = array(
|
||||||
$row = $conn->execQueryOne('SELECT * FROM quest WHERE accountid=:accountid AND quest_id=:quest_id AND quest_type=:quest_type;',
|
'draw_uuid' => $draw_uuid,
|
||||||
array(
|
'draw_list' => $draw_list,
|
||||||
':accountid' => $account_id,
|
);
|
||||||
':quest_id' => $activity_id,
|
$r -> set($draw_uuid, json_encode($draw_db));
|
||||||
':quest_type' => 3
|
$r -> pexpire($draw_uuid, 1000 * 3600 * 24);
|
||||||
));
|
} else {
|
||||||
if (!$row) {
|
$rowTime = $conn->execQueryOne('SELECT modify_time FROM activity WHERE accountid=:accountid;',
|
||||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个任务');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($row['quest_state'] == 1) {
|
|
||||||
$ret = $conn->execScript('UPDATE quest SET quest_state=:quest_state, modify_time=:modify_time ' .
|
|
||||||
' WHERE accountid=:accountid AND quest_id =:quest_id AND quest_type=:quest_type;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':quest_id' => $activity_id,
|
|
||||||
':quest_type' => 3,
|
|
||||||
':quest_state' => 2,
|
|
||||||
':modify_time' => time()
|
|
||||||
));
|
|
||||||
if (!$ret) {
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$item_id = $array[0][0];
|
|
||||||
$item_num = $array[0][1];
|
|
||||||
$row1 = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id
|
':accountid' => $account_id
|
||||||
));
|
));
|
||||||
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time' .
|
if (phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($rowTime['modify_time']) > 0) {
|
||||||
' WHERE accountid=:accountid;',
|
$draw_list = $this->randomReward();
|
||||||
array(
|
$draw_db = array(
|
||||||
':accountid' => $account_id,
|
'draw_uuid' => $draw_uuid,
|
||||||
':coin_num' => $item_num + $row1['coin_num'],
|
'draw_list' => $draw_list,
|
||||||
':modify_time' => time()
|
);
|
||||||
));
|
$r -> set($draw_uuid, json_encode($draw_db));
|
||||||
if (!$ret) {
|
$r -> pexpire($draw_uuid, 1000 * 3600 * 24);
|
||||||
die();
|
} else {
|
||||||
|
$user_db = json_decode($user_db_str, true);
|
||||||
|
if (empty($user_db)) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
foreach ($user_db['draw_list'] as $draw) {
|
||||||
|
array_push($draw_list, array(
|
||||||
|
'item_id' => $draw['item_id'],
|
||||||
|
'item_num' => $draw['item_num'],
|
||||||
|
));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'errcode' => 0,
|
'errcode' => 0,
|
||||||
'errmsg' => '',
|
'errmsg'=> '',
|
||||||
|
'draw_uuid' => $draw_uuid,
|
||||||
|
'free_times' => $free_times,
|
||||||
|
'video_times' => $video_times,
|
||||||
|
'item_list' => $draw_list,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLuckDraw()
|
||||||
|
{
|
||||||
|
$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 free_times, video_times FROM activity WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id
|
||||||
|
));
|
||||||
|
if (!$row) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($_REQUEST['type'] == 0) {
|
||||||
|
$p_flush = $this->getParameter(FREELOTTERY_TIME);
|
||||||
|
if ($p_flush['value'] <= $row['free_times']) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 3, '今日刷新次数已满');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$ret = $conn->execScript('UPDATE activity SET free_times=:free_times, item_id=:item_id, item_num=:item_num, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':free_times' => $row['free_times'] + 1,
|
||||||
|
':item_id' => $item_id,
|
||||||
|
':item_num' => $item_num,
|
||||||
|
':modify_time' => time()
|
||||||
|
));
|
||||||
|
if (!$ret) {
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($_REQUEST['type'] == 1) {
|
||||||
|
$p_flush = $this->getParameter(VIDEOLOTTERY_TIME);
|
||||||
|
if ($p_flush['value'] <= $row['video_times']) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 3, '今日刷新次数已满');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$ret = $conn->execScript('UPDATE activity SET video_times=:video_times,item_id=:item_id, item_num=:item_num, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':video_times' => $row['video_times'] + 1,
|
||||||
|
':item_id' => $item_id,
|
||||||
|
':item_num' => $item_num,
|
||||||
|
':modify_time' => time()
|
||||||
|
));
|
||||||
|
if (!$ret) {
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//随机确认奖励
|
||||||
|
$weight_sum = 0;
|
||||||
|
$g_conf_lot_cluster = require('../res/lottery@lottery.php');
|
||||||
|
for ($i = 1; $i <= count($g_conf_lot_cluster); $i++) {
|
||||||
|
$l = $this->getLottery($i);
|
||||||
|
$weight_sum += $l['jilv'];
|
||||||
|
}
|
||||||
|
$random = Rand(0, $weight_sum);
|
||||||
|
$weight = 0;
|
||||||
|
for ($ii = 0; $ii < count($g_conf_lot_cluster); $ii++) {
|
||||||
|
$l = $this->getLottery($ii);
|
||||||
|
$weight += $l['jilv'];
|
||||||
|
if ($weight > $random) {
|
||||||
|
$key = $ii;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$draw_uuid = $_REQUEST['draw_uuid'];
|
||||||
|
$item_id = 0;
|
||||||
|
$item_num = 0;
|
||||||
|
$flag = 0;
|
||||||
|
$r = $this->getRedis($draw_uuid);
|
||||||
|
$user_db_str = $r->get($draw_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['draw_list'] as $draw) {
|
||||||
|
if ($draw['key'] == $key + 1) {
|
||||||
|
$item_id = $draw['item_id'];
|
||||||
|
$item_num = $draw['item_num'];
|
||||||
|
$flag = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($flag == 0) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个物品');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//增加奖励
|
||||||
|
$addreward = new classes\AddReward();
|
||||||
|
$addreward->addReward($item_id, $item_num, $account_id);
|
||||||
|
//刷新奖励
|
||||||
|
$draw_list = $this->randomReward();
|
||||||
|
$draw_db = array(
|
||||||
|
'draw_uuid' => $draw_uuid,
|
||||||
|
'draw_list' => $draw_list,
|
||||||
|
);
|
||||||
|
$r -> set($draw_uuid, json_encode($draw_db));
|
||||||
|
$r -> pexpire($draw_uuid, 1000 * 3600 * 24);
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg'=> '',
|
||||||
|
'item_id' => $item_id,
|
||||||
|
'item_num' => $item_num,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function doubleLuckDraw()
|
||||||
|
{
|
||||||
|
$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 item_id, item_num FROM activity WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id
|
||||||
|
));
|
||||||
|
if (!$row) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//增加奖励
|
||||||
|
$addreward = new classes\AddReward();
|
||||||
|
$addreward->addReward($row['item_id'], $row['item_num'], $account_id);
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg'=> '',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function randomReward()
|
||||||
|
{
|
||||||
|
$draw_list = array();
|
||||||
|
$g_conf_lot_cluster = require('../res/lottery@lottery.php');
|
||||||
|
for ($i = 1; $i <= count($g_conf_lot_cluster); $i++) {
|
||||||
|
$item_id = 0;
|
||||||
|
$item_num = 0;
|
||||||
|
$key = 0;
|
||||||
|
$l = $this->getLottery($i);
|
||||||
|
//确定商品id和数量
|
||||||
|
$weight_sum = 0;
|
||||||
|
$weight_array = $this->getExplode($l['weight']);
|
||||||
|
for ($ii = 0; $ii < count($weight_array); $ii++) {
|
||||||
|
$weight_sum += $weight_array[$ii][0];
|
||||||
|
}
|
||||||
|
$random = Rand(0, $weight_sum);
|
||||||
|
$weight = 0;
|
||||||
|
for ($ii = 0; $ii < count($weight_array); $ii++) {
|
||||||
|
$weight += $weight_array[$ii][0];
|
||||||
|
if ($weight > $random) {
|
||||||
|
$key = $ii;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$item_id_array = $this->getExplode($l['item_id']);
|
||||||
|
$num_array = $this->getExplode($l['num']);
|
||||||
|
$item_id = $item_id_array[$key][0];
|
||||||
|
$item_num = $num_array[$key][0];
|
||||||
|
array_push($draw_list, array(
|
||||||
|
'key' => $i,
|
||||||
|
'item_id' => $item_id,
|
||||||
|
'item_num' => $item_num,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return $draw_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function randRewardInfo()
|
||||||
|
{
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$randreward_uuid = 'game2001api_randreward_uuid:' . md5($_REQUEST['account_id']);
|
||||||
|
$randreward_list = array();
|
||||||
|
$r = $this->getRedis($randreward_uuid);
|
||||||
|
if (!$r) {
|
||||||
|
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);
|
||||||
|
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_uuid'] as $randreward) {
|
||||||
|
//增加奖励
|
||||||
|
$addreward = new classes\AddReward();
|
||||||
|
$addreward->addReward($randreward['item_id'], $randreward['item_num'], $account_id);
|
||||||
|
}
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg'=> '',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function doubleRandReward()
|
||||||
|
{
|
||||||
|
$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_uuid'] as $randreward) {
|
||||||
|
//增加奖励
|
||||||
|
$addreward = new classes\AddReward();
|
||||||
|
$addreward->addReward($randreward['item_id'], $randreward['item_num'], $account_id);
|
||||||
|
}
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg'=> '',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getRandomReward()
|
||||||
|
{
|
||||||
|
$randreward_list = array();
|
||||||
|
$g_conf_re_cluster = require('../res/randreward@randreward.php');
|
||||||
|
for ($i = 1; $i <= count($g_conf_re_cluster); $i++) {
|
||||||
|
$item_id = 0;
|
||||||
|
$item_num = 0;
|
||||||
|
$key = 0;
|
||||||
|
$re = $this->getrandreward($i);
|
||||||
|
//确定商品id和数量
|
||||||
|
$weight_sum = 0;
|
||||||
|
$weight_array = $this->getExplode($re['weight']);
|
||||||
|
for ($ii = 0; $ii < count($weight_array); $ii++) {
|
||||||
|
$weight_sum += $weight_array[$ii][0];
|
||||||
|
}
|
||||||
|
$random = Rand(0, $weight_sum);
|
||||||
|
$weight = 0;
|
||||||
|
for ($ii = 0; $ii < count($weight_array); $ii++) {
|
||||||
|
$weight += $weight_array[$ii][0];
|
||||||
|
if ($weight > $random) {
|
||||||
|
$key = $ii;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$item_id_array = $this->getExplode($re['reward']);
|
||||||
|
$num_array = $this->getExplode($l['number']);
|
||||||
|
$item_id = $item_id_array[$key][0];
|
||||||
|
$item_num = $num_array[$key][0];
|
||||||
|
array_push($randreward_list, array(
|
||||||
|
'item_id' => $item_id,
|
||||||
|
'item_num' => $item_num,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return $randreward_list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -100,9 +100,9 @@ class RoleController{
|
|||||||
':accountid' => $account_id
|
':accountid' => $account_id
|
||||||
));
|
));
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status) ' .
|
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum) ' .
|
||||||
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, create_time, :modify_time, 0, 0, 0, 0, 0, 0) ' .
|
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0) ' .
|
||||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0;',
|
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0;',
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id,
|
':accountid' => $account_id,
|
||||||
':user_name' => $user_name,
|
':user_name' => $user_name,
|
||||||
@ -290,15 +290,6 @@ class RoleController{
|
|||||||
$quest->triggerQuest(QUEST_SUM_TEAMWIN, 2, 1, $account_id);
|
$quest->triggerQuest(QUEST_SUM_TEAMWIN, 2, 1, $account_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//触发活动任务
|
|
||||||
/*$act = $this->getActivityRewardConfig(QUEST_ACTIVITY_LOGIN);
|
|
||||||
$array = $this->getExplode($act['start_end_time']);
|
|
||||||
$nowTime = phpcommon\getdayseconds(time());
|
|
||||||
$start_time = $array[0][0] * 3600 + $array[0][1] * 60 + $nowTime;
|
|
||||||
$end_time = $array[1][0] * 3600 + $array[1][1] * 60 + $nowTime;
|
|
||||||
if (time() >= $start_time && time() < $start_time) {
|
|
||||||
$quest->triggerQuest(QUEST_ACTIVITY_GAME, 3, 1, $account_id);
|
|
||||||
}*/
|
|
||||||
//额外奖励
|
//额外奖励
|
||||||
$times = $this->getRewardTimes($coin_num);
|
$times = $this->getRewardTimes($coin_num);
|
||||||
$extra_coin = $coin_num * ($times - 1);
|
$extra_coin = $coin_num * ($times - 1);
|
||||||
|
@ -31,23 +31,6 @@ class SignController{
|
|||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getActivityRewardConfig($activityReward_id)
|
|
||||||
{
|
|
||||||
$g_conf_activityReward_cluster = require('../res/activityReward@activityReward.php');
|
|
||||||
$activityReward_conf = getActivityRewardConfig($g_conf_activityReward_cluster, $activityReward_id);
|
|
||||||
$act = array(
|
|
||||||
'id' => $activityReward_conf['id'],
|
|
||||||
'activity_id' => $activityReward_conf['activity_id'],
|
|
||||||
'condition' => $activityReward_conf['condition'],
|
|
||||||
'parameter' => $activityReward_conf['parameter'],
|
|
||||||
'start_end_time' => $activityReward_conf['start_end_time'],
|
|
||||||
'activity_reward' => $activityReward_conf['activity_reward'],
|
|
||||||
'exchange_num' => $activityReward_conf['exchange_num'],
|
|
||||||
'exchange_item' => $activityReward_conf['exchange_item']
|
|
||||||
);
|
|
||||||
return $act;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getExplode($string)
|
protected function getExplode($string)
|
||||||
{
|
{
|
||||||
$delim = "|";
|
$delim = "|";
|
||||||
@ -73,6 +56,28 @@ class SignController{
|
|||||||
return $p;
|
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()
|
public function signInfo()
|
||||||
{
|
{
|
||||||
$account_id = $_REQUEST['account_id'];
|
$account_id = $_REQUEST['account_id'];
|
||||||
@ -84,127 +89,89 @@ class SignController{
|
|||||||
}
|
}
|
||||||
$conn = $this->getMysql($account_id);
|
$conn = $this->getMysql($account_id);
|
||||||
$sign_days = 0;
|
$sign_days = 0;
|
||||||
$signable = 1;
|
|
||||||
if (!$conn) {
|
if (!$conn) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$row1 = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id
|
|
||||||
));
|
|
||||||
|
|
||||||
$row = $conn->execQueryOne('SELECT * FROM sign WHERE accountid=:accountid;',
|
$rows = $conn->execQuery('SELECT sign_id, sign_time FROM sign WHERE accountid=:accountid;',
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id
|
':accountid' => $account_id
|
||||||
));
|
));
|
||||||
$nowTime = phpcommon\getdayseconds(time());
|
$nowTime = phpcommon\getdayseconds(time());
|
||||||
//触发活动任务
|
if (!$rows) {
|
||||||
/*$act = $this->getActivityRewardConfig(QUEST_ACTIVITY_LOGIN);
|
|
||||||
$array = $this->getExplode($act['start_end_time']);
|
|
||||||
$nowTime = phpcommon\getdayseconds(time());
|
|
||||||
$start_time = $array[0][0] * 3600 + $array[0][1] * 60 + $nowTime;
|
|
||||||
$end_time = $array[1][0] * 3600 + $array[1][1] * 60 + $nowTime;*/
|
|
||||||
if (!$row) {
|
|
||||||
$ret = $conn->execScript('INSERT INTO sign(accountid, sign_days, sign_time, create_time, modify_time) ' .
|
|
||||||
' VALUES(:accountid, :sign_days, :sign_time, :create_time, :modify_time) ' .
|
|
||||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, sign_days=:sign_days, sign_time=:sign_time, modify_time=:modify_time;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':sign_days' => 0,
|
|
||||||
':sign_time' => 0,
|
|
||||||
':create_time' => time(),
|
|
||||||
':modify_time' => time()
|
|
||||||
));
|
|
||||||
if (!$ret) {
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$sign_days = 1;
|
$sign_days = 1;
|
||||||
$signable = 0;
|
//插入签到列表
|
||||||
|
$this->insertSign($account_id, $sign_days);
|
||||||
|
//更新签到总天数
|
||||||
|
$this->updateSignSum($account_id, $sign_days);
|
||||||
|
//完成签到任务
|
||||||
$quest = new classes\Quest();
|
$quest = new classes\Quest();
|
||||||
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
||||||
$quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id);
|
$quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id);
|
||||||
/*if (time() >= $start_time && time() < $end_time) {
|
|
||||||
$quest->triggerQuest(QUEST_ACTIVITY_LOGIN, 3, 1, $account_id);
|
|
||||||
}*/
|
|
||||||
} else {
|
} else {
|
||||||
if ($nowTime - phpcommon\getdayseconds($row['sign_time']) > 0) {
|
$sign_time = 0;
|
||||||
$sign_days = $row['sign_days'] + 1;
|
foreach ($rows as $row) {
|
||||||
$signable = 0;
|
if ($row['sign_time'] > $sign_time) {
|
||||||
|
$sign_time = $row['sign_time'];
|
||||||
//刷新每日任务和活动任务
|
$sign_days = $row['sign_id'];
|
||||||
$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 OR quest_type=:quest_type2;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':quest_num' => 0,
|
|
||||||
':quest_type1' => 1,
|
|
||||||
':quest_type2' => 3,
|
|
||||||
':quest_state' => 0,
|
|
||||||
':modify_time' => time()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
if (!$ret) {
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$quest = new classes\Quest();
|
if ($nowTime - phpcommon\getdayseconds($sign_time) > 0) {
|
||||||
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
//每日刷新
|
||||||
$quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id);
|
error_log($sign_days);
|
||||||
//刷新战斗结算奖励次数,商店刷新次数,客服
|
$this->updateDaily($account_id);
|
||||||
$battle_ret = $conn->execScript('UPDATE user SET battle_re_times=0, shop_flush_times=0, kefu_status=0, modify_time=:modify_time ' .
|
$sign_num = floor(($nowTime - phpcommon\getdayseconds($sign_time)) / (3600 * 24));
|
||||||
' WHERE accountid=:accountid;',
|
if ($sign_num > 7 - $sign_days) {
|
||||||
|
//每周更新一次
|
||||||
|
$ret = $conn->execScript('DELETE from sign WHERE accountid=:accountid;',
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id,
|
':accountid' => $account_id,
|
||||||
':modify_time' => time()
|
|
||||||
));
|
|
||||||
if (!$battle_ret) {
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//刷新活动皮肤碎片收集状态
|
|
||||||
/*$rowSkinCount = $conn->execQueryRowCount('SELECT * FROM skin WHERE accountid=:accountid AND skin_type=:skin_type;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':skin_type' => 2
|
|
||||||
));
|
|
||||||
if ($rowSkinCount != 0) {
|
|
||||||
for ($i = 0; $i < $rowSkinCount; $i++) {
|
|
||||||
$ret = $conn->execScript('UPDATE skin SET fragment_status=:fragment_status, modify_time=:modify_time ' .
|
|
||||||
' WHERE accountid=:accountid;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':fragment_status' => 0,
|
|
||||||
':modify_time' => time()
|
|
||||||
));
|
));
|
||||||
if (!$ret) {
|
if (!$ret) {
|
||||||
die();
|
die();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$num = ($sign_num - 7 + $sign_days) % 7;
|
||||||
|
for ($i = $sign_days + 1; $i < $num + $sign_days + 1; $i++) {
|
||||||
|
//插入补签列表
|
||||||
|
$this->insertSign($account_id, $i);
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
} else {
|
} else {
|
||||||
$sign_days = $row['sign_days'];
|
error_log($sign_num);
|
||||||
$signable = 1;
|
for ($i = $sign_days + 1; $i < $sign_num + $sign_days + 1; $i++) {
|
||||||
/*if (time() >= $start_time && time() < $end_time) {
|
//插入补签列表
|
||||||
|
$this->insertSign($account_id, $i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//更新签到总天数
|
||||||
|
$this->updateSignSum($account_id, $sign_num);
|
||||||
|
//完成签到任务
|
||||||
$quest = new classes\Quest();
|
$quest = new classes\Quest();
|
||||||
$quest->triggerQuest(QUEST_ACTIVITY_LOGIN, 3, 1, $account_id);
|
$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
|
||||||
|
));
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'errcode' => 0,
|
'errcode' => 0,
|
||||||
'errmsg' => '',
|
'errmsg' => '',
|
||||||
'sign_days' => $sign_days,
|
'sign_days' => $rowUser['sign_sum'],
|
||||||
'signable' => $signable
|
'sign_list' => $sign_list
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,20 +190,20 @@ class SignController{
|
|||||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$row = $conn->execQueryOne('SELECT * FROM sign WHERE accountid=:accountid;',
|
$row = $conn->execQueryOne('SELECT signable FROM sign WHERE accountid=:accountid AND sign_id=:sign_id;',
|
||||||
array(
|
|
||||||
':accountid' => $account_id
|
|
||||||
));
|
|
||||||
if (!$row || phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($row['sign_time']) <= 0) {
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 2, '今日已签到');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$sign_days = $row['sign_days'] + 1;
|
|
||||||
$ret = $conn->execScript('UPDATE sign SET sign_time=:sign_time, sign_days=:sign_days, modify_time=:modify_time ' .
|
|
||||||
' WHERE accountid=:accountid;',
|
|
||||||
array(
|
array(
|
||||||
':accountid' => $account_id,
|
':accountid' => $account_id,
|
||||||
':sign_days' => $sign_days,
|
':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(),
|
':sign_time' => time(),
|
||||||
':modify_time' => time()
|
':modify_time' => time()
|
||||||
));
|
));
|
||||||
@ -244,9 +211,13 @@ class SignController{
|
|||||||
die();
|
die();
|
||||||
return;
|
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');
|
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
|
||||||
$day = $sign_days % count($g_conf_sign_cluster);
|
$day = ($rowUser['sign_sum'] / 7 + $_REQUEST['sign_id']) % count($g_conf_sign_cluster);
|
||||||
if ($day == 0) {
|
if ($day == 0) {
|
||||||
$day = count($g_conf_sign_cluster);
|
$day = count($g_conf_sign_cluster);
|
||||||
}
|
}
|
||||||
@ -264,5 +235,78 @@ class SignController{
|
|||||||
'errmsg' => '',
|
'errmsg' => '',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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, shop_flush_times=0, kefu_status=0, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':modify_time' => time()
|
||||||
|
));
|
||||||
|
if (!$battle_ret) {
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
//刷新抽奖活动奖励
|
||||||
|
$lottery_ret = $conn->execScript('UPDATE activity SET free_times=0, video_times=0, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':modify_time' => time()
|
||||||
|
));
|
||||||
|
if (!$lottery_ret) {
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user