1
This commit is contained in:
commit
6b5fe94573
@ -102,6 +102,10 @@ CREATE TABLE `user` (
|
||||
`new_second_equip` int(11) NOT NULL DEFAULT '2' COMMENT '新玩家隔天结算武器',
|
||||
`sum_coin` double NOT NULL DEFAULT '0' COMMENT '累计充值金额',
|
||||
`recharge_times_total` int(11) NOT NULL DEFAULT '0' COMMENT '累计充值次数',
|
||||
`blobdata` mediumblob NOT NULL DEFAULT '' COMMENT 'cpa数据json',
|
||||
`cpa_times` int(11) NOT NULL DEFAULT '0' COMMENT 'cpa看视频次数',
|
||||
|
||||
`daily_diamond_times` 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;
|
||||
@ -144,6 +148,7 @@ CREATE TABLE `sign` (
|
||||
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
`sign_time` int(11) NOT NULL DEFAULT '0' COMMENT '签到时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `accountid` (`accountid`),
|
||||
UNIQUE KEY `account_sign_id` (`accountid`, `sign_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
@ -165,6 +170,7 @@ CREATE TABLE `quest` (
|
||||
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `accountid` (`accountid`),
|
||||
UNIQUE KEY `quest_uuid` (`accountid`, `quest_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
@ -183,6 +189,7 @@ CREATE TABLE `share_achievement` (
|
||||
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `accountid` (`accountid`),
|
||||
UNIQUE KEY `accountid_ach_id` (`accountid`, `ach_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
@ -251,6 +258,7 @@ CREATE TABLE `additem_log` (
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `accountid` (`accountid`),
|
||||
UNIQUE KEY `account_add_id_add_time` (`accountid`, `add_id` , `add_time`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
@ -271,6 +279,7 @@ CREATE TABLE `equip` (
|
||||
`using_id` int(11) NOT NULL DEFAULT '0' COMMENT '上阵id',
|
||||
`exp` int(11) NOT NULL DEFAULT '0' COMMENT '当前经验',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `accountid` (`accountid`),
|
||||
UNIQUE KEY `accountid_id` (`accountid`, id)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
@ -300,4 +309,31 @@ CREATE TABLE `festival_activity` (
|
||||
UNIQUE KEY `accountid` (`accountid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
DROP TABLE IF EXISTS `holiday`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `holiday` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`blobdata` mediumblob COMMENT '活动数据json',
|
||||
`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;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `draw`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `draw` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`accountid` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'accountid',
|
||||
`id` int(11) NOT NULL DEFAULT '0' COMMENT '抽奖id',
|
||||
`cd_time` int(11) NOT NULL DEFAULT '0' COMMENT 'cd时间',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `accountid_drawid` (`accountid`, `id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
-- Dump completed on 2015-08-19 18:51:22
|
||||
|
8
sql/gamedb2004_n_migrate_201111_01.sql
Normal file
8
sql/gamedb2004_n_migrate_201111_01.sql
Normal file
@ -0,0 +1,8 @@
|
||||
start transaction;
|
||||
|
||||
alter table `sign` add index accountid (`accountid`);
|
||||
alter table `quest` add index accountid (`accountid`);
|
||||
alter table `share_achievement` add index accountid (`accountid`);
|
||||
alter table `equip` add index accountid (`accountid`);
|
||||
|
||||
commit;
|
18
sql/gamedb2004_n_migrate_201208_01.sql
Normal file
18
sql/gamedb2004_n_migrate_201208_01.sql
Normal file
@ -0,0 +1,18 @@
|
||||
begin;
|
||||
|
||||
DROP TABLE IF EXISTS `holiday`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `holiday` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`blobdata` mediumblob COMMENT '活动数据json',
|
||||
`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;
|
||||
|
||||
insert into version (version) values(2020120801);
|
||||
|
||||
commit;
|
8
sql/gamedb2004_n_migrate_210119_01.sql
Normal file
8
sql/gamedb2004_n_migrate_210119_01.sql
Normal file
@ -0,0 +1,8 @@
|
||||
begin;
|
||||
|
||||
alter table user add column `blobdata` mediumblob NOT NULL DEFAULT '' COMMENT 'cpa数据json';
|
||||
alter table user add column `cpa_times` int(11) NOT NULL DEFAULT '0' COMMENT 'cpa看视频次数';
|
||||
|
||||
insert into version (version) values(20210119);
|
||||
|
||||
commit;
|
21
sql/gamedb2004_n_migrate_210129_01.sql
Normal file
21
sql/gamedb2004_n_migrate_210129_01.sql
Normal file
@ -0,0 +1,21 @@
|
||||
begin;
|
||||
|
||||
alter table user add column `daily_diamond_times` int(11) NOT NULL DEFAULT '0' COMMENT '兑换钻石次数';
|
||||
|
||||
DROP TABLE IF EXISTS `draw`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `draw` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`accountid` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'accountid',
|
||||
`id` int(11) NOT NULL DEFAULT '0' COMMENT '抽奖id',
|
||||
`cd_time` int(11) NOT NULL DEFAULT '0' COMMENT 'cd时间',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `accountid_drawid` (`accountid`, `id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
insert into version (version) values(2021012901);
|
||||
|
||||
commit;
|
@ -19,6 +19,9 @@ import functools
|
||||
|
||||
|
||||
CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/game2004api_rankserver/config'
|
||||
RANK_KEY_PREFIX = 'game2004api:'
|
||||
DBNAME_PREFIX = 'gamedb2004_'
|
||||
IGNORE_GUEST_ACCOUNT = 0
|
||||
|
||||
def _take_pass(elem):
|
||||
return elem[3]
|
||||
@ -85,7 +88,10 @@ def _refreshData(row, data_list, data_info):
|
||||
num = row[9]
|
||||
if (time.time() > row[10]):
|
||||
num = 0
|
||||
data_list.append((row[0], row[1].decode('utf-8'), row[2], kill, alive_time, harm, win_times, row[6], num))
|
||||
user_name = ''
|
||||
if row[1]:
|
||||
user_name = row[1].decode('utf-8')
|
||||
data_list.append((row[0], user_name, row[2], kill, alive_time, harm, win_times, row[6], num))
|
||||
data_list.sort(key=key_info, reverse=True)
|
||||
if (len(data_list) > 50):
|
||||
del data_list[50:]
|
||||
@ -123,7 +129,7 @@ def fullUpdateRank():
|
||||
port = conf['port'],
|
||||
user = conf['user'],
|
||||
passwd = conf['passwd'],
|
||||
db = 'gamedb2004_' + str(conf['instance_id']),
|
||||
db = DBNAME_PREFIX + str(conf['instance_id']),
|
||||
charset = 'utf8'
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
@ -135,6 +141,12 @@ def fullUpdateRank():
|
||||
has_data = False
|
||||
for row in cursor:
|
||||
has_data = True
|
||||
last_idx = max(row[8], last_idx)
|
||||
user_name = ''
|
||||
if row[1]:
|
||||
user_name = str(row[1], encoding='utf8')
|
||||
if IGNORE_GUEST_ACCOUNT and (user_name == '游客' or user_name == '极乐玩家'):
|
||||
continue
|
||||
#更新击杀榜
|
||||
channel = f7.getChannelByAccountId(row[0])
|
||||
if checkchannel(channel):
|
||||
@ -153,7 +165,6 @@ def fullUpdateRank():
|
||||
if channel not in integral_hash:
|
||||
integral_hash[channel] = []
|
||||
_refreshData(row, integral_hash[channel], take_integral_times)
|
||||
last_idx = max(row[8], last_idx)
|
||||
time.sleep(0.001);
|
||||
if not has_data:
|
||||
break
|
||||
@ -187,7 +198,7 @@ def incrementUpdateRank():
|
||||
port = conf['port'],
|
||||
user = conf['user'],
|
||||
passwd = conf['passwd'],
|
||||
db = 'gamedb2004_' + str(conf['instance_id']),
|
||||
db = DBNAME_PREFIX + str(conf['instance_id']),
|
||||
charset = 'utf8'
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
@ -201,26 +212,31 @@ def incrementUpdateRank():
|
||||
for row in cursor:
|
||||
has_data = True
|
||||
channel = f7.getChannelByAccountId(row[0])
|
||||
last_idx = max(row[8], last_idx)
|
||||
user_name = ''
|
||||
if row[1]:
|
||||
user_name = str(row[1], encoding='utf8')
|
||||
if IGNORE_GUEST_ACCOUNT and (user_name == '游客' or user_name == '极乐玩家'):
|
||||
continue
|
||||
if checkchannel(channel):
|
||||
#更新击杀榜
|
||||
if channel not in kill_hash:
|
||||
kill_list = r.get('game2004api:kill_rank_' + channel)
|
||||
kill_list = r.get(RANK_KEY_PREFIX + 'kill_rank_' + channel)
|
||||
kill_hash[channel] = [] if not kill_list else json.loads(kill_list)
|
||||
_delRepeatData(row, kill_hash[channel])
|
||||
_refreshData(row, kill_hash[channel], take_kills)
|
||||
#更新胜场榜
|
||||
if channel not in win_hash:
|
||||
win_list = r.get('game2004api:win_rank_' + channel)
|
||||
win_list = r.get(RANK_KEY_PREFIX + 'win_rank_' + channel)
|
||||
win_hash[channel] = [] if not win_list else json.loads(win_list)
|
||||
_delRepeatData(row, win_hash[channel])
|
||||
_refreshData(row, win_hash[channel], take_game_times)
|
||||
#更新积分榜
|
||||
if channel not in integral_hash:
|
||||
integral_list = r.get('game2004api:integral_rank_' + channel)
|
||||
integral_list = r.get(RANK_KEY_PREFIX + 'integral_rank_' + channel)
|
||||
integral_hash[channel] = [] if not integral_list else json.loads(integral_list)
|
||||
_delRepeatData(row, integral_hash[channel])
|
||||
_refreshData(row, integral_hash[channel], take_integral_times)
|
||||
last_idx = max(row[8], last_idx)
|
||||
time.sleep(0.001);
|
||||
if not has_data:
|
||||
break
|
||||
@ -240,13 +256,16 @@ def _incrementUpdateRank(rushtime):
|
||||
lambda : _incrementUpdateRank(rushtime))
|
||||
f7.app.createAsyncTask(done_callback, incrementUpdateRank, ())
|
||||
|
||||
conf = json.loads(open(CONFIG_DIR + '/rankserver.json', 'r').read())
|
||||
RANK_KEY_PREFIX = conf.get('key_prefix', RANK_KEY_PREFIX)
|
||||
DBNAME_PREFIX = conf.get('dbname_prefix', DBNAME_PREFIX)
|
||||
IGNORE_GUEST_ACCOUNT = conf.get('ignore_guest_account', IGNORE_GUEST_ACCOUNT)
|
||||
|
||||
if __name__ == "__main__":
|
||||
q7.xPrint('pid %d' % os.getpid())
|
||||
f7.app.init('/data/logs/game2004_rankserver/logs')
|
||||
f7.udplog.info('rankserver start pid:' + str(os.getpid()))
|
||||
|
||||
conf = json.loads(open(CONFIG_DIR + '/rankserver.json', 'r').read())
|
||||
|
||||
conf['rushtime'] = 300
|
||||
f7.timer.callLater(conf['rushtime'],
|
||||
lambda : _incrementUpdateRank(conf['rushtime']))
|
||||
|
@ -104,6 +104,8 @@ class AddReward {
|
||||
$this->addweizhuang($item['item_id'], $item['item_num'], $account_id);
|
||||
} else if ($i['type'] == 12) {
|
||||
$item_list = $this->addEquip($item['item_id'], $account_id);
|
||||
} else if ($i['type'] == 16) {
|
||||
$this->addSpoilsItem($item['item_id'], $item['item_num'], $account_id);
|
||||
} else {
|
||||
$price = $i['diamond'];
|
||||
if ($time != 0) {
|
||||
@ -119,6 +121,47 @@ class AddReward {
|
||||
return $item_list;
|
||||
}
|
||||
|
||||
public function addSpoilsItem($id, $num, $accountid)
|
||||
{
|
||||
$conn = $this->getMysql($accountid);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT num FROM bag WHERE accountid=:accountid AND id=:id;',
|
||||
array(
|
||||
':accountid' => $accountid,
|
||||
'id' => $id
|
||||
));
|
||||
if (!$row && $id != 0) {
|
||||
$ret = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, num, active_time, create_time, modify_time) ' .
|
||||
' VALUES(:account_id, :id, 0, 1, :num, 0, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=1, num=:num, active_time=0, modify_time=:modify_time;',
|
||||
array(
|
||||
':account_id' => $accountid,
|
||||
':id' => $id,
|
||||
':num' => $num,
|
||||
':create_time' => time(),
|
||||
':modify_time' => time()
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
$ret = $conn->execScript('UPDATE bag SET num=:num, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:account_id AND id=:id;',
|
||||
array(
|
||||
':account_id' => $accountid,
|
||||
':id' => $id,
|
||||
':num' => $row['num'] + $num,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCoinNum($accountid)
|
||||
{
|
||||
$conn = $this->getMysql($accountid);
|
||||
|
@ -132,5 +132,119 @@ class Quest{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//提交假日活动任务
|
||||
public function flushHolidayQuest($quest_id, $quest_num, $account_id)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
return;
|
||||
}
|
||||
$user_db = $this->readHolidayDB($account_id);
|
||||
if (!$user_db || empty($user_db)) {
|
||||
return;
|
||||
}
|
||||
$id = $quest_id;
|
||||
$flag = 0;
|
||||
foreach ($user_db['quest_list'] as &$user) {
|
||||
if (isset($user['quest_list']) && !empty($user['quest_list'])) {
|
||||
foreach ($user['quest_list'] as &$us) {
|
||||
if ($us['id'] != $id || $us['status'] != 0) {
|
||||
continue;
|
||||
}
|
||||
if ($id == 72009) {
|
||||
if($quest_num <= $us['condition']) {
|
||||
$us['status'] = 1;
|
||||
$flag = 1;
|
||||
}
|
||||
} else {
|
||||
$us['num'] = $us['num'] + $quest_num;
|
||||
if ($us['num'] >= $us['condition']) {
|
||||
$us['status'] = 1;
|
||||
$flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->saveHolidayDB($account_id, $user_db);
|
||||
if ($flag == 1 && $id != 72010) {
|
||||
$this->flushAllQuest($account_id);
|
||||
}
|
||||
}
|
||||
|
||||
public function flushAllQuest($account_id)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
return;
|
||||
}
|
||||
$user_db = $this->readHolidayDB($account_id);
|
||||
if (!$user_db || empty($user_db)) {
|
||||
return;
|
||||
}
|
||||
$id = 72010;
|
||||
foreach ($user_db['quest_list'] as &$user) {
|
||||
if (isset($user['quest_list']) && !empty($user['quest_list'])) {
|
||||
foreach ($user['quest_list'] as &$us) {
|
||||
if ($us['id'] != $id || $us['status'] != 0) {
|
||||
continue;
|
||||
}
|
||||
$us['num'] = $us['num'] + 1;
|
||||
if ($us['num'] >= $us['condition']) {
|
||||
$us['status'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->saveHolidayDB($account_id, $user_db);
|
||||
}
|
||||
|
||||
protected function readHolidayDB($account_id) {
|
||||
$conn = $this->getMysql($account_id);
|
||||
$row = $conn->execQueryOne('SELECT blobdata FROM holiday WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!empty($row)) {
|
||||
$hol_db_str = $row['blobdata'];
|
||||
$hol_db = json_decode($hol_db_str, true);
|
||||
return $hol_db;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveHolidayDB($account_id, $hol_db) {
|
||||
$conn = $this->getMysql($account_id);
|
||||
$row = $conn->execQueryOne('SELECT accountid FROM holiday WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
$hol_db_str = "";
|
||||
if (!empty($hol_db)) {
|
||||
$hol_db_str = json_encode($hol_db);
|
||||
}
|
||||
if (!empty($row)) {
|
||||
//update
|
||||
$row = $conn->execScript('UPDATE holiday SET blobdata=:blobdata, modify_time=:modify_time WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':blobdata' => $hol_db_str,
|
||||
':modify_time' => time()
|
||||
));
|
||||
} else {
|
||||
//insert
|
||||
$row = $conn->execScript('INSERT INTO holiday(accountid, blobdata, create_time, modify_time) ' .
|
||||
' VALUES(:account_id, :blobdata, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, blobdata=:blobdata, modify_time=:modify_time;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':blobdata' => $hol_db_str,
|
||||
':create_time' => time(),
|
||||
':modify_time' => time(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
require_once 'metatable/draw.php';
|
||||
require_once 'metatable/parameter.php';
|
||||
require_once 'metatable/drop.php';
|
||||
class ActivityController{
|
||||
|
||||
private $actTableCache = null;
|
||||
protected function getMysql($account_id)
|
||||
{
|
||||
$mysql_conf = getMysqlConfig(crc32($account_id));
|
||||
@ -87,8 +90,10 @@ class ActivityController{
|
||||
|
||||
protected function getLottery($lot_id)
|
||||
{
|
||||
$g_conf_lot_cluster = require('../res/lottery@lottery.php');
|
||||
$lot_conf = getLotteryConfig($g_conf_lot_cluster, $lot_id);
|
||||
if ($this->actTableCache == null) {
|
||||
$this->actTableCache = require('../res/lottery@lottery.php');
|
||||
}
|
||||
$lot_conf = getLotteryConfig($this->actTableCache, $lot_id);
|
||||
$l = array(
|
||||
'id' => $lot_conf['id'],
|
||||
'item_id' => $lot_conf['item_id'],
|
||||
@ -351,23 +356,7 @@ class ActivityController{
|
||||
));
|
||||
}
|
||||
}
|
||||
// for ($i1 = 0; $i1 < count($lot_array); $i1++) {
|
||||
// $l = $this->getLottery($lot_array[$i1]['key']);
|
||||
// $weight_sum += $l['jilv'];
|
||||
// }
|
||||
//$random = Rand(0, 100);
|
||||
//if ($random >= 50) {
|
||||
$key = $lot_array[0]['key'];
|
||||
// } else {
|
||||
// $key = $lot_array[1]['key'];
|
||||
// }
|
||||
// } else if ($row['free_times'] + $row['video_times'] + 1 == 6) {
|
||||
// foreach ($user_db['draw_list'] as $draw) {
|
||||
// if (isset($draw['status']) && $draw['status'] != 0) {
|
||||
// continue;
|
||||
// }
|
||||
// $key = $draw['key'] + 1;
|
||||
// }
|
||||
} else {
|
||||
foreach ($user_db['draw_list'] as $draw) {
|
||||
if (isset($draw['status']) && $draw['status'] != 0) {
|
||||
@ -427,6 +416,7 @@ class ActivityController{
|
||||
$item_list = array();
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(71004, 1, 1, $account_id);
|
||||
$quest->flushHolidayQuest(72004, 1, $account_id);
|
||||
array_push($item_list,array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
@ -715,7 +705,7 @@ class ActivityController{
|
||||
}
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(71004, 1, 1, $account_id);
|
||||
|
||||
$quest->flushHolidayQuest(72004, 1, $account_id);
|
||||
foreach ($user_db['drawtable_list'] as $draw) {
|
||||
if ($draw['key'] == $key - 1) {
|
||||
$item_id = $draw['item_id'];
|
||||
@ -904,6 +894,7 @@ class ActivityController{
|
||||
$item_list = array();
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(71004, 1, 1, $account_id);
|
||||
$quest->flushHolidayQuest(72004, 1, $account_id);
|
||||
array_push($item_list,array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
@ -1206,6 +1197,7 @@ class ActivityController{
|
||||
$diamond_num = $addreward->getDiamondNum($account_id);
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(71004, 1, 1, $account_id);
|
||||
$quest->flushHolidayQuest(72004, 1, $account_id);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
@ -1549,5 +1541,328 @@ class ActivityController{
|
||||
|
||||
return $item_list;
|
||||
}
|
||||
|
||||
protected function insertDrawDB($account_id, $id )
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
$ret = $conn->execScript('INSERT INTO draw(accountid, id, cd_time, createtime, modifytime) ' .
|
||||
' VALUES(:account_id, :id, 0, :createtime, :modifytime) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, cd_time=0, modifytime=:modifytime;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':id' => $id,
|
||||
':createtime' => time(),
|
||||
':modifytime' => time(),
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function drawBoxInfo()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$rows = $conn->execQuery('SELECT id, cd_time FROM draw WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
$info_list = array();
|
||||
if (!$rows) {
|
||||
$draw_conf = metatable\getDrawConf();
|
||||
foreach ($draw_conf as $d) {
|
||||
$this->insertDrawDB($account_id, $d['id']);
|
||||
array_push($info_list, array(
|
||||
'id' => $d['id'],
|
||||
'cd_time' => 0,
|
||||
));
|
||||
}
|
||||
} else {
|
||||
foreach ($rows as $row) {
|
||||
if ($row['cd_time'] <= time()) {
|
||||
$ret = $conn->execScript('UPDATE draw SET cd_time=:cd_time, modifytime=:modifytime ' .
|
||||
' WHERE accountid=:accountid AND id=:id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':cd_time' => 0,
|
||||
':id' => $row['id'],
|
||||
':modifytime' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
array_push($info_list, array(
|
||||
'id' => $row['id'],
|
||||
'cd_time' => 0,
|
||||
));
|
||||
} else {
|
||||
array_push($info_list, array(
|
||||
'id' => $row['id'],
|
||||
'cd_time' => $row['cd_time'],
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'info_list' => $info_list,
|
||||
));
|
||||
}
|
||||
|
||||
public function drawBoxReward()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$id = $_REQUEST['id'];
|
||||
$row = $conn->execQueryOne('SELECT cd_time FROM draw WHERE accountid=:accountid AND id=:id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':id' => $id,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
if ($row['cd_time'] < time() && $row['cd_time'] != 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '冷却时间未到');
|
||||
return;
|
||||
}
|
||||
|
||||
$dr = metatable\getDrawById($id);
|
||||
if (!$dr) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$drop_id = $dr['one_drop'];
|
||||
$times = $dr['one_count'];
|
||||
$item_list = array();
|
||||
$extra_id = $dr['ten_drop'];
|
||||
$extra_times = $dr['ten_count'];
|
||||
$cdtime = $dr['time_cd'];
|
||||
$ret = $conn->execScript('UPDATE draw SET cd_time=:cd_time, modifytime=:modifytime ' .
|
||||
' WHERE accountid=:accountid AND id=:id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':cd_time' => time() + $cdtime,
|
||||
':id' => $id,
|
||||
':modifytime' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
for ($j = 0; $j < $extra_times; $j++) {
|
||||
$item_list = metatable\getDropAllListById($extra_id, $item_list);
|
||||
}
|
||||
for ($i = 0; $i < $times; $i++) {
|
||||
$item_list = metatable\getDropAllListById($drop_id, $item_list);
|
||||
}
|
||||
|
||||
$all_item_list = array();
|
||||
$addreward = new classes\AddReward();
|
||||
if (is_array($item_list)) {
|
||||
foreach ($item_list as $item) {
|
||||
$items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time'], 0);
|
||||
foreach($items as $i) {
|
||||
array_push($all_item_list, array(
|
||||
'item_id' => $i['item_id'],
|
||||
'item_num' => $i['item_num'],
|
||||
'time' => $i['time'],
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
$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 drawSpeedUpTime()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$rowuser = $conn->execQueryOne('SELECT diamond_num, coin_num FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$rowuser) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$coin_num = $rowuser['coin_num'];
|
||||
$diamond_num = $rowuser['diamond_num'];
|
||||
if ($_REQUEST['type'] == 1) {
|
||||
$costid = metatable\getParameterByName('drawbox_cost');
|
||||
$cost = metatable\getParameterByName('drawbox_cost_num');
|
||||
if ($costid == 10001) {
|
||||
if($cost >= $rowuser['coin_num']) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '金币不足');
|
||||
return;
|
||||
} else {
|
||||
$coin_num = $rowuser['coin_num'] - $cost;
|
||||
}
|
||||
}
|
||||
|
||||
if ($costid == 10003) {
|
||||
if($cost >= $rowuser['diamond_num']) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足');
|
||||
return;
|
||||
} else {
|
||||
$diamond_num = $rowuser['diamond_num'] - $cost;
|
||||
}
|
||||
}
|
||||
|
||||
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, diamond_num=:diamond_num, modify_time=:modifytime ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':coin_num' => $coin_num,
|
||||
':diamond_num' => $diamond_num,
|
||||
':modifytime' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
$rows = $conn->execQuery('SELECT id, cd_time FROM draw WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
if (!$rows) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$speedtime = metatable\getParameterByName('drawbox_ad_cd');
|
||||
if ($_REQUEST['type'] == 1) {
|
||||
$speedtime = metatable\getParameterByName('drawbox_item_cd');
|
||||
}
|
||||
foreach ($rows as $row) {
|
||||
$cd_time = $row['cd_time'] - $speedtime;
|
||||
if ($cd_time <= time()) {
|
||||
$cd_time = 0;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE draw SET cd_time=:cd_time, modifytime=:modifytime ' .
|
||||
' WHERE accountid=:accountid AND id=:id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':cd_time' => $cd_time,
|
||||
':id' => $row['id'],
|
||||
':modifytime' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'coin_nums' => $coin_num,
|
||||
'diamond_nums' => $diamond_num,
|
||||
));
|
||||
}
|
||||
|
||||
public function duihuanCoin()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$rowuser = $conn->execQueryOne('SELECT daily_diamond_times FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$rowuser) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$num = metatable\getParameterByName('adddiamond_num');
|
||||
$times = metatable\getParameterByName('adddiamond_times');
|
||||
$addreward = new classes\AddReward();
|
||||
if ($rowuser['daily_diamond_times'] >= $times) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '今日兑换次数已用完');
|
||||
return;
|
||||
}
|
||||
$addreward->addReward(10003, $num, $account_id, 0, 0);
|
||||
$diamond_times = $rowuser['daily_diamond_times'] + 1;
|
||||
$ret = $conn->execScript('UPDATE user SET daily_diamond_times=:daily_diamond_times, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':daily_diamond_times' => $diamond_times,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
|
||||
$coin_num = $addreward->getCoinNum($account_id);
|
||||
$diamond_num = $addreward->getDiamondNum($account_id);
|
||||
$item_list = array();
|
||||
array_push($item_list, array(
|
||||
'item_id' => 10003,
|
||||
'item_num' => $num,
|
||||
'time' => 0,
|
||||
));
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'coin_nums' => $coin_num,
|
||||
'diamond_nums' => $diamond_num,
|
||||
'daily_diamond_times' => $diamond_times,
|
||||
'item_list' => $item_list,
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -100,7 +100,7 @@ class AdditemController{
|
||||
if ($it['type'] == 12) {
|
||||
$this->addEquip($item_id, $item_num, $time, $accountid);
|
||||
} else {
|
||||
if ($it['type'] == 10 || $it['type'] == 11) {
|
||||
if ($it['type'] == 10 || $it['type'] == 11 || $it['type'] == 16) {
|
||||
$item_num = $row['num'] + $item_num;
|
||||
} else {
|
||||
$item_num = 1;
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
require 'classes/AddReward.php';
|
||||
require_once 'metatable/activity.php';
|
||||
require_once 'metatable/activityplus.php';
|
||||
require 'classes/Quest.php';
|
||||
|
||||
class FesActivityController{
|
||||
|
||||
@ -121,12 +123,14 @@ class FesActivityController{
|
||||
$this->getfesActInfo($account_id);
|
||||
$user_db = $this->readFesActDB($account_id);
|
||||
//metatable\getRewardInfo(1,1,1);
|
||||
$act = metatable\getNowActivity();
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'isopen' => $user_db['isopen'],
|
||||
'id' => $user_db['act_id'],
|
||||
'info_list' => $user_db['info_list'],
|
||||
'act' => $act,
|
||||
));
|
||||
}
|
||||
|
||||
@ -287,10 +291,6 @@ class FesActivityController{
|
||||
}
|
||||
//更新奖励状态
|
||||
$this->saveFesActDB($account_id, $user_db);
|
||||
// if (empty($reward) || !$reward) {
|
||||
// phpcommon\sendError(ERR_USER_BASE + 5, '没有这个奖励');
|
||||
// return;
|
||||
// }
|
||||
$item_list = array();
|
||||
$all_item_list = array();
|
||||
$addreward = new classes\AddReward();
|
||||
@ -330,5 +330,496 @@ class FesActivityController{
|
||||
'id' => $id,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function readHolidayDB($account_id) {
|
||||
$conn = $this->getMysql($account_id);
|
||||
$row = $conn->execQueryOne('SELECT blobdata FROM holiday WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!empty($row)) {
|
||||
$hol_db_str = $row['blobdata'];
|
||||
$hol_db = json_decode($hol_db_str, true);
|
||||
return $hol_db;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveHolidayDB($account_id, $hol_db) {
|
||||
$conn = $this->getMysql($account_id);
|
||||
$row = $conn->execQueryOne('SELECT accountid FROM holiday WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
$hol_db_str = "";
|
||||
if (!empty($hol_db)) {
|
||||
$hol_db_str = json_encode($hol_db);
|
||||
}
|
||||
if (!empty($row)) {
|
||||
//update
|
||||
$row = $conn->execScript('UPDATE holiday SET blobdata=:blobdata, modify_time=:modify_time WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':blobdata' => $hol_db_str,
|
||||
':modify_time' => time()
|
||||
));
|
||||
} else {
|
||||
//insert
|
||||
$row = $conn->execScript('INSERT INTO holiday(accountid, blobdata, create_time, modify_time) ' .
|
||||
' VALUES(:account_id, :blobdata, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, blobdata=:blobdata, modify_time=:modify_time;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':blobdata' => $hol_db_str,
|
||||
':create_time' => time(),
|
||||
':modify_time' => time(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
//假日活动
|
||||
public function holidayInfo()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
//假日活动信息
|
||||
$this->getHolidayInfo($account_id);
|
||||
$user_db = $this->readHolidayDB($account_id);
|
||||
$quest_list = $user_db['quest_list'];
|
||||
$exc_list = $user_db['exchange_list'];
|
||||
foreach ($quest_list as &$q) {
|
||||
if (isset($q['id'])) {
|
||||
$act = metatable\getActPlusById($q['id']);
|
||||
if ($act) {
|
||||
$q['act'] = $act;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($exc_list as &$e) {
|
||||
if (isset($e['id'])) {
|
||||
$act = metatable\getActPlusById($e['id']);
|
||||
if ($act) {
|
||||
$e['act'] = $act;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'quest_list' => $quest_list,
|
||||
'exchange_list' => $exc_list,
|
||||
));
|
||||
}
|
||||
|
||||
protected function getHolidayInfo($account_id)
|
||||
{
|
||||
$user_db = $this->readHolidayDB($account_id);
|
||||
$quest_list = $this->getActQuestInfo(3, $user_db['quest_list'], $account_id);
|
||||
$exchange_list = $this->getActExchangeInfo(9, $user_db['exchange_list'], $account_id);
|
||||
$hol_db = array(
|
||||
'quest_list' => $quest_list,
|
||||
'exchange_list' => $exchange_list,
|
||||
);
|
||||
$this->saveHolidayDB($account_id, $hol_db);
|
||||
}
|
||||
|
||||
protected function insertQuestInfo($act, $id, $num, $account_id, $info_list)
|
||||
{
|
||||
$reward = array();
|
||||
$quest_list = $this->actQuestList($act['condition'], $account_id);
|
||||
$reward = $this->actQuestRewardList($act['reward']);
|
||||
array_push($info_list, array(
|
||||
'id' => $id,
|
||||
'idx' => $num,
|
||||
'quest_list' => $quest_list,
|
||||
'reward' => $reward,
|
||||
'time' => time(),
|
||||
'act' => array(),
|
||||
));
|
||||
return $info_list;
|
||||
}
|
||||
|
||||
protected function updateQuestInfo($act, $info_list, $id, $num, $account_id)
|
||||
{
|
||||
$reward = array();
|
||||
$temp_list = array();
|
||||
$quest_list = $this->actQuestList($act['condition'], $account_id);
|
||||
$reward = $this->actQuestRewardList($act['reward']);
|
||||
$temp_list = array(
|
||||
'id' => $id,
|
||||
'idx' => $num,
|
||||
'quest_list' => $quest_list,
|
||||
'reward' => $reward,
|
||||
'time' => time(),
|
||||
'act' => array(),
|
||||
);
|
||||
//$info_list = $temp_list;
|
||||
return $temp_list;
|
||||
}
|
||||
|
||||
|
||||
protected function actQuestList($quest, $account_id)
|
||||
{
|
||||
$task = new classes\Quest();
|
||||
$quest_conf = $this->getExplode($quest);
|
||||
$quest_list = array();
|
||||
foreach ($quest_conf as $q) {
|
||||
$status = 0;
|
||||
if ($q[0] == 1) {
|
||||
$status = 1;
|
||||
}
|
||||
$num = 0;
|
||||
if ($q[0] == 72001 ||
|
||||
$q[0] == 72010) {
|
||||
$num++;
|
||||
if ($num >= $q[1]) {
|
||||
$status = 1;
|
||||
}
|
||||
}
|
||||
array_push($quest_list, array(
|
||||
'id' => $q[0],
|
||||
'num' => $num,
|
||||
'condition' => $q[1],
|
||||
'status' => $status,
|
||||
));
|
||||
}
|
||||
return $quest_list;
|
||||
}
|
||||
|
||||
protected function actQuestRewardList($quest)
|
||||
{
|
||||
$quest_conf = $this->getExplode($quest);
|
||||
$quest_list = array();
|
||||
foreach ($quest_conf as $q) {
|
||||
array_push($quest_list, array(
|
||||
'item_id' => $q[0],
|
||||
'item_num' => $q[1],
|
||||
'time' => $q[2],
|
||||
));
|
||||
}
|
||||
return $quest_list;
|
||||
}
|
||||
|
||||
public function getActQuestInfo($type, $info_list, $account_id)
|
||||
{
|
||||
$quest = new classes\Quest();
|
||||
$id_list = metatable\getActPlusInfo($type);
|
||||
$num = 0;
|
||||
if (empty($info_list) || !$info_list) {
|
||||
$info_list = array();
|
||||
foreach ($id_list as $i) {
|
||||
$act = metatable\getActPlusById($i['id']);
|
||||
if (!$act) {
|
||||
return null;
|
||||
}
|
||||
if (time() < strtotime($act['time1']) || time() > strtotime($act['time2'])) {
|
||||
array_push($info_list, array());
|
||||
$num++;
|
||||
continue;
|
||||
}
|
||||
$info_list = $this->insertQuestInfo($act, $i['id'], $num, $account_id, $info_list);
|
||||
$num++;
|
||||
}
|
||||
} else {
|
||||
foreach ($id_list as $i) {
|
||||
$act = metatable\getActPlusById($i['id']);
|
||||
if (!$act) {
|
||||
return null;
|
||||
}
|
||||
if (time() < strtotime($act['time1']) || time() > strtotime($act['time2'])) {
|
||||
if (!empty($info_list[$num]) && $info_list[$num]) {
|
||||
$info_list[$num] = array();
|
||||
}
|
||||
} else {
|
||||
if (empty($info_list[$num]) || !$info_list[$num]) {
|
||||
$info_list[$num] = $this->updateQuestInfo($act, $info_list, $i['id'], $num, $account_id);
|
||||
} else {
|
||||
if (phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($info_list[$num]['time']) > 0) {
|
||||
if ($act['isreset'] == 1) {
|
||||
$quest_list = $this->actQuestList($act['condition'], $account_id);
|
||||
$info_list[$num]['quest_list'] = $quest_list;
|
||||
}
|
||||
$info_list[$num]['time'] = time();
|
||||
}
|
||||
}
|
||||
}
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
return $info_list;
|
||||
}
|
||||
|
||||
protected function actExchangeList($exc)
|
||||
{
|
||||
$exc_conf = $this->getExplode($exc);
|
||||
$exc_list = array();
|
||||
foreach ($exc_conf as $e) {
|
||||
$status = 0;
|
||||
$num = 0;
|
||||
array_push($exc_list, array(
|
||||
'id' => $e[0],
|
||||
'num' => $num,
|
||||
'condition' => $e[1],
|
||||
'status' => $status,
|
||||
));
|
||||
}
|
||||
return $exc_list;
|
||||
}
|
||||
|
||||
public function actExchangeRewardList($exc)
|
||||
{
|
||||
$exc_list = explode('|', $exc);
|
||||
return $exc_list;
|
||||
}
|
||||
|
||||
protected function insertExchangeInfo($act, $id, $num, $info_list)
|
||||
{
|
||||
$exc_list = $this->actExchangeList($act['condition']);
|
||||
$reward = $this->actExchangeRewardList($act['reward']);
|
||||
$times_list = explode('|', $act['exchange_times']);
|
||||
array_push($info_list, array(
|
||||
'id' => $id,
|
||||
'idx' => $num,
|
||||
'exc_list' => $exc_list,
|
||||
'reward' => $reward,
|
||||
'time' => time(),
|
||||
'act' => array(),
|
||||
'times_list' => $times_list,
|
||||
));
|
||||
return $info_list;
|
||||
}
|
||||
|
||||
protected function updateExchangeInfo($act, $info_list, $id, $num)
|
||||
{
|
||||
$temp_list = array();
|
||||
$exc_list = $this->actExchangeList($act['condition']);
|
||||
$reward = $this->actExchangeRewardList($act['reward']);
|
||||
$times_list = explode('|', $act['exchange_times']);
|
||||
$temp_list = array(
|
||||
'id' => $id,
|
||||
'idx' => $num,
|
||||
'exc_list' => $exc_list,
|
||||
'reward' => $reward,
|
||||
'time' => time(),
|
||||
'act' => array(),
|
||||
'times_list' => $times_list,
|
||||
);
|
||||
return $temp_list;
|
||||
}
|
||||
|
||||
public function getActExchangeInfo($type, $info_list, $account_id)
|
||||
{
|
||||
$id_list = metatable\getActPlusInfo($type);
|
||||
$num = 0;
|
||||
if (empty($info_list) || !$info_list) {
|
||||
$info_list = array();
|
||||
foreach ($id_list as $i) {
|
||||
$act = metatable\getActPlusById($i['id']);
|
||||
if (!$act) {
|
||||
return null;
|
||||
}
|
||||
if (time() < strtotime($act['time1']) || time() > strtotime($act['time2'])) {
|
||||
array_push($info_list, array());
|
||||
$num++;
|
||||
continue;
|
||||
}
|
||||
$info_list = $this->insertExchangeInfo($act, $i['id'], $num, $info_list);
|
||||
$num++;
|
||||
}
|
||||
} else {
|
||||
foreach ($id_list as $i) {
|
||||
$act = metatable\getActPlusById($i['id']);
|
||||
if (!$act) {
|
||||
return null;
|
||||
}
|
||||
if (time() < strtotime($act['time1']) || time() > strtotime($act['time2'])) {
|
||||
if (!empty($info_list[$num]) && $info_list[$num]) {
|
||||
$info_list[$num] = array();
|
||||
}
|
||||
} else {
|
||||
if (empty($info_list[$num]) || !$info_list[$num]) {
|
||||
$info_list[$num] = $this->updateExchangeInfo($act, $info_list, $i['id'], $num);
|
||||
}
|
||||
}
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
return $info_list;
|
||||
}
|
||||
|
||||
//假日活动奖励
|
||||
public function holidayReward()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$user_db = $this->readHolidayDB($account_id);
|
||||
if (!$user_db || empty($user_db)) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$type = $_REQUEST['type'];
|
||||
$id = $_REQUEST['id'];
|
||||
$idx = $_REQUEST['idx'];
|
||||
|
||||
$addreward = new classes\AddReward();
|
||||
$item_list = $this->getHolidayRewardList($account_id, $user_db, $type, $id, $idx);
|
||||
$all_item_list = array();
|
||||
foreach ($item_list as $item) {
|
||||
$items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time'], 0);
|
||||
foreach($items as $i) {
|
||||
array_push($all_item_list, array(
|
||||
'item_id' => $i['item_id'],
|
||||
'item_num' => $i['item_num'],
|
||||
'time' => $i['time'],
|
||||
));
|
||||
}
|
||||
}
|
||||
$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 getHolidayRewardList($account_id, $user_db, $type, $id, $idx)
|
||||
{
|
||||
$item_list = array();
|
||||
if ($type == 3) {
|
||||
$item_list = $this->getQuestReward($account_id, $user_db, $type, $id, $idx);
|
||||
} else if ($type == 9) {
|
||||
$item_list = $this->getExchangeReward($account_id, $user_db, $type, $id, $idx);
|
||||
}
|
||||
return $item_list;
|
||||
}
|
||||
|
||||
protected function getQuestReward($account_id, $user_db, $type, $id, $idx)
|
||||
{
|
||||
$item_list = array();
|
||||
foreach ($user_db['quest_list'] as &$us) {
|
||||
if ($us['id'] != $id) {
|
||||
continue;
|
||||
}
|
||||
$num = 0;
|
||||
foreach ($us['quest_list'] as &$q) {
|
||||
if ($q['id'] != $idx || $q['status'] != 1) {
|
||||
$num++;
|
||||
continue;
|
||||
}
|
||||
array_push($item_list, array(
|
||||
'item_id' => $us['reward'][$num]['item_id'],
|
||||
'item_num' => $us['reward'][$num]['item_num'],
|
||||
'time' => $us['reward'][$num]['time'],
|
||||
));
|
||||
$q['status'] = 2;
|
||||
$num++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
$this->saveHolidayDB($account_id, $user_db);
|
||||
return $item_list;
|
||||
}
|
||||
|
||||
protected function getExchangeReward($account_id, $user_db, $type, $id, $idx)
|
||||
{
|
||||
$item_list = array();
|
||||
foreach ($user_db['exchange_list'] as &$us) {
|
||||
if ($us['id'] != $id) {
|
||||
continue;
|
||||
}
|
||||
$num = 0;
|
||||
foreach ($us['exc_list'] as &$q) {
|
||||
if ($num != $idx || $q['status'] == 1) {
|
||||
$num++;
|
||||
continue;
|
||||
}
|
||||
$item_list = $this->subItem($q['id'], $q['condition'], $us['reward'][$num], $account_id);
|
||||
$q['status'] = 0;
|
||||
$q['num']++;
|
||||
if ($q['num'] >= $us['times_list'][$num]) {
|
||||
$q['status'] = 1;
|
||||
}
|
||||
$num++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
$this->saveHolidayDB($account_id, $user_db);
|
||||
return $item_list;
|
||||
}
|
||||
|
||||
protected function subItem($id, $num, $arr, $account_id)
|
||||
{
|
||||
$item_list = array();
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
return null;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT num FROM bag WHERE accountid=:accountid AND id=:id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
'id' => $id
|
||||
));
|
||||
if (!$row || $row['num'] - $num < 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '道具不足');
|
||||
die();
|
||||
return null;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE bag SET num=:num, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid AND id =:id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':id' => $id,
|
||||
':num' => $row['num'] - $num,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return null;
|
||||
}
|
||||
$arr1 = explode(';', $arr);
|
||||
$arr2 = array();
|
||||
foreach ($arr1 as $a) {
|
||||
$mul = explode(':', $a);
|
||||
array_push($arr2, $mul);
|
||||
}
|
||||
|
||||
foreach ($arr2 as $a2) {
|
||||
array_push ($item_list, array(
|
||||
'item_id' => $a2[0],
|
||||
'item_num' => $a2[1],
|
||||
'time' => $a2[2],
|
||||
));
|
||||
}
|
||||
return $item_list;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -226,6 +226,19 @@ class GameOverController{
|
||||
return;
|
||||
}
|
||||
$item_list = $user_db['first_list'];
|
||||
if (isset($_REQUEST['data'])) {
|
||||
$arr = json_decode($_REQUEST['data'], true);
|
||||
if ($arr) {
|
||||
foreach ($arr as $a) {
|
||||
$val = $a['values'];
|
||||
array_push($item_list, array(
|
||||
'item_id' => $val[0],
|
||||
'item_num' => $val[1],
|
||||
'time' => 0,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($item_list as $it) {
|
||||
$items = $addreward->addReward($it['item_id'], $it['item_num'], $account_id, $it['time'], 0);
|
||||
@ -498,7 +511,7 @@ class GameOverController{
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$rowUser = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
@ -522,4 +535,54 @@ class GameOverController{
|
||||
'diamond_nums' => $diamond_num,
|
||||
));
|
||||
}
|
||||
|
||||
public function addSpoilsItems()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$arr = json_decode($_REQUEST['data'], true);
|
||||
$addreward = new classes\AddReward();
|
||||
$item_list = array();
|
||||
$all_item_list = array();
|
||||
if (!$arr) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个道具');
|
||||
return;
|
||||
}
|
||||
foreach ($arr as $a) {
|
||||
$val = $a['values'];
|
||||
array_push($item_list, array(
|
||||
'item_id' => $val[0],
|
||||
'item_num' => $val[1],
|
||||
'time' => 0,
|
||||
));
|
||||
$items = $addreward->addReward($val[0], $val[1], $account_id, 0, 0);
|
||||
foreach($items as $it) {
|
||||
array_push($all_item_list, array(
|
||||
'item_id' => $it['item_id'],
|
||||
'item_num' => $it['item_num'],
|
||||
'time' => $it['time'],
|
||||
));
|
||||
}
|
||||
}
|
||||
$coin_num = $addreward->getCoinNum($account_id);
|
||||
$diamond_num = $addreward->getDiamondNum($account_id);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'coin_nums' => $coin_num,
|
||||
'diamond_nums' => $diamond_num,
|
||||
'item_list' => $item_list,
|
||||
'all_item_list' => $all_item_list
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ class PayController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT vip_score, shop_view_times, game_times, newhand, newhand2, view_times2, act_ad_status, game_times2, first_day_ad FROM user WHERE accountid=:accountid;',
|
||||
$row = $conn->execQueryOne('SELECT vip_score, shop_view_times, game_times, newhand, newhand2, view_times2, act_ad_status, game_times2, first_day_ad, cpa_times, blobdata FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
@ -749,7 +749,23 @@ class PayController{
|
||||
if ($row['vip_score'] + 1 >= 5 && $row['act_ad_status'] < 1){
|
||||
$status = 1;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE user SET vip_score=:vip_score, shop_view_times=:shop_view_times, modify_time=:modify_time, newhand=:newhand, act_ad_status=:act_ad_status, newhand2=:newhand2, view_times2=:view_times2, first_day_ad=:first_day_ad ' .
|
||||
$cpa_db = json_decode($row['blobdata'], true);
|
||||
if (!is_array($cpa_db)) {
|
||||
$cpa_db = array();
|
||||
array_push($cpa_db, array(
|
||||
'cpatime' => time(),
|
||||
'isview' => true,
|
||||
));
|
||||
} else {
|
||||
foreach ($cpa_db as &$c) {
|
||||
if (phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($c['cpatime']) == 0) {
|
||||
$c['isview'] = true;
|
||||
//break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$blobdata = json_encode($cpa_db);
|
||||
$ret = $conn->execScript('UPDATE user SET vip_score=:vip_score, shop_view_times=:shop_view_times, modify_time=:modify_time, newhand=:newhand, act_ad_status=:act_ad_status, newhand2=:newhand2, view_times2=:view_times2, first_day_ad=:first_day_ad, cpa_times=:cpa_times, blobdata=:blobdata ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
@ -760,7 +776,9 @@ class PayController{
|
||||
':shop_view_times' => $row['shop_view_times'] + 1,
|
||||
':newhand2' => $newhand2,
|
||||
':view_times2' => $rview_times2,
|
||||
':first_day_ad' => $row['first_day_ad'] + 1
|
||||
':first_day_ad' => $row['first_day_ad'] + 1,
|
||||
':cpa_times' => $row['cpa_times'] + 1,
|
||||
':blobdata' => $blobdata,
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
require_once 'metatable/parameter.php';
|
||||
class RoleController{
|
||||
|
||||
protected function getMysql($account_id)
|
||||
@ -199,9 +199,9 @@ class RoleController{
|
||||
break;
|
||||
}
|
||||
}
|
||||
$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, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo, first_day_ad, share_video_times, share_video_sums, act_video_status, act_ad_status, biogame_times, shop_view_times, new_first_equip, newhand2,game_times2, view_times2, guildcoin_num, new_second_equip) ' .
|
||||
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0,0,0,0,0,0,0,2) ' .
|
||||
' 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, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo, first_day_ad=0, share_video_times=0, share_video_sums=0, act_video_status=0, act_ad_status=0, biogame_times=0, shop_view_times=0, new_first_equip=0, newhand2=0, game_times2=0,view_times2=0, guildcoin_num=0, new_second_equip=2;',
|
||||
$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, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo, first_day_ad, share_video_times, share_video_sums, act_video_status, act_ad_status, biogame_times, shop_view_times, new_first_equip, newhand2,game_times2, view_times2, guildcoin_num, new_second_equip, blobdata, cpa_times, daily_diamond_times) ' .
|
||||
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0,0,0,0,0,0,0,2,:blobdata, 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, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo, first_day_ad=0, share_video_times=0, share_video_sums=0, act_video_status=0, act_ad_status=0, biogame_times=0, shop_view_times=0, new_first_equip=0, newhand2=0, game_times2=0,view_times2=0, guildcoin_num=0, new_second_equip=2, blobdata=:blobdata, cpa_times=0, daily_diamond_times=0;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':user_name' => $user_name,
|
||||
@ -211,7 +211,8 @@ class RoleController{
|
||||
':daily_time' => 0,
|
||||
':update_time' => time(),
|
||||
':newInfo' => '',
|
||||
':season_time' => $season_time
|
||||
':season_time' => $season_time,
|
||||
':blobdata' => '',
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
@ -273,6 +274,9 @@ class RoleController{
|
||||
'view_times2'=>0,
|
||||
'guildcoin_num' => 0,
|
||||
'new_second_equip' => 2,
|
||||
'blobdata' => '',
|
||||
'cpa_times' => 0,
|
||||
'daily_diamond_times' => 0,
|
||||
));
|
||||
} else {
|
||||
if ($avatar_url != '') {
|
||||
@ -303,6 +307,12 @@ class RoleController{
|
||||
$share_video_times = $row['share_video_times'];
|
||||
$act_ad_status = $row['act_ad_status'];
|
||||
$new_second_equip = $row['new_second_equip'];
|
||||
$blobdata = $row['blobdata'];
|
||||
$cpa_times = $row['cpa_times'];
|
||||
$daily_diamond_times = $row['daily_diamond_times'];
|
||||
if (!$blobdata) {
|
||||
$blobdata = '';
|
||||
}
|
||||
if ($row['vip_score'] >= 5 && $act_ad_status != 2) {
|
||||
$act_ad_status = 1;
|
||||
$ret = $conn->execScript('UPDATE user SET act_ad_status=:act_ad_status WHERE accountid=:accountid;',
|
||||
@ -319,12 +329,17 @@ class RoleController{
|
||||
if ($new_second_equip == 2 && $row['new_first_equip'] == 1) {
|
||||
$new_second_equip = 0;
|
||||
}
|
||||
$cpa_list = $this->getCpa($row['blobdata'], $cpa_times);
|
||||
$blobdata = $cpa_list['cpastr'];
|
||||
$cpa_times = $cpa_list['cpa_times'];
|
||||
$ret = $conn->execScript('UPDATE user SET daily_first_login=0, kefu_status=0, coin_times=0, ' .
|
||||
'modify_time=:modify_time, first_day_ad=0, share_video_times=0, new_second_equip=:new_second_equip WHERE accountid=:accountid;',
|
||||
'modify_time=:modify_time, first_day_ad=0, share_video_times=0, new_second_equip=:new_second_equip, cpa_times=:cpa_times, blobdata=:blobdata, daily_diamond_times=0 WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':modify_time' => time(),
|
||||
':new_second_equip' => $new_second_equip,
|
||||
':blobdata' => $blobdata,
|
||||
':cpa_times' => $cpa_times,
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
@ -335,6 +350,7 @@ class RoleController{
|
||||
$coin_times = 0;
|
||||
$first_day_ad = 0;
|
||||
$share_video_times = 0;
|
||||
$daily_diamond_times = 0;
|
||||
if (time() > $row['season_time'] && $row['season_time'] != 0) {
|
||||
$this->updateSeasonStatus($account_id);
|
||||
}
|
||||
@ -397,10 +413,55 @@ class RoleController{
|
||||
'view_times2'=>$row['view_times2'],
|
||||
'guildcoin_num'=> $row['guildcoin_num'],
|
||||
'new_second_equip' => $new_second_equip,
|
||||
'login_day' => floor(($nowTime - phpcommon\getdayseconds($row['create_time'])) / 3600 / 24),
|
||||
'blobdata' => $blobdata,
|
||||
'cpa_times' => $cpa_times,
|
||||
'daily_diamond_times' => $daily_diamond_times,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
protected function getCpa($cpastr, $cpa_times)
|
||||
{
|
||||
$cpa_db = json_decode($cpastr, true);
|
||||
if (!is_array($cpa_db)) {
|
||||
$cpa_db = array();
|
||||
}
|
||||
if (count($cpa_db) < metatable\getParameterByName('showcpa_noad_day')) {
|
||||
array_push($cpa_db, array(
|
||||
'cpatime' => time(),
|
||||
'isview' => false,
|
||||
));
|
||||
} else {
|
||||
$flag = false;
|
||||
foreach ($cpa_db as $c) {
|
||||
if ($c['isview']) {
|
||||
$flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$flag) {
|
||||
$cpa_db = array();
|
||||
$cpa_times = 0;
|
||||
array_push($cpa_db, array(
|
||||
'cpatime' => time(),
|
||||
'isview' => false,
|
||||
));
|
||||
} else {
|
||||
array_splice($cpa_db, 0, 1);
|
||||
array_push($cpa_db, array(
|
||||
'cpatime' => time(),
|
||||
'isview' => false,
|
||||
));
|
||||
}
|
||||
}
|
||||
$cpa_list = array(
|
||||
'cpastr' => json_encode($cpa_db),
|
||||
'cpa_times' => $cpa_times,
|
||||
);
|
||||
return $cpa_list;
|
||||
}
|
||||
|
||||
protected function newPlayerReward($account_id)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
@ -677,11 +738,17 @@ class RoleController{
|
||||
$quest->triggerQuest(QUEST_DAY_ALIVE, 1, (int)($alive_time / 1000 / 60), $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_HARM, 1, $harm, $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_KILL, 1, $kills, $account_id);
|
||||
$quest->flushHolidayQuest(72003, 1, $account_id);
|
||||
$quest->flushHolidayQuest(72006, $harm, $account_id);
|
||||
$quest->flushHolidayQuest(72007, $kills, $account_id);
|
||||
$quest->flushHolidayQuest(72008, (int)($alive_time / 1000 / 60), $account_id);
|
||||
if ($team_status == 1 && $rank <= 5) {
|
||||
$quest->triggerQuest(QUEST_DAY_RANK, 1, 1, $account_id);
|
||||
$quest->flushHolidayQuest(72009, $rank, $account_id);
|
||||
}
|
||||
if ($team_status == 1) {
|
||||
$quest->triggerQuest(QUEST_DAY_TEAM, 1, 1, $account_id);
|
||||
$quest->flushHolidayQuest(72005, 1, $account_id);
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
@ -968,13 +1035,18 @@ class RoleController{
|
||||
$quest->triggerQuest(QUEST_DAY_HARM, 1, $harm, $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_KILL, 1, $kills, $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_HELP, 1, $rescue_member, $account_id);
|
||||
$quest->flushHolidayQuest(72003, 1, $account_id);
|
||||
$quest->flushHolidayQuest(72006, $harm, $account_id);
|
||||
$quest->flushHolidayQuest(72007, $kills, $account_id);
|
||||
$quest->flushHolidayQuest(72008, (int)($alive_time / 1000 / 60), $account_id);
|
||||
if ($team_status == 1 && $rank <= 5) {
|
||||
$quest->triggerQuest(QUEST_DAY_RANK, 1, 1, $account_id);
|
||||
$quest->flushHolidayQuest(72009, $rank, $account_id);
|
||||
}
|
||||
if ($team_status == 1) {
|
||||
$quest->triggerQuest(QUEST_DAY_TEAM, 1, 1, $account_id);
|
||||
$quest->flushHolidayQuest(72005, 1, $account_id);
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
@ -1044,6 +1116,7 @@ class RoleController{
|
||||
}
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_DAY_SHARE, 1, 1, $account_id);
|
||||
$quest->flushHolidayQuest(72002, 1, $account_id);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
|
@ -296,6 +296,10 @@ class ShopController{
|
||||
$id = $_REQUEST['id'];
|
||||
$type = $_REQUEST['type'];
|
||||
$num = $_REQUEST['num'];
|
||||
if ($num < 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2,'没有这个商品');
|
||||
return;
|
||||
}
|
||||
$user_db = $this->readShopDB($account_id);
|
||||
$redis_goods = $this->getGoodsDiscount($id, $type, $user_db);
|
||||
$shop_conf = metatable\getShopById($type);
|
||||
|
@ -92,6 +92,7 @@ class TeamController{
|
||||
'win_times' => $row['win_times'],
|
||||
'kills' => $row['kills'],
|
||||
'create_time' => $row['create_time'],
|
||||
'custom_data' => empty($_REQUEST['custom_data']) ? '' : $_REQUEST['custom_data'],
|
||||
)
|
||||
));
|
||||
|
||||
@ -144,6 +145,7 @@ class TeamController{
|
||||
'win_times' => $member['win_times'],
|
||||
'kills' => $member['kills'],
|
||||
'create_time' => $member['create_time'],
|
||||
'custom_data' => $member['custom_data'],
|
||||
));
|
||||
}
|
||||
echo json_encode(array(
|
||||
@ -241,6 +243,7 @@ class TeamController{
|
||||
'win_times' => $row['win_times'],
|
||||
'kills' => $row['kills'],
|
||||
'create_time' => $row['create_time'],
|
||||
'custom_data' => empty($_REQUEST['custom_data']) ? '' : $_REQUEST['custom_data'],
|
||||
));
|
||||
$r->set(TEAMID_KEY . $team_uuid, json_encode($user_db));
|
||||
$r -> pexpire(TEAMID_KEY . $team_uuid, 1000 * 600);
|
||||
|
54
webapp/metatable/activityplus.php
Normal file
54
webapp/metatable/activityplus.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace metatable;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
/*
|
||||
配置表规范
|
||||
getXXXConf:获取表所有数据
|
||||
getXxxById():通过id获取单个数据
|
||||
_internalGetXXXConf:获取表所有数据内部实现不对外开放
|
||||
|
||||
使用方式
|
||||
require_once 'metatable/XXXX.php';
|
||||
|
||||
!!!注意必须使用require_once
|
||||
*/
|
||||
|
||||
function getActPlusConf()
|
||||
{
|
||||
return _internalGetActPlusConf();
|
||||
}
|
||||
|
||||
function getActPlusById($act_id)
|
||||
{
|
||||
$conf = getActPlusConf();
|
||||
$act_id = (int)$act_id;
|
||||
return array_key_exists($act_id, $conf) ? $conf[$act_id] : null;
|
||||
}
|
||||
|
||||
function _internalGetActPlusConf()
|
||||
{
|
||||
global $g_act_table;
|
||||
if (!$g_act_table) {
|
||||
$g_act_table = require(getConfigBaseDir() . 'activityplus@activityplus.php');
|
||||
}
|
||||
return $g_act_table;
|
||||
}
|
||||
|
||||
function getActPlusInfo($type)
|
||||
{
|
||||
$conf = getActPlusConf();
|
||||
$info_list = array();
|
||||
for ($i = 1; $i <= count($conf); $i++) {
|
||||
$act = getActPlusById($i);
|
||||
if ($act['type'] != $type) {
|
||||
continue;
|
||||
}
|
||||
array_push($info_list, array(
|
||||
'id' => $act['id'],
|
||||
));
|
||||
}
|
||||
return $info_list;
|
||||
}
|
26
webapp/metatable/draw.php
Normal file
26
webapp/metatable/draw.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace metatable;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
function getDrawConf()
|
||||
{
|
||||
return _internalGetDrawConf();
|
||||
}
|
||||
|
||||
function getDrawById($draw_id)
|
||||
{
|
||||
$conf = getDrawConf();
|
||||
$draw_id = (int)$draw_id;
|
||||
return array_key_exists($draw_id, $conf) ? $conf[$draw_id] : null;
|
||||
}
|
||||
|
||||
function _internalGetDrawConf()
|
||||
{
|
||||
global $g_draw_table;
|
||||
if (!$g_draw_table) {
|
||||
$g_draw_table = require(getConfigBaseDir() . 'draw@draw.php');
|
||||
}
|
||||
return $g_draw_table;
|
||||
}
|
138
webapp/metatable/drop.php
Normal file
138
webapp/metatable/drop.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace metatable;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
function getDropConf()
|
||||
{
|
||||
return _internalGetDropConf();
|
||||
}
|
||||
|
||||
function getDropById($drop_id)
|
||||
{
|
||||
$conf = getDropConf();
|
||||
$drop_id = (int)$drop_id;
|
||||
return array_key_exists($drop_id, $conf) ? $conf[$drop_id] : null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function _internalGetDropConf()
|
||||
{
|
||||
global $g_drop_table;
|
||||
if (!$g_drop_table) {
|
||||
$g_drop_table = require(getConfigBaseDir() . 'drop@drop.php');
|
||||
}
|
||||
return $g_drop_table;
|
||||
}
|
||||
|
||||
function getDropAllListById($drop_id, $item_list)
|
||||
{
|
||||
$d = getDropById($drop_id);
|
||||
if (!$d) {
|
||||
return null;
|
||||
}
|
||||
$item_list = getDropInfo($d, $item_list);
|
||||
return $item_list;
|
||||
}
|
||||
|
||||
function getDropInfo($d, $item_list) {
|
||||
$item_id_array = getExplode($d['item_id']);
|
||||
$item_num_array = getExplode($d['num']);
|
||||
$weight_array = getExplode($d['weight']);
|
||||
$time_array = getExplode($d['time']);
|
||||
if ($d['type'] == 1) {
|
||||
for ($i = 0; $i < count($weight_array); $i++) {
|
||||
$random = Rand(0, 10000);
|
||||
if ($weight_array[$i][0] > $random) {
|
||||
$item_id = $item_id_array[$i][0];
|
||||
$item_num = $item_num_array[$i][0];
|
||||
$time = 0;
|
||||
if (!empty($time_array[$i][0]) && $time_array[$i][0] != '') {
|
||||
$time = $time_array[$i][0];
|
||||
}
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
'time' => $time,
|
||||
));
|
||||
}
|
||||
}
|
||||
} else if ($d['type'] == 2) {
|
||||
$weight_sum = 0;
|
||||
$keys = 0;
|
||||
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];
|
||||
$item_time = $time_array[$keys][0];
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
'time' => $item_time,
|
||||
));
|
||||
}
|
||||
return $item_list;
|
||||
}
|
||||
|
||||
function getDropListById($drop_id)
|
||||
{
|
||||
$d = getDropById($drop_id);
|
||||
if (!$d) {
|
||||
return null;
|
||||
}
|
||||
$item_list = array();
|
||||
$item_list = getDropInfo($d, $item_list);
|
||||
return $item_list;
|
||||
}
|
||||
|
||||
function getDropInfoById($drop_id)
|
||||
{
|
||||
$d = getDropById($drop_id);
|
||||
if (!$d) {
|
||||
return null;
|
||||
}
|
||||
$item_list = array();
|
||||
$item_id_array = getExplode($d['item_id']);
|
||||
$item_num_array = getExplode($d['num']);
|
||||
$weight_array = getExplode($d['weight']);
|
||||
$time_array = getExplode($d['time']);
|
||||
for ($i = 0; $i < count($weight_array); $i++) {
|
||||
$item_id = $item_id_array[$i][0];
|
||||
$item_num = $item_num_array[$i][0];
|
||||
$weight = $weight_array[$i][0];
|
||||
$time = 0;
|
||||
if (!empty($time_array[$i][0]) && $time_array[$i][0] != '') {
|
||||
$time = $time_array[$i][0];
|
||||
}
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
'time' => $time,
|
||||
'weight' => $weight,
|
||||
));
|
||||
}
|
||||
return $item_list;
|
||||
}
|
@ -21,7 +21,7 @@ function getParameterByName($param_name)
|
||||
$conf = getParameterConf();
|
||||
foreach ($conf as $key => $val) {
|
||||
if ($val['param_name'] == $param_name) {
|
||||
return $val;
|
||||
return $val['param_value'];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user