ith5 4 månader sedan
förälder
incheckning
23eda62479

+ 2 - 2
app/v1/controller/customer/AccountController.php

@@ -78,8 +78,8 @@ class AccountController extends BaseController
             ['action', ''],
             ['value','']
         ]);
-        $query = $this->logic->search($where);
-        $data = $this->logic->getBanList($query);
+        // $query = $this->logic->search($where);
+        $data = $this->logic->getBanList($where);
         return $this->success($data);
     }
 

+ 0 - 1
app/v1/logic/advert/AgentSiteLogic.php

@@ -101,7 +101,6 @@ class AgentSiteLogic extends BaseLogic
                 'name' => $data['name'].$i,
             ];
         }
-        echo 'insertData:'.json_encode($insertData);
         $this->model->insertAll($insertData);
         return true;
     }

+ 51 - 6
app/v1/logic/customer/AccountLogic.php

@@ -79,30 +79,75 @@ class AccountLogic extends BaseLogic
     /**
      * 封禁列表 
      */
-    public function getBanList($query)
+    public function getBanList($where)
     {
         $saiType = request()->input('saiType', 'list');
         $page = request()->input('page', 1);
         $limit = request()->input('limit', 10);
         $orderBy = request()->input('orderBy', '');
         $orderType = request()->input('orderType', $this->orderType);
+        
         if(empty($orderBy)) {
             $orderBy = $this->orderField !== '' ? $this->orderField : $this->model->getPk();
         }
+        
+        // 处理查询条件,特别是处理逗号分隔的value值
+        $query = Db::connect('db_game_log')->table('ban_log');
+        
+        // 处理where条件
+        foreach ($where as $key => $val) {
+            if ($val !== '' && $key !== 'value') {
+                $query->where($key, $val);
+            }
+        }
+        
+        // 特殊处理value字段
+        if (isset($where['value']) && !empty($where['value'])) {
+            $value = trim($where['value']);
+            
+            // 如果输入的值包含逗号,说明要搜索多个值
+            if (strpos($value, ',') !== false) {
+                $values = explode(',', $value);
+                $values = array_map('trim', $values);
+                
+                // 构建FIND_IN_SET查询条件
+                $findInSetConditions = [];
+                foreach ($values as $val) {
+                    if (!empty($val)) {
+                        $findInSetConditions[] = "FIND_IN_SET('" . addslashes($val) . "', value) > 0";
+                    }
+                }
+                
+                if (!empty($findInSetConditions)) {
+                    $query->whereRaw('(' . implode(' OR ', $findInSetConditions) . ')');
+                }
+            } else {
+                // 如果输入的是单个值,需要同时考虑两种情况:
+                // 1. 数据库中存储的是单个值(精确匹配)
+                // 2. 数据库中存储的是逗号分隔的值(使用FIND_IN_SET)
+                $query->where(function($q) use ($value) {
+                    $q->where('value', $value)  // 精确匹配
+                    ->whereOr('value', 'like', '%' . $value . '%')  // 模糊匹配
+                    ->whereOrRaw("FIND_IN_SET('" . addslashes($value) . "', value) > 0");  // FIND_IN_SET匹配
+                });
+            }
+        }
+        
+        // 执行查询
         if ($saiType === 'all') {
-            $data = Db::connect('db_game_log')->table('ban_log')->where($query)->order($orderBy, $orderType)->select()->toArray();
-        }else{
-            $data = Db::connect('db_game_log')->table('ban_log')->where($query)->order($orderBy, $orderType)->paginate($limit)->toArray();
+            $data = $query->order($orderBy, $orderType)->select()->toArray();
+        } else {
+            $data = $query->order($orderBy, $orderType)->paginate($limit)->toArray();
         }
 
-
         $data['data'] = array_map(function($item) {
             $item['action'] = $item['action'] == 1 ? '封禁' : '解封';
             $item['type'] = $item['type'] == 1 ? 'UID' : ($item['type'] == 2 ? 'IP' : '设备');
             return $item;
         }, $data['data']);
+        
         $data['data'] = $this->trandformListColumn($data['data'],['auth']);
-       return $data;
+        return $data;
     }
 
     /**