Ver código fonte

格式化与优化

PC-202304251453\Administrator 5 meses atrás
pai
commit
e75bb5c554

+ 5 - 3
app/v1/controller/customer/RoleDataController.php

@@ -52,8 +52,10 @@ class RoleDataController extends BaseController
      */
     public function update(Request $request, $id): Response
     {
-      
-        $data = $this->logic->update($id, $request->post());
-        return $this->success($data);
+        $data = $request->post();
+
+        if($this->logic->myUpdate($id, $data)===false) return $this->fail('更新失败');
+
+        return $this->success();
     }
 }

+ 0 - 65
app/v1/logic/center/GameLogic.php

@@ -138,71 +138,6 @@ class GameLogic extends BaseLogic
         }
         return array_values($groupedGames);
     }
-    /**
-     * 根据权限获取游戏列表
-     */
-    public function getGameListByPermission($where)
-    {
-        $authGameList = request()->header('auth_game_list');
-        $query = $this->search($where);
-        if(!empty($authGameList)) {
-            $authGameList = explode(',', $authGameList);
-            $query->where('id', 'in', $authGameList);
-        }
-        $query->where('status', 1);
-        $query->order('sort', 'desc');
-        return $query->select()->toArray();
-    }
-
-    /**
-     * 根据权限获取游戏列表树形(无权限)
-     */
-    public function getGameListTreeNoAuth($where)
-    {
-        $pfGame = $this->model->where('status', 1)->order('sort', 'desc')->select()->toArray();
-        $mainGameMap = $this->gameMainLogic->getMainGameMap();
-        $groupedGames = [];
-        foreach ($pfGame as $game) {
-            $mainId = $game['main_id'];
-            $groupedGames[$mainId]['id'] = 'main_id_'.$mainId;
-            $groupedGames[$mainId]['disabled'] = ($where['single'] ?? false);
-            $groupedGames[$mainId]['name'] = $mainGameMap[$mainId] ?? $mainId;
-            $groupedGames[$mainId]['children'][] = [
-                'id' => $game['id'],
-                'name' => '['.$game['id'].']'.$game['name']
-            ];
-        }
-        return array_values($groupedGames);
-    }
-
-    /**
-     * 根据权限获取游戏列表树形(有权限)
-     */
-    public function getGameListTree($where)
-    {
-        $authGameList = request()->header('auth_game_list');
-        $query = $this->search();
-        if(!empty($authGameList)) {
-            $authGameList = explode(',', $authGameList);
-            $query->where('id', 'in', $authGameList);
-        }
-        $query->where('status', 1);
-        $query->order('sort', 'desc');
-        $gameList = $query->select()->toArray();
-        $mainGameMap = $this->gameMainLogic->getMainGameMap();
-        $groupedGames = [];
-        foreach ($gameList as $game) {
-            $mainId = $game['main_id'];
-            $groupedGames[$mainId]['id'] = 'main_id_'.$mainId;
-            $groupedGames[$mainId]['disabled'] = ($where['single'] ?? false);
-            $groupedGames[$mainId]['name'] = $mainGameMap[$mainId] ?? $mainId;
-            $groupedGames[$mainId]['children'][] = [
-                'id' => $game['id'],
-                'name' => '['.$game['id'].']'.$game['name']
-            ];
-        }
-        return array_values($groupedGames);
-    }
 
     /**
      * 设置部门游戏权限

+ 0 - 10
app/v1/logic/center/GameMainLogic.php

@@ -39,16 +39,6 @@ class GameMainLogic extends BaseLogic
         return $list;
     }
 
-    /**
-     * 根据主包ID获取主包名称
-     * @param int $mainId
-     * @return string
-     */
-    public function getMainGameNameById($mainId)
-    {
-        return $this->model->where('id', $mainId)->value('name');
-    }
-
     /**
      * 获取主包map
      * @return array

+ 1 - 2
app/v1/logic/center/GamePayChannelLogic.php

@@ -27,8 +27,7 @@ class GamePayChannelLogic extends BaseLogic
      */
     public function getPaySubject()
     {
-        $result = Db::connect('db_center')->name('pay_channel')->where('status', 1)->select()->toArray();
-        return $result;
+        return Db::connect('db_center')->name('pay_channel')->where('status', 1)->select()->toArray();
     }
 
 }

+ 5 - 7
app/v1/logic/customer/AccountLogic.php

@@ -78,8 +78,7 @@ class AccountLogic extends BaseLogic
     public function updatePwd($data)
     {
         $user_pwd = password_hash($data['user_pwd'], PASSWORD_DEFAULT);
-        $result = Db::connect('db_origin')->table('user_'.$data['uid']%10)->where('uid', $data['uid'])->update(['user_pwd' => $user_pwd]);
-        return $result;
+        return Db::connect('db_origin')->table('user_'.$data['uid']%10)->where('uid', $data['uid'])->update(['user_pwd' => $user_pwd]);
     }
 
     /**
@@ -87,8 +86,7 @@ class AccountLogic extends BaseLogic
      */
     public function updateMobile($data)
     {
-        $result = Db::connect('db_origin')->table('user_'.$data['uid']%10)->where('uid', $data['uid'])->update(['mobile' => $data['mobile']]);
-        return $result;
+        return Db::connect('db_origin')->table('user_'.$data['uid']%10)->where('uid', $data['uid'])->update(['mobile' => $data['mobile']]);
     }
 
     /**
@@ -96,8 +94,7 @@ class AccountLogic extends BaseLogic
      */
     public function updateReal($data)
     {
-        $result = Db::connect('db_origin')->table('user_'.$data['uid']%10)->where('uid', $data['uid'])->update(['real_name' => $data['real_name'], 'id_card' => $data['id_card']]);
-        return $result;
+        return Db::connect('db_origin')->table('user_'.$data['uid']%10)->where('uid', $data['uid'])->update(['real_name' => $data['real_name'], 'id_card' => $data['id_card']]);
     }
 
     /**
@@ -115,8 +112,9 @@ class AccountLogic extends BaseLogic
         }
         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 = Db::connect('db_game_log')->table('ban_log')->where($query)->order($orderBy, $orderType)->paginate($limit, false, ['page' => $page])->toArray();
 
 
         $data['data'] = array_map(function($item) {

+ 106 - 117
app/v1/logic/customer/ReconciliationLogic.php

@@ -7,144 +7,133 @@ use support\think\Db;
 
 class ReconciliationLogic extends BaseLogic
 {
-  // 充值渠道收入
-  public function getChannelIncome($where)
-  {
+    // 充值渠道收入
+    public function getChannelIncome($where)
+    {
 
-    $params = $this->searchByAuth($where);
+        $params = $this->searchByAuth($where);
 
-    $channelIncomeQuery = Db::connect('db_game_log')->table('sdk_order_success');
+        $channelIncomeQuery = Db::connect('db_game_log')->table('sdk_order_success');
 
-    if(!empty($params['pay_date'])){
-      $channelIncomeQuery = $channelIncomeQuery
-      ->where('pay_date', '>=', $params['pay_date'][0] . ' 00:00:00')
-      ->where('pay_date', '<=', $params['pay_date'][1] . ' 23:59:59');
-    }
+        if (!empty($params['pay_date'])) {
+            $channelIncomeQuery = $channelIncomeQuery
+                ->where('pay_date', 'between', [$params['pay_date'][0] . ' 00:00:00', $params['pay_date'][1] . ' 23:59:59']);
+        }
 
-    if(!empty($params['pay_channel_id'])){
-      $channelIncomeQuery->where('pay_channel_id', 'in', is_array($params['pay_channel_id']) ? implode(',', $params['pay_channel_id']) : $params['pay_channel_id']);
-    }
+        if (!empty($params['pay_channel_id'])) {
+            $channelIncomeQuery->where('pay_channel_id', 'in', is_array($params['pay_channel_id']) ? implode(',', $params['pay_channel_id']) : $params['pay_channel_id']);
+        }
 
-    if(!empty($params['game_id'])){
-      $channelIncomeQuery->where('game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']);
-    }
+        if (!empty($params['game_id'])) {
+            $channelIncomeQuery->where('game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']);
+        }
 
+        $channelIncomeQuery->field('game_id,pay_channel_id,sum(money) as money');
+
+
+        $channelIncomeQuery->group('pay_channel_id');
+
+        $columns = [
+            [
+                'title' => '游戏ID',
+                'dataIndex' => 'game_id',
+                'width' => 180,
+            ],
+            [
+                'title' => '游戏名称',
+                'dataIndex' => 'game_name',
+                'width' => 180,
+            ],
+            [
+                'title' => '合计',
+                'dataIndex' => 'money',
+                'width' => 180,
+            ],
+        ];
 
-    if(!empty($params['pay_date'])){
-      $channelIncomeQuery
-      ->where('pay_date', '>=', $params['pay_date'][0] . ' 00:00:00')
-      ->where('pay_date', '<=', $params['pay_date'][1] . ' 23:59:59');
-    }
+        $payChannelList = Db::connect('db_center')->table('pay_channel')
+            ->where('status', 1);
 
-    $channelIncomeQuery->field('game_id,pay_channel_id,sum(money) as money');
+        if (!empty($params['pay_channel_id'])) {
+            $payChannelList = $payChannelList->where('id', 'in', $params['pay_channel_id']);
+        }
+        $payChannelList = $payChannelList->select()->toArray();
+
+        foreach ($payChannelList as $payChannel) {
+            $title = $payChannel['name'];
+            $payChannelId = $payChannel['id'];
+            $columns[] = [
+                'title' => $title,
+                'dataIndex' => 'pay_channel_id_' . $payChannelId,
+                'width' => 180,
+            ];
+        }
 
 
-    $channelIncomeQuery->group('pay_channel_id');
+        $data = $channelIncomeQuery->select()->toArray();
 
 
+        $data = $this->trandformListColumn($data, ['game', 'pay_channel']);
 
+        foreach ($data as $key => $value) {
 
-    $columns = [
-      [
-        'title' => '游戏ID',
-        'dataIndex' => 'game_id',
-        'width' => 180,
-      ],
-      [
-        'title' => '游戏名称',
-        'dataIndex' => 'game_name',
-        'width' => 180,
-      ],
-      [
-        'title' => '合计',
-        'dataIndex' => 'money',
-        'width' => 180,
-      ],
-    ];
+            $data[$key]['pay_channel_id_' . $value['pay_channel_id']] = $value['money'];
+        }
 
-    $payChannelList = Db::connect('db_center')->table('pay_channel')
-    ->where('status',1);
+        // 按game_id分组合并数据
+        $mergedData = [];
+        foreach ($data as $item) {
+            $gameId = $item['game_id'];
+
+            if (!isset($mergedData[$gameId])) {
+                $mergedData[$gameId] = [
+                    'game_id' => $gameId,
+                    'game_name' => $item['game_name'],
+                    'money' => 0
+                ];
+
+                // 初始化所有pay_channel_id金额为0
+                foreach ($payChannelList as $channel) {
+                    $mergedData[$gameId]['pay_channel_id_' . $channel['id']] = 0;
+                }
+            }
 
-    if(!empty($params['pay_channel_id'])){
-      $payChannelList = $payChannelList->where('id', 'in', $params['pay_channel_id']);
-    }
-    $payChannelList = $payChannelList->select()->toArray();
-
-    foreach($payChannelList as $payChannel){
-      $title = $payChannel['name'];
-      $payChannelId = $payChannel['id'];
-       $columns[] = [
-          'title' => $title,
-          'dataIndex' => 'pay_channel_id_' . $payChannelId,
-          'width' => 180,
-        ];
-    }
-    
+            // 累加合计金额
+            $mergedData[$gameId]['money'] += floatval($item['money']);
 
-    $data = $channelIncomeQuery->select()->toArray();
-  
+            // 设置对应渠道金额
+            $channelKey = 'pay_channel_id_' . $item['pay_channel_id'];
+            $mergedData[$gameId][$channelKey] = $item[$channelKey];
+        }
+        // 添加合计行
+        $totalRow = [
+            'game_id' => '合计',
+            'game_name' => '',
+            'money' => 0
+        ];
 
-     $data = $this->trandformListColumn($data, ['game','pay_channel']);
-   
-    foreach($data as $key => $value){
+        // 初始化所有渠道金额为0
+        foreach ($payChannelList as $channel) {
+            $totalRow['pay_channel_id_' . $channel['id']] = 0;
+        }
 
-      $data[$key]['pay_channel_id_' . $value['pay_channel_id']] = $value['money'];
-    }
+        // 计算合计数据
+        foreach ($mergedData as $row) {
+            $totalRow['money'] += floatval($row['money']);
 
-    // 按game_id分组合并数据
-    $mergedData = [];
-    foreach($data as $item) {
-        $gameId = $item['game_id'];
-        
-        if(!isset($mergedData[$gameId])) {
-            $mergedData[$gameId] = [
-                'game_id' => $gameId,
-                'game_name' => $item['game_name'],
-                'money' => 0
-            ];
-            
-            // 初始化所有pay_channel_id金额为0
-            foreach($payChannelList as $channel) {
-                $mergedData[$gameId]['pay_channel_id_'.$channel['id']] = 0;
+            foreach ($payChannelList as $channel) {
+                $channelKey = 'pay_channel_id_' . $channel['id'];
+                $totalRow[$channelKey] += floatval($row[$channelKey]);
             }
         }
-        
-        // 累加合计金额
-        $mergedData[$gameId]['money'] += floatval($item['money']);
-        
-        // 设置对应渠道金额
-        $channelKey = 'pay_channel_id_'.$item['pay_channel_id'];
-        $mergedData[$gameId][$channelKey] = $item[$channelKey];
+
+        // 将合计行插入到数组最前面
+        array_unshift($mergedData, $totalRow);
+        // 转为数组格式
+        $data = array_values($mergedData);
+        return [
+            'columns' => $columns,
+            'data' => $data,
+        ];
     }
-      // 添加合计行
-      $totalRow = [
-          'game_id' => '合计',
-          'game_name' => '',
-          'money' => 0
-      ];
-
-      // 初始化所有渠道金额为0
-      foreach($payChannelList as $channel) {
-          $totalRow['pay_channel_id_'.$channel['id']] = 0;
-      }
-
-      // 计算合计数据
-      foreach($mergedData as $row) {
-          $totalRow['money'] += floatval($row['money']);
-          
-          foreach($payChannelList as $channel) {
-              $channelKey = 'pay_channel_id_'.$channel['id'];
-              $totalRow[$channelKey] += floatval($row[$channelKey]);
-          }
-      }
-
-      // 将合计行插入到数组最前面
-      array_unshift($mergedData, $totalRow);
-      // 转为数组格式
-      $data = array_values($mergedData);
-    return [
-      'columns' => $columns,
-      'data' => $data,
-    ];
-  }
 }

+ 19 - 36
app/v1/logic/customer/RoleDataLogic.php

@@ -36,59 +36,42 @@ class RoleDataLogic extends BaseLogic
 
         // 1. 根据game_id 查找 main_id
         $game_ids = array_unique(array_column($data, 'game_id'));
-        $main_id_arr = Db::connect('db_center')->table('pf_game')->whereIn('id', $game_ids)->column('main_id','id');
-
-
-        $data = array_map(function($item) use ($main_id_arr){
-           // 最后登录时间
-           $item['login_time'] = Db::connect('db_origin')->table('agent_reg_'.$item['uid']%10)->where('main_id', $main_id_arr[$item['game_id']])->where('uid', $item['uid'])->value('login_time');
-           $item['login_time'] = date('Y-m-d H:i:s', $item['login_time']);
-           // 支付记录
-           $pay_data = Db::connect('db_game_log')->table('sdk_order_success')->where('game_id', $item['game_id'])->where('uid', $item['uid'])->where('role_id', $item['role_id'])->order('pay_date', 'desc');
-           // 最新的一条支付记录时间
-           $item['last_recharge_time'] =  $pay_data->value('pay_date');
-           // 累计充值
-           $item['total_recharge'] = $pay_data->sum('money');
-
-           return $item;
+        $main_id_arr = Db::connect('db_center')->table('pf_game')->whereIn('id', $game_ids)->column('main_id', 'id');
+
+        $data = array_map(function ($item) use ($main_id_arr) {
+            // 最后登录时间
+            $item['login_time'] = Db::connect('db_origin')->table('agent_reg_' . $item['uid'] % 10)->where('main_id', $main_id_arr[$item['game_id']])->where('uid', $item['uid'])->value('login_time');
+            $item['login_time'] = date('Y-m-d H:i:s', $item['login_time']);
+            // 支付记录
+            $pay_data = Db::connect('db_game_log')->table('sdk_order_success')->where('game_id', $item['game_id'])->where('uid', $item['uid'])->where('role_id', $item['role_id'])->order('pay_date', 'desc');
+            // 最新的一条支付记录时间
+            $item['last_recharge_time'] = $pay_data->value('pay_date');
+            // 累计充值
+            $item['total_recharge'] = $pay_data->sum('money');
+
+            return $item;
         }, $data);
 
-
-
-
-
-
-
-
-
-
-        $data = $this->trandformListColumn($data,['game','media','site', 'agent']);
+        $data = $this->trandformListColumn($data, ['game', 'media', 'site', 'agent']);
 
         return $data;
-
     }
 
     /**
      * 更新
      */
-    public function update($id, $data)
+    public function myUpdate($id, $data): int
     {
         $platform = $data['platform'];
         $table = $platform === 'android' ? 'role_data_and' : 'role_data_ios';
-        
+
         // 移除platform字段,避免更新到数据库
         unset($data['platform']);
-        
+
         // 直接使用Db更新指定表的数据
-        $result = Db::connect('db_game_log')
+        return Db::connect('db_game_log')
             ->table($table)
             ->where('id', $id)
             ->update($data);
-            
-        if ($result === false) {
-            throw new ApiException('更新失败');
-        }
-        
-        return $result;
     }
 }

+ 47 - 51
app/v1/logic/customer/SdkOrderLogic.php

@@ -23,65 +23,48 @@ class SdkOrderLogic extends BaseLogic
         $this->model = new SdkOrder();
     }
 
-    /**
-     * 获取年月
-     */
-    public function queryOrdersByDateRange($start, $end)
-    {
-            $start = new DateTime($start);
-            $end = new DateTime($end);
-            $end->modify('first day of next month');
-
-            $months = [];
-            while ($start < $end) {
-                $months[] = $start->format('Ym'); // 例如 202505
-                $start->modify('+1 month');
-            }
-            return $months;
-    }
-
     /**
      * 获取订单列表
      */
     public function getOrderList($where)
     {
-    $startDate = $where['pay_date'][0];
-    $endDate = $where['pay_date'][1];
-    $page       = max(1, (int)($where['page'] ?? 1));
-    $limit      = max(1, (int)($where['limit'] ?? 10));
-    $offset     = ($page - 1) * $limit;
-    $orderBy =   $where['orderBy'] ? $where['orderBy'] : 'pay_date';
-    $orderType = $where['orderType'] ? $where['orderType'] : 'DESC';
-    $orderBy = $orderBy . ' ' . $orderType;
-
-       // 获取年月
+        $startDate = $where['pay_date'][0];
+        $endDate = $where['pay_date'][1];
+        $page = max(1, (int)($where['page'] ?? 1));
+        $limit = max(1, (int)($where['limit'] ?? 10));
+        $offset = ($page - 1) * $limit;
+        $orderBy = $where['orderBy'] ?: 'pay_date';
+        $orderType = $where['orderType'] ?: 'DESC';
+        $orderBy = $orderBy . ' ' . $orderType;
+
+        // 获取年月
         $table_name_array = $this->queryOrdersByDateRange($startDate, $endDate);
-       
+
         // 合并表 union all
         $where_sql = "";
-        if(!empty($where['game_id'])){
+        if (!empty($where['game_id'])) {
             $where_sql .= " AND game_id IN({$where['game_id']})";
         }
-        if(!empty($where['user_name'])){
+        if (!empty($where['user_name'])) {
             $where_sql .= " AND user_name = '{$where['user_name']}'";
         }
-        if(!empty($where['order_id'])){
+        if (!empty($where['order_id'])) {
             $where_sql .= " AND order_id = '{$where['order_id']}'";
         }
-        if(!empty($where['trade_id'])){
+        if (!empty($where['trade_id'])) {
             $where_sql .= " AND trade_id = '{$where['trade_id']}'";
         }
-        if(!empty($where['role_id'])){
+        if (!empty($where['role_id'])) {
             $where_sql .= " AND role_id = '{$where['role_id']}'";
         }
-        if(!empty($where['role_name'])){
+        if (!empty($where['role_name'])) {
             $where_sql .= " AND role_name = '{$where['role_name']}'";
         }
-        if(!empty($where['pay_date'])){
+        if (!empty($where['pay_date'])) {
             $where_sql .= " AND pay_date BETWEEN '{$startDate} 00:00:00' AND '{$endDate} 23:59:59'";
         }
         $sql_parts = [];
-        foreach($table_name_array as $table_name){
+        foreach ($table_name_array as $table_name) {
             // 安全过滤,避免 SQL 注入
             if (!preg_match('/^\d{6}$/', $table_name)) {
                 continue;
@@ -112,28 +95,42 @@ class SdkOrderLogic extends BaseLogic
                 {$unionSql}
             ) AS sum_orders
         ";
-    
+
         $count = Db::connect('db_game_log')->query($countSql)[0]['total'] ?? 0;
 
         $data = Db::connect('db_game_log')->query($finalSql);
 
-        $moneySum   = Db::connect('db_game_log')->query($sumSql)[0]['money_sum'] ?? 0;
+        $moneySum = Db::connect('db_game_log')->query($sumSql)[0]['money_sum'] ?? 0;
 
-        $data = $this->trandformListColumn($data,['game','pay_channel']);
+        $data = $this->trandformListColumn($data, ['game', 'pay_channel']);
 
 
         return [
-            'total'         => $count,
-            'current_page'  => $page,
-            'per_page'      => $limit,
-            'last_page'     => ceil($count / $limit),
-            'has_more'      => $page < ceil($count / $limit),
-            'data'          => $data,
-            'totalRow'     => $moneySum
+            'total' => $count,
+            'current_page' => $page,
+            'per_page' => $limit,
+            'last_page' => ceil($count / $limit),
+            'has_more' => $page < ceil($count / $limit),
+            'data' => $data,
+            'totalRow' => $moneySum
         ];
-   
-   
-   
+    }
+
+    /**
+     * 获取年月
+     */
+    public function queryOrdersByDateRange($start, $end)
+    {
+        $start = new DateTime($start);
+        $end = new DateTime($end);
+        $end->modify('first day of next month');
+
+        $months = [];
+        while ($start < $end) {
+            $months[] = $start->format('Ym'); // 例如 202505
+            $start->modify('+1 month');
+        }
+        return $months;
     }
 
     /**
@@ -141,7 +138,6 @@ class SdkOrderLogic extends BaseLogic
      */
     public function send($order_id)
     {
-      $res = Redis::lpush("request_cp_callback_queue", $order_id);
-      return $res;
+        return Redis::lpush("request_cp_callback_queue", $order_id);
     }
 }

Diferenças do arquivo suprimidas por serem muito extensas
+ 526 - 447
app/v1/logic/gameLog/AnalyseLogic.php


Diferenças do arquivo suprimidas por serem muito extensas
+ 414 - 251
app/v1/logic/gameLog/ChannelAnalysisLogic.php


+ 101 - 116
app/v1/logic/gameLog/MaterialLogic.php

@@ -6,126 +6,114 @@ namespace app\v1\logic\gameLog;
 
 use app\v1\logic\tool\ToolLogic;
 use plugin\saiadmin\basic\BaseLogic;
-use plugin\saiadmin\service\OpenSpoutWriter;
 use support\think\Db;
-use support\Request;
 
 class MaterialLogic extends BaseLogic
 {
 
-  public function getMaterialList($where)
-  {
-    $params = $this->searchByAuth($where);
-    $tableName = 'media_cost_material';
-    $field  = "
-      material_name,
-      material_id,
-      author_id,
-      auth_id,
-      media_id,
-      tdate,
-      SUM(money) as cost,
-      SUM(ad_show) as ad_show,
-      SUM(click) as click,
-      SUM(active) as active,
-      SUM(register) as register,
-      SUM(pay_count) as pay_count,
-      SUM(pay_amount) as pay_amount
-    ";
-
-
-    // 基础筛选
-    $whereSql = $this->generateWhereSql($params);
-    //  作者筛选
-    if(!empty($params['author_id'])){
-      $whereSql .= " AND author_id = {$params['author_id']}";
-    }
-    // 消耗筛选
-    if(!empty($params['cost_type'])){
-      switch ($params['cost_type']) {
-        case '1':
-          $whereSql .= " AND ori_money >= 2000";
-          break;
-        case '2':
-          $whereSql .= " AND ori_money < 2000";
-          break;
-      }
-    }
-    // 素材名称筛选
-    if(!empty($params['material_name'])){
-      $whereSql .= " AND material_name LIKE '%{$params['material_name']}%'";
-    }
-    // 素材id筛选
-    if(!empty($params['material_id'])){
-      $whereSql .= " AND material_id = {$params['material_id']}";
-    }
-    // 分组筛选
-    $group = 'material_id';
-    switch ($params['group']) {
-      case 1:
+    public function getMaterialList($where)
+    {
+        $params = $this->searchByAuth($where);
+        $tableName = 'media_cost_material';
+        $field = "
+          material_name,
+          material_id,
+          author_id,
+          auth_id,
+          media_id,
+          tdate,
+          SUM(money) as cost,
+          SUM(ad_show) as ad_show,
+          SUM(click) as click,
+          SUM(active) as active,
+          SUM(register) as register,
+          SUM(pay_count) as pay_count,
+          SUM(pay_amount) as pay_amount
+        ";
+
+        // 基础筛选
+        $whereSql = $this->generateWhereSql($params);
+        //  作者筛选
+        if (!empty($params['author_id'])) {
+            $whereSql .= " AND author_id = {$params['author_id']}";
+        }
+        // 消耗筛选
+        if (!empty($params['cost_type'])) {
+            switch ($params['cost_type']) {
+                case '1':
+                    $whereSql .= " AND ori_money >= 2000";
+                    break;
+                case '2':
+                    $whereSql .= " AND ori_money < 2000";
+                    break;
+            }
+        }
+        // 素材名称筛选
+        if (!empty($params['material_name'])) {
+            $whereSql .= " AND material_name LIKE '%{$params['material_name']}%'";
+        }
+        // 素材id筛选
+        if (!empty($params['material_id'])) {
+            $whereSql .= " AND material_id = {$params['material_id']}";
+        }
+        // 分组筛选
         $group = 'material_id';
-        break;
-      case 2:
-        $group = 'author_id';
-        break;
-      default:
-        $group = 'material_id,author_id';
-        break;
-    }
+        switch ($params['group']) {
+            case 1:
+                $group = 'material_id';
+                break;
+            case 2:
+                $group = 'author_id';
+                break;
+            default:
+                $group = 'material_id,author_id';
+                break;
+        }
 
+        $sql = " SELECT $field FROM $tableName WHERE 1=1 $whereSql GROUP BY $group";
+        $data = Db::connect('db_advert')->query($sql);
 
-    $sql = "
-      SELECT
-        $field
-        FROM
-        $tableName
-      WHERE 1=1
-        $whereSql
-      GROUP BY
-        $group
-      ";
-    $data = Db::connect('db_advert')->query($sql);
-            
-    $totalData = [];
-    foreach ($data as &$row) {
-
-      if($params['group'] == 2){
-        $row['material_name'] = '';
-        $row['material_id'] = '';
-      }
-
-
-      $row['cost'] = round($row['cost'],2);
-      $row['ad_click_rate'] = ToolLogic::getPercent($row['click'] ,$row['ad_show'],2);
-      $row['reg_cost'] = ToolLogic::getRound($row['cost'],$row['register'],2);
-      $row['pay_cost'] = ToolLogic::getRound($row['cost'],(int)$row['pay_count'],2);
-
-
-      $totalData['cost'] = !empty($totalData['cost']) ? round($totalData['cost'] + $row['cost'],2) : $row['cost'];
-      $totalData['ad_show'] = !empty($totalData['ad_show']) ? $totalData['ad_show'] + $row['ad_show'] : $row['ad_show'];
-      $totalData['click'] = !empty($totalData['click']) ? $totalData['click'] + $row['click'] : $row['click'];
-      $totalData['active'] = !empty($totalData['active']) ? $totalData['active'] + $row['active'] : $row['active'];
-      $totalData['register'] = !empty($totalData['register']) ? $totalData['register'] + $row['register'] : $row['register'];
-      $totalData['pay_count'] = !empty($totalData['pay_count']) ? $totalData['pay_count'] + $row['pay_count'] : $row['pay_count'];
-      $totalData['pay_amount'] = !empty($totalData['pay_amount']) ? $totalData['pay_amount'] + $row['pay_amount'] : $row['pay_amount'];
+        $totalData = [];
+        foreach ($data as &$row) {
+
+            if ($params['group'] == 2) {
+                $row['material_name'] = '';
+                $row['material_id'] = '';
+            }
 
-    }
 
-    $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);
+            $row['cost'] = round($row['cost'], 2);
+            $row['ad_click_rate'] = ToolLogic::getPercent($row['click'], $row['ad_show'], 2);
+            $row['reg_cost'] = ToolLogic::getRound($row['cost'], $row['register'], 2);
+            $row['pay_cost'] = ToolLogic::getRound($row['cost'], (int)$row['pay_count'], 2);
 
-    return [
-      'data' => $data,
-      'totalRow' => $totalData
-    ];
-  }
 
-   // 生成wheresql
-    public function generateWhereSql($params){
+            $totalData['cost'] = !empty($totalData['cost']) ? round($totalData['cost'] + $row['cost'], 2) : $row['cost'];
+            $totalData['ad_show'] = !empty($totalData['ad_show']) ? $totalData['ad_show'] + $row['ad_show'] : $row['ad_show'];
+            $totalData['click'] = !empty($totalData['click']) ? $totalData['click'] + $row['click'] : $row['click'];
+            $totalData['active'] = !empty($totalData['active']) ? $totalData['active'] + $row['active'] : $row['active'];
+            $totalData['register'] = !empty($totalData['register']) ? $totalData['register'] + $row['register'] : $row['register'];
+            $totalData['pay_count'] = !empty($totalData['pay_count']) ? $totalData['pay_count'] + $row['pay_count'] : $row['pay_count'];
+            $totalData['pay_amount'] = !empty($totalData['pay_amount']) ? $totalData['pay_amount'] + $row['pay_amount'] : $row['pay_amount'];
+
+        }
+
+        $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);
+
+        return [
+            'data' => $data,
+            'totalRow' => $totalData
+        ];
+    }
+
+    // 生成wheresql
+    public function generateWhereSql($params)
+    {
         $whereSql = "";
         // 游戏id
-        if(!empty($params['game_id'])){
+        if (!empty($params['game_id'])) {
             if (is_array($params['game_id'])) {
                 $whereSql .= " AND game_id IN(" . implode(',', $params['game_id']) . ")";
             } else {
@@ -133,15 +121,15 @@ class MaterialLogic extends BaseLogic
             }
         }
         // 媒体id
-        if(!empty($params['media_id'])){
+        if (!empty($params['media_id'])) {
             $whereSql .= " AND media_id = {$params['media_id']}";
         }
         // 渠道id
-        if(!empty($params['agent_id'])){
+        if (!empty($params['agent_id'])) {
             $whereSql .= " AND agent_id = {$params['agent_id']}";
         }
         // 广告位id
-        if(!empty($params['site_id'])){
+        if (!empty($params['site_id'])) {
             if (is_array($params['site_id'])) {
                 $whereSql .= " AND site_id IN(" . implode(',', $params['site_id']) . ")";
             } else {
@@ -149,7 +137,7 @@ class MaterialLogic extends BaseLogic
             }
         }
         // 负责人
-        if(!empty($params['auth_id'])){
+        if (!empty($params['auth_id'])) {
             if (is_array($params['auth_id'])) {
                 $whereSql .= " AND auth_id IN(" . implode(',', $params['auth_id']) . ")";
             } else {
@@ -157,17 +145,14 @@ class MaterialLogic extends BaseLogic
             }
         }
         // 注册日期
-        if(!empty($params['reg_date']) && is_array($params['reg_date'])){
+        if (!empty($params['reg_date']) && is_array($params['reg_date'])) {
             $whereSql .= " AND tdate BETWEEN '{$params['reg_date'][0]}' AND '{$params['reg_date'][1]}'";
         }
         // 注册日期,不是数组,则认为是单个日期
-        if(!empty($params['reg_date']) && !is_array($params['reg_date'])){
-          $whereSql .= " AND tdate = '{$params['reg_date']}'";
+        if (!empty($params['reg_date']) && !is_array($params['reg_date'])) {
+            $whereSql .= " AND tdate = '{$params['reg_date']}'";
         }
-        
 
         return $whereSql;
     }
-
-
 }

+ 319 - 324
app/v1/logic/gameLog/UserLogLogic.php

@@ -7,185 +7,122 @@ namespace app\v1\logic\gameLog;
 use plugin\saiadmin\basic\BaseLogic;
 use plugin\saiadmin\service\OpenSpoutWriter;
 use support\think\Db;
-use support\Request;
 
 class UserLogLogic extends BaseLogic
 {
 
-  // 注册日志
+    // 注册日志
     public function getRegLogList($where): mixed
     {
-      
-      $params = $this->searchByAuth($where);
-
-      $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);
-  
-
-      // 获取这一天的注册日志
-      $regLogQuery = Db::connect('db_game_log')
-          ->table($tableName)
-          ->where('reg_time', '>=', strtotime($regTime . ' 00:00:00'))
-          ->where('reg_time', '<=', strtotime($regTime . ' 23:59:59'));
-
-      // 添加其他查询条件
-      if (!empty($params['game_id'])) {
-          $regLogQuery = $regLogQuery->where('game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']);
-      }
-      if(!empty($params['user_name'])){
-        $regLogQuery = $regLogQuery->where('user_name', $params['user_name']);
-      }
-      if(!empty($params['media_id'])){
-        $regLogQuery = $regLogQuery->where('media_id', $params['media_id']);
-      }
-      if(!empty($params['site_id'])){
-        $regLogQuery = $regLogQuery->where('site_id', $params['site_id']);
-      }
-      if(!empty($params['agent_id'])){
-        $regLogQuery = $regLogQuery->where('agent_id', $params['agent_id']);
-      }
-      if(!empty($params['vt'])){
-        $regLogQuery = $regLogQuery->where('vt', $params['vt']);
-      }
-
-      // 执行查询并排序
-      $data = $regLogQuery->order($orderBy, $orderType)->select()->toArray();
-
-      // 分页
-     
-      $data = $regLogQuery->paginate($limit, false, ['page' => $page])->toArray();
-
-      return $data;
+        $params = $this->searchByAuth($where);
+
+        $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);
+
+
+        // 获取这一天的注册日志
+        $regLogQuery = Db::connect('db_game_log')
+            ->table($tableName)
+            ->where('reg_time', '>=', strtotime($regTime . ' 00:00:00'))
+            ->where('reg_time', '<=', strtotime($regTime . ' 23:59:59'));
+
+        // 添加其他查询条件
+        if (!empty($params['game_id'])) {
+            $regLogQuery = $regLogQuery->where('game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']);
+        }
+        if (!empty($params['user_name'])) {
+            $regLogQuery = $regLogQuery->where('user_name', $params['user_name']);
+        }
+        if (!empty($params['media_id'])) {
+            $regLogQuery = $regLogQuery->where('media_id', $params['media_id']);
+        }
+        if (!empty($params['site_id'])) {
+            $regLogQuery = $regLogQuery->where('site_id', $params['site_id']);
+        }
+        if (!empty($params['agent_id'])) {
+            $regLogQuery = $regLogQuery->where('agent_id', $params['agent_id']);
+        }
+        if (!empty($params['vt'])) {
+            $regLogQuery = $regLogQuery->where('vt', $params['vt']);
+        }
+
+        // 执行查询并排序
+        // $data = $regLogQuery->order($orderBy, $orderType)->select()->toArray();
+
+        // 分页
+        $data = $regLogQuery->paginate($limit)->toArray();
+
+        return $data;
     }
 
     // 登录日志
     public function getLoginLogList($where): mixed
     {
-    
-      $orderBy = request()->input('orderBy', 'login_time');
-      $orderType = request()->input('orderType', 'desc');
-      $page = request()->input('page', 1);
-      $limit = request()->input('limit', 10);
-
-      $params = $this->searchByAuth($where);
-      $loginTime = $params['login_time'];
-      $tableName = 'sdk_login_log_'.date('Ym',strtotime($loginTime));
-
-
-      $loginLogQuery = Db::connect('db_game_log')
-          ->table($tableName)
-          ->where('login_time', '>=', strtotime($params['login_time'] . ' 00:00:00'))
-          ->where('login_time', '<=', strtotime($params['login_time'] . ' 23:59:59'));
-
-      if(!empty($params['game_id'])){
-        $loginLogQuery = $loginLogQuery->where('game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']);
-      }
-      if(!empty($params['user_name'])){
-        $loginLogQuery = $loginLogQuery->where('user_name', $params['user_name']);
-      }
-      if(!empty($params['media_id'])){
-        $loginLogQuery = $loginLogQuery->where('media_id', $params['media_id']);
-      }
-      if(!empty($params['site_id'])){
-        $loginLogQuery = $loginLogQuery->where('site_id', $params['site_id']);
-      }
-      if(!empty($params['auth_id'])){
-        $loginLogQuery = $loginLogQuery->where('auth_id', $params['auth_id']);
-      }
-      if(!empty($params['agent_id'])){
-        $loginLogQuery = $loginLogQuery->where('agent_id', $params['agent_id']);
-      }
-      if(!empty($params['reg_time'])){
-        $loginLogQuery = $loginLogQuery
-        ->where('reg_time', '>=', strtotime($params['reg_time'] . ' 00:00:00'))
-        ->where('reg_time', '<=', strtotime($params['reg_time'] . ' 23:59:59'));
-      }
-      if(!empty($params['login_time'])){
-        $loginLogQuery = $loginLogQuery
-        ->where('login_time', '>=', strtotime($params['login_time'] . ' 00:00:00'))
-        ->where('login_time', '<=', strtotime($params['login_time'] . ' 23:59:59'));
-      }
-       // 执行查询并排序
-     
-      $loginLogQuery->order($orderBy, $orderType);
-   
-      $data = $loginLogQuery->paginate($limit, false, ['page' => $page])->toArray();
-      return $data;
-    }
+        $orderBy = request()->input('orderBy', 'login_time');
+        $orderType = request()->input('orderType', 'desc');
+        $page = request()->input('page', 1);
+        $limit = request()->input('limit', 10);
 
-    // 充值明细
-    public function getRechargeDetailList($where,$type="list"): mixed
-    {
-      $orderBy = request()->input('orderBy', 'pay_date');
-      $orderType = request()->input('orderType', 'desc');
-      $page = request()->input('page', 1);
-      $limit = request()->input('limit', 10);
-
-      $params = $this->searchByAuth($where);
-   
-      $tableName = 'sdk_order_success';
-
-      $rechargeDetailQuery = Db::connect('db_game_log')
-          ->table($tableName)
-          ->where('pay_date', '>=', $params['pay_date'][0] . ' 00:00:00')
-          ->where('pay_date', '<=', $params['pay_date'][1] . ' 23:59:59');
-
-
-      if(!empty($params['game_id'])){
-        $rechargeDetailQuery = $rechargeDetailQuery->where('game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']);
-      }
-      if(!empty($params['user_name'])){
-        $rechargeDetailQuery = $rechargeDetailQuery->where('user_name', $params['user_name']);
-      }
-      if(!empty($params['media_id'])){
-        $rechargeDetailQuery = $rechargeDetailQuery->where('media_id', $params['media_id']);
-      }
-      if(!empty($params['auth_id'])){
-        $rechargeDetailQuery = $rechargeDetailQuery->where('auth_id', $params['auth_id']);
-      }
-      if(!empty($params['agent_id'])){
-        $rechargeDetailQuery = $rechargeDetailQuery->where('agent_id', $params['agent_id']);
-      }
-      if(!empty($params['site_id'])){
-        $rechargeDetailQuery = $rechargeDetailQuery->where('site_id', $params['site_id']);
-      }
-      if(!empty($params['server_id'])){
-        $rechargeDetailQuery = $rechargeDetailQuery->where('server_id', $params['server_id']);
-      }
-      if(!empty($params['server_name'])){
-        $rechargeDetailQuery = $rechargeDetailQuery->where('server_name', $params['server_name']);
-      }
-      if(!empty($params['reg_date'])){
-        $rechargeDetailQuery = $rechargeDetailQuery
-        ->where('reg_date', '>=', $params['reg_date'][0] . ' 00:00:00')
-        ->where('reg_date', '<=', $params['reg_date'][1] . ' 23:59:59');
-      }
-
-      $rechargeDetailQuery->order($orderBy, $orderType);
-
-      if($type == 'all'){
-        $data = $rechargeDetailQuery->select()->toArray();
-      }else{
-        $data = $rechargeDetailQuery->paginate($limit, false, ['page' => $page])->toArray();
-      }
-      
-      return $data;
+        $params = $this->searchByAuth($where);
+        $loginTime = $params['login_time'];
+        $tableName = 'sdk_login_log_' . date('Ym', strtotime($loginTime));
+
+
+        $loginLogQuery = Db::connect('db_game_log')
+            ->table($tableName)
+            ->where('login_time', '>=', strtotime($params['login_time'] . ' 00:00:00'))
+            ->where('login_time', '<=', strtotime($params['login_time'] . ' 23:59:59'));
+
+        if (!empty($params['game_id'])) {
+            $loginLogQuery = $loginLogQuery->where('game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']);
+        }
+        if (!empty($params['user_name'])) {
+            $loginLogQuery = $loginLogQuery->where('user_name', $params['user_name']);
+        }
+        if (!empty($params['media_id'])) {
+            $loginLogQuery = $loginLogQuery->where('media_id', $params['media_id']);
+        }
+        if (!empty($params['site_id'])) {
+            $loginLogQuery = $loginLogQuery->where('site_id', $params['site_id']);
+        }
+        if (!empty($params['auth_id'])) {
+            $loginLogQuery = $loginLogQuery->where('auth_id', $params['auth_id']);
+        }
+        if (!empty($params['agent_id'])) {
+            $loginLogQuery = $loginLogQuery->where('agent_id', $params['agent_id']);
+        }
+        if (!empty($params['reg_time'])) {
+            $loginLogQuery = $loginLogQuery
+                ->where('reg_time', '>=', strtotime($params['reg_time'] . ' 00:00:00'))
+                ->where('reg_time', '<=', strtotime($params['reg_time'] . ' 23:59:59'));
+        }
+        if (!empty($params['login_time'])) {
+            $loginLogQuery = $loginLogQuery
+                ->where('login_time', '>=', strtotime($params['login_time'] . ' 00:00:00'))
+                ->where('login_time', '<=', strtotime($params['login_time'] . ' 23:59:59'));
+        }
+
+        // 执行查询并排序
+        $loginLogQuery->order($orderBy, $orderType);
+
+        $data = $loginLogQuery->paginate($limit)->toArray();
+        return $data;
     }
 
-    // 充值明细导出
+    // 充值明细
     public function exportRechargeDetailList($where): mixed
     {
         $data = $this->getRechargeDetailList($where, 'all');
 
         print_r($data);
-       
-        $data = $this->trandformListColumn($data, ['game', 'ip', 'agent','auth', 'pay_channel']);
-        $data = array_map(function($item){
+
+        $data = $this->trandformListColumn($data, ['game', 'ip', 'agent', 'auth', 'pay_channel']);
+        $data = array_map(function ($item) {
             return [
                 'order_id' => $item['order_id'],
                 'user_name' => $item['user_name'],
@@ -198,13 +135,12 @@ class UserLogLogic extends BaseLogic
                 'money' => $item['money'],
                 'pay_date' => $item['pay_date'],
                 'reg_date' => $item['reg_date'],
-                
                 'first_payment' => $item['first_payment'],
                 'agent_name' => $item['agent_name'],
                 'auth_name' => $item['auth_name'],
             ];
         }, $data);
-      
+
         // 是否首次付费
         $filter = [
             'first_payment' => [
@@ -212,9 +148,9 @@ class UserLogLogic extends BaseLogic
                 ['value' => 0, 'label' => '否']
             ]
         ];
-        $file_name = '充值明细_'.date('YmdHis').'.xlsx';
-        $header = ['订单号', '用户名', '渠道ID', '广告位ID', '游戏名', '服务器ID', '服务器名', '支付方式', '充值金额', '充值时间', '注册时间', '是否首次付费',  '渠道名', '负责人'];
-       
+        $file_name = '充值明细_' . date('YmdHis') . '.xlsx';
+        $header = ['订单号', '用户名', '渠道ID', '广告位ID', '游戏名', '服务器ID', '服务器名', '支付方式', '充值金额', '充值时间', '注册时间', '是否首次付费', '渠道名', '负责人'];
+
         $writer = new OpenSpoutWriter($file_name);
         $writer->setWidth([15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]);
         $writer->setHeader($header);
@@ -224,55 +160,116 @@ class UserLogLogic extends BaseLogic
         return response()->download($file_path, urlencode($file_name));
     }
 
+    // 充值明细导出
+
+    public function getRechargeDetailList($where, $type = "list"): mixed
+    {
+        $orderBy = request()->input('orderBy', 'pay_date');
+        $orderType = request()->input('orderType', 'desc');
+        $page = request()->input('page', 1);
+        $limit = request()->input('limit', 10);
+
+        $params = $this->searchByAuth($where);
+
+        $tableName = 'sdk_order_success';
+
+        $rechargeDetailQuery = Db::connect('db_game_log')
+            ->table($tableName)
+            ->where('pay_date', '>=', $params['pay_date'][0] . ' 00:00:00')
+            ->where('pay_date', '<=', $params['pay_date'][1] . ' 23:59:59');
+
+
+        if (!empty($params['game_id'])) {
+            $rechargeDetailQuery = $rechargeDetailQuery->where('game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']);
+        }
+        if (!empty($params['user_name'])) {
+            $rechargeDetailQuery = $rechargeDetailQuery->where('user_name', $params['user_name']);
+        }
+        if (!empty($params['media_id'])) {
+            $rechargeDetailQuery = $rechargeDetailQuery->where('media_id', $params['media_id']);
+        }
+        if (!empty($params['auth_id'])) {
+            $rechargeDetailQuery = $rechargeDetailQuery->where('auth_id', $params['auth_id']);
+        }
+        if (!empty($params['agent_id'])) {
+            $rechargeDetailQuery = $rechargeDetailQuery->where('agent_id', $params['agent_id']);
+        }
+        if (!empty($params['site_id'])) {
+            $rechargeDetailQuery = $rechargeDetailQuery->where('site_id', $params['site_id']);
+        }
+        if (!empty($params['server_id'])) {
+            $rechargeDetailQuery = $rechargeDetailQuery->where('server_id', $params['server_id']);
+        }
+        if (!empty($params['server_name'])) {
+            $rechargeDetailQuery = $rechargeDetailQuery->where('server_name', $params['server_name']);
+        }
+        if (!empty($params['reg_date'])) {
+            $rechargeDetailQuery = $rechargeDetailQuery
+                ->where('reg_date', '>=', $params['reg_date'][0] . ' 00:00:00')
+                ->where('reg_date', '<=', $params['reg_date'][1] . ' 23:59:59');
+        }
+
+        $rechargeDetailQuery->order($orderBy, $orderType);
+
+        if ($type == 'all') {
+            $data = $rechargeDetailQuery->select()->toArray();
+        } else {
+            $data = $rechargeDetailQuery->paginate($limit)->toArray();
+        }
+
+        return $data;
+    }
+
     // 充值排行
+
     public function getRechargeRankList($where): mixed
     {
-      $orderBy = request()->input('orderBy', 'searchTotalMoney');
-      $orderType = request()->input('orderType', 'desc');
-      $page = request()->input('page', 1);
-      $limit = request()->input('limit', 10);
-
-      $params = $this->searchByAuth($where);
-
-      $tableName = 'sdk_order_success';
-
-      $rechargeRankQuery = Db::connect('db_game_log')
-          ->table($tableName)
-          ->where('pay_date', '>=', $params['pay_date'][0] . ' 00:00:00')
-          ->where('pay_date', '<=', $params['pay_date'][1] . ' 23:59:59');
-
-      if(!empty($params['game_id'])){
-        $rechargeRankQuery = $rechargeRankQuery->where('game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']);
-      }
-      if(!empty($params['user_name'])){
-        $rechargeRankQuery = $rechargeRankQuery->where('user_name', $params['user_name']);
-      }
-      if(!empty($params['media_id'])){
-        $rechargeRankQuery = $rechargeRankQuery->where('media_id', $params['media_id']);
-      }
-      if(!empty($params['auth_id'])){
-        $rechargeRankQuery = $rechargeRankQuery->where('auth_id', $params['auth_id']);
-      }
-      if(!empty($params['agent_id'])){
-        $rechargeRankQuery = $rechargeRankQuery->where('agent_id', $params['agent_id']);
-      }
-      if(!empty($params['site_id'])){
-        $rechargeRankQuery = $rechargeRankQuery->where('site_id', $params['site_id']);
-      }
-      if(!empty($params['server_id'])){
-        $rechargeRankQuery = $rechargeRankQuery->where('server_id', $params['server_id']);
-      }
-      if(!empty($params['server_name'])){
-        $rechargeRankQuery = $rechargeRankQuery->where('server_name', $params['server_name']);
-      }
-      if(!empty($params['reg_date'])){
-        $rechargeRankQuery = $rechargeRankQuery
-        ->where('reg_date', '>=', $params['reg_date'][0] . ' 00:00:00')
-        ->where('reg_date', '<=', $params['reg_date'][1] . ' 23:59:59');
-      }
-
-      // 先选择字段,包括计算字段
-      $rechargeRankQuery->field('user_name,sum(money) as searchTotalMoney,
+        $orderBy = request()->input('orderBy', 'searchTotalMoney');
+        $orderType = request()->input('orderType', 'desc');
+        $page = request()->input('page', 1);
+        $limit = request()->input('limit', 10);
+
+        $params = $this->searchByAuth($where);
+
+        $tableName = 'sdk_order_success';
+
+        $rechargeRankQuery = Db::connect('db_game_log')
+            ->table($tableName)
+            ->where('pay_date', '>=', $params['pay_date'][0] . ' 00:00:00')
+            ->where('pay_date', '<=', $params['pay_date'][1] . ' 23:59:59');
+
+        if (!empty($params['game_id'])) {
+            $rechargeRankQuery = $rechargeRankQuery->where('game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']);
+        }
+        if (!empty($params['user_name'])) {
+            $rechargeRankQuery = $rechargeRankQuery->where('user_name', $params['user_name']);
+        }
+        if (!empty($params['media_id'])) {
+            $rechargeRankQuery = $rechargeRankQuery->where('media_id', $params['media_id']);
+        }
+        if (!empty($params['auth_id'])) {
+            $rechargeRankQuery = $rechargeRankQuery->where('auth_id', $params['auth_id']);
+        }
+        if (!empty($params['agent_id'])) {
+            $rechargeRankQuery = $rechargeRankQuery->where('agent_id', $params['agent_id']);
+        }
+        if (!empty($params['site_id'])) {
+            $rechargeRankQuery = $rechargeRankQuery->where('site_id', $params['site_id']);
+        }
+        if (!empty($params['server_id'])) {
+            $rechargeRankQuery = $rechargeRankQuery->where('server_id', $params['server_id']);
+        }
+        if (!empty($params['server_name'])) {
+            $rechargeRankQuery = $rechargeRankQuery->where('server_name', $params['server_name']);
+        }
+        if (!empty($params['reg_date'])) {
+            $rechargeRankQuery = $rechargeRankQuery
+                ->where('reg_date', '>=', $params['reg_date'][0] . ' 00:00:00')
+                ->where('reg_date', '<=', $params['reg_date'][1] . ' 23:59:59');
+        }
+
+        // 先选择字段,包括计算字段
+        $rechargeRankQuery->field('user_name,sum(money) as searchTotalMoney,
             order_id,
             game_id,
             media_id,
@@ -288,91 +285,91 @@ class UserLogLogic extends BaseLogic
             role_name,
             role_id');
 
-      $rechargeRankQuery->group('uid, game_id,site_id,server_id,media_id,auth_id,agent_id,server_id,auth_id,role_id');
+        $rechargeRankQuery->group('uid, game_id,site_id,server_id,media_id,auth_id,agent_id,server_id,auth_id,role_id');
 
-      $rechargeRankQuery->order($orderBy, $orderType);
+        $rechargeRankQuery->order($orderBy, $orderType);
 
 
-      $data = $rechargeRankQuery->paginate($limit, false, ['page' => $page])->toArray();
+        $data = $rechargeRankQuery->paginate($limit)->toArray();
 
 
-      $data['data'] = $this->trandformListColumn($data['data'], ['game','auth', 'agent', 'pay_channel']);
+        $data['data'] = $this->trandformListColumn($data['data'], ['game', 'auth', 'agent', 'pay_channel']);
 
 
-       // // 告警提示,查询最近登录时间,查询最近充值时间,和现在时间对比,如果超过3天,则告警,并提示
+        // // 告警提示,查询最近登录时间,查询最近充值时间,和现在时间对比,如果超过3天,则告警,并提示
 
-      foreach($data['data'] as &$item){
-          // 最后登录时间
-          $item['login_time'] = Db::connect('db_origin')->table('user_'.$item['uid']%10)->where('uid', $item['uid'])->value('login_time');
-          // 最近注册时间
-          $item['pay_time'] = Db::connect('db_origin')->table('user_'.$item['uid']%10)->where('uid', $item['uid'])->value('pay_time');
-          // 现在时间
-          $item['now_time'] = time();
+        foreach ($data['data'] as &$item) {
+            // 最后登录时间
+            $item['login_time'] = Db::connect('db_origin')->table('user_' . $item['uid'] % 10)->where('uid', $item['uid'])->value('login_time');
+            // 最近注册时间
+            $item['pay_time'] = Db::connect('db_origin')->table('user_' . $item['uid'] % 10)->where('uid', $item['uid'])->value('pay_time');
+            // 现在时间
+            $item['now_time'] = time();
 
-          // 最近登录时间与现在时间对比,如果超过3天,则告警,并提示
-          if($item['login_time'] < $item['now_time'] - 3 * 24 * 60 * 60){
-          $item['login_alert'] = 1;
-          }else{
-          $item['login_alert'] = 0;
-          }
-          // 最近充值时间与现在时间对比,如果超过3天,则告警,并提示
-          if($item['pay_time'] < $item['now_time'] - 3 * 24 * 60 * 60){
-          $item['pay_alert'] = 1;
-          }else{
-          $item['pay_alert'] = 0;
-          }
-      }
+            // 最近登录时间与现在时间对比,如果超过3天,则告警,并提示
+            if ($item['login_time'] < $item['now_time'] - 3 * 24 * 60 * 60) {
+                $item['login_alert'] = 1;
+            } else {
+                $item['login_alert'] = 0;
+            }
+            // 最近充值时间与现在时间对比,如果超过3天,则告警,并提示
+            if ($item['pay_time'] < $item['now_time'] - 3 * 24 * 60 * 60) {
+                $item['pay_alert'] = 1;
+            } else {
+                $item['pay_alert'] = 0;
+            }
+        }
 
 
-      $totalWhere = [];
-      if(!empty($params['game_id'])){
+        $totalWhere = [];
+        if (!empty($params['game_id'])) {
             $totalWhere[] = ['game_id', 'in', is_array($params['game_id']) ? implode(',', $params['game_id']) : $params['game_id']];
-       }
-       if(!empty($where['auth_id'])){
+        }
+        if (!empty($where['auth_id'])) {
             $totalWhere[] = ['auth_id', 'in', is_array($params['auth_id']) ? implode(',', $params['auth_id']) : $params['auth_id']];
-       }
-       if(!empty($where['agent_id'])){
+        }
+        if (!empty($where['agent_id'])) {
             $totalWhere['agent_id'] = $params['agent_id'];
-       }
-       if(!empty($where['site_id'])){
+        }
+        if (!empty($where['site_id'])) {
             $totalWhere['site_id'] = $params['site_id'];
-       }
-       if(!empty($where['server_id'])){
+        }
+        if (!empty($where['server_id'])) {
             $totalWhere['server_id'] = $params['server_id'];
-       }
-       if(!empty($where['user_name'])){
+        }
+        if (!empty($where['user_name'])) {
             $totalWhere['user_name'] = $params['user_name'];
-       }
-       if(!empty($where['server_name'])){
+        }
+        if (!empty($where['server_name'])) {
             $totalWhere['server_name'] = $params['server_name'];
-       }
-       if(!empty($where['reg_date'])){
+        }
+        if (!empty($where['reg_date'])) {
             $totalWhere['reg_date'] = $params['reg_date'];
-       }
-
-      $totalList = Db::connect('db_game_log')->table('sdk_order_success')
-                  ->where($totalWhere)
-                  ->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)) {
-          foreach ($totalList as $totalItem) {
-              $key = $totalItem['uid'] . '_' . $totalItem['game_id'];
-              $totalMoneyMap[$key] = $totalItem['totalMoney'] ?? 0;
-          }
-      }
-      
-      // 为搜索结果添加累计充值金额
-      foreach($data['data'] as &$item){
-          $key = $item['uid'] . '_' . $item['game_id'];
-          $item['totalMoney'] = $totalMoneyMap[$key] ?? 0;
-      }
-
-      return $data;
+        }
+
+        $totalList = Db::connect('db_game_log')->table('sdk_order_success')
+            ->where($totalWhere)
+            ->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)) {
+            foreach ($totalList as $totalItem) {
+                $key = $totalItem['uid'] . '_' . $totalItem['game_id'];
+                $totalMoneyMap[$key] = $totalItem['totalMoney'] ?? 0;
+            }
+        }
+
+        // 为搜索结果添加累计充值金额
+        foreach ($data['data'] as &$item) {
+            $key = $item['uid'] . '_' . $item['game_id'];
+            $item['totalMoney'] = $totalMoneyMap[$key] ?? 0;
+        }
+
+        return $data;
     }
 
     // 角色数据
@@ -380,63 +377,61 @@ 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);
+        $orderBy = request()->input('orderBy', 'reg_time');
+        $orderType = request()->input('orderType', 'desc');
+        $page = request()->input('page', 1);
+        $limit = request()->input('limit', 10);
+
+        $params = $this->searchByAuth($where);
+        $regTime = $params['reg_time'];
+
 
-      $params = $this->searchByAuth($where);
-      $regTime = $params['reg_time'];
+        $egTableName = 'sdk_reg_log_' . date('Ym', strtotime($regTime));
 
 
-      $egTableName = 'sdk_reg_log_' . date('Ym', strtotime($regTime));
+        $userData = Db::connect('db_game_log')->table($egTableName)->where('reg_time', '>=', strtotime($regTime . ' 00:00:00'))->where('reg_time', '<=', strtotime($regTime . ' 23:59:59'))->select()->toArray();
 
+        $where_sql = "";
+        if (!empty($params['game_id'])) {
+            $where_sql .= is_array($params['game_id']) ? " AND game_id in (" . implode(',', $params['game_id']) . ")" : " AND game_id = {$params['game_id']}";
+        }
 
-      $userData = Db::connect('db_game_log')->table($egTableName)->where('reg_time', '>=', strtotime($regTime . ' 00:00:00'))->where('reg_time', '<=', strtotime($regTime . ' 23:59:59'))->select()->toArray();
+        if (!empty($params['media_id'])) {
+            $where_sql .= " AND media_id = {$params['media_id']}";
+        }
 
-      $where_sql = "";
-      if(!empty($params['game_id'])){
-          $where_sql .= is_array($params['game_id']) ? " AND game_id in (".implode(',', $params['game_id']).")" : " AND game_id = {$params['game_id']}";
-      }
+        if (!empty($params['site_id'])) {
+            $where_sql .= " AND site_id = {$params['site_id']}";
+        }
 
-      if(!empty($params['media_id'])){
-          $where_sql .= " AND media_id = {$params['media_id']}";
-      }
+        if (!empty($params['auth_id'])) {
+            $where_sql .= " AND auth_id = {$params['auth_id']}";
+        }
 
-      if(!empty($params['site_id'])){
-          $where_sql .= " AND site_id = {$params['site_id']}";
-      }
+        if (!empty($params['user_name'])) {
+            $where_sql .= " AND user_name = {$params['user_name']}";
+        }
 
-      if(!empty($params['auth_id'])){
-          $where_sql .= " AND auth_id = {$params['auth_id']}";
-      }
 
-      if(!empty($params['user_name'])){
-          $where_sql .= " AND user_name = {$params['user_name']}";
-      }
+        $uids = array_column($userData, 'uid');
 
 
+        if (empty($userData)) {
+            return [];
+        }
 
-      $uids = array_column($userData, 'uid');
+        $where_sql = " AND uid in (" . implode(',', $uids) . ") {$where_sql}";
 
-  
-      if(empty($userData)){
-          return [];
-      }
-      
-      $where_sql = " AND uid in (".implode(',', $uids).") {$where_sql}";
-      
 
-      $sql_parts = [];
-      $sql_parts[] = "SELECT * FROM role_data_and WHERE 1=1 {$where_sql}";
-      $sql_parts[] = "SELECT * FROM role_data_ios WHERE 1=1 {$where_sql}";
+        $sql_parts = [];
+        $sql_parts[] = "SELECT * FROM role_data_and WHERE 1=1 {$where_sql}";
+        $sql_parts[] = "SELECT * FROM role_data_ios WHERE 1=1 {$where_sql}";
 
 
+        $unionSql = implode(" UNION ALL ", $sql_parts);
 
-      $unionSql = implode(" UNION ALL ", $sql_parts);
+        // 分页
 
-      // 分页
-       
         $offset = ($page - 1) * $limit;
         $unionSql .= " LIMIT {$offset}, {$limit}";
         $roleData = Db::connect('db_game_log')->query($unionSql);
@@ -445,13 +440,13 @@ class UserLogLogic extends BaseLogic
         $mergedData = [];
         foreach ($roleData as $item) {
             $uid = $item['uid'];
-            
+
             if (!isset($mergedData[$uid])) {
                 // 创建用户基础信息,排除角色相关字段
                 $baseInfo = array_diff_key($item, array_flip(['role_id', 'role_name', 'role_level']));
                 $mergedData[$uid] = $baseInfo + ['roles' => []];
             }
-            
+
             // 添加角色信息到数组
             $mergedData[$uid]['roles'][] = [
                 'server_name' => $item['server_name'],
@@ -459,19 +454,19 @@ class UserLogLogic extends BaseLogic
                 'role_level' => $item['role_level'],
             ];
         }
-        
+
         // 转换回数组格式
         $roleData = array_values($mergedData);
         $roleData = $this->trandformListColumn($roleData, ['game', 'ip', 'auth', 'agent']);
         $count = count($roleData);
 
         return [
-            'data'          => $roleData,
-            'current_page'  => $page,
-            'per_page'      => $limit,
-            'last_page'     => ceil($count / $limit),
-            'has_more'      => $page < ceil($count / $limit),
-            'total'         =>  $count
+            'data' => $roleData,
+            'current_page' => $page,
+            'per_page' => $limit,
+            'last_page' => ceil($count / $limit),
+            'has_more' => $page < ceil($count / $limit),
+            'total' => $count
         ];
 
     }

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff