Explorar el Código

添加强制模式

Tree hace 2 semanas
padre
commit
9d345de9f0

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

@@ -1925,6 +1925,66 @@ class GlobalController extends Controller
         return view('admin.global.add_tax', compact('UserID'));
     }
 
+    public function force_stock_mode(Request $request, $UserID)
+    {
+        // 常量定义
+        $USER_RIGHT_FORCE_STOCKMODE1 = 0b00000001; // 强制使用普通控制模式
+        $USER_RIGHT_FORCE_STOCKMODE2 = 0b00000010; // 强制使用库存模式2
+
+        if ($request->isMethod('post')) {
+            $force_mode = (int)$request->force_mode;
+
+            // 获取当前UserRight值
+            $gameScoreInfo = DB::table('QPTreasureDB.dbo.GameScoreInfo')
+                ->where('UserID', $UserID)
+                ->select('UserRight')
+                ->first();
+
+            if (!$gameScoreInfo) {
+                return apiReturnFail('用户不存在');
+            }
+
+            $currentUserRight = (int)($gameScoreInfo->UserRight ?? 0);
+
+            // 清除现有的强制模式标志
+            $newUserRight = $currentUserRight & ~($USER_RIGHT_FORCE_STOCKMODE1 | $USER_RIGHT_FORCE_STOCKMODE2);
+
+            // 根据选择设置新的强制模式
+            switch ($force_mode) {
+                case 1: // 强制使用普通控制模式
+                    $newUserRight |= $USER_RIGHT_FORCE_STOCKMODE1;
+                    break;
+                case 2: // 强制使用库存模式2
+                    $newUserRight |= $USER_RIGHT_FORCE_STOCKMODE2;
+                    break;
+                case 0: // 关闭所有强制模式
+                default:
+                    // 已经清除了标志,无需额外操作
+                    break;
+            }
+
+            // 更新UserRight
+            DB::table('QPTreasureDB.dbo.GameScoreInfo')
+                ->where('UserID', $UserID)
+                ->update(['UserRight' => $newUserRight]);
+
+            return apiReturnSuc('操作成功');
+        }
+
+        // 获取当前模式状态
+        $gameScoreInfo = DB::table('QPTreasureDB.dbo.GameScoreInfo')
+            ->where('UserID', $UserID)
+            ->select('UserRight')
+            ->first();
+
+        $userRight = (int)($gameScoreInfo->UserRight ?? 0);
+        $isForceStockMode1 = ($userRight & $USER_RIGHT_FORCE_STOCKMODE1) !== 0;
+        $isForceStockMode2 = ($userRight & $USER_RIGHT_FORCE_STOCKMODE2) !== 0;
+
+        return view('admin.global.force_stock_mode', compact('UserID', 'isForceStockMode1', 'isForceStockMode2'));
+    }
+
+
 
     // 推广限制开关
     public function register_invite_switches(Request $request, $UserID)

+ 76 - 0
resources/views/admin/global/force_stock_mode.blade.php

@@ -0,0 +1,76 @@
+@extends('base.base')
+@section('base')
+    <!-- 内容区域 -->
+    <div class="main-panel">
+        <div class="content-wrapper">
+            <div class="row">
+                <div class="col-12 grid-margin stretch-card">
+                    <div class="card">
+                        <div class="card-body">
+                            <h4 class="card-title">强制用户模式</h4>
+                            <form class="forms-sample" id="form">
+                                <div class="form-group">
+                                    <label>当前模式状态:</label>
+                                    <div class="alert alert-info">
+                                        @if($isForceStockMode1)
+                                            <span class="badge badge-success">已开启</span> 强制使用普通控制模式
+                                        @elseif($isForceStockMode2)
+                                            <span class="badge badge-success">已开启</span> 强制使用库存模式2
+                                        @else
+                                            <span class="badge badge-secondary">未设置</span> 未强制任何模式
+                                        @endif
+                                    </div>
+                                </div>
+
+                                <div class="form-group">
+                                    <label><h5>选择强制模式:</h5></label><br>
+                                    <label style="margin-right: 20px;">
+                                        <input type="radio" name="force_mode" value="0" {{ (!$isForceStockMode1 && !$isForceStockMode2) ? 'checked' : '' }}>
+                                        关闭所有强制模式
+                                    </label><br>
+                                    <label style="margin-right: 20px;">
+                                        <input type="radio" name="force_mode" value="1" {{ $isForceStockMode1 ? 'checked' : '' }}>
+                                        强制使用普通控制模式
+                                    </label><br>
+                                    <label style="margin-right: 20px;">
+                                        <input type="radio" name="force_mode" value="2" {{ $isForceStockMode2 ? 'checked' : '' }}>
+                                        强制使用库存模式2
+                                    </label>
+                                </div>
+
+                                <div class="alert alert-warning">
+                                    <i class="mdi mdi-alert"></i>
+                                    <strong>注意:</strong>这两种模式是互斥的,不可以同时都打开,但是可以同时都关闭。
+                                </div>
+
+                                <button type="button" onclick="commit( {{ $UserID }} )" class="btn btn-sm btn-gradient-primary btn-icon-text">
+                                    <i class="mdi mdi-file-check btn-icon-prepend"></i>
+                                    {{ __('auto.提交') }}
+                                </button>
+                                <button type="button" onclick="cancel()" class="btn btn-sm btn-gradient-warning btn-icon-text">
+                                    <i class="mdi mdi-reload btn-icon-prepend"></i>
+                                    {{ __('auto.取消') }}
+                                </button>
+                            </form>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <script>
+        function commit(userid){
+            var data = $("#form").serializeObject();
+            myRequest("/admin/global/force_stock_mode/"+userid,"post",data ,function(res){
+                layer.msg(res.msg)
+                setTimeout(function(){
+                    parent.location.reload();
+                },1500)
+            });
+        }
+        function cancel() {
+            parent.location.reload();
+        }
+
+    </script>
+@endsection

+ 18 - 0
resources/views/admin/global/id_list.blade.php

@@ -359,6 +359,13 @@
 
                         <button class="btn btn-sm btn-success" onclick="add_tax({{ $userInfo->UserID }})">{{ __('auto.操作税收') }}
                         </button>
+
+
+                        <button class="btn btn-sm btn-info" onclick="force_stock_mode({{ $userInfo->UserID }})">强制用户模式
+                        </button>
+
+
+
                         &nbsp;&nbsp;{{ __('auto.裂变领取限制开关:') }}
                         @if ($registerInviteSwitches == 1)
                             {{ __('auto.被限制') }}
@@ -473,6 +480,17 @@
             });
         }
 
+        function force_stock_mode(userid) {
+            var page = layer.open({
+                type: 2,
+                title: '强制用户模式',
+                shadeClose: true,
+                shade: 0.8,
+                area: ['40%', '50%'],
+                content: '/admin/global/force_stock_mode/' + userid
+            });
+        }
+
 
 
 

+ 3 - 0
routes/web.php

@@ -451,6 +451,9 @@ Route::group([
         $route->get('global/id_find', 'Admin\GlobalController@id_find');
         $route->any('global/add_draw_base/{id}', 'Admin\GlobalController@add_draw_base');
         $route->any('global/add_tax/{id}', 'Admin\GlobalController@add_tax');
+
+        $route->any('global/force_stock_mode/{id}', 'Admin\GlobalController@force_stock_mode');
+
         //用户列表 关联姓名 设备 IP
         $route->get('global/join', 'Admin\GlobalController@join');
         //用户列表-用户单控系统