PC-202304251453\Administrator 5 hónapja
szülő
commit
81d709e069
1 módosított fájl, 8 hozzáadás és 15 törlés
  1. 8 15
      app/v1/logic/dataReport/UserLogLogic.php

+ 8 - 15
app/v1/logic/dataReport/UserLogLogic.php

@@ -17,34 +17,27 @@ class UserLogLogic extends BaseLogic
     {
         $params = $this->searchByAuth($where);
 
+        $page = request()->input('page', 10);
         $limit = request()->input('limit', 10);
+        $offset = ($page - 1) * $limit;
+
         if(!$params['reg_time']){
             throw new ApiException("注册时间不能为空");
         }
 
         // 公共处理完的where, 自然量ID, auth_id=0为自然量
         [$where, $whereRaw] = $this->getUlogCommonWhere($params);
-
         $monthRange = getMonthsBetweenDates($params['reg_time'][0], $params['reg_time'][1]);
 
-        $query = null;
+        $db = Db::connect('db_game_log');
+        $unionQuery = [];
         foreach ($monthRange as $month){
             $tableName = 'sdk_reg_log_' . $month;
-            $monthQuery = Db::connect("db_game_log")->table($tableName)
-                ->field("*")
-                ->where($where)
-                ->whereRaw($whereRaw);
-
-            // 如果是第一个查询,直接赋值;否则使用 unionAll 合并
-            if ($query === null) {
-                $query = $monthQuery;
-            } else {
-                $query->unionAll($monthQuery);
-            }
+            $unionQuery[] = $db->table($tableName)->field("uid,reg_time,imei,brand")->where($where)->whereRaw($whereRaw)->buildSql();
         }
+        $fullSql = "(" . implode(' UNION ALL ', $unionQuery) . ") as unTable";
 
-        // 分页
-        return $query->paginate($limit)->toArray();
+        return $db->table($fullSql)->paginate($limit)->toArray();
     }
 
     // 登录日志