aiden 2 mesiacov pred
rodič
commit
f45800d6a3

+ 0 - 9
app/common/CommonUtils.php

@@ -35,15 +35,6 @@ class CommonUtils
 
     // 转换 分数 * 10000 or / 10000
     public static function convertBalance($balance = 0, $isTenThousandfold = true) {
-        // $balance = (float)$balance;
-        // // 分数小数点 * 10000;
-        // // $GLOBALS['balanceTenThousandfold'] = 10000;
-        // $balanceTenThousandfold = 10000;
-        // if ($isTenThousandfold) {
-        //     $balance = bcmul($balance, $balanceTenThousandfold);
-        // } else {
-        //     $balance = bcdiv($balance, $balanceTenThousandfold, 4);
-        // }
         return (float)$balance;
     }
 

+ 6 - 6
app/controller/GameStatis.php

@@ -68,7 +68,7 @@ class GameStatis extends BaseController
                 $item['bet_amount'] = CommonUtils::convertBalance($item['bet_amount'], false);
                 $item['commission_amount'] = CommonUtils::convertBalance($item['game_profit'] * 0.08, false);
                 $item['platform_fee'] = CommonUtils::convertBalance($item['bet_amount'] * 0.08, false);
-                $item['buy_free_bet'] = $item['buy_free_bet_count'] ?? 0;
+                $item['buy_free_bet'] = intval($item['buy_free_bet_count'] ?? 0);
             }
             
             return json_success($result, '获取成功');
@@ -132,7 +132,7 @@ class GameStatis extends BaseController
                     $item['rtp'] = $gameInfo['rtp'] ?? '';
 
                     // 计算游戏RTP
-                    $item['game_rtp'] = $item['total_bet'] > 0 ? bcdiv($item['total_score'], $item['total_bet'], 4) * 100 : 0;                    
+                    $item['game_rtp'] = calculateRTP($item['total_score'], $item['total_bet']);                    
                     
                     // 格式化数据
                     $item['game_id'] = (int) $item['game_id'];
@@ -144,7 +144,7 @@ class GameStatis extends BaseController
                     // 计算历史游戏RTP
                     if (isset($result['history'][$game_id])) {
                         $history = $result['history'][$game_id];
-                        $item['history_rtp'] = (float) bcdiv($history['total_score'], $history['total_bet'], 4) * 100;
+                        $item['history_rtp'] = calculateRTP($history['total_score'], $history['total_bet']);
                     } else {
                         $item['history_rtp'] = 0;
                     }
@@ -168,6 +168,7 @@ class GameStatis extends BaseController
             ], '获取成功');
             
         } catch (\Exception $e) {
+            echo $e->getTraceAsString();
             return json_error([], '获取游戏汇总数据失败:' . $e->getMessage());
         }
     }
@@ -226,9 +227,8 @@ class GameStatis extends BaseController
                     $item['game_platform'] = CommonUtils::getGameTypeConfig($gameInfo['game_platform']);
                     
                     // 游戏RTP
-                    $item['game_rtp'] = bcmul(bcdiv($item['total_score'], $item['total_bet'], 4), "100", 2);
-
-                     $item['bet'] = CommonUtils::convertBalance($item['bet'], false);
+                    $item['game_rtp'] = calculateRTP($item['total_score'], $item['total_bet']);
+                    $item['bet'] = CommonUtils::convertBalance($item['bet'], false);
                     $item['total_bet_rate'] = bcmul(bcdiv($item['total_bet'], $result['total_stats']['total_bet_all'], 4), "100", 2);
                     $item['total_bet'] = CommonUtils::convertBalance($item['total_bet'], false);
                     $item['bet_count_rate'] = bcmul(bcdiv((string)$item['bet_count'], (string)$result['total_stats']['total_count_all'], 4), "100", 2);

+ 9 - 9
app/controller/RankList.php

@@ -37,9 +37,9 @@ class RankList extends BaseController
             foreach ($result['list'] as &$item) {
                 $item['general_merchant'] = '';
                 $item['channel'] = '';                
-                $item['total_win'] = CommonUtils::convertBalance($item['total_win'], false);
-                $item['total_bet'] = CommonUtils::convertBalance($item['total_bet'], false);
-                $item['balance'] = CommonUtils::convertBalance($item['balance'], false);
+                $item['total_win'] = (float)$item['total_win'];
+                $item['total_bet'] = (float)$item['total_bet'];
+                $item['balance'] = (float)$item['balance'];
             }
             
             return json_success($result, '获取成功');
@@ -72,9 +72,9 @@ class RankList extends BaseController
             foreach ($result['list'] as &$item) {
                 $item['general_merchant'] = '';
                 $item['channel'] = '';
-                $item['total_lose'] = CommonUtils::convertBalance($item['total_lose'], false);
-                $item['total_bet'] = CommonUtils::convertBalance($item['total_bet'], false);
-                $item['balance'] = CommonUtils::convertBalance($item['balance'], false);
+                $item['total_lose'] = (float)$item['total_lose'];
+                $item['total_bet'] = (float)$item['total_bet'];
+                $item['balance'] = (float)$item['balance'];
             }
             
             return json_success($result, '获取成功');
@@ -107,9 +107,9 @@ class RankList extends BaseController
             foreach ($result['list'] as &$item) {
                 $item['general_merchant'] = '';
                 $item['channel'] = '';                
-                $item['total_win'] = CommonUtils::convertBalance($item['total_win'], false);
-                $item['total_bet'] = CommonUtils::convertBalance($item['total_bet'], false);
-                $item['balance'] = CommonUtils::convertBalance($item['balance'], false);
+                $item['total_win'] = (float)$item['total_win'];
+                $item['total_bet'] = (float)$item['total_bet'];
+                $item['balance'] = (float)$item['balance'];
             }
             
             return json_success($result, '获取成功');

+ 3 - 5
app/model/GameBetGameModel.php

@@ -118,8 +118,6 @@ class GameBetGameModel extends Model
         ->having('total_win > 0')
         ->buildSql();
         
-        // echo $subQuery;
-
         // 获取总数
         $total = self::table($subQuery . ' t')->count();
 
@@ -148,7 +146,7 @@ class GameBetGameModel extends Model
                 $item['nickname'] = $users[$userId]['nickname'] ?? '未知用户';
                 $item['balance'] = $userBanlance[$userId]['balance'] ?? 0;
                 // 计算RTP (返还率)
-                $item['rtp'] = $item['total_bet'] > 0 ? round($item['total_win'] / $item['total_bet'] * 100, 2) : 0;
+                $item['rtp'] = calculateRTP(abs($item['total_win']), $item['total_bet']);
             }
         }
         
@@ -219,7 +217,7 @@ class GameBetGameModel extends Model
                 $item['nickname'] = $users[$userId]['nickname'] ?? '未知用户';
                 $item['balance'] = $userBanlance[$userId]['balance'] ?? 0;
                 // 计算RTP (返还率)
-                $item['rtp'] = $item['total_bet'] > 0 ? round(abs((int)$item['total_lose']) / $item['total_bet'] * 100, 2) : 0;
+                $item['rtp'] = calculateRTP(abs($item['total_lose']), $item['total_bet']);
             }
         }
         
@@ -288,7 +286,7 @@ class GameBetGameModel extends Model
                 $item['nickname'] = $users[$userId]['nickname'] ?? '未知用户';
                 $item['balance'] = $userBanlance[$userId]['balance'] ?? 0;
                 // 计算RTP (返还率)
-                $item['rtp'] = $item['total_bet'] > 0 ? round(abs((int)$item['total_win']) / $item['total_bet'] * 100, 2) : 0;
+                $item['rtp'] = calculateRTP(abs($item['total_win']), $item['total_bet']);
             }
         }
         

+ 9 - 13
app/model/GameStatisModel.php

@@ -46,11 +46,11 @@ class GameStatisModel extends Model
         $subQuery = self::field([
                 "FROM_UNIXTIME(create_time, '%Y-%m-%d') as date", // 日期
                 'game_id',  //游戏id
-                'AVG(rtp) AS rtp', // 平均RTP
                 'COUNT(DISTINCT uname) as bet_users',  // 投注用户数
                 'COUNT(id) as bet_count',  // 注单数
                 'SUM(bet) as bet_amount',  // 注单金额(下注分数)
                 'SUM(total_win_amount) as game_profit',  // 游戏输赢(金额变化)
+                'SUM(winning_score) as total_winning_score', // 总赢金额
         ])
         ->where($where)
         ->group('date, game_id')
@@ -71,6 +71,7 @@ class GameStatisModel extends Model
         
         foreach ($list as &$row)
         {
+            $row['rtp'] = calculateRTP($row['total_winning_score'], $row['bet_amount']);
             $row['login_users'] = $merchantsUserStatic[$row['date']]['login_users'] ?? 0;
             $row['register_users'] = $merchantsUserStatic[$row['date']]['register_users'] ?? 0;
         }
@@ -147,19 +148,14 @@ class GameStatisModel extends Model
         ->toArray();
 
         // 获取统计数据
-        $summaryData = self::table('tp_game_rtp_win_bet')
-        ->where([
-            ['app_id', '=', $merchantId],
-        ])
-        ->field([
-            'SUM(bet_amount) as total_bet',
-            'SUM(bet_count) as total_bet_count',
-            'SUM(total_win_amount) as total_win',
-            'SUM(winning_score) as total_score',
-            'COUNT(DISTINCT user_id) as total_user_count'
+        $summaryData = self::field([
+            'COUNT(*) as total_bet_count', // 注单数
+            'COUNT(DISTINCT user_id) as total_user_count', // 投注用户数
+            'SUM(bet) as total_bet', // 总投注
+            'SUM(total_win_amount) as total_win', // 总输赢
+            'SUM(winning_score) as total_score', // 总赢奖
         ])
-        ->find()
-        ->toArray();
+        ->where($where)->find()->toArray();
                     
         return [
             'list' => $list,

+ 5 - 5
app/model/TransferLogModel.php

@@ -35,12 +35,12 @@ class TransferLogModel extends Model
         
         // 时间筛选
         if (!empty($filters['start_time'])) {
-            $startTime = strtotime($filters['start_time'] . ' 00:00:00');
+            $startTime = strtotime($filters['start_time']);
             $where[] = ['create_time', '>=', $startTime];
         }
         
         if (!empty($filters['end_time'])) {
-            $endTime = strtotime($filters['end_time'] . ' 23:59:59');
+            $endTime = strtotime($filters['end_time']);
             $where[] = ['create_time', '<=', $endTime];
         }
         
@@ -99,9 +99,9 @@ class TransferLogModel extends Model
         // 格式化数据
         foreach ($list as &$item) {            
             // 格式化金额(分转元)
-            $item['amount'] = bcdiv($item['amount'], "10000", 2);
-            $item['prev_amount'] = bcdiv($item['prev_amount'], "10000", 2);
-            $item['next_amount'] = bcdiv($item['next_amount'], "10000", 2);
+            $item['amount'] = (float)$item['amount'];
+            $item['prev_amount'] = (float)$item['prev_amount'];
+            $item['next_amount'] = (float)$item['next_amount'];
             // 状态文本
             $item['status_text'] = self::getStatusText($item['status']);
             // 平台昵称