PC-202304251453\Administrator 5 mesi fa
parent
commit
1ca27b5813

+ 17 - 46
app/v1/logic/dataReport/UserLogLogic.php

@@ -19,9 +19,6 @@ class UserLogLogic extends BaseLogic
         $regTime = $params['reg_time'];
         $tableName = 'sdk_reg_log_' . date('Ym', strtotime($regTime));
         $params['reg_time'] = strtotime($regTime . " 00:00:00") . "<=" . strtotime($regTime . " 23:59:59");
-        $orderBy = request()->input('orderBy', 'reg_time');
-        $orderType = request()->input('orderType', 'desc');
-        $page = request()->input('page', 1);
         $limit = request()->input('limit', 10);
 
 
@@ -56,16 +53,10 @@ class UserLogLogic extends BaseLogic
         }
 
         // 自然量ID, auth_id=0为自然量
-        $whereRaw = [];
-        if(!empty($params['nomal_game_id'])){
-            for($i=0;$i<count($params['nomal_game_id']);$i++){
-                $whereRaw[] = "(game_id = {$params['nomal_game_id'][$i]} AND auth_id=0)";
-            }
+        $whereRaw = $this->nomalGameWhere($params['nomal_game_id']);
+        if($whereRaw){
+            $regLogQuery = $regLogQuery->whereRaw($whereRaw);
         }
-        $whereRaw = implode(' OR ', $whereRaw);
-        $regLogQuery = $regLogQuery->whereRaw($whereRaw);
-
-        echo $regLogQuery->buildSql();
 
         // 分页
         $data = $regLogQuery->paginate($limit)->toArray();
@@ -121,14 +112,10 @@ class UserLogLogic extends BaseLogic
         }
 
         // 自然量ID, auth_id=0为自然量
-        $whereRaw = [];
-        if(!empty($params['nomal_game_id'])){
-            for($i=0;$i<count($params['nomal_game_id']);$i++){
-                $whereRaw[] = "(game_id = {$params['nomal_game_id'][$i]} AND auth_id=0)";
-            }
+        $whereRaw = $this->nomalGameWhere($params['nomal_game_id']);
+        if($whereRaw){
+            $loginLogQuery = $loginLogQuery->whereRaw($whereRaw);
         }
-        $whereRaw = implode(' OR ', $whereRaw);
-        $loginLogQuery = $loginLogQuery->whereRaw($whereRaw);
 
         // 执行查询并排序
         $loginLogQuery->order($orderBy, $orderType);
@@ -231,15 +218,13 @@ class UserLogLogic extends BaseLogic
                 ->where('reg_date', '>=', $params['reg_date'][0] . ' 00:00:00')
                 ->where('reg_date', '<=', $params['reg_date'][1] . ' 23:59:59');
         }
+
+
         // 自然量ID, auth_id=0为自然量
-        $whereRaw = [];
-        if(!empty($params['nomal_game_id'])){
-            for($i=0;$i<count($params['nomal_game_id']);$i++){
-                $whereRaw[] = "(game_id = {$params['nomal_game_id'][$i]} AND auth_id=0)";
-            }
+        $whereRaw = $this->nomalGameWhere($params['nomal_game_id']);
+        if($whereRaw){
+            $rechargeDetailQuery = $rechargeDetailQuery->whereRaw($whereRaw);
         }
-        $whereRaw = implode(' OR ', $whereRaw);
-        $rechargeDetailQuery = $rechargeDetailQuery->whereRaw($whereRaw);
 
         $rechargeDetailQuery->order($orderBy, $orderType);
 
@@ -298,15 +283,12 @@ class UserLogLogic extends BaseLogic
                 ->where('reg_date', '>=', $params['reg_date'][0] . ' 00:00:00')
                 ->where('reg_date', '<=', $params['reg_date'][1] . ' 23:59:59');
         }
+
         // 自然量ID, auth_id=0为自然量
-        $whereRaw = [];
-        if(!empty($params['nomal_game_id'])){
-            for($i=0;$i<count($params['nomal_game_id']);$i++){
-                $whereRaw[] = "(game_id = {$params['nomal_game_id'][$i]} AND auth_id=0)";
-            }
+        $whereRaw = $this->nomalGameWhere($params['nomal_game_id']);
+        if($whereRaw){
+            $rechargeRankQuery = $rechargeRankQuery->whereRaw($whereRaw);
         }
-        $whereRaw = implode(' OR ', $whereRaw);
-        $rechargeRankQuery = $rechargeRankQuery->whereRaw($whereRaw);
 
         // 先选择字段,包括计算字段
         $rechargeRankQuery->field('user_name,sum(money) as searchTotalMoney,
@@ -332,10 +314,8 @@ class UserLogLogic extends BaseLogic
 
         $data = $rechargeRankQuery->paginate($limit)->toArray();
 
-
         $data['data'] = $this->trandformListColumn($data['data'], ['game', 'auth', 'agent', 'pay_channel']);
 
-
         // // 告警提示,查询最近登录时间,查询最近充值时间,和现在时间对比,如果超过3天,则告警,并提示
 
         foreach ($data['data'] as &$item) {
@@ -386,16 +366,9 @@ class UserLogLogic extends BaseLogic
         if (!empty($where['reg_date'])) {
             $totalWhere['reg_date'] = $params['reg_date'];
         }
-        // 自然量ID, auth_id=0为自然量
-        $whereRaw = [];
-        if(!empty($params['nomal_game_id'])){
-            for($i=0;$i<count($params['nomal_game_id']);$i++){
-                $whereRaw[] = "(game_id = {$params['nomal_game_id'][$i]} AND auth_id=0)";
-            }
-        }
-        $whereRaw = implode(' OR ', $whereRaw);
-     
 
+        // 自然量ID, auth_id=0为自然量
+        $whereRaw = $this->nomalGameWhere($params['nomal_game_id']);
 
         $totalList = Db::connect('db_game_log')->table('sdk_order_success')
             ->where($totalWhere)
@@ -427,8 +400,6 @@ class UserLogLogic extends BaseLogic
 
     public function getRoleDataList($where): mixed
     {
-        $orderBy = request()->input('orderBy', 'reg_time');
-        $orderType = request()->input('orderType', 'desc');
         $page = request()->input('page', 1);
         $limit = request()->input('limit', 10);
 

+ 13 - 2
plugin/saiadmin/basic/BaseLogic.php

@@ -257,7 +257,8 @@ class BaseLogic
         }
 
         // 看指定游戏的自然量
-        if(!empty($authNormalGameList)&&$authNormalGameList!='*'&&$authNormalGameList!='-1'){
+        $data['nomal_game_id'] = "";
+        if(!empty($authNormalGameList) && $authNormalGameList!='*' && $authNormalGameList!='-1'){
             // 如果传入了game_id,则取auth_normal_game_list交集
             if(!empty($data['game_id'])){
                 $authNormalGameList = explode(',', $authNormalGameList);
@@ -266,11 +267,21 @@ class BaseLogic
                 $data['nomal_game_id'] = $authNormalGameList ? explode(',', $authNormalGameList) : '';
             }
         }
+
         /**自然量权限-结束***************************************** */
         return $data;
     }
 
-
+    protected function nomalGameWhere($nomalGameId): string
+    {
+        $whereRaw = [];
+        if(!empty($nomalGameId)){
+            for($i=0;$i<count($nomalGameId);$i++){
+                $whereRaw[] = "(game_id = {$nomalGameId[$i]} AND auth_id=0)";
+            }
+        }
+        return $whereRaw ? implode(' OR ', $whereRaw) : "1=1";
+    }
     
     /**
      * 分页查询数据