优化后台修改玩家信息(钱包等)没有更新缓存的问题

This commit is contained in:
2026-03-16 16:16:25 +08:00
parent 27e9de0ac9
commit 1213f8e58a
3 changed files with 80 additions and 42 deletions

View File

@@ -14,6 +14,7 @@ use support\think\Db;
use app\api\controller\BaseController;
use support\Request;
use support\Response;
use app\api\cache\UserCache;
/**
* 平台 v1 游戏接口
@@ -297,6 +298,12 @@ class GameController extends BaseController
return $this->fail('操作失败:' . $e->getMessage(), ReturnCode::SERVER_ERROR);
}
// 出于安全:删除该玩家相关缓存,后续 API 调用按需重建
UserCache::deleteUser($player->id);
if ($player->username !== '') {
UserCache::deletePlayerByUsername($player->username);
}
$recordArr = $record->toArray();
$recordArr['dice_player'] = ['id' => (int) $player->id, 'username' => $player->username ?? '', 'phone' => $player->phone ?? ''];
return $this->success($recordArr);