ith5 5 kuukautta sitten
vanhempi
commit
9b5e767ab6
1 muutettua tiedostoa jossa 27 lisäystä ja 11 poistoa
  1. 27 11
      app/v1/logic/dataReport/UserLogLogic.php

+ 27 - 11
app/v1/logic/dataReport/UserLogLogic.php

@@ -4,6 +4,7 @@
 
 namespace app\v1\logic\dataReport;
 
+use app\v1\logic\tool\ToolLogic;
 use plugin\saiadmin\basic\BaseLogic;
 use plugin\saiadmin\service\OpenSpoutWriter;
 use support\think\Db;
@@ -16,21 +17,31 @@ class UserLogLogic extends BaseLogic
     {
         $params = $this->searchByAuth($where);
 
-        $tableName = 'sdk_reg_log_' . date('Ym', strtotime($params['reg_time']));
-        $limit = request()->input('limit', 10);
 
-        // 获取这一天的注册日志
-        $regLogQuery = Db::connect('db_game_log')->table($tableName);
+        $tableNames = ToolLogic::getMonthlyTableNames('sdk_reg_log_', $params['reg_time'][0], $params['reg_time'][1]);
+       
+        $limit = request()->input('limit', 10);
 
         // 公共处理完的where, 自然量ID, auth_id=0为自然量
         [$where, $whereRaw] = $this->getUlogCommonWhere($params);
-        if($where){
-            $regLogQuery = $regLogQuery->where($where);
-        }
-        if($whereRaw){
-            $regLogQuery = $regLogQuery->whereRaw($whereRaw);
+        
+        $currentQuery = Db::connect('db_game_log');
+        foreach($tableNames as $index => $tableName){
+            if($index === 0){
+                $currentQuery = $currentQuery->table($tableName)->field('*')->where($where)->whereRaw($whereRaw);
+            }else{
+                $currentQuery->unionAll($currentQuery->table($tableName)->field('*')->where($where)->whereRaw($whereRaw));
+            }
         }
 
+
+        // echo $currentQuery->buildSql();
+        // exit;
+
+        
+
+
+        $regLogQuery = $currentQuery->select();
         // 分页
         return $regLogQuery->paginate($limit)->toArray();
     }
@@ -77,6 +88,7 @@ class UserLogLogic extends BaseLogic
 
         $rechargeDetailQuery = Db::connect('db_game_log')->table($tableName);
 
+       
         // 公共处理完的where, 自然量ID, auth_id=0为自然量
         [$where, $whereRaw] = $this->getUlogCommonWhere($params);
         if($where){
@@ -213,12 +225,16 @@ class UserLogLogic extends BaseLogic
         }
 
         $totalList = Db::connect('db_game_log')->table('sdk_order_success')
-            ->where($where)
-            ->whereRaw($whereRaw)
+            ->where($where);
+            if(!empty($whereRaw)){
+                $totalList = $totalList->whereRaw($whereRaw);
+            }
+        $totalList = $totalList
             ->field('game_id,uid,sum(money) as totalMoney')
             ->group('uid,game_id,site_id,server_id,media_id,auth_id,agent_id,server_id,auth_id,role_id')
             ->select()->toArray();
 
+
         // 查询累计充值金额(对每一行数据单独查询历史充值金额)
         $totalMoneyMap = [];
         if (!empty($data['data']) && !empty($totalList)) {