|
@@ -79,30 +79,75 @@ class AccountLogic extends BaseLogic
|
|
|
/**
|
|
/**
|
|
|
* 封禁列表
|
|
* 封禁列表
|
|
|
*/
|
|
*/
|
|
|
- public function getBanList($query)
|
|
|
|
|
|
|
+ public function getBanList($where)
|
|
|
{
|
|
{
|
|
|
$saiType = request()->input('saiType', 'list');
|
|
$saiType = request()->input('saiType', 'list');
|
|
|
$page = request()->input('page', 1);
|
|
$page = request()->input('page', 1);
|
|
|
$limit = request()->input('limit', 10);
|
|
$limit = request()->input('limit', 10);
|
|
|
$orderBy = request()->input('orderBy', '');
|
|
$orderBy = request()->input('orderBy', '');
|
|
|
$orderType = request()->input('orderType', $this->orderType);
|
|
$orderType = request()->input('orderType', $this->orderType);
|
|
|
|
|
+
|
|
|
if(empty($orderBy)) {
|
|
if(empty($orderBy)) {
|
|
|
$orderBy = $this->orderField !== '' ? $this->orderField : $this->model->getPk();
|
|
$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') {
|
|
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) {
|
|
$data['data'] = array_map(function($item) {
|
|
|
$item['action'] = $item['action'] == 1 ? '封禁' : '解封';
|
|
$item['action'] = $item['action'] == 1 ? '封禁' : '解封';
|
|
|
$item['type'] = $item['type'] == 1 ? 'UID' : ($item['type'] == 2 ? 'IP' : '设备');
|
|
$item['type'] = $item['type'] == 1 ? 'UID' : ($item['type'] == 2 ? 'IP' : '设备');
|
|
|
return $item;
|
|
return $item;
|
|
|
}, $data['data']);
|
|
}, $data['data']);
|
|
|
|
|
+
|
|
|
$data['data'] = $this->trandformListColumn($data['data'],['auth']);
|
|
$data['data'] = $this->trandformListColumn($data['data'],['auth']);
|
|
|
- return $data;
|
|
|
|
|
|
|
+ return $data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|