修改缓存方式

This commit is contained in:
2026-04-20 10:31:14 +08:00
parent 025cce3e3e
commit 92fb40ae80
19 changed files with 512 additions and 57 deletions

View File

@@ -4,6 +4,7 @@ namespace app\admin\controller\config;
use app\common\controller\Backend;
use app\common\library\game\DepositTier as DepositTierLib;
use app\common\service\GameHotDataRedis;
use InvalidArgumentException;
use support\think\Db;
use support\Response;
@@ -125,6 +126,8 @@ class DepositTier extends Backend
return $this->error($e->getMessage());
}
GameHotDataRedis::gameConfigForget(DepositTierLib::CONFIG_KEY);
return $this->success(__('Saved successfully'));
}
}

View File

@@ -6,6 +6,7 @@ namespace app\admin\controller\config;
use app\common\controller\Backend;
use app\common\library\game\StreakWinReward as StreakWinRewardLib;
use app\common\service\GameHotDataRedis;
use support\think\Db;
use support\Response;
use Throwable;
@@ -115,6 +116,7 @@ class StreakWinReward extends Backend
return $this->error($e->getMessage());
}
StreakWinRewardLib::clearCache();
GameHotDataRedis::gameConfigForget(StreakWinRewardLib::CONFIG_KEY);
return $this->success('保存成功');
}

View File

@@ -3,6 +3,7 @@
namespace app\admin\controller\config;
use app\common\controller\Backend;
use app\common\service\GameHotDataRedis;
use app\common\library\game\ZiHuaDictionary as ZiHuaDictionaryLib;
use InvalidArgumentException;
use support\think\Db;
@@ -125,6 +126,8 @@ class ZiHuaDictionary extends Backend
return $this->error($e->getMessage());
}
GameHotDataRedis::gameConfigForget(ZiHuaDictionaryLib::CONFIG_KEY);
return $this->success(__('Saved successfully'));
}
}

View File

@@ -71,9 +71,11 @@ class Live extends Backend
$manualNumber = is_numeric((string) $manualRaw) ? (int) $manualRaw : null;
$res = GameLiveService::calculateResult($recordId, $manualNumber);
if (!($res['ok'] ?? false)) {
return $this->error((string) ($res['msg'] ?? '计算失败'));
$errMsg = $res['msg'] ?? null;
return $this->error(is_string($errMsg) ? $errMsg : __('Calculation failed'));
}
return $this->success((string) $res['msg'], $res);
$okMsg = $res['msg'] ?? '';
return $this->success(is_string($okMsg) ? $okMsg : '', $res);
}
/**
@@ -92,13 +94,15 @@ class Live extends Backend
$recordId = is_numeric((string) $recordIdRaw) ? (int) $recordIdRaw : null;
$manualRaw = $request->post('manual_number');
if (!is_numeric((string) $manualRaw)) {
return $this->error('请填写开奖号码');
return $this->error(__('Please enter the draw number'));
}
$manualNumber = (int) $manualRaw;
$res = GameLiveService::scheduleDraw($recordId, $manualNumber);
if (!($res['ok'] ?? false)) {
return $this->error((string) ($res['msg'] ?? '预约失败'));
$errMsg = $res['msg'] ?? null;
return $this->error(is_string($errMsg) ? $errMsg : __('Schedule failed'));
}
return $this->success((string) $res['msg'], $res);
$okMsg = $res['msg'] ?? '';
return $this->success(is_string($okMsg) ? $okMsg : '', $res);
}
}

View File

@@ -4,6 +4,7 @@ namespace app\admin\controller\game;
use app\common\controller\Backend;
use app\common\library\game\ZiHuaDictionary as ZiHuaDictionaryLib;
use app\common\service\GameHotDataRedis;
use InvalidArgumentException;
use support\think\Db;
use support\Response;
@@ -111,6 +112,8 @@ class ZiHuaDictionary extends Backend
return $this->error($e->getMessage());
}
GameHotDataRedis::gameConfigForget(ZiHuaDictionaryLib::CONFIG_KEY);
return $this->success(__('Saved successfully'));
}
}

View File

@@ -277,7 +277,30 @@ class Auth extends \ba\Auth
public function getMenus(int $uid = 0): array
{
return parent::getMenus($uid ?: $this->id);
$menus = parent::getMenus($uid ?: $this->id);
return $this->translateMenuRuleTitles($menus);
}
/**
* 将 admin_rule.title库内中文等按当前请求语言翻译供侧边栏/标签与 meta.title 一致。
* 英文词条见 app/common/lang/en/admin_rule_title.php
*
* @param array<int, array<string, mixed>> $menus
* @return array<int, array<string, mixed>>
*/
private function translateMenuRuleTitles(array $menus): array
{
foreach ($menus as $k => $item) {
if (isset($item['title']) && is_string($item['title']) && $item['title'] !== '') {
$menus[$k]['title'] = __($item['title']);
}
if (!empty($item['children']) && is_array($item['children'])) {
$menus[$k]['children'] = $this->translateMenuRuleTitles($item['children']);
}
}
return $menus;
}
public function isSuperAdmin(): bool