Ken 3 天之前
父节点
当前提交
27f26ef9f9
共有 2 个文件被更改,包括 38 次插入31 次删除
  1. 38 30
      app/Services/GameplayRuleService.php
  2. 0 1
      composer.json

+ 38 - 30
app/Services/GameplayRuleService.php

@@ -14,16 +14,16 @@ use App\Constants\GameplayRuleEnum;
 
 /**
  * 玩法规则服务类
-*/
-class GameplayRuleService extends BaseService 
+ */
+class GameplayRuleService extends BaseService
 {
     const CACHE_KEY = 'gameplay_rules_';
 
     /**
      * @description: 模型
      * @return {string}
-     */    
-    public static function model() :string
+     */
+    public static function model(): string
     {
         return GameplayRule::class;
     }
@@ -31,8 +31,8 @@ class GameplayRuleService extends BaseService
     /**
      * @description: 枚举
      * @return {*}
-     */    
-    public static function enum() :string
+     */
+    public static function enum(): string
     {
         return GameplayRuleEnum::class;
     }
@@ -41,24 +41,24 @@ class GameplayRuleService extends BaseService
      * @description: 获取查询条件
      * @param {array} $search 查询内容
      * @return {array}
-     */    
-    public static function getWhere(array $search = []) :array
+     */
+    public static function getWhere(array $search = []): array
     {
         $where = [];
-        if(isset($search['groups']) && !empty($search['groups'])){
+        if (isset($search['groups']) && !empty($search['groups'])) {
             $where[] = ['groups', '=', $search['groups']];
         }
-        if(isset($search['keywords']) && !empty($search['keywords'])){
+        if (isset($search['keywords']) && !empty($search['keywords'])) {
             $where[] = ['keywords', '=', $search['keywords']];
         }
-        if(isset($search['id']) && !empty($search['id'])){
+        if (isset($search['id']) && !empty($search['id'])) {
             $where[] = ['id', '=', $search['id']];
         }
-    
+
         return $where;
     }
 
-     /**
+    /**
      * @description: 查询单条数据
      * @param array $search
      * @return \App\Models\Coin|null
@@ -85,29 +85,29 @@ class GameplayRuleService extends BaseService
      */
     public static function paginate(array $search = [])
     {
-        $limit = isset($search['limit'])?$search['limit']:15;
+        $limit = isset($search['limit']) ? $search['limit'] : 15;
         $paginator = self::model()::where(self::getWhere($search))->paginate($limit);
         return ['total' => $paginator->total(), 'data' => $paginator->items()];
     }
 
     /**
-     * @description: 
+     * @description:
      * @param {*} $params
      * @return {*}
-     */    
+     */
     public static function submit($params = [])
     {
         $result = false;
         $msg['code'] = self::NOT;
         $msg['msg'] = '';
-        
+
         // 2. 判断是否是更新
         if (!empty($params['id'])) {
             // 更新
-            $info = self::findOne(['id'=>$params['id']] );
+            $info = self::findOne(['id' => $params['id']]);
             if (!$info) {
                 $msg['msg'] = '规则不存在!';
-            }else{
+            } else {
                 $result = $info->update($params);
                 $id = $params['id'];
             }
@@ -117,14 +117,14 @@ class GameplayRuleService extends BaseService
             $result = $info = self::model()::create($params);
             $id = $result->id;
         }
-        
-       
-        if($result){
+
+
+        if ($result) {
             self::clearCache($params['keywords']);
-           $msg['code'] = self::YES;
-           $msg['msg'] = '设置成功';
-        }else{
-            $msg['msg'] = empty($msg['msg']) ?'操作失败':$msg['msg'];
+            $msg['code'] = self::YES;
+            $msg['msg'] = '设置成功';
+        } else {
+            $msg['msg'] = empty($msg['msg']) ? '操作失败' : $msg['msg'];
         }
 
         return $msg;
@@ -168,10 +168,18 @@ class GameplayRuleService extends BaseService
      * @description: 校验输入的内容
      * @param {*} $input
      * @return {*}
-     */    
+     */
     public static function bettingRuleVerify($input)
     {
-        $result = self::validateInput($input);
+        $input = explode(' ', $input);
+        $result = [];
+        foreach ($input as $value) {
+            $res = self::validateInput($value);
+            if ($res !== null) {
+                $result[] = $res;
+            }
+        }
+        if (empty($result)) return null;
         return $result;
     }
 
@@ -182,7 +190,7 @@ class GameplayRuleService extends BaseService
      */
     public static function validateInput($input)
     {
-         // 获取所有玩法
+        // 获取所有玩法
         $allRules = self::model()::pluck('keywords')->toArray();
 
         // 玩法正则(防止玩法里有特殊符号出错)
@@ -191,7 +199,7 @@ class GameplayRuleService extends BaseService
         // 匹配玩法 + 金额
         if (preg_match('/^(' . $rulesPattern . ')(\d+)$/u', $input, $matches)) {
             return [
-                'rule'   => $matches[1],
+                'rule' => $matches[1],
                 'amount' => (int)$matches[2]
             ];
         }

+ 0 - 1
composer.json

@@ -19,7 +19,6 @@
     "firebase/php-jwt": "^6.10",
     "guzzlehttp/guzzle": "^7.2",
     "irazasyed/telegram-bot-sdk": "^3.15",
-    "jpush/jpush": "^3.6",
     "kornrunner/keccak": "^1.1",
     "kornrunner/secp256k1": "^0.3.0",
     "laravel-lang/lang": "^14.7",