浏览代码

点控列表

ssvfdn 3 月之前
父节点
当前提交
e6ab20f6f4

+ 17 - 0
app/common/CommonMerchantUserAndBalance.php

@@ -9,6 +9,7 @@ class CommonMerchantUserAndBalance
 
     const merchant_user_table = 'tp_merchants_user';
     const merchant_user_balance_table = 'tp_merchants_user_balance';
+    const merchant_user_game_rtp_win_bet = "tp_game_rtp_win_bet";
     const table_name = 'fortue_tiger';
 
 
@@ -16,6 +17,22 @@ class CommonMerchantUserAndBalance
     {
         return Db::connect(self::table_name);
     }
+
+    /**
+     * 获取指定用户的游戏 rtp win bet
+     * @param $wheres
+     * @param $field
+     * @return mixed
+     */
+    public static function getMerchantUserGameRtpWinBetInfo($wheres, $field = [])
+    {
+        $query = self::getFortueTigerTable()->table(self::merchant_user_game_rtp_win_bet)->where($wheres);
+        if(!empty($field)){
+            $query = $query->field($field);
+        }
+        return $query->select()->toArray();
+    }
+
     /**
      * 批量获取用户余额
      * @param $userIds

+ 138 - 3
app/controller/PlayerControl.php

@@ -76,7 +76,9 @@ class PlayerControl extends BaseController
         }
 
 
-        $merchantsUserList = MerchantsUserModel::getPlayerListByIds($userInfo['merchant_id'], $unameList);
+        $merchantsUserList = MerchantsUserModel::getPlayerListByIds($userInfo['merchant_id'], [
+            ['uname', 'in', $unameList]
+        ]);
         $merchantsUserList = array_column($merchantsUserList, null, 'uname');
 
 
@@ -89,8 +91,21 @@ class PlayerControl extends BaseController
             if(empty($merchantsUserInfo)) {
                 continue;
             }
+
+            $user_id = $merchantsUserInfo['user_id'];
+            $rtpGameLIst = CommonMerchantUserAndBalance::getMerchantUserGameRtpWinBetInfo([
+                ['user_id', '=' , $user_id],
+                ['game_id', 'in', $gameIds],
+            ], ['rtp','game_id']);
+
+            $gameRtp = [];
+            foreach ($rtpGameLIst as $item) {
+                $gameRtp[$item['game_id']] = $item['rtp'];
+            }
+
+
             foreach ($game_ids as $gameId) {
-                $user_id = $merchantsUserInfo['user_id'];
+                $old_rtp = $gameRtp[$gameId] ?? 0;
                 $info = PlayerControlModel::getPlayerControlInfo($userInfo['merchant_id'], $user_id, $gameId);
                 $balanceInfo = $userBalanceList[$user_id] ?? [];
                 if(!empty($info)) {
@@ -98,14 +113,15 @@ class PlayerControl extends BaseController
                     $info->control_rpt = bcmul( $data['rtp'], 100);
                     $info->auto_cancel_rtp = bcmul($data['auto_cancel_rtp'], 100);
                     $info->max_win_multi = $data['max_win_multi'];
+                    $info->old_rtp = $old_rtp;
                     $info->save();
-                    $message = "update";
                 }else {
                     $item =  [
                         'app_id' => $userInfo['merchant_id'],
                         'user_id' => $userInfo['user_id'],
                         'player_id' => $merchantsUserInfo['user_id'],// 玩家id
                         'game_id' => $gameId,
+                        'old_rtp' => $old_rtp,
                         'control_rpt' => bcmul( $data['rtp'], 100),
                         'auto_cancel_rtp' => bcmul($data['auto_cancel_rtp'], 100), // 达到RTP值取消
                         'max_win_multi' => $data['max_win_multi'], // 最高倍数
@@ -117,4 +133,123 @@ class PlayerControl extends BaseController
         }
         return json_success([],'操作成功');
     }
+
+    public function getPlayerControlList()
+    {
+        // 获取当前用户信息
+        $userInfo = $this->getUserInfo();
+
+        // 获取查询参数
+        $page = Request::get('page', 1, 'intval');
+        $limit = Request::get('limit', 10, 'intval');
+
+        // 过滤条件
+        // 筛选条件
+        $filters = [
+            // 时间筛选
+            'start_time' => Request::get('start_time', '', 'trim'),
+            'end_time' => Request::get('end_time', '', 'trim'),
+            // 游戏筛选
+            'game_id' => Request::get('game_id', '', 'trim'),
+            // 平台ID筛选
+            'uname' => Request::get('uname', '', 'trim'),
+            // 玩家ID筛选
+            'player_id' => Request::get('user_id', '', 'trim'),
+            // 平台昵称
+            'nickname' => Request::get('nickname', '', 'trim'),
+        ];
+
+
+        $controlWhere = [];
+
+
+        $where = [];
+        $isFindUserId = false;
+        // 平台ID筛选
+        if (!empty($filters['uname'])) {
+            $where[] = ['uname', '=', $filters['uname']];
+            $isFindUserId = true;
+        }
+        // 平台昵称筛选
+        if (!empty($filters['nickname'])) {
+            $where[] = ['nickname', 'like', '%' . $filters['nickname'] . '%'];
+            $isFindUserId = true;
+        }
+        // 玩家id筛选
+        if (!empty($filters['player_id'])) {
+            $where[] = ['user_id', 'like', '%' . $filters['player_id'] . '%'];
+            $isFindUserId = true;
+        }
+        if($isFindUserId) {
+            $merchantsUserIds = MerchantsUserModel::getPlayerListByIds($userInfo['merchant_id'], $where, ['user_id']);
+            $controlWhere[] = ['user_id', 'in', $merchantsUserIds];
+        }
+
+        if(!empty($filters['game_id'])) {
+            $controlWhere[] = ['game_id', 'in', explode(",", $filters['game_id'])];
+        }
+
+        if(!empty($filters['start_time']) && !empty($filters['end_time'])) {
+            $controlWhere[] = ['update_time', '>=', $filters['start_time']];
+            $controlWhere[] = ['update_time', '<=', $filters['end_time']];
+        }
+
+        $results = PlayerControlModel::getPlayerControlList($userInfo['merchant_id'], $page, $limit, $controlWhere);
+
+        $allGameList = GameModel::getGames($userInfo['merchant_id'], [], ['id', 'game_id', 'title', 'game_platform']);
+        $gameConfig = array_column($allGameList, null, 'game_id');
+
+        $player_id = array_column($results['list'],  'player_id');
+
+        $userListBalance = CommonMerchantUserAndBalance::getMerchantUserBalance($player_id);
+        $userBalanceConfig = [];
+        foreach ($userListBalance as $item) {
+            $userBalanceConfig[$item['user_id']] = $item['balance'];
+        }
+
+        $rtpUserList = [];
+        foreach ($results['list'] as $item) {
+            $player_id = $item['player_id'];
+            if(empty($rtpUserList[$player_id])) {
+                $rtpUserList[$player_id] = [];
+            }
+            $rtpUserList[$player_id][] = $item['game_id'];
+        }
+        $rtpConfigList = [];
+        foreach ($rtpUserList as $player_id => $gameIds) {
+            $temp = CommonMerchantUserAndBalance::getMerchantUserGameRtpWinBetInfo([
+                ['user_id', '=' , $player_id],
+                ['game_id', 'in', $gameIds],
+            ], ['rtp','game_id']);
+            foreach ($temp as $item) {
+                $game_id = $item['game_id'];
+                $rtp = $item['rtp'];
+                $key = "{$player_id}_{$game_id}";
+                $rtpConfigList[$key] = $rtp;
+            }
+        }
+
+
+        foreach ($results['list'] as $key => $item) {
+            $game_id = $item['game_id'];
+            $player_id = $item['player_id'];
+            $one_key = "{$player_id}_{$game_id}";
+            $gameInfo = $gameConfig[$game_id] ?? [];
+            if (!empty($gameInfo))
+            {
+                $gameImages = CommonUtils::getGameDefaultImage($gameInfo);
+            }
+            $item['game_image_url'] = $gameImages['image_url'] ?? '';
+            $item['game_title'] = $gameInfo['title'] ?? '';
+            $item['game_type_text'] = CommonUtils::getGameTypeConfig($gameInfo['game_platform']);
+            $item['balance'] = CommonUtils::convertBalance($userBalanceConfig[$player_id] ?? 0, false);
+            $item['control_rpt'] = bcdiv($item['control_rpt'], 100, 2) . "%";
+            $item['old_rtp'] = bcdiv($item['old_rtp'], 100, 2) . "%";
+            $item['now_rtp'] = bcdiv($rtpConfigList[$one_key] ?? 0, 100, 2) . "%";
+            $results['list'][$key] = $item;
+        }
+
+        return json_success($results);
+
+    }
 }

+ 2 - 2
app/model/GameModel.php

@@ -172,7 +172,7 @@ class GameModel extends Model
         ];
     }
 
-    public static function getGames($merchantId, $filters = [])
+    public static function getGames($merchantId, $filters = [], $field = ['id', 'game_id', 'title'])
     {
         $query = self::where('merchant_id', $merchantId);
         // 排序
@@ -180,7 +180,7 @@ class GameModel extends Model
         $sort = $filters['sort'] ?? 'desc';
         $query->order($order, $sort);
 
-        return $query->field(['id', 'game_id', 'title'])->select()->toArray();
+        return $query->field($field)->select()->toArray();
     }    
 
     /**

+ 7 - 4
app/model/MerchantsUserModel.php

@@ -96,13 +96,16 @@ class MerchantsUserModel extends Model
     /**
      * 通过unameList批量获取指定平台用户详情
      * @param $merchantId
-     * @param $unameList
+     * @param $wheres
      * @return mixed
      */
-    public static function getPlayerListByIds($merchantId, $unameList = [])
+    public static function getPlayerListByIds($merchantId, $wheres = [], $field = [])
     {
-        $query = self::where('app_id', $merchantId);
-        return $query->whereIn('uname', $unameList)->select()->toArray();
+        $query = self::where('app_id', $merchantId)->where($wheres);
+        if(!empty($field)) {
+            $query = $query->field($field);
+        }
+        return $query->select()->toArray();
     }
 
     /**

+ 2 - 16
app/model/PlayerControlModel.php

@@ -21,6 +21,7 @@ class PlayerControlModel extends Model
         'user_id' => 'int', // 用户ID
         'player_id' => 'int', // 玩家ID
         'game_id' => 'string', // 游戏ID
+        'old_rtp' => 'int', // 设置时当前RTP值,
         'control_rpt' => 'int', // 设置的RTP值
         'auto_cancel_rtp' => 'int', // 达到此RTP解除点控
         'max_win_multi' => 'int', // 赢取倍数限制
@@ -44,23 +45,8 @@ class PlayerControlModel extends Model
     /**
      * 根据商户ID获取玩家列表
      */
-    public static function getPlayerControlList($merchantId, $page = 1, $limit = 10, $filters = [])
+    public static function getPlayerControlList($merchantId, $page = 1, $limit = 10, $wheres = [])
     {
-        $wheres = [];
-        $wheres[] = ['app_id', '=', $merchantId];
-        // 应用过滤条件
-        if (!empty($filters['uname'])) {
-            $wheres[] = ['uname', 'like', '%' . $filters['uname'] . '%'];
-        }
-        if (!empty($filters['nickname'])) {
-            $wheres[] = ['nickname', 'like', '%' . $filters['nickname'] . '%'];
-        }
-        if (!empty($filters['user_id'])) {
-            $wheres[] = ['user_id', '=', $filters['user_id']];
-        }
-        if(!empty($filters['game_id'])) {
-            $wheres[] = ['game_id', 'in', $filters['game_id']];
-        }
 
         $query = self::where($wheres);
         $order = $filters['order'] ?? 'create_time';

+ 1 - 0
route/app.php

@@ -60,6 +60,7 @@ Route::group('game', function () {
 
 Route::group('player_control', function () {
     Route::post('update', 'PlayerControl/updatePlayerControl');
+    Route::get('list', 'PlayerControl/getPlayerControlList');
 })->middleware([\app\middleware\AuthMiddleware::class, \app\middleware\BehaviorLogMiddleware::class]);