Tree 2 ay önce
ebeveyn
işleme
859bffef8d

+ 60 - 0
app/Http/Controllers/Admin/CommonConfigController.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Redis;
+
+class CommonConfigController extends Controller
+{
+    public function index()
+    {
+        // 从 Redis 获取公用配置数据
+        $configData = Redis::get("GameConfigX_Common");
+        $config = $configData ? json_decode($configData, true) : null;
+        
+        // 5档配置
+        $configs = [];
+        for ($level = 1; $level <= 5; $level++) {
+            $configs[] = [
+                'level' => $level,
+                'levelName' => "第{$level}档",
+                'config' => $config
+            ];
+        }
+
+        return view('admin.common_config.index', compact('configs'));
+    }
+
+    public function update(Request $request)
+    {
+        $config = $request->input('config');
+
+        \Log::info('公用配置更新请求', [
+            'config' => $config,
+            'all_data' => $request->all()
+        ]);
+
+        if (!$config) {
+            \Log::error('公用配置更新失败:参数错误');
+            return response()->json(['status' => 'error', 'message' => '参数错误']);
+        }
+
+        try {
+            $configData = json_decode($config, true);
+            if (json_last_error() !== JSON_ERROR_NONE) {
+                \Log::error('公用配置更新失败:JSON格式错误', ['error' => json_last_error_msg()]);
+                throw new \Exception('JSON格式错误: ' . json_last_error_msg());
+            }
+
+            Redis::set("GameConfigX_Common", $config);
+            \Log::info('公用配置更新成功');
+            return response()->json(['status' => 'success', 'message' => '更新成功']);
+        } catch (\Exception $e) {
+            \Log::error('公用配置更新失败:异常', ['message' => $e->getMessage()]);
+            return response()->json(['status' => 'error', 'message' => $e->getMessage()]);
+        }
+    }
+
+}

+ 61 - 0
app/Http/Controllers/Admin/ProtectController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
 use App\Facade\TableName;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Redis;
 
 class ProtectController
 {
@@ -34,4 +35,64 @@ class ProtectController
             return view('admin.protect.protect_config_info_update', compact('info'));
         }
     }
+
+    // 免费保护配置
+    public function free_protect_config()
+    {
+        $configData = Redis::get("FreeProtectConfig");
+        $config = $configData ? json_decode($configData, true) : [
+            "ProtectScore" => 3,
+            "ScoreBetRatio" => 3,
+            "ScoreBet" => 10,
+            "ProtectRounds" => [40, 100],
+            "ProtectRoundsLoop" => 100,
+            "ProtectRoundsRatio" => 10
+        ];
+
+        return view('admin.protect.free_protect_config', compact('config'));
+    }
+
+    // 免费保护配置修改
+    public function free_protect_config_update(Request $request)
+    {
+        if ($request->isMethod('post')) {
+            $config = $request->input('config');
+
+            \Log::info('免费保护配置更新请求', [
+                'config' => $config,
+                'all_data' => $request->all()
+            ]);
+
+            if (!$config) {
+                \Log::error('免费保护配置更新失败:参数错误');
+                return response()->json(['status' => 'error', 'message' => '参数错误']);
+            }
+
+            try {
+                $configData = json_decode($config, true);
+                if (json_last_error() !== JSON_ERROR_NONE) {
+                    \Log::error('免费保护配置更新失败:JSON格式错误', ['error' => json_last_error_msg()]);
+                    throw new \Exception('JSON格式错误: ' . json_last_error_msg());
+                }
+
+                Redis::set("FreeProtectConfig", $config);
+                \Log::info('免费保护配置更新成功');
+                return response()->json(['status' => 'success', 'message' => '更新成功']);
+            } catch (\Exception $e) {
+                \Log::error('免费保护配置更新失败:异常', ['message' => $e->getMessage()]);
+                return response()->json(['status' => 'error', 'message' => $e->getMessage()]);
+            }
+        } else {
+            $configData = Redis::get("FreeProtectConfig");
+            $config = $configData ? json_decode($configData, true) : [
+                "ProtectScore" => 3,
+                "ScoreBetRatio" => 3,
+                "ScoreBet" => 10,
+                "ProtectRounds" => [40, 100],
+                "ProtectRoundsLoop" => 100,
+                "ProtectRoundsRatio" => 10
+            ];
+            return view('admin.protect.free_protect_config_update', compact('config'));
+        }
+    }
 }

+ 139 - 0
resources/views/admin/common_config/index.blade.php

@@ -0,0 +1,139 @@
+@extends('base.base')
+@section('base')
+<meta name="csrf-token" content="{{ csrf_token() }}">
+<div class="container-fluid">
+    <div class="row">
+        <div class="col-12">
+            <div class="card">
+                <div class="card-header d-flex align-items-center justify-content-between">
+                    <h3 class="card-title mb-0">公用配置管理</h3>
+                    <small class="text-muted">编辑 5 档参数并一键保存</small>
+                </div>
+                <div class="card-body">
+                    @php 
+                        $configData = $configs[0]['config'] ? $configs[0]['config'] : [
+                            "0" => ["FreeWinMax" => 1000, "TaxPercent" => 100, "RechargeMaxPercent" => 0, "RechargeMin" => 0,   "RechargeMax" => 1],
+                            "1" => ["FreeWinMax" => 20, "TaxPercent" => 100, "RechargeMaxPercent" => 80, "RechargeMin" => 1,   "RechargeMax" => 101],
+                            "2" => ["FreeWinMax" => 100, "TaxPercent" => 95, "RechargeMaxPercent" => 70, "RechargeMin" => 101, "RechargeMax" => 501],
+                            "3" => ["FreeWinMax" => 400, "TaxPercent" => 90, "RechargeMaxPercent" => 60, "RechargeMin" => 501, "RechargeMax" => 1001],
+                            "4" => ["FreeWinMax" => 8000, "TaxPercent" => 85, "RechargeMaxPercent" => 55, "RechargeMin" => 1001,"RechargeMax" => 10001],
+                            "5" => ["FreeWinMax" => 0,"TaxPercent" => 80, "RechargeMaxPercent" => 50, "RechargeMin" => 10001,"RechargeMax" => 99999999]
+                        ];
+                    @endphp
+
+                    <div class="table-responsive">
+                        <table class="table table-striped table-hover align-middle mb-0" style="min-width: 900px;">
+                            <thead class="thead-light">
+                                <tr>
+                                    <th style="width:82px;">档位</th>
+                                    <th style="width:180px;">充值区间下限 (RechargeMin)</th>
+                                    <th style="width:180px;">充值区间上限 (RechargeMax)</th>
+                                    <th style="width:180px;">固定值 (FreeWinMax)</th>
+                                    <th style="width:180px;">充值最大百分比 (RechargeMaxPercent)</th>
+                                    <th style="width:160px;">税收系数比例 (TaxPercent)</th>
+                                </tr>
+                            </thead>
+                            <tbody class="config-form">
+                                @foreach([0,1,2,3,4,5] as $level)
+                                    <tr>
+                                        <td>
+                                            <span class="badge badge-primary">等级{{ $level }}</span>
+                                        </td>
+                                        <td>
+                                            <input type="number" class="form-control form-control-sm" 
+                                                   name="level[{{ $level }}][RechargeMin]" 
+                                                   value="{{ $configData[$level]['RechargeMin'] ?? 0 }}" />
+                                        </td>
+                                        <td>
+                                            <input type="number" class="form-control form-control-sm" 
+                                                   name="level[{{ $level }}][RechargeMax]" 
+                                                   value="{{ $configData[$level]['RechargeMax'] ?? 0 }}" />
+                                        </td>
+                                        <td>
+                                            <input type="number" class="form-control form-control-sm" 
+                                                   name="level[{{ $level }}][FreeWinMax]" 
+                                                   value="{{ $configData[$level]['FreeWinMax'] ?? 0 }}" />
+                                        </td>
+                                        <td>
+                                            <div class="input-group input-group-sm">
+                                                <input type="number" class="form-control" 
+                                                       name="level[{{ $level }}][RechargeMaxPercent]" 
+                                                       value="{{ $configData[$level]['RechargeMaxPercent'] ?? 0 }}" />
+                                                <div class="input-group-append"><span class="input-group-text">%</span></div>
+                                            </div>
+                                        </td>
+                                        <td>
+                                            <div class="input-group input-group-sm">
+                                                <input type="number" class="form-control" 
+                                                       name="level[{{ $level }}][TaxPercent]" 
+                                                       value="{{ $configData[$level]['TaxPercent'] ?? 0 }}" />
+                                                <div class="input-group-append"><span class="input-group-text">%</span></div>
+                                            </div>
+                                        </td>
+                                    </tr>
+                                @endforeach
+                            </tbody>
+                        </table>
+                    </div>
+
+                    <div class="d-flex align-items-center mt-4">
+                        <button class="btn btn-gradient-primary btn-sm save-config">
+                            <i class="mdi mdi-content-save"></i> 保存配置
+                        </button>
+                        <span class="save-status ml-3"></span>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script>
+$(function() {
+    $('.save-config').click(function(event) {
+        const $form = $('.config-form');
+        const $btn = $(this);
+        const $status = $('.save-status');
+        $btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> 保存中...');
+        $status.html('').removeClass('text-success text-danger');
+
+        let configObj = {"0":{},"1":{},"2":{},"3":{},"4":{},"5":{}};
+        $form.find('input').each(function() {
+            const name = this.name; // level[1][RechargeMin]
+            const val = this.value;
+            const m = name.match(/level\[(\d+)\]\[([^\]]+)\]/);
+            if (m) {
+                const lvl = m[1];
+                const key = m[2];
+                let num = (key === 'RechargeMaxPercent' || key === 'TaxPercent') ? parseInt(val || 0) : parseFloat(val || 0);
+                if (isNaN(num)) num = 0;
+                configObj[lvl][key] = num;
+            }
+        });
+
+        $.post("{{ url('/admin/common-config/update') }}", {
+            config: JSON.stringify(configObj),
+            _token: "{{ csrf_token() }}"
+        }).done(function(res){
+            $btn.prop('disabled', false).html('<i class="mdi mdi-content-save"></i> 保存配置');
+            if (res.status === 'success') {
+                $status.text('更新成功').addClass('text-success');
+            } else {
+                $status.text(res.message || '更新失败').addClass('text-danger');
+            }
+            setTimeout(function(){ $status.fadeOut(function(){ $(this).text('').show().removeClass('text-success text-danger'); }); }, 3000);
+        }).fail(function(){
+            $btn.prop('disabled', false).html('<i class="mdi mdi-content-save"></i> 保存配置');
+            $status.text('系统错误').addClass('text-danger');
+        });
+    });
+});
+</script>
+
+<style>
+.table thead th { white-space: nowrap; }
+.table tbody td { vertical-align: middle; }
+.input-group-text { min-width: 34px; justify-content: center; }
+.badge { font-size: .85rem; padding: .5em .6em; }
+</style>
+@endsection

+ 127 - 0
resources/views/admin/protect/free_protect_config.blade.php

@@ -0,0 +1,127 @@
+@extends('base.base')
+@section('base')
+<meta name="csrf-token" content="{{ csrf_token() }}">
+<div class="container-fluid">
+    <div class="row">
+        <div class="col-12">
+            <div class="card">
+                <div class="card-header d-flex align-items-center justify-content-between">
+                    <h3 class="card-title mb-0">免费保护配置</h3>
+                    <small class="text-muted">管理免费保护相关参数</small>
+                </div>
+                <div class="card-body">
+                    <div class="row">
+                        <div class="col-md-6">
+                            <div class="form-group">
+                                <label>最小携带身金 (ProtectScore)</label>
+                                <input type="number" class="form-control" id="ProtectScore" value="{{ $config['ProtectScore'] ?? 3 }}">
+                                <small class="form-text text-muted">用户最小携带金币数量</small>
+                            </div>
+                        </div>
+                        <div class="col-md-6">
+                            <div class="form-group">
+                                <label>身金/下注最大比 (ScoreBetRatio)</label>
+                                <input type="number" class="form-control" id="ScoreBetRatio" value="{{ $config['ScoreBetRatio'] ?? 3 }}">
+                                <small class="form-text text-muted">身金与下注的最大比例</small>
+                            </div>
+                        </div>
+                    </div>
+                    
+                    <div class="row">
+                        <div class="col-md-6">
+                            <div class="form-group">
+                                <label>下注身金 (ScoreBet)</label>
+                                <input type="number" class="form-control" id="ScoreBet" value="{{ $config['ScoreBet'] ?? 10 }}">
+                                <small class="form-text text-muted">下注时的身金数量</small>
+                            </div>
+                        </div>
+                        <div class="col-md-6">
+                            <div class="form-group">
+                                <label>触发保护局数 (ProtectRounds)</label>
+                                <input type="text" class="form-control" id="ProtectRounds" value="{{ is_array($config['ProtectRounds'] ?? []) ? implode(',', $config['ProtectRounds']) : ($config['ProtectRounds'] ?? '40,100') }}">
+                                <small class="form-text text-muted">用逗号分隔多个值,如:40,100</small>
+                            </div>
+                        </div>
+                    </div>
+                    
+                    <div class="row">
+                        <div class="col-md-6">
+                            <div class="form-group">
+                                <label>触发后循环触发局数 (ProtectRoundsLoop)</label>
+                                <input type="number" class="form-control" id="ProtectRoundsLoop" value="{{ $config['ProtectRoundsLoop'] ?? 100 }}">
+                                <small class="form-text text-muted">触发保护后的循环局数</small>
+                            </div>
+                        </div>
+                        <div class="col-md-6">
+                            <div class="form-group">
+                                <label>触发概率 (ProtectRoundsRatio)</label>
+                                <div class="input-group">
+                                    <input type="number" class="form-control" id="ProtectRoundsRatio" value="{{ $config['ProtectRoundsRatio'] ?? 10 }}">
+                                    <div class="input-group-append">
+                                        <span class="input-group-text">%</span>
+                                    </div>
+                                </div>
+                                <small class="form-text text-muted">保护触发的概率百分比</small>
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="d-flex align-items-center mt-4">
+                        <button class="btn btn-gradient-primary btn-sm save-config">
+                            <i class="mdi mdi-content-save"></i> 保存配置
+                        </button>
+                        <span class="save-status ml-3"></span>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script>
+$(function() {
+    $('.save-config').click(function(event) {
+        const $btn = $(this);
+        const $status = $('.save-status');
+        $btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> 保存中...');
+        $status.html('').removeClass('text-success text-danger');
+
+        // 构建配置对象
+        let configObj = {
+            "ProtectScore": parseInt($('#ProtectScore').val()) || 3,
+            "ScoreBetRatio": parseInt($('#ScoreBetRatio').val()) || 3,
+            "ScoreBet": parseInt($('#ScoreBet').val()) || 10,
+            "ProtectRounds": $('#ProtectRounds').val().split(',').map(x => parseInt(x.trim())).filter(x => !isNaN(x)),
+            "ProtectRoundsLoop": parseInt($('#ProtectRoundsLoop').val()) || 100,
+            "ProtectRoundsRatio": parseInt($('#ProtectRoundsRatio').val()) || 10
+        };
+
+        // 验证 ProtectRounds 数组
+        if (configObj.ProtectRounds.length === 0) {
+            configObj.ProtectRounds = [40, 100];
+        }
+
+        $.post("{{ url('/admin/Protect/free_protect_config_update') }}", {
+            config: JSON.stringify(configObj),
+            _token: "{{ csrf_token() }}"
+        }).done(function(res){
+            $btn.prop('disabled', false).html('<i class="mdi mdi-content-save"></i> 保存配置');
+            if (res.status === 'success') {
+                $status.text('更新成功').addClass('text-success');
+            } else {
+                $status.text(res.message || '更新失败').addClass('text-danger');
+            }
+            setTimeout(function(){ $status.fadeOut(function(){ $(this).text('').show().removeClass('text-success text-danger'); }); }, 3000);
+        }).fail(function(){
+            $btn.prop('disabled', false).html('<i class="mdi mdi-content-save"></i> 保存配置');
+            $status.text('系统错误').addClass('text-danger');
+        });
+    });
+});
+</script>
+
+<style>
+.form-group label { font-weight: 600; }
+.input-group-text { min-width: 34px; justify-content: center; }
+</style>
+@endsection

+ 3 - 3
resources/views/admin/protect/protect_config_info.blade.php

@@ -8,12 +8,12 @@
                      <span class="page-title-icon bg-gradient-primary text-white mr-2">
                         <i class="mdi mdi-shield-check"></i>
                     </span>
-                    保护配置管理
+                    触底保护机制
                 </h3>
                 <nav aria-label="breadcrumb">
                     <ol class="breadcrumb">
                         <li class="breadcrumb-item"><a href="#">系统管理</a></li>
-                        <li class="breadcrumb-item active" aria-current="page">保护配置管理</li>
+                        <li class="breadcrumb-item active" aria-current="page">触底保护机制配置管理</li>
                     </ol>
                 </nav>
             </div>
@@ -21,7 +21,7 @@
                 <div class="col-lg-12 grid-margin stretch-card">
                     <div class="card">
                         <div class="card-body">
-                            <h4 class="card-title">保护配置列表</h4>
+                            <h4 class="card-title">触底保护配置列表</h4>
                             <table class="table table-bordered">
                                 <thead>
                                 <tr>

+ 4 - 0
routes/web.php

@@ -453,6 +453,8 @@ Route::group([
         // 保护配置管理
         $route->get('/Protect/protect_config_info', 'Admin\ProtectController@protect_config_info');
         $route->any('/Protect/protect_config_info_update/{id}', 'Admin\ProtectController@protect_config_info_update');
+        $route->get('/Protect/free_protect_config', 'Admin\ProtectController@free_protect_config');
+        $route->any('/Protect/free_protect_config_update', 'Admin\ProtectController@free_protect_config_update');
 
 
         /* 系统设置  IP白名单管理*/
@@ -710,6 +712,8 @@ Route::group([
 
         // PG游戏参数配置
         $route->any('/pg-game-config', 'Admin\PGGameConfigController@index')->name('admin.pg-game-config');
+        $route->any('/common-config', 'Admin\CommonConfigController@index')->name('admin.common-config');
+        $route->any('/common-config/update', 'Admin\CommonConfigController@update')->name('admin.common-config.update');
         $route->any('/pg-game-config/update', 'Admin\PGGameConfigController@update')->name('admin.pg-game-config.update');
         $route->post('/pg-game-config/copy_all', 'Admin\PGGameConfigController@copyAll')->name('admin.pg-game-config.copy_all');
         // PG游戏参数配置