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; diff --git a/tools/migratedb/import_redis.py b/tools/migratedb/import_redis.py index ab587d6..45a6eeb 100644 --- a/tools/migratedb/import_redis.py +++ b/tools/migratedb/import_redis.py @@ -12,11 +12,12 @@ import pprint argv = sys.argv host = argv[1] port = argv[2] -script_name = argv[3] +passwd = argv[3] +script_name = argv[4] def writeToRedis(conn, cmdline): assert len(cmdline) > 1 -# print(cmdline) + print(cmdline) if cmdline[0] == 'hset': conn.hset(cmdline[1], cmdline[2], cmdline[3]) elif cmdline[0] == 'zadd': @@ -24,14 +25,19 @@ def writeToRedis(conn, cmdline): elif cmdline[0] == 'sadd': conn.sadd(cmdline[1], cmdline[2]) elif cmdline[0] == 'set': - conn.set(cmdline[1], cmdline[2]) + if cmdline[2] != None: + conn.set(cmdline[1], cmdline[2]) + else: + print('[warning]', cmdline) elif cmdline[0] == 'expire': - conn.expire(cmdline[1], cmdline[2]) + if int(cmdline[2]) >= 0: + conn.expire(cmdline[1], cmdline[2]) else: assert False conn = redis.Redis(host = host, port = port, + password = passwd, db = 0, decode_responses = True ) diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index 79b51bf..4703236 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -254,23 +254,30 @@ class ActivityController{ } else { $user_db_str = $r->get($draw_uuid); $user_db = json_decode($user_db_str, true); - if (empty($user_db)) { - phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); - return; - } - - foreach ($user_db['draw_list'] as $draw) { - $status = 0; - if (isset($draw['status'])) { - $status = $draw['status']; + if (empty($user_db) || empty($user_db['draw_list'])) { + $user_db_str = $r->get($draw_uuid); + $draw_list = $this->randomNewReward(1,$account_id,$now_days); + $draw_db = json_decode($user_db_str, true); + $draw_db = array( + 'draw_uuid' => $draw_uuid, + 'draw_list' => $draw_list, + ); + $r -> set($draw_uuid, json_encode($draw_db)); + $r -> pexpire($draw_uuid, 1000 * 3600 * 24); + } else { + foreach ($user_db['draw_list'] as $draw) { + $status = 0; + if (isset($draw['status'])) { + $status = $draw['status']; + } + array_push($draw_list, array( + 'item_id' => $draw['item_id'], + 'item_num' => $draw['item_num'], + 'quailty' => $draw['quailty'], + 'time' => $draw['time'], + 'status' => $status, + )); } - array_push($draw_list, array( - 'item_id' => $draw['item_id'], - 'item_num' => $draw['item_num'], - 'quailty' => $draw['quailty'], - 'time' => $draw['time'], - 'status' => $status, - )); } } } @@ -376,7 +383,6 @@ class ActivityController{ $weight_sum += $l['jilv']; } $random = Rand(1, $weight_sum); - // error_log($random); for ($ii = 0; $ii < count($lot_array); $ii++) { $l = $this->getLottery($lot_array[$ii]['key']); @@ -853,7 +859,6 @@ class ActivityController{ $weight_sum += $l['jilv']; } $random = Rand(1, $weight_sum); - // error_log($random); for ($ii = 0; $ii < count($lot_array); $ii++) { $l = $this->getLottery($lot_array[$ii]['key']); $weight += $l['jilv']; @@ -1179,7 +1184,7 @@ class ActivityController{ } //固定奖励 $delim2 = ":"; - $re_multiply = explode($delim2, $rec['re_reward']);; + $re_multiply = explode($delim2, $rec['re_reward']); array_push($item_list, array( 'item_id' => $re_multiply[0], 'item_num' => $re_multiply[1], 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,