1.优化游戏记录审核

2.优化游戏配置页面
3.备份数据库
This commit is contained in:
2026-04-29 10:10:50 +08:00
parent ba4ece422a
commit e47857fcf2
8 changed files with 1607 additions and 117 deletions

View File

@@ -8,6 +8,7 @@ use app\common\library\game\DepositTier;
use app\common\library\game\FinanceCashierConfig;
use app\common\library\game\StreakWinReward;
use app\common\library\game\ZiHuaDictionary as ZiHuaDictionaryLib;
use support\think\Db;
use support\Response;
use Webman\Http\Request as WebmanRequest;
@@ -50,6 +51,17 @@ class GameConfig extends Backend
];
}
/**
* @return list<string>
*/
protected function formExcludedKeys(): array
{
return [
'period_auto_create_enabled',
'period_manual_create_enabled',
];
}
/**
* 列表:排除独立表单维护的配置键
*/
@@ -128,4 +140,84 @@ class GameConfig extends Backend
'total' => $res->total(),
]);
}
/**
* 表单批量保存:一次提交当前页面全部配置
*/
public function save(WebmanRequest $request): Response
{
$response = $this->initializeBackend($request);
if ($response !== null) {
return $response;
}
if ($request->method() !== 'POST') {
return $this->error(__('Parameter error'));
}
$payload = $request->post();
if (!is_array($payload)) {
return $this->error(__('Parameter error'));
}
$items = $payload['items'] ?? null;
if (!is_array($items)) {
return $this->error(__('Parameter error'));
}
$exclude = array_merge($this->excludedConfigKeys(), $this->formExcludedKeys());
$rows = Db::name('game_config')
->whereNotIn('config_key', $exclude)
->field(['id', 'config_key', 'value_type'])
->select()
->toArray();
if ($rows === []) {
return $this->success(__('Operation completed'));
}
$allowMap = [];
foreach ($rows as $row) {
if (!isset($row['config_key']) || !is_string($row['config_key']) || $row['config_key'] === '') {
continue;
}
$allowMap[$row['config_key']] = $row;
}
$now = time();
Db::startTrans();
try {
foreach ($items as $configKey => $configValue) {
if (!is_string($configKey) || $configKey === '' || !isset($allowMap[$configKey])) {
continue;
}
$valueType = isset($allowMap[$configKey]['value_type']) && is_string($allowMap[$configKey]['value_type'])
? $allowMap[$configKey]['value_type']
: 'string';
$persistValue = $configValue;
if (is_array($persistValue)) {
if ($valueType === 'json') {
$persistValue = json_encode($persistValue, JSON_UNESCAPED_UNICODE);
} else {
$persistValue = '';
}
}
if ($persistValue === null) {
$persistValue = '';
}
Db::name('game_config')->where('id', $allowMap[$configKey]['id'])->update([
'config_value' => (string) $persistValue,
'update_time' => $now,
]);
}
Db::commit();
} catch (\Throwable $e) {
Db::rollback();
return $this->error($e->getMessage());
}
return $this->success(__('Operation completed'));
}
}