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

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

@@ -10,6 +10,7 @@ use plugin\saiadmin\basic\think\BaseLogic;
use plugin\saiadmin\exception\ApiException;
use app\dice\model\player_wallet_record\DicePlayerWalletRecord;
use app\dice\model\player\DicePlayer;
use app\api\cache\UserCache;
/**
* 玩家钱包流水逻辑层
@@ -73,6 +74,12 @@ class DicePlayerWalletRecordLogic extends BaseLogic
DicePlayer::where('id', $playerId)->update(['coin' => $walletAfter]);
// 出于安全:删除该玩家相关缓存,后续 API 按需重建
UserCache::deleteUser($playerId);
if (isset($player->username) && $player->username !== '') {
UserCache::deletePlayerByUsername($player->username);
}
$playerAdminId = ($player->admin_id ?? null) ? (int) $player->admin_id : null;
$record = [
'player_id' => $playerId,