diff --git a/Application/Sdk/Controller/ExchangeController.class.php b/Application/Sdk/Controller/ExchangeController.class.php index 571e54ea..7c23cf26 100644 --- a/Application/Sdk/Controller/ExchangeController.class.php +++ b/Application/Sdk/Controller/ExchangeController.class.php @@ -14,7 +14,7 @@ use Org\JtpaySDK\Jtpay; use Org\GoldPig\GoldPig; - +use Base\Tool\Redis; @@ -81,14 +81,22 @@ class ExchangeController extends BaseController{ } - $role = M("user_play_info", "tab_")->where([ - 'user_id' => $request['user_id'], - 'game_id' => $request['game_id'], - 'server_id' => $request['server_id'] - ])->find(); - if (!$role || !$role['role_id']) { - $this->set_message(0,"fail","未上传角色,不允许充值"/* .M("user_play_info", "tab_")->_sql() */); - } + $gameId = $request['game_id'] ?? 0; + $userId = $request['user_id'] ?? 0; + $serverId = $request['server_id'] ?? 0; + $roleId = $request['game_player_id'] ?? 0; + $key = 'sdk.role_cache:' . $gameId . '_' . $userId . '_' . $serverId . '_' . $roleId; + + if (!Redis::get($key)) { + $role = M("user_play_info", "tab_")->where([ + 'user_id' => $request['user_id'], + 'game_id' => $request['game_id'], + 'server_id' => $request['server_id'] + ])->find(); + if (!$role || !$role['role_id']) { + $this->set_message(0,"fail","未上传角色,不允许充值"/* .M("user_play_info", "tab_")->_sql() */); + } + } } $prefix = $request['code'] == 1 ? "SP_" : "PF_"; diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index a74ca647..4e0f0851 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -1437,6 +1437,14 @@ class UserController extends BaseController 'client_ip' => get_client_ip() ]; + $gameId = $request['game_id'] ?? 0; + $userId = $request['user_id'] ?? 0; + $serverId = $request['server_id'] ?? 0; + $roleId = $request['game_player_id'] ?? 0; + $key = 'sdk.role_cache:' . $gameId . '_' . $userId . '_' . $serverId . '_' . $roleId; + + Redis::set($key, 1); + try { $taskClient = new TaskClient(); $taskClient->post('/game-event/save-role', $params);