redis中排行榜中的数据
public function execute(string $date){$query = ChannelConfig::query();$query->where('module_name', 'rank_reward');$rewardData = $query->first();$rewards = [];if( $rewardData ){$rewardContents = $rewardData->content;foreach ($rewardContents as $key => $value) {if( !key_exists($value["game_type"], $rewards) ){$rewards[$value["game_type"]] = [];}$rewards[$value["game_type"]][$value["rank"]] = $value["reward"];}}echo json_encode($rewards);$redisFactory = ApplicationContext::getContainer()->get(RedisFactory::class);$redis = $redisFactory->get('rank');$day = substr($date,5,2).substr($date,8,2);$keys = $redis->keys("RANK:*:$day:0-0");foreach ($keys as $key => $value) {// echo "key = $value \n";$kuCuns = $redis->ZREVRANGE($value, 0, 29, true);// echo "data = ".json_encode($kuCuns)."\n";$gameType = explode(":",$value)[1];$count = count($kuCuns);$index = 1;foreach ($kuCuns as $keyItem => $valueItem) {$mode = new RankLog();$mode->date = $date;$mode->index = $index;$mode->gameType = $gameType;$mode->userId = $keyItem;$mode->score = $valueItem;$mode->reward = key_exists($gameType, $rewards) ? $rewards[$gameType][$index] : "";$mode->save();$index++;}}}