ith5 vor 5 Monaten
Ursprung
Commit
9db6c9a6ed

+ 2 - 2
app/v1/logic/dataReport/AnalyseLogic.php

@@ -126,10 +126,10 @@ class AnalyseLogic extends BaseLogic
             $whereSql .= " AND tdate = '{$params['reg_date']}'";
         }
 
-        // 自然量ID, agent_id=1000为自然量
+        // 自然量ID, auth_id=0为自然量
         if(!empty($params['nomal_game_id'])){
             for($i=0;$i<count($params['nomal_game_id']);$i++){
-                $whereSql .= " OR (game_id = {$params['nomal_game_id'][$i]} AND agent_id=1000)";
+                $whereSql .= " OR (game_id = {$params['nomal_game_id'][$i]} AND auth_id=0)";
             }
         }
 

+ 7 - 0
app/v1/logic/dataReport/ChannelAnalysisLogic.php

@@ -162,6 +162,13 @@ class ChannelAnalysisLogic extends BaseLogic
             $whereSql .= " AND tdate BETWEEN '{$params['reg_date'][0]}' AND '{$params['reg_date'][1]}'";
         }
 
+        // 自然量ID, auth_id=0为自然量
+        if(!empty($params['nomal_game_id'])){
+            for($i=0;$i<count($params['nomal_game_id']);$i++){
+                $whereSql .= " OR (game_id = {$params['nomal_game_id'][$i]} AND auth_id=0)";
+            }
+        }
+
         return $whereSql;
     }
 

+ 19 - 3
app/v1/logic/dataReport/MaterialLogic.php

@@ -33,6 +33,9 @@ class MaterialLogic extends BaseLogic
 
         // 基础筛选
         $whereSql = $this->generateWhereSql($params);
+
+        echo $whereSql;
+
         //  作者筛选
         if (!empty($params['author_id'])) {
             $whereSql .= " AND author_id = {$params['author_id']}";
@@ -73,6 +76,13 @@ class MaterialLogic extends BaseLogic
         $sql = " SELECT $field FROM $tableName WHERE 1=1 $whereSql GROUP BY $group";
         $data = Db::connect('db_advert')->query($sql);
 
+        if(empty($data)){
+            return [
+                'data' => [],
+                'totalRow' => []
+            ];
+        }
+
         $totalData = [];
         foreach ($data as &$row) {
 
@@ -98,9 +108,9 @@ class MaterialLogic extends BaseLogic
 
         }
 
-        $totalData['ad_click_rate'] = ToolLogic::getPercent($totalData['click'], $totalData['ad_show'], 2);
-        $totalData['reg_cost'] = ToolLogic::getRound($totalData['cost'], $totalData['register'], 2);
-        $totalData['pay_cost'] = ToolLogic::getRound($totalData['cost'], (int)$totalData['pay_count'], 2);
+        $totalData['ad_click_rate'] = ToolLogic::getPercent($totalData['click']??0, $totalData['ad_show']??0, 2);
+        $totalData['reg_cost'] = ToolLogic::getRound($totalData['cost']??0, $totalData['register']??0, 2);
+        $totalData['pay_cost'] = ToolLogic::getRound($totalData['cost']??0, (int)$totalData['pay_count']??0, 2);
 
         return [
             'data' => $data,
@@ -152,6 +162,12 @@ class MaterialLogic extends BaseLogic
         if (!empty($params['reg_date']) && !is_array($params['reg_date'])) {
             $whereSql .= " AND tdate = '{$params['reg_date']}'";
         }
+        // 自然量ID, auth_id=0为自然量
+        if(!empty($params['nomal_game_id'])){
+            for($i=0;$i<count($params['nomal_game_id']);$i++){
+                $whereSql .= " OR (game_id = {$params['nomal_game_id'][$i]} AND auth_id=0)";
+            }
+        }
 
         return $whereSql;
     }

+ 2 - 2
app/v1/middleware/FilterPermission.php

@@ -32,9 +32,9 @@ class FilterPermission implements MiddlewareInterface
 
         // 获取游戏自然量数据权限
         if(in_array(1,$currentUserRoleList)){
-            $auth_normal_game_list = '';
+            $auth_normal_game_list = '*';
         }else{
-            $auth_normal_game_list = $user_info['normal_game_list'] ?? '';
+            $auth_normal_game_list = $user_info['normal_game_list'] ?? '-1';
         }
 
         // 获取广告投放数据权限

+ 3 - 2
plugin/saiadmin/app/controller/system/SystemUserController.php

@@ -200,15 +200,16 @@ class SystemUserController extends BaseController
         $game_list = $request->post('game_list');
         $normal_game_list = $request->post('normal_game_list');
         $ad_permission = $request->post('ad_permission');
+        $data = [];
         if ($game_list) {
             $data['game_list'] = $game_list;
         }
         if ($normal_game_list) {
             $data['normal_game_list'] = $normal_game_list;
         }
-        if($ad_permission){
+        if($ad_permission!==null){
             $data['ad_permission'] = $ad_permission;
-        }
+        }      
         
         $this->logic->authEdit($id, $data);
         $userInfoCache = new UserInfoCache($id);

+ 27 - 22
plugin/saiadmin/basic/BaseLogic.php

@@ -195,27 +195,8 @@ class BaseLogic
                 $data['game_id'] = $authGameList ? explode(',', $authGameList) : '';
             }
         }
-           
-        // 自然量游戏权限
-        if(!empty($authNormalGameList)){
-            // 如果传入了game_id,则取auth_normal_game_list交集
-            if(!empty($data['game_id'])){
-                $data['nomal_game_id'] = array_values(array_intersect($authNormalGameList, $data['game_id']));
-            }else{
-                $data['nomal_game_id'] = $authNormalGameList ? explode(',', $authNormalGameList) : '';
-            }
-        }
-
         /**广告数据权限-开始***************************************** */
-        // 广告数据权限-全公司数据
-        if($authAdPermission==1){
-            // 如果传入了auth_id,则取交集
-            if(!empty($data['auth_id'])){
-                $data['auth_id'] = array_values(array_intersect(explode(',', $data['auth_id']), explode(',', $authAdPermission)));
-            }else{
-                $data['auth_id'] =  '';
-            }
-        }
+    
 
         // 广告数据权限-自己以及下面组员
         if($authAdPermission==2){
@@ -228,7 +209,8 @@ class BaseLogic
 
             if(!empty($data['auth_id'])){
                // 如果传入了负责人ID,则取交集
-               $data['auth_id'] = array_values(array_intersect(explode(',', $data['auth_id']), array_values($under_user_ids)));
+               print_r($under_user_ids);
+               $data['auth_id'] = array_values(array_intersect( $data['auth_id'], array_values($under_user_ids)));
             }else{
                 // 如果没有传入负责人ID, 则取当前用户以及下面组员
                 $data['auth_id'] =  array_values($under_user_ids);
@@ -240,13 +222,36 @@ class BaseLogic
             $current_user_id = $this->adminInfo['id'];
             if(!empty($data['auth_id'])){
                // 如果传入了负责人ID,则取交集
-               $data['auth_id'] = array_values(array_intersect(explode(',', $data['auth_id']), array_values($under_user_ids)));
+               $data['auth_id'] = array_values(array_intersect( $data['auth_id'], array_values($under_user_ids)));
             }else{
                 // 如果没有传入负责人ID, 则取当前用户
                 $data['auth_id'] =  $current_user_id;
             }
         }
         /**广告数据权限-结束***************************************** */
+
+
+        /**自然量权限-开始***************************************** */
+        // 全部游戏的自然量
+        if($authNormalGameList=='*'){
+            if(!empty($data['auth_id'])){
+                $data['auth_id'][] = 0;
+            }else{
+                $data['auth_id'] =  [0];
+            }
+        }
+
+        // 看指定游戏的自然量
+        if(!empty($authNormalGameList)&&$authNormalGameList!='*'&&$authNormalGameList!='-1'){
+            // 如果传入了game_id,则取auth_normal_game_list交集
+            if(!empty($data['game_id'])){
+                $authNormalGameList = explode(',', $authNormalGameList);
+                $data['nomal_game_id'] = array_values(array_intersect($authNormalGameList, $data['game_id']));
+            }else{
+                $data['nomal_game_id'] = $authNormalGameList ? explode(',', $authNormalGameList) : '';
+            }
+        }
+        /**自然量权限-结束***************************************** */
         return $data;
     }