From 014266a4490fc47fc42937cbd3db75c2aac0fd98 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 10 Nov 2020 19:48:27 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/gamedb.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index dc7249b..8d3cad6 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -150,6 +150,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; @@ -171,6 +172,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; @@ -189,6 +191,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; @@ -257,6 +260,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; @@ -277,6 +281,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; From c988bdc6ef26fb12fa684134bc623617acfbbb23 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 10 Nov 2020 20:09:30 +0800 Subject: [PATCH 02/19] 1 --- sql/gamedb2004_n_migrate_201111_01.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 sql/gamedb2004_n_migrate_201111_01.sql diff --git a/sql/gamedb2004_n_migrate_201111_01.sql b/sql/gamedb2004_n_migrate_201111_01.sql new file mode 100644 index 0000000..a4588e5 --- /dev/null +++ b/sql/gamedb2004_n_migrate_201111_01.sql @@ -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; From a72a97fd21c603f1dd3e670903f2d84ebdb5affe Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 30 Nov 2020 18:51:09 +0800 Subject: [PATCH 03/19] 1 --- webapp/controller/FesActivityController.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/controller/FesActivityController.class.php b/webapp/controller/FesActivityController.class.php index e58c654..3c0f9d8 100644 --- a/webapp/controller/FesActivityController.class.php +++ b/webapp/controller/FesActivityController.class.php @@ -133,6 +133,7 @@ class FesActivityController{ protected function getfesActInfo($account_id) { $user_db = $this->readFesActDB($account_id); + $act_id = $user_db['act_id']; $act = metatable\getNowActivity(); $info_list = array(); if (!$act) { @@ -145,7 +146,7 @@ class FesActivityController{ $this->saveFesActDB($account_id, $act_db); } else { //活动开启 - if (empty($user_db) || empty($user_db['info_list'])) { + if (empty($user_db) || empty($user_db['info_list']) || $act_id != $act['id']) { $info_list = $this->getActItem($act['id']); $act_db = array( 'isopen' => 1, From 0507739fbc8c17fd1634de29a18ce91d0563706c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 30 Nov 2020 18:55:07 +0800 Subject: [PATCH 04/19] 1 --- sql/gamedb.sql | 5 +++++ sql/gamedb2004_n_migrate_201111_01.sql | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 sql/gamedb2004_n_migrate_201111_01.sql diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 7b77702..e4b1c1e 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -144,6 +144,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 +166,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 +185,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 +254,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 +275,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; diff --git a/sql/gamedb2004_n_migrate_201111_01.sql b/sql/gamedb2004_n_migrate_201111_01.sql new file mode 100644 index 0000000..a4588e5 --- /dev/null +++ b/sql/gamedb2004_n_migrate_201111_01.sql @@ -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; From d8905a842c759c611f7a43c3bc56d03284ca55ab Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 1 Dec 2020 16:32:43 +0800 Subject: [PATCH 05/19] 1 --- sql/gamedb.sql | 24 ---------------------- webapp/controller/HangController.class.php | 12 ----------- 2 files changed, 36 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index dc7249b..7b77702 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -102,12 +102,6 @@ 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 '累计充值次数', - - /* - `rmb_num` int(11) NOT NULL DEFAULT '0' COMMENT '点券数量', - `max_single_recharge` int(11) NOT NULL DEFAULT '0' COMMENT '最大单次充值数量', - `passcard` 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; @@ -306,22 +300,4 @@ CREATE TABLE `festival_activity` ( UNIQUE KEY `accountid` (`accountid`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*DROP TABLE IF EXISTS `orderinfo`;*/ -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -/* -CREATE TABLE `orderinfo` ( - `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', - `accountid` varchar(60) DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', - `orderid` varchar(60) DEFAULT '' COMMENT '订单id', - `rmb_num` int(11) NOT NULL DEFAULT '0' COMMENT '点券数量', - `money` int(11) NOT NULL DEFAULT '0' COMMENT '金钱数量', - `custom_data` mediumblob COMMENT '其他字段', - `itemid` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', - `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', - PRIMARY KEY (`idx`), - UNIQUE KEY `account_orderid` (`accountid`, `orderid`) -) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -*/ -- Dump completed on 2015-08-19 18:51:22 diff --git a/webapp/controller/HangController.class.php b/webapp/controller/HangController.class.php index 8bcd956..5059f91 100644 --- a/webapp/controller/HangController.class.php +++ b/webapp/controller/HangController.class.php @@ -148,20 +148,8 @@ class HangController{ if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) { $open_time = strtotime($season['open_time']); $end_time = strtotime($season['end_time']); - /*$ret = $conn->execScript('UPDATE user SET season_time=:season_time, modify_time=:modify_time ' . - ' WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':season_time' => $end_time, - ':modify_time' => time() - )); - if (!$ret) { - die(); - return; - }*/ $number = $i; $item_multiply = $this->getExplode($season['reward']); - //$ii = 0; for($ii = 1; $ii <= count($item_multiply); $ii++) { $rowpass = $conn->execQueryOne('SELECT active_status, honor_status ' . ' FROM passinfo WHERE accountid=:accountid AND passid=:passid;', From 190921fd12be9263370e10f2fb88944153988c34 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 1 Dec 2020 16:33:20 +0800 Subject: [PATCH 06/19] 1 --- webapp/metatable/item.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 webapp/metatable/item.php diff --git a/webapp/metatable/item.php b/webapp/metatable/item.php new file mode 100644 index 0000000..a266624 --- /dev/null +++ b/webapp/metatable/item.php @@ -0,0 +1,26 @@ + Date: Wed, 2 Dec 2020 15:04:16 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E6=94=B9=E4=B8=BA=E5=8F=AF=E4=BB=A5=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/rankserver/app.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/rankserver/app.py b/tools/rankserver/app.py index 87a5131..e7bafb7 100644 --- a/tools/rankserver/app.py +++ b/tools/rankserver/app.py @@ -19,6 +19,8 @@ import functools CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/game2004api_rankserver/config' +RANK_KEY_PREFIX = 'game2004api:' +DBNAME_PREFIX = 'gamedb2004_' def _take_pass(elem): return elem[3] @@ -123,7 +125,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() @@ -187,7 +189,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() @@ -204,19 +206,19 @@ def incrementUpdateRank(): 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) @@ -246,6 +248,8 @@ if __name__ == "__main__": f7.udplog.info('rankserver start pid:' + str(os.getpid())) 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) conf['rushtime'] = 300 f7.timer.callLater(conf['rushtime'], From 5b0463bede3530cdbcdc623ed3ebdc6331121a98 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 4 Dec 2020 10:49:32 +0800 Subject: [PATCH 08/19] 1 --- tools/rankserver/app.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/rankserver/app.py b/tools/rankserver/app.py index e7bafb7..03409c9 100644 --- a/tools/rankserver/app.py +++ b/tools/rankserver/app.py @@ -21,6 +21,7 @@ import functools CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/game2004api_rankserver/config' RANK_KEY_PREFIX = 'game2004api:' DBNAME_PREFIX = 'gamedb2004_' +IGNORE_GUESET_ACCOUNT = 0 def _take_pass(elem): return elem[3] @@ -137,6 +138,9 @@ def fullUpdateRank(): has_data = False for row in cursor: has_data = True + last_idx = max(row[8], last_idx) + if IGNORE_GUESET_ACCOUNT and (row[1] == '游客' or row[1] == '极乐玩家'): + continue #更新击杀榜 channel = f7.getChannelByAccountId(row[0]) if checkchannel(channel): @@ -155,7 +159,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 @@ -203,6 +206,9 @@ def incrementUpdateRank(): for row in cursor: has_data = True channel = f7.getChannelByAccountId(row[0]) + last_idx = max(row[8], last_idx) + if IGNORE_GUESET_ACCOUNT and (row[1] == '游客' or row[1] == '极乐玩家'): + continue if checkchannel(channel): #更新击杀榜 if channel not in kill_hash: @@ -222,7 +228,6 @@ def incrementUpdateRank(): 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 @@ -250,6 +255,7 @@ if __name__ == "__main__": 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_GUESET_ACCOUNT = conf.get('ignore_guest_account', IGNORE_GUESET_ACCOUNT) conf['rushtime'] = 300 f7.timer.callLater(conf['rushtime'], From 4d1302659b7a36d87b94a3770cfa4fe7e99ae2ff Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 4 Dec 2020 13:28:28 +0800 Subject: [PATCH 09/19] 1 --- tools/rankserver/app.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/rankserver/app.py b/tools/rankserver/app.py index 03409c9..4adc2d6 100644 --- a/tools/rankserver/app.py +++ b/tools/rankserver/app.py @@ -21,7 +21,7 @@ import functools CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/game2004api_rankserver/config' RANK_KEY_PREFIX = 'game2004api:' DBNAME_PREFIX = 'gamedb2004_' -IGNORE_GUESET_ACCOUNT = 0 +IGNORE_GUEST_ACCOUNT = 0 def _take_pass(elem): return elem[3] @@ -139,7 +139,8 @@ def fullUpdateRank(): for row in cursor: has_data = True last_idx = max(row[8], last_idx) - if IGNORE_GUESET_ACCOUNT and (row[1] == '游客' or 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]) @@ -207,7 +208,8 @@ def incrementUpdateRank(): has_data = True channel = f7.getChannelByAccountId(row[0]) last_idx = max(row[8], last_idx) - if IGNORE_GUESET_ACCOUNT and (row[1] == '游客' or row[1] == '极乐玩家'): + user_name = str(row[1], encoding='utf8') + if IGNORE_GUEST_ACCOUNT and (user_name == '游客' or user_name == '极乐玩家'): continue if checkchannel(channel): #更新击杀榜 @@ -247,16 +249,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()) - RANK_KEY_PREFIX = conf.get('key_prefix', RANK_KEY_PREFIX) - DBNAME_PREFIX = conf.get('dbname_prefix', DBNAME_PREFIX) - IGNORE_GUESET_ACCOUNT = conf.get('ignore_guest_account', IGNORE_GUESET_ACCOUNT) - conf['rushtime'] = 300 f7.timer.callLater(conf['rushtime'], lambda : _incrementUpdateRank(conf['rushtime'])) From da9c86495e00924a6fceec9efff61ada46c8bf80 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 7 Dec 2020 19:25:59 +0800 Subject: [PATCH 10/19] 1 --- tools/rankserver/app.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/rankserver/app.py b/tools/rankserver/app.py index 4adc2d6..1054d38 100644 --- a/tools/rankserver/app.py +++ b/tools/rankserver/app.py @@ -88,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:] @@ -139,7 +142,9 @@ def fullUpdateRank(): for row in cursor: has_data = True last_idx = max(row[8], last_idx) - user_name = str(row[1], encoding='utf8') + user_name = '' + if row[1]: + user_name = str(row[1], encoding='utf8') if IGNORE_GUEST_ACCOUNT and (user_name == '游客' or user_name == '极乐玩家'): continue #更新击杀榜 @@ -208,7 +213,9 @@ def incrementUpdateRank(): has_data = True channel = f7.getChannelByAccountId(row[0]) last_idx = max(row[8], last_idx) - user_name = str(row[1], encoding='utf8') + 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): From 0ec41feaa2e80f422a0a96d1bf9f1d2795b591db Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Dec 2020 19:50:53 +0800 Subject: [PATCH 11/19] 1 --- sql/gamedb.sql | 13 + sql/gamedb2004_n_migrate_201208_01.sql | 18 + webapp/classes/AddReward.php | 43 ++ webapp/classes/Quest.php | 114 ++++ .../controller/ActivityController.class.php | 5 +- webapp/controller/AdditemController.class.php | 2 +- .../FesActivityController.class.php | 485 +++++++++++++++++- .../controller/GameOverController.class.php | 65 ++- webapp/controller/RoleController.class.php | 15 +- webapp/metatable/activityplus.php | 54 ++ 10 files changed, 806 insertions(+), 8 deletions(-) create mode 100644 sql/gamedb2004_n_migrate_201208_01.sql create mode 100644 webapp/metatable/activityplus.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index e4b1c1e..0504ba1 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -305,4 +305,17 @@ 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; + -- Dump completed on 2015-08-19 18:51:22 diff --git a/sql/gamedb2004_n_migrate_201208_01.sql b/sql/gamedb2004_n_migrate_201208_01.sql new file mode 100644 index 0000000..118513f --- /dev/null +++ b/sql/gamedb2004_n_migrate_201208_01.sql @@ -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; diff --git a/webapp/classes/AddReward.php b/webapp/classes/AddReward.php index b1a701e..fad278d 100644 --- a/webapp/classes/AddReward.php +++ b/webapp/classes/AddReward.php @@ -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); diff --git a/webapp/classes/Quest.php b/webapp/classes/Quest.php index 5955e97..e4c53dd 100644 --- a/webapp/classes/Quest.php +++ b/webapp/classes/Quest.php @@ -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(), + )); + } + } } ?> diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index 4703236..52e8e6c 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -426,6 +426,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, @@ -714,7 +715,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']; @@ -902,6 +903,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, @@ -1202,6 +1204,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'=> '', diff --git a/webapp/controller/AdditemController.class.php b/webapp/controller/AdditemController.class.php index 44ef8f5..a17778d 100644 --- a/webapp/controller/AdditemController.class.php +++ b/webapp/controller/AdditemController.class.php @@ -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; diff --git a/webapp/controller/FesActivityController.class.php b/webapp/controller/FesActivityController.class.php index 3c0f9d8..aab13af 100644 --- a/webapp/controller/FesActivityController.class.php +++ b/webapp/controller/FesActivityController.class.php @@ -2,6 +2,8 @@ require 'classes/AddReward.php'; require_once 'metatable/activity.php'; +require_once 'metatable/activityplus.php'; +require 'classes/Quest.php'; class FesActivityController{ @@ -287,10 +289,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 +328,484 @@ 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); + echo json_encode(array( + 'errcode' => 0, + 'errmsg'=> '', + 'quest_list' => $user_db['quest_list'], + 'exchange_list' => $user_db['exchange_list'], + )); + } + + protected function getHolidayInfo($account_id) + { + $user_db = $this->readHolidayDB($account_id); + //$quest_list = $this->getActQuestInfo(3, array(), $account_id); + //$exchange_list = $this->getActExchangeInfo(9, array(), $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 = array(); + $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' => $act, + )); + 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']); + //$info_list[$num] = $temp_list; + array_push($temp_list, array( + 'id' => $id, + 'idx' => $num, + 'quest_list' => $quest_list, + 'reward' => $reward, + 'time' => time(), + 'act' => $act, + )); + $info_list = $temp_list; + return $info_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); + $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 = $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 = array(); + $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' => $act, + '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']); + array_push($temp_list, array( + 'id' => $id, + 'idx' => $num, + 'exc_list' => $exc_list, + 'reward' => $reward, + 'time' => time(), + 'act' => $act, + 'times_list' => $times_list, + )); + $info_list = $temp_list; + return $info_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); + $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 = $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; + } } ?> diff --git a/webapp/controller/GameOverController.class.php b/webapp/controller/GameOverController.class.php index c3a41b2..f0d6d26 100644 --- a/webapp/controller/GameOverController.class.php +++ b/webapp/controller/GameOverController.class.php @@ -225,6 +225,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); @@ -497,7 +510,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( @@ -521,4 +534,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 + )); + } } diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index 761dc7b..53ed3c2 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -677,11 +677,18 @@ 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 +975,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 +1056,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' => '', diff --git a/webapp/metatable/activityplus.php b/webapp/metatable/activityplus.php new file mode 100644 index 0000000..88042cf --- /dev/null +++ b/webapp/metatable/activityplus.php @@ -0,0 +1,54 @@ + $act['id'], + )); + } + return $info_list; +} From 8d220716dba2f5a972bad501fb13a6592e9d97d0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 19 Jan 2021 19:58:37 +0800 Subject: [PATCH 12/19] 1 --- sql/gamedb.sql | 3 + sql/gamedb2004_n_migrate_210119_01.sql | 8 +++ .../FesActivityController.class.php | 64 ++++++++++------- webapp/controller/PayController.class.php | 24 ++++++- webapp/controller/RoleController.class.php | 70 +++++++++++++++++-- 5 files changed, 134 insertions(+), 35 deletions(-) create mode 100644 sql/gamedb2004_n_migrate_210119_01.sql diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 0504ba1..b06588d 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -102,6 +102,9 @@ 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看视频次数', PRIMARY KEY (`idx`), UNIQUE KEY `accountid` (`accountid`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; diff --git a/sql/gamedb2004_n_migrate_210119_01.sql b/sql/gamedb2004_n_migrate_210119_01.sql new file mode 100644 index 0000000..f1400e2 --- /dev/null +++ b/sql/gamedb2004_n_migrate_210119_01.sql @@ -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; diff --git a/webapp/controller/FesActivityController.class.php b/webapp/controller/FesActivityController.class.php index aab13af..d948d2c 100644 --- a/webapp/controller/FesActivityController.class.php +++ b/webapp/controller/FesActivityController.class.php @@ -123,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, )); } @@ -396,19 +398,35 @@ class FesActivityController{ //假日活动信息 $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 ($q['id']) { + $act = metatable\getActPlusById($q['id']); + if ($act) { + $q['act'] = $act; + } + } + } + foreach ($exc_list as &$e) { + if ($e['id']) { + $act = metatable\getActPlusById($e['id']); + if ($act) { + $e['act'] = $act; + } + } + } echo json_encode(array( 'errcode' => 0, 'errmsg'=> '', - 'quest_list' => $user_db['quest_list'], - 'exchange_list' => $user_db['exchange_list'], + 'quest_list' => $quest_list, + 'exchange_list' => $exc_list, )); } protected function getHolidayInfo($account_id) { $user_db = $this->readHolidayDB($account_id); - //$quest_list = $this->getActQuestInfo(3, array(), $account_id); - //$exchange_list = $this->getActExchangeInfo(9, array(), $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( @@ -418,9 +436,8 @@ class FesActivityController{ $this->saveHolidayDB($account_id, $hol_db); } - protected function insertQuestInfo($act, $id, $num, $account_id) + protected function insertQuestInfo($act, $id, $num, $account_id, $info_list) { - $info_list = array(); $reward = array(); $quest_list = $this->actQuestList($act['condition'], $account_id); $reward = $this->actQuestRewardList($act['reward']); @@ -430,7 +447,7 @@ class FesActivityController{ 'quest_list' => $quest_list, 'reward' => $reward, 'time' => time(), - 'act' => $act, + 'act' => array(), )); return $info_list; } @@ -441,17 +458,16 @@ class FesActivityController{ $temp_list = array(); $quest_list = $this->actQuestList($act['condition'], $account_id); $reward = $this->actQuestRewardList($act['reward']); - //$info_list[$num] = $temp_list; - array_push($temp_list, array( + $temp_list = array( 'id' => $id, 'idx' => $num, 'quest_list' => $quest_list, 'reward' => $reward, 'time' => time(), - 'act' => $act, - )); - $info_list = $temp_list; - return $info_list; + 'act' => array(), + ); + //$info_list = $temp_list; + return $temp_list; } @@ -514,7 +530,7 @@ class FesActivityController{ $num++; continue; } - $info_list = $this->insertQuestInfo($act, $i['id'], $num, $account_id); + $info_list = $this->insertQuestInfo($act, $i['id'], $num, $account_id, $info_list); $num++; } } else { @@ -529,7 +545,7 @@ class FesActivityController{ } } else { if (empty($info_list[$num]) || !$info_list[$num]) { - $info_list = $this->updateQuestInfo($act, $info_list, $i['id'], $num, $account_id); + $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) { @@ -569,9 +585,8 @@ class FesActivityController{ return $exc_list; } - protected function insertExchangeInfo($act, $id, $num) + protected function insertExchangeInfo($act, $id, $num, $info_list) { - $info_list = array(); $exc_list = $this->actExchangeList($act['condition']); $reward = $this->actExchangeRewardList($act['reward']); $times_list = explode('|', $act['exchange_times']); @@ -581,7 +596,7 @@ class FesActivityController{ 'exc_list' => $exc_list, 'reward' => $reward, 'time' => time(), - 'act' => $act, + 'act' => array(), 'times_list' => $times_list, )); return $info_list; @@ -593,17 +608,16 @@ class FesActivityController{ $exc_list = $this->actExchangeList($act['condition']); $reward = $this->actExchangeRewardList($act['reward']); $times_list = explode('|', $act['exchange_times']); - array_push($temp_list, array( + $temp_list = array( 'id' => $id, 'idx' => $num, 'exc_list' => $exc_list, 'reward' => $reward, 'time' => time(), - 'act' => $act, + 'act' => array(), 'times_list' => $times_list, - )); - $info_list = $temp_list; - return $info_list; + ); + return $temp_list; } public function getActExchangeInfo($type, $info_list, $account_id) @@ -622,7 +636,7 @@ class FesActivityController{ $num++; continue; } - $info_list = $this->insertExchangeInfo($act, $i['id'], $num); + $info_list = $this->insertExchangeInfo($act, $i['id'], $num, $info_list); $num++; } } else { @@ -637,7 +651,7 @@ class FesActivityController{ } } else { if (empty($info_list[$num]) || !$info_list[$num]) { - $info_list = $this->updateExchangeInfo($act, $info_list, $i['id'], $num); + $info_list[$num] = $this->updateExchangeInfo($act, $info_list, $i['id'], $num); } } $num++; diff --git a/webapp/controller/PayController.class.php b/webapp/controller/PayController.class.php index 940ac23..a33172c 100644 --- a/webapp/controller/PayController.class.php +++ b/webapp/controller/PayController.class.php @@ -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(); diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index 53ed3c2..c2ad8cf 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -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) ' . + ' 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) ' . + ' 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;', 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,8 @@ class RoleController{ 'view_times2'=>0, 'guildcoin_num' => 0, 'new_second_equip' => 2, + 'blobdata' => '', + 'cpa_times' => 0, )); } else { if ($avatar_url != '') { @@ -303,6 +306,11 @@ 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']; + 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 +327,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 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(); @@ -397,10 +410,54 @@ 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, )); } } + 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,7 +734,6 @@ 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); From 84678d76f965a371c0c4e24f0222b885f706fe8b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 19 Jan 2021 21:01:04 +0800 Subject: [PATCH 13/19] 1 --- webapp/controller/FesActivityController.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/controller/FesActivityController.class.php b/webapp/controller/FesActivityController.class.php index d948d2c..5e518c8 100644 --- a/webapp/controller/FesActivityController.class.php +++ b/webapp/controller/FesActivityController.class.php @@ -401,7 +401,7 @@ class FesActivityController{ $quest_list = $user_db['quest_list']; $exc_list = $user_db['exchange_list']; foreach ($quest_list as &$q) { - if ($q['id']) { + if (isset($q['id'])) { $act = metatable\getActPlusById($q['id']); if ($act) { $q['act'] = $act; @@ -409,7 +409,7 @@ class FesActivityController{ } } foreach ($exc_list as &$e) { - if ($e['id']) { + if (isset($e['id'])) { $act = metatable\getActPlusById($e['id']); if ($act) { $e['act'] = $act; From 7b9f9300a06e97ba4fd11560bba78e337f66013b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 20 Jan 2021 20:16:47 +0800 Subject: [PATCH 14/19] 1 --- webapp/controller/ShopController.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 18e9191..70399d0 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -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); From 1e9fa161f2fac9447aaf1964879b4a2856d6b18c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 21 Jan 2021 11:18:19 +0800 Subject: [PATCH 15/19] 1 --- .../controller/ActivityController.class.php | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index 52e8e6c..db0172b 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -5,6 +5,7 @@ require 'classes/AddReward.php'; class ActivityController{ + private $actTableCache = null; protected function getMysql($account_id) { $mysql_conf = getMysqlConfig(crc32($account_id)); @@ -87,8 +88,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'], @@ -350,23 +353,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; - } + $key = $lot_array[0]['key']; } else { foreach ($user_db['draw_list'] as $draw) { if (isset($draw['status']) && $draw['status'] != 0) { From 2eace9543980b8436ed9217cfe154ded5f36dad2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 29 Jan 2021 13:29:23 +0800 Subject: [PATCH 16/19] 1 --- sql/gamedb.sql | 17 +- sql/gamedb2004_n_migrate_210129_01.sql | 21 ++ .../controller/ActivityController.class.php | 322 +++++++++++++++++- webapp/controller/RoleController.class.php | 12 +- webapp/metatable/draw.php | 26 ++ webapp/metatable/drop.php | 138 ++++++++ webapp/metatable/parameter.php | 2 +- 7 files changed, 531 insertions(+), 7 deletions(-) create mode 100644 sql/gamedb2004_n_migrate_210129_01.sql create mode 100644 webapp/metatable/draw.php create mode 100644 webapp/metatable/drop.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index b06588d..c377f0c 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -102,9 +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; @@ -321,4 +322,18 @@ CREATE TABLE `holiday` ( 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 diff --git a/sql/gamedb2004_n_migrate_210129_01.sql b/sql/gamedb2004_n_migrate_210129_01.sql new file mode 100644 index 0000000..119b9e1 --- /dev/null +++ b/sql/gamedb2004_n_migrate_210129_01.sql @@ -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; diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index db0172b..31384f8 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -2,7 +2,9 @@ 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; @@ -1535,5 +1537,323 @@ 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' => $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, + )); + } } ?> diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index c2ad8cf..53ea7a6 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -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, blobdata, cpa_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) ' . - ' 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;', + $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, @@ -276,6 +276,7 @@ class RoleController{ 'new_second_equip' => 2, 'blobdata' => '', 'cpa_times' => 0, + 'daily_diamond_times' => 0, )); } else { if ($avatar_url != '') { @@ -308,6 +309,7 @@ class RoleController{ $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 = ''; } @@ -331,7 +333,7 @@ class RoleController{ $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, cpa_times=:cpa_times, blobdata=:blobdata 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(), @@ -348,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); } @@ -413,6 +416,7 @@ class RoleController{ 'login_day' => floor(($nowTime - phpcommon\getdayseconds($row['create_time'])) / 3600 / 24), 'blobdata' => $blobdata, 'cpa_times' => $cpa_times, + 'daily_diamond_times' => $daily_diamond_times, )); } } diff --git a/webapp/metatable/draw.php b/webapp/metatable/draw.php new file mode 100644 index 0000000..056cc87 --- /dev/null +++ b/webapp/metatable/draw.php @@ -0,0 +1,26 @@ + $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; +} diff --git a/webapp/metatable/parameter.php b/webapp/metatable/parameter.php index f730816..e1a88a9 100644 --- a/webapp/metatable/parameter.php +++ b/webapp/metatable/parameter.php @@ -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; From bc706444b08212f9a4eb392091bd6cafd63eb8f3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 1 Feb 2021 13:55:59 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E5=AE=9D=E7=AE=B1=E5=A4=B8=E5=A4=A9?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/controller/ActivityController.class.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index 31384f8..28b3053 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -1599,11 +1599,16 @@ class ActivityController{ 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'], + )); } - array_push($info_list, array( - 'id' => $row['id'], - 'cd_time' => $row['cd_time'], - )); } } From a0b7fe1b1feda4d5a13c8f5a7a79d3f64aa5e72a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 2 Feb 2021 13:46:48 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E6=B7=BB=E5=8A=A0custom=20data=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/controller/TeamController.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webapp/controller/TeamController.class.php b/webapp/controller/TeamController.class.php index d41a8e2..e8c890b 100644 --- a/webapp/controller/TeamController.class.php +++ b/webapp/controller/TeamController.class.php @@ -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); From 6e1c4b250028c8aa095222a9c14b3726d3dab0be Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 5 Feb 2021 20:00:46 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E6=B7=BB=E5=8A=A06007=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/controller/GameOverController.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/controller/GameOverController.class.php b/webapp/controller/GameOverController.class.php index f0d6d26..729ff48 100644 --- a/webapp/controller/GameOverController.class.php +++ b/webapp/controller/GameOverController.class.php @@ -165,7 +165,8 @@ class GameOverController{ //道具物品 $first_list = array(); if (phpcommon\extractChannel($account_id) == 6001 || - phpcommon\extractChannel($account_id) == 6000) { + phpcommon\extractChannel($account_id) == 6007 || + phpcommon\extractChannel($account_id) == 6000) { array_push($first_list, array( 'item_id' => 18006, 'item_num' => $num,