seven 3 周之前
父节点
当前提交
af4f2f2eb7
共有 3 个文件被更改,包括 44 次插入1 次删除
  1. 17 0
      app/Http/Controllers/admin/Issue.php
  2. 26 1
      app/Services/GameplayRuleService.php
  3. 1 0
      routes/admin.php

+ 17 - 0
app/Http/Controllers/admin/Issue.php

@@ -121,4 +121,21 @@ class Issue extends Controller
         }
         return $this->success([], $ret['msg']);
     }
+
+    /**
+     * @description: 删除
+     */
+    public function destroy()
+    {
+        $id = request()->post('id');
+        // 示例:通过 ID 删除
+        $info = IssueService::findOne(['id' => $id]);
+        if (!$info) {
+            return $this->error(0, '期数不存在');
+        }
+
+        $info->delete();
+
+        return $this->success([], '删除成功');
+    }
 }

+ 26 - 1
app/Services/GameplayRuleService.php

@@ -171,7 +171,32 @@ class GameplayRuleService extends BaseService
      */    
     public static function bettingRuleVerify($input)
     {
-        $result = self::enum()::validateInput($input);
+        $result = self::validateInput($input);
         return $result;
     }
+
+    /**
+     * @description: 校验输入的内容
+     * @param {*} $input
+     * @return {*}
+     */
+    public static function validateInput($input)
+    {
+         // 获取所有玩法
+        $allRules = self::model()::pluck('keywords')->toArray();
+        
+
+        // 玩法正则(防止玩法里有特殊符号出错)
+        $rulesPattern = implode('|', array_map('preg_quote', $allRules));
+
+        // 匹配玩法 + 金额
+        if (preg_match('/^(' . $rulesPattern . ')(\d+)$/u', $input, $matches)) {
+            return [
+                'rule'   => $matches[1],
+                'amount' => (int)$matches[2]
+            ];
+        }
+
+        return null;
+    }
 }

+ 1 - 0
routes/admin.php

@@ -57,6 +57,7 @@ Route::middleware(['admin.jwt'])->group(function () {
             Route::post('/betting', [Issue::class, 'betting']);
             Route::post('/close', [Issue::class, 'close']);
             Route::post('/lotteryDraw', [Issue::class, 'lotteryDraw']); // 开奖
+            Route::post('/delete', [Issue::class, 'destroy']); // 删除
         });