[游戏管理]游戏奖励配置-优化样式

This commit is contained in:
2026-04-13 11:03:14 +08:00
parent f8d5a5ffe9
commit 938d0a60aa
13 changed files with 702 additions and 662 deletions

View File

@@ -4,6 +4,7 @@ namespace app\admin\controller\game;
use Throwable;
use app\common\controller\Backend;
use app\common\library\GameRewardConfigTemplate;
use support\think\Db;
use support\Response;
use Webman\Http\Request as WebmanRequest;
@@ -229,6 +230,7 @@ class Channel extends Backend
if ($this->isPositiveChannelId($newChannelId)) {
try {
$this->copyGameConfigFromChannelZero($newChannelId);
$this->copyRewardConfigFromTemplate($newChannelId);
} catch (Throwable $e) {
return $this->error(__('Game channel copy default config failed') . ': ' . $e->getMessage());
}
@@ -595,10 +597,38 @@ class Channel extends Backend
}
/**
* 新建渠道后:将 channel_id=0 的全局默认游戏配置复制一份channel_id 指向新渠道主键
* 新建渠道后:game_reward_config 优先从 game_channel_id=0 的默认模板复制;若无则使用 resource JSON 模板
*
* @param int|string $newChannelId 新建 game_channel.id
*/
private function copyRewardConfigFromTemplate(int|string $newChannelId): void
{
$exists = Db::name('game_reward_config')->where('game_channel_id', $newChannelId)->count();
if ($exists > 0) {
return;
}
$now = time();
$tpl = Db::name('game_reward_config')->whereIn('game_channel_id', [0, '0'])->order('id', 'asc')->find();
if ($tpl) {
Db::name('game_reward_config')->insert([
'game_channel_id' => $newChannelId,
'tier_reward_form' => $tpl['tier_reward_form'],
'bigwin_form' => $tpl['bigwin_form'],
'create_time' => $now,
'update_time' => $now,
]);
return;
}
$cols = GameRewardConfigTemplate::getDefaultJsonColumns();
Db::name('game_reward_config')->insert([
'game_channel_id' => $newChannelId,
'tier_reward_form' => $cols['tier_reward_form'],
'bigwin_form' => $cols['bigwin_form'],
'create_time' => $now,
'update_time' => $now,
]);
}
private function copyGameConfigFromChannelZero(int|string $newChannelId): void
{
$exists = Db::name('game_config')->where('channel_id', $newChannelId)->count();