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 @@ 达成日期 可领取福利日期 + + 签到日期 奖励内容 订单生成时间 @@ -245,6 +247,8 @@ {$data.award_date} {$data.award_date_range} + + {$data.award_date} {$data.gift_content} diff --git a/Application/Base/Service/GameRebateService.class.php b/Application/Base/Service/GameRebateService.class.php index 2fd07996c..acdfa97a8 100644 --- a/Application/Base/Service/GameRebateService.class.php +++ b/Application/Base/Service/GameRebateService.class.php @@ -29,6 +29,8 @@ class GameRebateService 'D' => '首充福利发放', 'E' => '单日累充福利发放', 'F' => '周卡福利发放', + 'G' => '首次进游福利', + 'H' => '签到福利发放', ]; public $typeNames = [ @@ -38,6 +40,8 @@ class GameRebateService 'D' => 'firstPay', 'E' => 'dayAccumulative', 'F' => 'weekly', + 'G' => 'newRole', + 'H' => 'dailySign', ]; public function isGiftItemSend($order, $item) @@ -296,6 +300,8 @@ class GameRebateService $fields['award_date'] = '达成日期'; } elseif($awardType == 'F') { $fields['award_date_range'] = '可领取福利日期'; + } elseif($awardType == 'H') { + $fields['award_date'] = '签到日期'; } $fields = array_merge($fields, [