diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index 0fb7f9b3d..8be9a8ce8 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -790,4 +790,75 @@ class ConsoleController extends Think { M('spend', 'tab_')->where(['promote_id' => ['in', $ids], 'spend_time' => ['egt', $orderTime]])->save(['market_admin_id' => $toPromote['admin_id']]); } */ } + + public function roleHash() + { + $lastId = 0; + do { + $records = M('user_play_info', 'tab_')->field(['id', 'role_id', 'user_id', 'base_game_id'])->where(['id' => ['gt', $lastId]])->limit(1000)->select(); + $count = 0; + foreach ($records as $record) { + $lastId = $record['id']; + $salt = 0; + $count ++; + $value = $record['base_game_id'] . '#' . $record['user_id'] . '#' . 0 . '#' . $record['role_id'] . '#' . $salt; + $hashCode = $this->hashCode64($value); + $key = 'role_key:' . $hashCode; + if ($existRecord = Redis::get($key)) { + $existRecord = json_decode($existRecord, true); + if ($record['base_game_id'] == $existRecord['base_game_id'] && $record['user_id'] == $existRecord['user_id'] && $record['role_id'] == $existRecord['role_id']) { + } else { + [$salt, $hashCode] = $this->getNewSalt($record); + M('user_play_info', 'tab_')->where(['id' => $record['id']])->save([ + 'role_key' => $hashCode, + 'role_key_salt' => $salt, + ]); + $key = 'role_key:' . $hashCode; + Redis::set($key, json_encode($record)); + echo 'UPDATE: ' . $record['id']; + echo "\n"; + } + } else { + Redis::set($key, json_encode($record)); + } + /* M('user_play_info', 'tab_')->where(['id' => $record['id']])->save([ + 'role_key' => $hashCode, + 'role_key_salt' => $salt, + ]); */ + } + echo 'SUCCESS_COUNT: ' . $count . ' LAST_ID:' . $lastId; + echo "\n"; + } while ($count > 0); + } + + private function getNewSalt($record) + { + $salt = 0; + $hashCode = 0; + do { + $salt += 1; + $value = $record['game_id'] . '#' . $record['user_id'] . '#' . 0 . '#' . $record['role_id'] . '#' . $salt; + $hashCode = $this->hashCode64($value); + $key = 'role_key:' . $hashCode; + $existRecord = Redis::get($key); + } while ($existRecord); + + return [$salt, $hashCode]; + } + + private function hashCode64($str) { + $str = (string)$str; + $hash = 0; + $len = strlen($str); + if ($len == 0 ) + return $hash; + for ($i = 0; $i < $len; $i++) { + $h = $hash << 5; + $h -= $hash; + $h += ord($str[$i]); + $hash = $h; + $hash &= 0x7FFFFFFF; + } + return $hash; + } } diff --git a/Application/Admin/Controller/GameRebateController.class.php b/Application/Admin/Controller/GameRebateController.class.php index 99b40e294..5ba7fd9bc 100644 --- a/Application/Admin/Controller/GameRebateController.class.php +++ b/Application/Admin/Controller/GameRebateController.class.php @@ -42,6 +42,16 @@ class GameRebateController extends ThinkController $this->records('F'); } + public function newRole() + { + $this->records('G'); + } + + public function dailySign() + { + $this->records('H'); + } + public function records($awardType) { $params = I('get.'); diff --git a/Application/Admin/View/GameRebate/records.html b/Application/Admin/View/GameRebate/records.html index f676c6ddc..111ff909c 100644 --- a/Application/Admin/View/GameRebate/records.html +++ b/Application/Admin/View/GameRebate/records.html @@ -200,6 +200,8 @@