Tree 2 týždňov pred
rodič
commit
b6416bc1e0

+ 1 - 1
app/Console/Kernel.php

@@ -54,7 +54,7 @@ class Kernel extends ConsoleKernel
         $schedule->command('RecordUserScoreChangeStatistics')->cron('03 0 * * * ')->description('用户金额变化明细按天按用户汇总');
         $schedule->command('online_report')->everyMinute()->description('每分钟统计曲线');
 
-        $schedule->command('record_three_game_yesterday')->cron('05 0 * * * ')->description('按天统计游戏人数--今日执行昨日');
+//        $schedule->command('record_three_game_yesterday')->cron('05 0 * * * ')->description('按天统计游戏人数--今日执行昨日');
     }
 
     /**

+ 80 - 0
app/Http/Controllers/Admin/GameTaxController.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+
+class GameTaxController extends Controller
+{
+    /**
+     * 显示游戏税收比例配置页面
+     * 
+     * @return \Illuminate\View\View
+     */
+    public function index()
+    {
+        // 从数据库中获取一个示例值(所有游戏的税收值都是一样的)
+        $gameRoom = DB::connection('read')
+            ->table('QPPlatformDB.dbo.GameRoomInfo')
+            ->select('RevenueRatio')
+            ->first();
+
+        // 将千分比转换为百分比显示(例如:50 -> 5%)
+        $revenueRatio = $gameRoom ? ($gameRoom->RevenueRatio / 10) : 0;
+
+        return view('admin.game_tax.index', compact('revenueRatio'));
+    }
+
+    /**
+     * 更新所有游戏的税收比例
+     * 
+     * @param Request $request
+     * @return mixed
+     */
+    public function update(Request $request)
+    {
+        $revenueRatioPercent = $request->input('revenue_ratio');
+
+        // 验证输入
+        if ($revenueRatioPercent === null || $revenueRatioPercent === '') {
+            return $this->json(400, '税收比例不能为空');
+        }
+
+        // 转换为浮点数
+        $revenueRatioPercent = floatval($revenueRatioPercent);
+
+        // 验证范围(0-100)
+        if ($revenueRatioPercent < 0 || $revenueRatioPercent > 100) {
+            return $this->json(400, '税收比例必须在0-100之间');
+        }
+
+        try {
+            // 将百分比转换为千分比(例如:5% -> 50)
+            $revenueRatioValue = $revenueRatioPercent * 10;
+
+            // 更新所有游戏房间的税收比例
+            $affectedRows = DB::connection('write')
+                ->table('QPPlatformDB.dbo.GameRoomInfo')
+                ->update(['RevenueRatio' => $revenueRatioValue]);
+
+            // 记录日志
+            \Log::info('游戏税收比例更新成功', [
+                'revenue_ratio_percent' => $revenueRatioPercent,
+                'revenue_ratio_value' => $revenueRatioValue,
+                'affected_rows' => $affectedRows
+            ]);
+
+            return $this->json(200, '更新成功,共更新 ' . $affectedRows . ' 条记录');
+
+        } catch (\Exception $e) {
+            \Log::error('游戏税收比例更新失败', [
+                'error' => $e->getMessage(),
+                'trace' => $e->getTraceAsString()
+            ]);
+
+            return $this->json(500, '更新失败:' . $e->getMessage());
+        }
+    }
+}

+ 169 - 0
resources/views/admin/game_tax/index.blade.php

@@ -0,0 +1,169 @@
+@extends('base.base')
+@section('base')
+<meta name="csrf-token" content="{{ csrf_token() }}">
+<div class="main-panel">
+    <div class="content-wrapper">
+        <div class="page-header">
+            <h3 class="page-title">
+                <span class="page-title-icon bg-gradient-primary text-white mr-2">
+                    <i class="mdi mdi-percent"></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>
+                </ol>
+            </nav>
+        </div>
+        <div class="row">
+            <div class="col-12">
+                <div class="card">
+                    <div class="card-header">
+                        <h3 class="card-title mb-0">游戏税收比例配置</h3>
+                    </div>
+                    <div class="card-body">
+                        <div class="row">
+                            <div class="col-md-8">
+                                <form id="taxForm">
+                                    <div class="form-group">
+                                        <label for="revenue_ratio">税收比例 <small class="text-muted">(所有游戏共用此比例)</small></label>
+                                        <div class="input-group" style="max-width: 300px;">
+                                            <input type="number" 
+                                                   class="form-control" 
+                                                   id="revenue_ratio" 
+                                                   name="revenue_ratio" 
+                                                   value="{{ $revenueRatio }}" 
+                                                   min="0" 
+                                                   max="100" 
+                                                   step="0.1"
+                                                   placeholder="请输入税收比例">
+                                            <div class="input-group-append">
+                                                <span class="input-group-text">%</span>
+                                            </div>
+                                        </div>
+                                        <small class="form-text text-muted">
+                                            说明:此税收比例将应用到所有游戏房间。输入5表示5%,系统会自动转换为千分比(50)存储到数据库。
+                                        </small>
+                                    </div>
+                                    <div class="form-group">
+                                        <button type="submit" class="btn btn-gradient-primary" id="saveBtn">
+                                            <i class="mdi mdi-content-save"></i> 保存修改
+                                        </button>
+                                        <span class="ml-3" id="saveStatus"></span>
+                                    </div>
+                                </form>
+                            </div>
+                        </div>
+                        <div class="row mt-4">
+                            <div class="col-md-12">
+                                <div class="alert alert-info">
+                                    <h5 class="alert-heading"><i class="mdi mdi-information"></i> 注意事项</h5>
+                                    <ul class="mb-0">
+                                        <li>税收比例范围为 0% - 100%</li>
+                                        <li>所有游戏的税收值都是统一的,修改后将更新 <code>QPPlatformDB.dbo.GameRoomInfo</code> 表中所有记录的 <code>RevenueRatio</code> 字段</li>
+                                        <li>数据库存储格式为千分比,例如:输入 5% 会存储为 50</li>
+                                        <li>修改操作会影响所有游戏房间,请谨慎操作</li>
+                                    </ul>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script>
+$(function() {
+    // 设置CSRF token
+    $.ajaxSetup({
+        headers: {
+            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
+        }
+    });
+
+    $('#taxForm').on('submit', function(e) {
+        e.preventDefault();
+        
+        const $btn = $('#saveBtn');
+        const $status = $('#saveStatus');
+        const revenueRatio = $('#revenue_ratio').val();
+
+        // 验证输入
+        if (!revenueRatio || revenueRatio === '') {
+            $status.html('<span class="text-danger">请输入税收比例</span>');
+            return;
+        }
+
+        const revenueRatioFloat = parseFloat(revenueRatio);
+        if (isNaN(revenueRatioFloat) || revenueRatioFloat < 0 || revenueRatioFloat > 100) {
+            $status.html('<span class="text-danger">税收比例必须在 0-100 之间</span>');
+            return;
+        }
+
+        // 禁用按钮,显示加载状态
+        $btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> 保存中...');
+        $status.html('');
+
+        // 发送AJAX请求
+        $.ajax({
+            url: "{{ url('/admin/game-tax/update') }}",
+            type: 'POST',
+            data: {
+                revenue_ratio: revenueRatioFloat
+            },
+            success: function(response) {
+                $btn.prop('disabled', false).html('<i class="mdi mdi-content-save"></i> 保存修改');
+                
+                if (response.code == 200) {
+                    $status.html('<span class="text-success"><i class="mdi mdi-check-circle"></i> ' + response.msg + '</span>');
+                    // 3秒后清除提示
+                    setTimeout(function() {
+                        $status.fadeOut(function() {
+                            $(this).html('').show();
+                        });
+                    }, 3000);
+                } else {
+                    $status.html('<span class="text-danger"><i class="mdi mdi-alert-circle"></i> ' + (response.msg || '保存失败') + '</span>');
+                }
+            },
+            error: function(xhr) {
+                $btn.prop('disabled', false).html('<i class="mdi mdi-content-save"></i> 保存修改');
+                
+                let errorMsg = '系统错误';
+                if (xhr.responseJSON && xhr.responseJSON.msg) {
+                    errorMsg = xhr.responseJSON.msg;
+                } else if (xhr.responseText) {
+                    try {
+                        const response = JSON.parse(xhr.responseText);
+                        errorMsg = response.msg || errorMsg;
+                    } catch(e) {
+                        errorMsg = '保存失败,请稍后重试';
+                    }
+                }
+                
+                $status.html('<span class="text-danger"><i class="mdi mdi-alert-circle"></i> ' + errorMsg + '</span>');
+            }
+        });
+    });
+});
+</script>
+
+<style>
+.input-group-text {
+    min-width: 40px;
+    justify-content: center;
+}
+.alert ul {
+    padding-left: 20px;
+}
+.alert code {
+    background-color: rgba(0,0,0,0.1);
+    padding: 2px 6px;
+    border-radius: 3px;
+}
+</style>
+@endsection

+ 4 - 0
routes/web.php

@@ -734,6 +734,10 @@ Route::group([
         $route->any('/game-some-config', 'Admin\GameSomeConfigController@index')->name('admin.game-some-config');
         $route->post('/game-some-config/update', 'Admin\GameSomeConfigController@update')->name('admin.game-some-config.update');
         
+        // 游戏税收比例配置
+        $route->any('/game-tax', 'Admin\GameTaxController@index')->name('admin.game-tax');
+        $route->post('/game-tax/update', 'Admin\GameTaxController@update')->name('admin.game-tax.update');
+        
         // 数字游戏映射管理
         $route->get('/game-number-mapping', 'Admin\GameNumberMappingController@index')->name('admin.game-number-mapping');
         $route->any('/game-number-mapping/add', 'Admin\GameNumberMappingController@add')->name('admin.game-number-mapping.add');