Tree преди 7 часа
родител
ревизия
570d5a2ffa

+ 1 - 1
app/Game/Banner.php

@@ -16,7 +16,7 @@ class Banner extends Model
     protected $primaryKey = 'bid';
 
     // 确定哪些字段可以被赋值
-    protected $fillable = ['img','img_pt','img_es', 'alt', 'link_game', 'link_module', 'theme_key'];
+    protected $fillable = ['img','img_pt','img_es', 'alt', 'link_game', 'link_module', 'theme_key', 'link', 'b_order', 'state', 'start_time', 'end_time'];
 
 
     // 隐藏不需要返回的字段

+ 76 - 3
app/Http/Controllers/Admin/BannerController.php

@@ -18,7 +18,9 @@ class BannerController
             $query->where('theme_key', $request->theme_key);
         }
 
-        $list = $query->orderBy('bid', 'desc')->paginate(20);
+        $list = $query->orderByRaw('ISNULL(b_order), b_order ASC')
+            ->orderBy('bid', 'desc')
+            ->paginate(20);
 
         // 获取所有主题用于筛选
         $themes = WebThemeConfig::all();
@@ -39,13 +41,25 @@ class BannerController
                 'link_game' => 'nullable|integer',
                 'link_module' => 'nullable|integer',
                 'theme_key' => 'nullable|string|max:30',
+                'link' => 'nullable|string|max:200',
+                'b_order' => 'nullable|integer',
+                'state' => 'nullable|integer',
             ]);
 
             if ($validator->fails()) {
                 return apiReturnFail($validator->errors()->first());
             }
 
-            $data = $request->only(['img', 'img_pt', 'img_es', 'alt', 'link_game', 'link_module', 'theme_key']);
+            $data = $request->only([
+                'img', 'img_pt', 'img_es', 'alt', 'link_game', 'link_module',
+                'theme_key', 'link', 'b_order', 'state'
+            ]);
+
+            // 默认值处理
+            $data['link'] = $data['link'] ?? '';
+            $data['state'] = isset($data['state']) && $data['state'] !== '' ? (int)$data['state'] : 127;
+            $data['b_order'] = $data['b_order'] !== '' ? $data['b_order'] : null;
+
             Banner::create($data);
 
             return apiReturnSuc();
@@ -66,13 +80,24 @@ class BannerController
                 'link_game' => 'nullable|integer',
                 'link_module' => 'nullable|integer',
                 'theme_key' => 'nullable|string|max:30',
+                'link' => 'nullable|string|max:200',
+                'b_order' => 'nullable|integer',
+                'state' => 'nullable|integer',
             ]);
 
             if ($validator->fails()) {
                 return apiReturnFail($validator->errors()->first());
             }
 
-            $data = $request->only(['img', 'img_pt', 'img_es', 'alt', 'link_game', 'link_module', 'theme_key']);
+            $data = $request->only([
+                'img', 'img_pt', 'img_es', 'alt', 'link_game', 'link_module',
+                'theme_key', 'link', 'b_order', 'state'
+            ]);
+
+            $data['link'] = $data['link'] ?? '';
+            $data['state'] = isset($data['state']) && $data['state'] !== '' ? (int)$data['state'] : 127;
+            $data['b_order'] = $data['b_order'] !== '' ? $data['b_order'] : null;
+
             $info->update($data);
 
             return apiReturnSuc();
@@ -92,4 +117,52 @@ class BannerController
 
         return apiReturnSuc();
     }
+
+    /**
+     * 同步当前 banner(事件)到其他所有主题
+     * 规则:通过 link 字段识别"事件"
+     *       其他主题如果没有相同 link 的 banner,则复制过去
+     */
+    public function sync($id)
+    {
+        $info = Banner::findOrFail($id);
+
+        if (empty($info->link)) {
+            return apiReturnFail('当前 Banner 没有设置 link(事件),无法识别为一个事件进行同步');
+        }
+
+        $themes = WebThemeConfig::all();
+        $copied = 0;
+        $skipped = 0;
+
+        foreach ($themes as $theme) {
+            $themeKey = $theme->ThemeKey;
+
+            // 跳过当前 banner 所在的主题
+            if ($themeKey === $info->theme_key) {
+                continue;
+            }
+
+            // 检查该主题下是否已存在相同 link 的 banner
+            $exists = Banner::where('theme_key', $themeKey)
+                ->where('link', $info->link)
+                ->exists();
+
+            if ($exists) {
+                $skipped++;
+                continue;
+            }
+
+            // 复制一份到该主题(使用原始属性,避免 accessor 处理过的 img)
+            $new = $info->replicate();
+            $new->theme_key = $themeKey;
+            $new->save();
+            $copied++;
+        }
+
+        return apiReturnSuc([
+            'copied' => $copied,
+            'skipped' => $skipped,
+        ], '', "同步完成:新增 {$copied} 个,跳过 {$skipped} 个已存在");
+    }
 }

+ 6 - 0
app/Services/OrderServices.php

@@ -641,6 +641,12 @@ class  OrderServices
                 ->where('UserID', $user_id)
                 ->delete();
 
+            DB::connection('write')->table('QPRecordDB.dbo.RecordUserGameDayCount')
+                ->where('UserID', $user_id)
+                ->delete();
+
+
+
             $userModel = GlobalUserInfo::getGameUserInfo('UserID', $user_id);
             if ($userModel && $userModel->RegisterDate){
                 $RecordPlatformDataModel = new \App\Models\RecordPlatformData();

+ 13 - 0
resources/views/admin/banner/add.blade.php

@@ -39,6 +39,19 @@
                                     <label>Link Module ID</label>
                                     <input type="number" class="form-control" name="link_module">
                                 </div>
+                                <div class="form-group">
+                                    <label>{{ __('auto.事件') }} (link)</label>
+                                    <input type="text" class="form-control" name="link" placeholder="事件链接/标识,例如 /activity/xxx 或活动唯一标识" maxlength="200">
+                                    <small class="form-text text-muted">用于在"同步到其他主题"时识别事件是否已存在</small>
+                                </div>
+                                <div class="form-group">
+                                    <label>{{ __('auto.排序') }} (b_order)</label>
+                                    <input type="number" class="form-control" name="b_order" placeholder="数字越小越靠前,留空为末尾">
+                                </div>
+                                <div class="form-group">
+                                    <label>{{ __('auto.状态') }} (state)</label>
+                                    <input type="number" class="form-control" name="state" value="127" placeholder="默认 127">
+                                </div>
                                 <div class="form-group">
                                     <label>{{ __('auto.主题KEY') }}</label>
                                     <select class="form-control" name="theme_key">

+ 13 - 0
resources/views/admin/banner/edit.blade.php

@@ -39,6 +39,19 @@
                                     <label>Link Module ID</label>
                                     <input type="number" class="form-control" name="link_module" value="{{$info->link_module}}">
                                 </div>
+                                <div class="form-group">
+                                    <label>{{ __('auto.事件') }} (link)</label>
+                                    <input type="text" class="form-control" name="link" value="{{$info->link}}" placeholder="事件链接/标识" maxlength="200">
+                                    <small class="form-text text-muted">用于在"同步到其他主题"时识别事件是否已存在</small>
+                                </div>
+                                <div class="form-group">
+                                    <label>{{ __('auto.排序') }} (b_order)</label>
+                                    <input type="number" class="form-control" name="b_order" value="{{$info->b_order}}" placeholder="数字越小越靠前,留空为末尾">
+                                </div>
+                                <div class="form-group">
+                                    <label>{{ __('auto.状态') }} (state)</label>
+                                    <input type="number" class="form-control" name="state" value="{{$info->state}}" placeholder="默认 127">
+                                </div>
                                 <div class="form-group">
                                     <label>{{ __('auto.主题KEY') }}</label>
                                     <select class="form-control" name="theme_key">

+ 29 - 1
resources/views/admin/banner/index.blade.php

@@ -52,6 +52,9 @@
                                     <th>Alt</th>
                                     <th>Link Game</th>
                                     <th>Link Module</th>
+                                    <th>{{ __('auto.事件') }}(link)</th>
+                                    <th>{{ __('auto.排序') }}</th>
+                                    <th>{{ __('auto.状态') }}</th>
                                     <th>{{ __('auto.主题KEY') }}</th>
                                     <th>{{ __('auto.操作') }}</th>
                                 </tr>
@@ -68,9 +71,13 @@
                                         <td>{{$v->alt}}</td>
                                         <td>{{$v->link_game}}</td>
                                         <td>{{$v->link_module}}</td>
+                                        <td style="max-width: 200px; word-break: break-all;">{{$v->link}}</td>
+                                        <td>{{$v->b_order}}</td>
+                                        <td>{{$v->state}}</td>
                                         <td>{{$v->theme_key}}</td>
-                                        <td>
+                                        <td style="min-width: 260px;">
                                             <a href="{{ url('admin/banner/edit/'.$v->bid) }}" class="btn btn-sm btn-gradient-info">{{ __('auto.编辑') }}</a>
+                                            <button class="btn btn-sm btn-gradient-success" onclick="syncBanner({{$v->bid}})" title="其他主题若没有此事件(link)则复制过去">{{ __('auto.同步到其他主题') }}</button>
                                             <button class="btn btn-sm btn-gradient-danger" onclick="deleteBanner({{$v->bid}})">{{ __('auto.删除') }}</button>
                                         </td>
                                     </tr>
@@ -105,5 +112,26 @@
                 });
             }
         }
+
+        function syncBanner(id) {
+            if (!confirm('确认将此 Banner(事件) 同步到所有其他主题吗?\n规则:其他主题若不存在相同 link 的 Banner,则复制过去。')) {
+                return;
+            }
+            $.ajax({
+                url: '/admin/banner/sync/' + id,
+                type: 'POST',
+                success: function(res) {
+                    if (res.code === 200) {
+                        alert(res.msg || '同步成功');
+                        location.reload();
+                    } else {
+                        alert(res.msg || '同步失败');
+                    }
+                },
+                error: function(xhr) {
+                    alert('请求失败:' + (xhr.responseJSON && xhr.responseJSON.msg ? xhr.responseJSON.msg : xhr.status));
+                }
+            });
+        }
     </script>
 @endsection

+ 1 - 0
routes/web.php

@@ -360,6 +360,7 @@ Route::group([
         $route->any('/banner/add', 'Admin\BannerController@add');
         $route->any('/banner/edit/{id}', 'Admin\BannerController@edit');
         $route->post('/banner/delete/{id}', 'Admin\BannerController@delete');
+        $route->post('/banner/sync/{id}', 'Admin\BannerController@sync');