Tree 2 ماه پیش
والد
کامیت
59f8a3698e

+ 10 - 13
app/Http/Controllers/Admin/CommonConfigController.php

@@ -12,19 +12,16 @@ class CommonConfigController extends Controller
     {
         // 从 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'));
+        $config = $configData ? json_decode($configData, true) : [
+            ["RechargeMin" => 0, "RechargeMax" => 1, "FreeWinMax" => 1000, "RechargeMaxPercent" => 0, "TaxPercent" => 100],
+            ["RechargeMin" => 1, "RechargeMax" => 101, "FreeWinMax" => 20, "RechargeMaxPercent" => 80, "TaxPercent" => 100],
+            ["RechargeMin" => 101, "RechargeMax" => 501, "FreeWinMax" => 100, "RechargeMaxPercent" => 70, "TaxPercent" => 95],
+            ["RechargeMin" => 501, "RechargeMax" => 1001, "FreeWinMax" => 400, "RechargeMaxPercent" => 60, "TaxPercent" => 90],
+            ["RechargeMin" => 1001, "RechargeMax" => 10001, "FreeWinMax" => 8000, "RechargeMaxPercent" => 55, "TaxPercent" => 85],
+            ["RechargeMin" => 10001, "RechargeMax" => 99999999, "FreeWinMax" => 0, "RechargeMaxPercent" => 50, "TaxPercent" => 80]
+        ];
+
+        return view('admin.common_config.index', compact('config'));
     }
 
     public function update(Request $request)

+ 3 - 3
app/Http/Controllers/Api/WiwiPayController.php

@@ -30,11 +30,11 @@ class WiwiPayController implements PayMentInterFace
             return apiReturnFail($logic->getError());
         }
 
-        if (!empty($res) && isset($res['status']) && $res['status'] > 0) {
+        if (!empty($res) && isset($res['code']) && $res['code'] == 0) {
             $data = [
-                'content' => urldecode($res['payUrl'] ?? $res['url'] ?? ''),
+                'content' => $res['data']['cashierUrl'],
                 'money' => $payAmt,
-                'prdOrdNo' => $res['mchOrderNo'],
+                'prdOrdNo' => $res['data']['mchOrderNo'],
             ];
             return apiReturnSuc($data);
         } else if ($res == false) {

+ 25 - 25
resources/views/admin/common_config/index.blade.php

@@ -7,20 +7,9 @@
             <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>
+                    <small class="text-muted">编辑 6 档参数并一键保存 (索引 0-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">
@@ -30,11 +19,11 @@
                                     <th style="width:180px;">充值区间上限 (RechargeMax)</th>
                                     <th style="width:180px;">固定值 (FreeWinMax)</th>
                                     <th style="width:180px;">充值最大百分比 (RechargeMaxPercent)</th>
-                                    <th style="width:160px;">税收系数比例 (TaxPercent)</th>
+                                    <th style="width:160px;">税收比例 (TaxPercent)</th>
                                 </tr>
                             </thead>
                             <tbody class="config-form">
-                                @foreach([0,1,2,3,4,5] as $level)
+                                @foreach([0,1,2,3,4,5] as $index => $level)
                                     <tr>
                                         <td>
                                             <span class="badge badge-primary">等级{{ $level }}</span>
@@ -42,23 +31,23 @@
                                         <td>
                                             <input type="number" class="form-control form-control-sm" 
                                                    name="level[{{ $level }}][RechargeMin]" 
-                                                   value="{{ $configData[$level]['RechargeMin'] ?? 0 }}" />
+                                                   value="{{ $config[$level]['RechargeMin'] ?? 0 }}" />
                                         </td>
                                         <td>
                                             <input type="number" class="form-control form-control-sm" 
                                                    name="level[{{ $level }}][RechargeMax]" 
-                                                   value="{{ $configData[$level]['RechargeMax'] ?? 0 }}" />
+                                                   value="{{ $config[$level]['RechargeMax'] ?? 0 }}" />
                                         </td>
                                         <td>
                                             <input type="number" class="form-control form-control-sm" 
                                                    name="level[{{ $level }}][FreeWinMax]" 
-                                                   value="{{ $configData[$level]['FreeWinMax'] ?? 0 }}" />
+                                                   value="{{ $config[$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 }}" />
+                                                       value="{{ $config[$level]['RechargeMaxPercent'] ?? 0 }}" />
                                                 <div class="input-group-append"><span class="input-group-text">%</span></div>
                                             </div>
                                         </td>
@@ -66,7 +55,7 @@
                                             <div class="input-group input-group-sm">
                                                 <input type="number" class="form-control" 
                                                        name="level[{{ $level }}][TaxPercent]" 
-                                                       value="{{ $configData[$level]['TaxPercent'] ?? 0 }}" />
+                                                       value="{{ $config[$level]['TaxPercent'] ?? 0 }}" />
                                                 <div class="input-group-append"><span class="input-group-text">%</span></div>
                                             </div>
                                         </td>
@@ -97,22 +86,33 @@ $(function() {
         $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":{}};
+        // 构建索引数组
+        let configArray = [];
+        for (let i = 0; i <= 5; i++) {
+            configArray[i] = {
+                "RechargeMin": 0,
+                "RechargeMax": 0,
+                "FreeWinMax": 0,
+                "RechargeMaxPercent": 0,
+                "TaxPercent": 0
+            };
+        }
+
         $form.find('input').each(function() {
-            const name = this.name; // level[1][RechargeMin]
+            const name = this.name; // level[0][RechargeMin]
             const val = this.value;
             const m = name.match(/level\[(\d+)\]\[([^\]]+)\]/);
             if (m) {
-                const lvl = m[1];
+                const lvl = parseInt(m[1]);
                 const key = m[2];
-                let num = (key === 'RechargeMaxPercent' || key === 'TaxPercent') ? parseInt(val || 0) : parseFloat(val || 0);
+                let num = parseInt(val || 0);
                 if (isNaN(num)) num = 0;
-                configObj[lvl][key] = num;
+                configArray[lvl][key] = num;
             }
         });
 
         $.post("{{ url('/admin/common-config/update') }}", {
-            config: JSON.stringify(configObj),
+            config: JSON.stringify(configArray),
             _token: "{{ csrf_token() }}"
         }).done(function(res){
             $btn.prop('disabled', false).html('<i class="mdi mdi-content-save"></i> 保存配置');