Selaa lähdekoodia

后台 查询加nolock

Tree 1 viikko sitten
vanhempi
sitoutus
ec8441a33a

+ 2 - 2
app/Game/BigWinner.php

@@ -50,7 +50,7 @@ class BigWinner extends Model
             rs.ChangeScore,
             rs.UpdateTime,
             ROW_NUMBER() OVER (PARTITION BY rs.UserID ORDER BY rs.ChangeScore DESC) AS rn
-        FROM $scoreTableName AS rs
+        FROM $scoreTableName AS rs WITH (NOLOCK)
         WHERE rs.UpdateTime >= ?
     )
     SELECT TOP 50
@@ -60,7 +60,7 @@ class BigWinner extends Model
         ai.NickName as nick,
         ai.FaceID as img
     FROM RankedScores AS rs
-    JOIN $accountTableName AS ai ON rs.UserID = ai.UserID
+    JOIN $accountTableName AS ai WITH (NOLOCK) ON rs.UserID = ai.UserID
     WHERE rs.rn = 1 and rs.ChangeScore>10
     ORDER BY rs.ChangeScore DESC";
         try {

+ 2 - 2
app/Http/Controllers/Admin/GameWinLoseRankController.php

@@ -63,8 +63,8 @@ class GameWinLoseRankController extends BaseController
         try {
             // 查询输赢数据并关联用户信息
             $query = DB::connection('read')
-                ->table(TableName::QPTreasureDB() . $monthTable . ' as r')
-                ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'r.UserID', '=', 'ai.UserID')
+                ->table(DB::raw(TableName::QPTreasureDB() . $monthTable . ' as r WITH (NOLOCK)'))
+                ->join(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'), 'r.UserID', '=', 'ai.UserID')
                 ->whereIn('r.ServerID', $serverIds)
                 ->whereBetween('r.UpdateTime', [$startTime, $endTime])
                 ->select([

+ 110 - 110
app/Http/Controllers/Admin/GlobalController.php

@@ -94,7 +94,7 @@ class GlobalController extends Controller
         $pay_sum = isset($order->pay_sum) ? number_float($order->pay_sum / NumConfig::NUM_VALUE) : 0;
 
         // 签到总奖励
-        $totalSignIn = DB::connection('read')->table('QPAccountsDB.dbo.UserSignInInfo')
+        $totalSignIn = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.UserSignInInfo WITH (NOLOCK)'))
                 ->selectRaw('IsNull(sum(TotalReward),0) TotalReward')
                 ->first()->TotalReward / 100 ?? 0;
 
@@ -103,7 +103,7 @@ class GlobalController extends Controller
 
 
         // 历史流水和税收
-        $gameInfo = DB::connection('read')->table('QPRecordDB.dbo.RecordUserTotalStatistics')
+        $gameInfo = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserTotalStatistics WITH (NOLOCK)'))
             ->selectRaw('IsNull((abs(sum(LostScore)) + sum(WinScore)),0) flowing_water,Isnull(sum(Revenue),0) as Revenue,IsNull((sum(LostScore) + sum(WinScore)),0) Score,IsNull(sum(Withdraw),0) WithDraw,Isnull(SUM(Handsel),0) as ChangeScore')
             ->first();
 
@@ -111,7 +111,7 @@ class GlobalController extends Controller
         $txAmount = $gameInfo->WithDraw / 100 ?? 0;
 
         // 累计提现回收金额
-        $WithDrawRecovery = DB::connection('read')->table('QPAccountsDB.dbo.OrderWithDraw as ow')
+        $WithDrawRecovery = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.OrderWithDraw as ow WITH (NOLOCK)'))
                 ->where('State', 4)
                 ->selectRaw('sum(WithDraw+ServiceFee) as WithDraw')
                 ->first()->WithDraw ?? 0;
@@ -172,7 +172,7 @@ class GlobalController extends Controller
         // 用户彩金
         $ScoreType = [21, 33, 36, 37, 42, 44, 45, 49, 51, 52, 53, 59, 70];
         // 21、绑定手机赠送 33、注册赠送 36、推广赚金(彩金) 37、人工增加金币 42、邮件附件(充值彩金) 45、充值彩金 49、月卡彩金 51、首充礼包(彩金)  52、邮件附件(群发彩金) 53、推广赚金(佣金)
-        $RecordUserScoreStatistics = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew')
+        $RecordUserScoreStatistics = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserScoreStatisticsNew WITH (NOLOCK)'))
             ->whereBetween('DateID', [date('Ymd', strtotime($start_time)), date('Ymd', strtotime($end_time))])
             ->whereIn('ScoreType', $ScoreType)
             ->select('ScoreType')
@@ -195,7 +195,7 @@ class GlobalController extends Controller
 
 
         // 签到
-        $signIn = DB::connection('read')->table('QPRecordDB.dbo.RecordSignIn')
+        $signIn = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordSignIn WITH (NOLOCK)'))
                 ->where('SignInDate', '>=', date("Y-m-d 00:00:00", strtotime("$start_time")))
                 ->where('SignInDate', '<=', date("Y-m-d 23:59:59", strtotime("$end_time")))
                 ->selectRaw('IsNull(sum(RewardScore),0) RewardScore')
@@ -203,15 +203,15 @@ class GlobalController extends Controller
 
 
         // 推广总奖励
-        $TotalReward = DB::connection('read')->table('QPAccountsDB.dbo.SystemAgentReward')->select('TotalReward')->first()->TotalReward;
+        $TotalReward = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.SystemAgentReward WITH (NOLOCK)'))->select('TotalReward')->first()->TotalReward;
 
 
         $data['TotalReward'] = number_float($TotalReward / 100);
 
 
         // 非正式会员的彩金
-        $notMemberProfit = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew as rs')
-            ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'ai.UserID', 'rs.UserID')
+        $notMemberProfit = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserScoreStatisticsNew as rs WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'ai.UserID', 'rs.UserID')
             ->where('Channel', 100)
             ->whereIn('ScoreType', $ScoreType)
             ->whereBetween('DateID', [date('Ymd', strtotime($start_time)), date('Ymd', strtotime($end_time))])
@@ -219,8 +219,8 @@ class GlobalController extends Controller
             ->first()->Score;
 
         // 正式会员彩金
-        $MemberProfit = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew as rs')
-            ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'ai.UserID', 'rs.UserID')
+        $MemberProfit = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserScoreStatisticsNew as rs WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'ai.UserID', 'rs.UserID')
             ->whereIn('ScoreType', $ScoreType)
             ->where('Channel', '<>', 100)
             ->whereBetween('DateID', [date('Ymd', strtotime($start_time)), date('Ymd', strtotime($end_time))])
@@ -232,8 +232,8 @@ class GlobalController extends Controller
 
         // 非正式会员人数-- 进入TP试玩场人数
 
-        $notMemberNum = DB::connection('read')->table('QPTreasureDB.dbo.RecordUserInout as ri')
-                ->join('QPPlatformDB.dbo.GameRoomInfo as gi', 'ri.ServerID', 'gi.ServerID')
+        $notMemberNum = DB::connection('read')->table(DB::raw('QPTreasureDB.dbo.RecordUserInout as ri WITH (NOLOCK)'))
+                ->join(DB::raw('QPPlatformDB.dbo.GameRoomInfo as gi WITH (NOLOCK)'), 'ri.ServerID', 'gi.ServerID')
                 ->where('gi.ServerType', 2)
                 ->where('GameID', 1005)
                 ->where('ri.EnterTime', '>=', date("Y-m-d 00:00:00", strtotime("$start_time")))
@@ -242,8 +242,8 @@ class GlobalController extends Controller
                 ->first()->count_u ?? 0;
 
         // 谷歌渠道--付费人数--付费金额
-        $google_pay = DB::connection('read')->table('agent.dbo.order as o')
-            ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'o.user_id', '=', 'ai.UserID')
+        $google_pay = DB::connection('read')->table(DB::raw('agent.dbo.order as o WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'o.user_id', '=', 'ai.UserID')
             ->where('Channel', 100)
             ->where('o.pay_at', '>=', "$start_time")
             ->where('o.pay_at', '<=', "$end_time")
@@ -254,7 +254,7 @@ class GlobalController extends Controller
         /*                     用户数据              */
 
         //注册用户
-        $data['today_register'] = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
+        $data['today_register'] = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->selectRaw('count(*) as today_register')
             ->where('IsAndroid', 0)
             ->where('RegisterDate', '>=', "$start_time")
@@ -262,14 +262,14 @@ class GlobalController extends Controller
             ->first()->today_register;
 
         //充值人数
-        $pay_count = DB::connection('read')->table('agent.dbo.order')
+        $pay_count = DB::connection('read')->table(DB::raw('agent.dbo.order WITH (NOLOCK)'))
             ->where('pay_at', '>=', "$start_time")
             ->where('pay_at', '<=', "$end_time")
             ->selectRaw('count(DISTINCT user_id) as today_pay_count,cast(sum(amount) as int) as today_pay_sum')
             ->first();
 
         // 提现人数
-        $cash = DB::connection('read')->table('QPAccountsDB.dbo.OrderWithDraw')
+        $cash = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.OrderWithDraw WITH (NOLOCK)'))
             ->where('finishDate', '>=', "$start_time")
             ->where('finishDate', '<=', "$end_time")
             ->selectRaw('count(DISTINCT UserID) as cash_count,cast(sum(WithDraw) as int) as cash_sum,count(RecordID) cash_bi')
@@ -277,14 +277,14 @@ class GlobalController extends Controller
 
         $data['today_pay_count'] = $pay_count->today_pay_count;
         //活跃用户数
-        $data['lively_num'] = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogin')->selectRaw('count(distinct(UserID)) as lively_num')
+        $data['lively_num'] = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserLogin WITH (NOLOCK)'))->selectRaw('count(distinct(UserID)) as lively_num')
             ->where('DateID', '>=', date('Ymd', strtotime($start_time)))
             ->where('DateID', '<=', date('Ymd', strtotime($start_time)))
             ->first()->lively_num;
 
 
         //ios 安卓新增用户
-        $player_list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
+        $player_list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->where('IsAndroid', 0)
             ->whereIn('LastLogonMobile', ['Android', 'IOS'])
             ->where('RegisterDate', '>=', "$start_time")
@@ -311,10 +311,10 @@ class GlobalController extends Controller
         $data['cash_count'] = $cash->cash_count;
         $data['cash_bi'] = $cash->cash_bi;
 
-        $pay = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as rsn')
+        $pay = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as rsn WITH (NOLOCK)'))
             ->where('DateID', '>=', date('Ymd', strtotime($start_time)))
             ->where('DateID', '<=', date('Ymd', strtotime($end_time)))
-            ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'rsn.UserID', 'ai.UserID')
+            ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'rsn.UserID', 'ai.UserID')
             ->where('LastLogonMobile', 'Android')
             ->selectRaw('count(rsn.UserID) count_u,sum(Recharge) amount')
             ->first();
@@ -323,7 +323,7 @@ class GlobalController extends Controller
 
 
         // 游客人数
-        $tourist = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
+        $tourist = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->where('WebLogonTimes', 1)
             ->where('IsAndroid', 0)
             ->where('RegisterDate', '>=', $start_time)
@@ -331,13 +331,13 @@ class GlobalController extends Controller
             ->count();
 
         // 手机账号人数-包括游客升级来的
-        $phoneNum = DB::connection('read')->table('QPAccountsDB.dbo.AccountPhone')
+        $phoneNum = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountPhone WITH (NOLOCK)'))
             ->where('BindDate', '>=', $start_time)
             ->where('BindDate', '<=', $end_time)
             ->count();
 
         // Facebook 人数
-        $facebookNum = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
+        $facebookNum = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->where('RegisterDate', '>=', $start_time)
             ->where('RegisterDate', '<=', $end_time)
             ->where('IsAndroid', 0)
@@ -374,7 +374,7 @@ class GlobalController extends Controller
         $WeeklyCard = $logic->WeeklyCard();
 
         /*                     游戏房间数据              */
-        $gameRoomInfo = DB::connection('read')->table('QPRecordDB.dbo.RecordServerDataStatistics')
+        $gameRoomInfo = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordServerDataStatistics WITH (NOLOCK)'))
             ->where('DateID', '>=', date('Ymd', strtotime($start_time)))
             ->where('DateID', '<=', date('Ymd', strtotime($start_time)))
             ->selectRaw('Isnull((sum(WinScore) + abs(sum(LostScore))),0) as flowing_water,Isnull(sum(Revenue),0) as Revenue,Isnull((sum(WinScore) + sum(LostScore)),0) as win_lose')
@@ -387,14 +387,14 @@ class GlobalController extends Controller
         //税收
         $gameRoomInfo->Revenue = isset($gameRoomInfo->Revenue) ? number_float($gameRoomInfo->Revenue / NumConfig::NUM_VALUE) : 0;
         // 累计玩游戏人数
-        $gameRoomInfo->GameCountUser = DB::connection('read')->table('QPRecordDB.dbo.PD_RecordScoreInfo')
+        $gameRoomInfo->GameCountUser = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.PD_RecordScoreInfo WITH (NOLOCK)'))
             ->where('AtDate', '>=', date('Ymd', strtotime($start_time)))
             ->where('AtDate', '<=', date('Ymd', strtotime($end_time)))
             ->count(DB::raw('DISTINCT UserID'));
 
 
-        $game_list = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi')
-            ->leftJoin('QPRecordDB.dbo.RecordServerDataStatistics as rds', 'rds.ServerID', 'gi.ServerID')
+        $game_list = DB::connection('read')->table(DB::raw('QPPlatformDB.dbo.GameRoomInfo as gi WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPRecordDB.dbo.RecordServerDataStatistics as rds WITH (NOLOCK)'), 'rds.ServerID', 'gi.ServerID')
             ->where('DateID', '>=', date('Ymd', strtotime($start_time)))
             ->where('DateID', '<=', date('Ymd', strtotime($start_time)))
             ->select('gi.GameID', 'gi.ServerName', 'gi.ServerID')
@@ -403,7 +403,7 @@ class GlobalController extends Controller
             ->orderByDesc('flowing_water')
             ->get();
         // 玩过游戏的人
-        $playGameUser = DB::connection('write')->table(TableName::QPRecordDB() . 'RecordUserGameCount')
+        $playGameUser = DB::connection('write')->table(DB::raw(TableName::QPRecordDB() . 'RecordUserGameCount WITH (NOLOCK)'))
             ->where('AtDate', '>=', date('Ymd', strtotime($start_time)))
             ->where('AtDate', '<=', date('Ymd', strtotime($end_time)))
             ->selectRaw('count(distinct(UserID)) as count_u,ServerID')
@@ -459,10 +459,10 @@ class GlobalController extends Controller
     {
 
         $field = ['LostUserCount', 'WinUserCount', 'gi.GameID', 'gi.Nullity', 'gi.SortID', 'gi.ServerName', 'gi.ServerID', 'gi.RoomStock', 'WinInning', 'LostInning', 'TotalInning', 'Revenue', 'LostScore', 'WinScore'];
-        $list = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi')
+        $list = DB::connection('read')->table(DB::raw('QPPlatformDB.dbo.GameRoomInfo as gi WITH (NOLOCK)'))
             ->whereIn('GameID', config('games.openKGame'))
-            ->leftJoin('QPRecordDB.dbo.RecordServerDataStatistics as rds', 'gi.ServerID', '=', 'rds.ServerID')
-            ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as gl', function ($query) {
+            ->leftJoin(DB::raw('QPRecordDB.dbo.RecordServerDataStatistics as rds WITH (NOLOCK)'), 'gi.ServerID', '=', 'rds.ServerID')
+            ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreLocker as gl WITH (NOLOCK)'), function ($query) {
                 $query->on('gl.ServerID', 'gi.ServerID')->selectRaw('gl.ServerID')->groupBy('ServerID')->whereRaw('datediff(hh,gl.CollectDate,getdate())<=5');
             })
             ->where('rds.DateID', date('Ymd'))
@@ -480,7 +480,7 @@ class GlobalController extends Controller
 //            ->selectRaw('count(DISTINCT UserID) as game_count')
 //            ->whereDate('CollectDate', date('Y-m-d'))
 //            ->first()->game_count;
-        $line = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreLocker')
+        $line = DB::connection('read')->table(DB::raw('QPTreasureDB.dbo.GameScoreLocker WITH (NOLOCK)'))
             ->selectRaw('count(DISTINCT UserID) as game_count')
             ->whereRaw('datediff(hh,CollectDate,getdate())<=5')
             ->first()->game_count;
@@ -615,14 +615,14 @@ class GlobalController extends Controller
     //用户列表
     public function userlist1(Request $request)
     {
-        $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-            ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai1', 'ai.SpreaderID', '=', 'ai1.UserID')
-            ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as gi', 'ai.UserID', '=', 'gi.UserID')
-            ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as gsl', 'gsl.UserID', '=', 'ai.UserID')
-            ->leftJoin('QPPlatformDB.dbo.GameRoomInfo as gri', 'gsl.ServerID', '=', 'gri.ServerID')
-            ->leftJoin('QPAccountsDB.dbo.AccountPhone as ap', 'ai.UserID', 'ap.UserID')
-            ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
-            ->leftJoin('QPRecordDB.dbo.RecordPackageName as rn', 'ai.UserID', 'rn.UserID')
+        $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai1 WITH (NOLOCK)'), 'ai.SpreaderID', '=', 'ai1.UserID')
+            ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreInfo as gi WITH (NOLOCK)'), 'ai.UserID', '=', 'gi.UserID')
+            ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreLocker as gsl WITH (NOLOCK)'), 'gsl.UserID', '=', 'ai.UserID')
+            ->leftJoin(DB::raw('QPPlatformDB.dbo.GameRoomInfo as gri WITH (NOLOCK)'), 'gsl.ServerID', '=', 'gri.ServerID')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountPhone as ap WITH (NOLOCK)'), 'ai.UserID', 'ap.UserID')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.IDWhiteUser as iu WITH (NOLOCK)'), 'ai.UserID', 'iu.UserID')
+            ->leftJoin(DB::raw('QPRecordDB.dbo.RecordPackageName as rn WITH (NOLOCK)'), 'ai.UserID', 'rn.UserID')
             ->where('ai.IsAndroid', 0);
 
         $UserID = (int)$request->UserID ?: "";
@@ -758,7 +758,7 @@ class GlobalController extends Controller
 
             // 游戏中用户
 
-            $query_UserID = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser')->whereIn('UserID', $userID)->pluck('UserID')->toArray();
+            $query_UserID = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.IDWhiteUser WITH (NOLOCK)'))->whereIn('UserID', $userID)->pluck('UserID')->toArray();
 
             // 禁止查看敏感信息
             $helper = new Helper();
@@ -799,7 +799,7 @@ class GlobalController extends Controller
 
             $WebLogonTimes = [1 => 'facebook', 2 => '游客', 3 => '手机号'];
 
-            $channels = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('IsAndroid', 0)->groupBy('Channel')->pluck('Channel');
+            $channels = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))->where('IsAndroid', 0)->groupBy('Channel')->pluck('Channel');
             return view('admin.global.userlist', [
                 'list' => $list,
                 'UserID' => $UserID,
@@ -830,12 +830,12 @@ class GlobalController extends Controller
     {
         if ($request->isMethod('get')) {
             $userID = $request->id;
-            $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-                ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ain', 'ai.SpreaderID', '=', 'ain.UserID')
+            $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as ain WITH (NOLOCK)'), 'ai.SpreaderID', '=', 'ain.UserID')
                 ->where('ai.UserID', $userID)
                 ->selectRaw('ai.UserID,ai.NickName,ai.Nullity,ai.Compellation,ai.SpreaderID,ai.GameID as ai_GameID,IsNull(ain.GameID,0) as GameID')
                 ->first();
-            $IDWhiteUser = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser')->where('UserID', $userID)->first();
+            $IDWhiteUser = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.IDWhiteUser WITH (NOLOCK)'))->where('UserID', $userID)->first();
             return view('admin.global.user_update', ['list' => $list, 'IDWhiteUser' => $IDWhiteUser]);
 
         } elseif ($request->isMethod('post')) {
@@ -846,13 +846,13 @@ class GlobalController extends Controller
 
             $official = $request->post('official');
 
-            $query = $IDWhiteUser = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser')->where('UserID', $UserID)->first();
+            $query = $IDWhiteUser = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.IDWhiteUser WITH (NOLOCK)'))->where('UserID', $UserID)->first();
 
 
             $arr = [];
 
             if (!empty(trim($SpreaderID))) {
-                $account = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('GameID', $SpreaderID)->selectRaw('UserID')->first();
+                $account = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))->where('GameID', $SpreaderID)->selectRaw('UserID')->first();
 
                 $arr['SpreaderID'] = $account->UserID;
             }
@@ -889,7 +889,7 @@ class GlobalController extends Controller
                 DB::table('QPAccountsDB.dbo.AccountsInfo')->whereIn('UserID', $id)->update(['Nullity' => 1]);
 
                 // 查询用户gameId
-                $gameID = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->whereIn('UserID', $id)->select('GameID')->get();
+                $gameID = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))->whereIn('UserID', $id)->select('GameID')->get();
                 $data = [];
 
 
@@ -958,7 +958,7 @@ class GlobalController extends Controller
 
         if ($id == 1) {
             $ip = $request->RegisterIP;
-            $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
+            $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
                 ->where('RegisterIP', $ip)
                 ->where('IsAndroid', 0)
                 ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,UserID')
@@ -983,7 +983,7 @@ class GlobalController extends Controller
         } elseif ($id == 2) {
             $userid = $request->UserID;
 
-            $mac = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics')
+            $mac = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserLogonStatistics WITH (NOLOCK)'))
                      ->where('UserID', $userid)
                      ->where('mac', '<>','')
                      ->pluck('mac')->toArray();
@@ -992,12 +992,12 @@ class GlobalController extends Controller
 
             $list=[];
             if($mac) {
-                $userids= DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics')
+                $userids= DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserLogonStatistics WITH (NOLOCK)'))
                          ->whereIn('mac', $mac)
                          ->pluck('UserID')
                          ->toArray();
                 $userids=array_unique($userids);
-                $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
+                $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
                           ->whereIn('UserID', $userids)
                           ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,UserID')
                           ->paginate(100);
@@ -1006,7 +1006,7 @@ class GlobalController extends Controller
 
 
             foreach ($list as &$value) {
-                $value->login_count = DB::table('QPRecordDB.dbo.RecordUserLogin')->where('UserID', $value->UserID)->count();
+                $value->login_count = DB::table(DB::raw('QPRecordDB.dbo.RecordUserLogin WITH (NOLOCK)'))->where('UserID', $value->UserID)->count();
             }
 
             // 获取总充值和总提现
@@ -1028,8 +1028,8 @@ class GlobalController extends Controller
         } elseif ($id == 3) {
 
             $BankNo = $request->Phone;
-            $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountPhone as di')
-                ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
+            $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountPhone as di WITH (NOLOCK)'))
+                ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'di.UserID', 'ai.UserID')
                 ->where('di.PhoneNum', $BankNo)
                 ->selectRaw('RegisterDate,LastLogonDate,ai.GameID,Compellation,ai.Channel,ai.NickName,ai.UserID')
                 ->paginate(10);
@@ -1052,8 +1052,8 @@ class GlobalController extends Controller
             return view('admin.global.join_bankNo', ['list' => $list, 'id' => $id, 'BankNo' => $BankNo]);
         } elseif ($id == 4) {
             $BankNo = $request->BankUserName;
-            $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountWithDrawInfo as di')
-                ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
+            $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountWithDrawInfo as di WITH (NOLOCK)'))
+                ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'di.UserID', 'ai.UserID')
                 ->where('di.BankUserName', $BankNo)
                 ->selectRaw('RegisterDate,LastLogonDate,ai.GameID,Compellation,Channel,ai.NickName,ai.UserID')
                 ->paginate(10);
@@ -1076,8 +1076,8 @@ class GlobalController extends Controller
             return view('admin.global.join_bankNo', ['list' => $list, 'id' => $id, 'BankNo' => $BankNo]);
         } elseif ($id == 5) {
             $BankNo = $request->EmailAddress;
-            $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountWithDrawInfo as di')
-                ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
+            $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountWithDrawInfo as di WITH (NOLOCK)'))
+                ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'di.UserID', 'ai.UserID')
                 ->where('di.EmailAddress', $BankNo)
                 ->selectRaw('RegisterDate,LastLogonDate,ai.GameID,Compellation,Channel,ai.NickName,ai.UserID')
                 ->paginate(100);
@@ -1102,8 +1102,8 @@ class GlobalController extends Controller
 
             $UserID = $request->UserID;
 
-            $UserIDs = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics as rs')
-                ->join('QPRecordDB.dbo.RecordUserLogonStatistics as rs1', function ($join) {
+            $UserIDs = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserLogonStatistics as rs WITH (NOLOCK)'))
+                ->join(DB::raw('QPRecordDB.dbo.RecordUserLogonStatistics as rs1 WITH (NOLOCK)'), function ($join) {
                     $join->on('rs.LogonIP', 'rs1.LogonIP');
                 })
                 ->where('rs.UserID', $UserID)
@@ -1112,7 +1112,7 @@ class GlobalController extends Controller
                 ->limit(2000)
                 ->pluck('rs1.UserID');
 
-            $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
+            $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
                 ->whereIn('ai.UserID', $UserIDs)
                 ->where('IsAndroid', 0)
                 ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,ai.UserID')
@@ -1137,8 +1137,8 @@ class GlobalController extends Controller
         } elseif ($id == 7) { // 登录IP记录
             $UserID = $request->UserID;
 
-            $list = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics as rls')
-                ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'rls.UserID', 'ai.UserID')
+            $list = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserLogonStatistics as rls WITH (NOLOCK)'))
+                ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'rls.UserID', 'ai.UserID')
                 ->where('rls.UserID', $UserID)
                 ->where('IsAndroid', 0)
                 ->select('rls.UserID','LastLogonDate', 'LogonIP', 'LastDate', 'ai.GameID', 'NickName', 'Channel')
@@ -1149,7 +1149,7 @@ class GlobalController extends Controller
         } elseif ($id == 8) { // 关联cpf
             $UserID = $request->UserID;
             $cpf=Cpf::getCpf($UserID,1);
-            $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
+            $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
                       ->whereIn('ai.UserID', Cpf::getCpf($UserID))
                       ->where('IsAndroid', 0)
                       ->selectRaw('RegisterDate,LastLogonDate,GameID,Compellation,Channel,NickName,ai.UserID')
@@ -1211,8 +1211,8 @@ class GlobalController extends Controller
         $end_time = str_replace('T', ' ', $end_time);
 
         $list = (new GlobalUser())->dk_userlist($GameID, $SpreaderID, $NickName, $start_time, $end_time, $user_label, $is_line, $game_room, $UserScoreControl, $ScoreSort, $amountSort, $sort_tx, $sort_date, $ChangeScoreSort, $Channel, $label_sort, $ServerNameSort);
-        $game_room_line = DB::connection('read')->table(TableName::QPPlatformDB() . 'GameRoomInfo')->select('ServerName', 'ServerID')->get();
-        $allChannel = DB::connection('read')->table(TableName::QPPlatformDB() . 'ChannelPackageName')->pluck('Channel');
+        $game_room_line = DB::connection('read')->table(DB::raw(TableName::QPPlatformDB() . 'GameRoomInfo WITH (NOLOCK)'))->select('ServerName', 'ServerID')->get();
+        $allChannel = DB::connection('read')->table(DB::raw(TableName::QPPlatformDB() . 'ChannelPackageName WITH (NOLOCK)'))->pluck('Channel');
         $page = Paginator::resolveCurrentPage('page');
 
         $start_time = \App\Http\helper\Helper::timeChange($start_time);
@@ -1245,7 +1245,7 @@ class GlobalController extends Controller
             }
 
             $admin_id = session('admin')->id;
-            $admin_user = DB::connection('read')->table('agent.dbo.admin_users')->where('id', $admin_id)->first();
+            $admin_user = DB::connection('read')->table(DB::raw('agent.dbo.admin_users WITH (NOLOCK)'))->where('id', $admin_id)->first();
             /*管理员彩金控制*/
             if ($ControlScore > 0) {
                 if ($admin_user->recharge_amount < $ControlScore) return apiReturnFail('管理员彩金额度不足!');
@@ -1255,7 +1255,7 @@ class GlobalController extends Controller
             // 记录单控操作(只记金额和总体概率)
             $prefix = $ControlScore < 0 ? '输' : '赢';
             $content = $prefix . $ControlScore . '/ 概率:' . number_float($Probability) . '%';
-            $score = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->select('Score')->first()->Score ?? 0;
+            $score = DB::connection('read')->table(DB::raw('QPTreasureDB.dbo.GameScoreInfo WITH (NOLOCK)'))->where('UserID', $UserID)->select('Score')->first()->Score ?? 0;
             ControlRecord::record_add($UserID, $admin_id, $content, $score);
 
             $data = [
@@ -1306,7 +1306,7 @@ class GlobalController extends Controller
 
 
         if ($res) {
-            $score = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $UserID)->select('Score')->first()->Score ?? 0;
+            $score = DB::connection('read')->table(DB::raw('QPTreasureDB.dbo.GameScoreInfo WITH (NOLOCK)'))->where('UserID', $UserID)->select('Score')->first()->Score ?? 0;
             ControlRecord::record_add($UserID, $admin_id, '取消单控', $score);
 
             // 埋点,执行存储过程
@@ -1385,7 +1385,7 @@ class GlobalController extends Controller
             case 1:
                 $OrderIDs = explode(',', $orderIds);
 
-                $list = DB::connection('write')->table('agent.dbo.extension_user_profit_log')
+                $list = DB::connection('write')->table(DB::raw('agent.dbo.extension_user_profit_log WITH (NOLOCK)'))
                     ->whereIn('OrderID', $OrderIDs)
                     ->where('OrderID', '>', 0)
                     ->where('Type', $Type)
@@ -1401,9 +1401,9 @@ class GlobalController extends Controller
             case 2:
                 break;
             case 3:
-                $list = DB::connection('read')->table('QPRecordDB.dbo.RecordUserAgent as ua')
-                    ->join('QPAccountsDB.dbo.accountsInfo as ai', 'ua.UserID', 'ai.UserID')
-                    ->leftJoin('QPAccountsDB.dbo.accountsInfo as ain', 'ain.UserID', '=', 'ua.SourceUserID')
+                $list = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserAgent as ua WITH (NOLOCK)'))
+                    ->join(DB::raw('QPAccountsDB.dbo.accountsInfo as ai WITH (NOLOCK)'), 'ua.UserID', 'ai.UserID')
+                    ->leftJoin(DB::raw('QPAccountsDB.dbo.accountsInfo as ain WITH (NOLOCK)'), 'ain.UserID', '=', 'ua.SourceUserID')
                     ->select('ai.GameID', 'ain.GameID as SourceUserID', 'DirectRebate', 'SendTime', 'OrderSn', 'ain.UserID', 'ua.Level')
                     ->where('ua.Id', $Id)
                     ->orderBy('SendTime', 'desc')
@@ -1449,13 +1449,13 @@ class GlobalController extends Controller
     {
 
         $list = cache()->remember('match_information_' . $RoomCode, 10, function () use ($RoomCode) {
-            return DB::connection('game')->table(TableName::QPRecordDB() . 'RecordUniqueScoreCode')
+            return DB::connection('game')->table(DB::raw(TableName::QPRecordDB() . 'RecordUniqueScoreCode WITH (NOLOCK)'))
                 ->where('uniquescorecode', $RoomCode)
                 ->get();
         });
 
         if (count($list) < 1 || empty($list)) {
-            $info = DB::connection('game')->table(TableName::QPRecordDB() . 'RecordGamePlayNew')
+            $info = DB::connection('game')->table(DB::raw(TableName::QPRecordDB() . 'RecordGamePlayNew WITH (NOLOCK)'))
                 ->where('RoomCode', $RoomCode)
                 ->value('RecordJson');
 
@@ -1478,7 +1478,7 @@ class GlobalController extends Controller
             foreach ($list as $value) {
                 $uniquecode = $value->uniquecode;
                 $info = cache()->remember('match_information_info_' . $uniquecode, 10, function () use ($uniquecode) {
-                    return DB::connection('game')->table(TableName::QPRecordDB() . 'RecordGamePlayNew')
+                    return DB::connection('game')->table(DB::raw(TableName::QPRecordDB() . 'RecordGamePlayNew WITH (NOLOCK)'))
                         ->where('RoomCode', $uniquecode)
                         ->value('RecordJson');
                 });
@@ -1576,9 +1576,9 @@ class GlobalController extends Controller
         $link = 'http://' . $request->getHttpHost() . '/admin/global/online_user?index=';
         $service = new Paging($pageNum, $total, $index, ($total / $pageNum), $link);
 
-        $list = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-            ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as lck', 'ai.UserID', 'lck.UserID')
-            ->leftJoin('QPPlatformDB.dbo.GameRoomInfo as gi', 'lck.ServerID', '=', 'gi.ServerID')
+        $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreLocker as lck WITH (NOLOCK)'), 'ai.UserID', 'lck.UserID')
+            ->leftJoin(DB::raw('QPPlatformDB.dbo.GameRoomInfo as gi WITH (NOLOCK)'), 'lck.ServerID', '=', 'gi.ServerID')
             ->whereIn('ai.UserID', $onLineUser['UserIDs'])
             ->select('ai.GameID', 'NickName', 'ai.UserID', 'gi.ServerName')->get();
         $page = $service->subPageCss2();
@@ -1593,9 +1593,9 @@ class GlobalController extends Controller
     // 无感维护开关
     public function GameRoomSwitch_view()
     {
-        $list = DB::connection('read')->table('QPPlatformDB.dbo.GameRoomInfo as gi')
+        $list = DB::connection('read')->table(DB::raw('QPPlatformDB.dbo.GameRoomInfo as gi WITH (NOLOCK)'))
             //->leftJoin('QPRecordDB.dbo.RecordGameInfo as ri', 'gi.ServerID', '=', 'ri.ServerID')
-            ->leftJoin('QPTreasureDB.dbo.GameScoreLocker as gl', function ($query) {
+            ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreLocker as gl WITH (NOLOCK)'), function ($query) {
                 $query->on('gl.ServerID', 'gi.ServerID')->selectRaw('gl.ServerID')->groupBy('ServerID')->whereDate('CollectDate', date('Y-m-d'));
             })
             ->whereIn('gi.GameID', [1005, 2030, 2050])
@@ -1682,9 +1682,9 @@ class GlobalController extends Controller
             CreateLog::SystemStatusInfo_log($admin_id, 'AgentCommisionState');
             return apiReturnSuc();
         } else {
-            $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
-                ->leftJoin('agent.dbo.SystemStatusInfo_log as log', 'si.StatusName', 'log.StatusName')
-                ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
+            $list = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo as si WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('agent.dbo.SystemStatusInfo_log as log WITH (NOLOCK)'), 'si.StatusName', 'log.StatusName')
+                ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'log.admin_id', '=', 'au.id')
                 ->select('StatusString', 'StatusValue', 'account', 'create_at')
                 ->where('si.StatusName', 'AndroidCheck')
                 ->get();
@@ -1733,7 +1733,7 @@ class GlobalController extends Controller
 
             return apiReturnSuc();
         } else {
-            $type = DB::connection('read')->table('QPAccountsDB.dbo.AccountLabelDanControlLabel')->where('UserID', $id)->value('type');
+            $type = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountLabelDanControlLabel WITH (NOLOCK)'))->where('UserID', $id)->value('type');
             $label = [
                 20 => '其他1',
                 21 => '其他2'
@@ -1761,9 +1761,9 @@ class GlobalController extends Controller
             CreateLog::SystemStatusInfo_log($admin_id, 'AgentCommisionState');
             return apiReturnSuc();
         } else {
-            $list = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
-                ->leftJoin('agent.dbo.SystemStatusInfo_log as log', 'si.StatusName', 'log.StatusName')
-                ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
+            $list = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo as si WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('agent.dbo.SystemStatusInfo_log as log WITH (NOLOCK)'), 'si.StatusName', 'log.StatusName')
+                ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'log.admin_id', '=', 'au.id')
                 ->select('StatusString', 'StatusValue', 'account', 'create_at')
                 ->where('si.StatusName', 'AgentCommisionState')
                 ->get();
@@ -1793,9 +1793,9 @@ class GlobalController extends Controller
         $now_time = '2021-11-17 14:25:00';
 
         // 普通玩家 -- 控制分数
-        $ptAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-                ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
-                ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
+        $ptAccounts = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.IDWhiteUser as iu WITH (NOLOCK)'), 'ai.UserID', 'iu.UserID')
+                ->join(DB::raw('QPRecordDB.dbo.RecordUserScoreControl as rc WITH (NOLOCK)'), 'ai.UserID', 'rc.UserID')
                 ->whereNull('iu.UserID')
                 ->where('ControlDate', '>', $now_time)
                 ->where('ControlState', 0)
@@ -1803,9 +1803,9 @@ class GlobalController extends Controller
                 ->first()->ControlScore ?? 0;
 
         // 普通玩家 -- 控制赢分数
-        $ptWinAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-            ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
-            ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
+        $ptWinAccounts = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.IDWhiteUser as iu WITH (NOLOCK)'), 'ai.UserID', 'iu.UserID')
+            ->join(DB::raw('QPRecordDB.dbo.RecordUserScoreControl as rc WITH (NOLOCK)'), 'ai.UserID', 'rc.UserID')
             ->whereNull('iu.UserID')
             ->where('ControlDate', '>', $now_time)
             ->where('ControlState', 0)
@@ -1815,9 +1815,9 @@ class GlobalController extends Controller
 
 
         // 普通玩家 -- 控制输分数
-        $ptLoseAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-                ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
-                ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
+        $ptLoseAccounts = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.IDWhiteUser as iu WITH (NOLOCK)'), 'ai.UserID', 'iu.UserID')
+                ->join(DB::raw('QPRecordDB.dbo.RecordUserScoreControl as rc WITH (NOLOCK)'), 'ai.UserID', 'rc.UserID')
                 ->whereNull('iu.UserID')
                 ->where('ControlDate', '>', $now_time)
                 ->where('ControlState', 0)
@@ -1831,18 +1831,18 @@ class GlobalController extends Controller
         // +-------------------------------------
 
         // 官方玩家 -- 控制分数
-        $gfAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-                ->join('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
-                ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
+        $gfAccounts = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+                ->join(DB::raw('QPAccountsDB.dbo.IDWhiteUser as iu WITH (NOLOCK)'), 'ai.UserID', 'iu.UserID')
+                ->join(DB::raw('QPRecordDB.dbo.RecordUserScoreControl as rc WITH (NOLOCK)'), 'ai.UserID', 'rc.UserID')
                 ->where('ControlState', 0)
                 ->where('ControlDate', '>', $now_time)
                 ->selectRaw('sum(abs(ControlScore)) / 100 ControlScore')
                 ->first()->ControlScore ?? 0;
 
         // 官方玩家 -- 控制赢分数
-        $gfWinAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-            ->join('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
-            ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
+        $gfWinAccounts = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.IDWhiteUser as iu WITH (NOLOCK)'), 'ai.UserID', 'iu.UserID')
+            ->join(DB::raw('QPRecordDB.dbo.RecordUserScoreControl as rc WITH (NOLOCK)'), 'ai.UserID', 'rc.UserID')
             ->where('ControlState', 0)
             ->where('ControlDate', '>', $now_time)
             ->where('ControlScore', '>', 0)
@@ -1850,9 +1850,9 @@ class GlobalController extends Controller
             ->first();
 
         // 官方玩家 -- 控制输分数
-        $gfLoseAccounts = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-                ->join('QPAccountsDB.dbo.IDWhiteUser as iu', 'ai.UserID', 'iu.UserID')
-                ->join('QPRecordDB.dbo.RecordUserScoreControl as rc', 'ai.UserID', 'rc.UserID')
+        $gfLoseAccounts = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+                ->join(DB::raw('QPAccountsDB.dbo.IDWhiteUser as iu WITH (NOLOCK)'), 'ai.UserID', 'iu.UserID')
+                ->join(DB::raw('QPRecordDB.dbo.RecordUserScoreControl as rc WITH (NOLOCK)'), 'ai.UserID', 'rc.UserID')
                 ->where('ControlState', 0)
                 ->where('ControlDate', '>', $now_time)
                 ->where('ControlScore', '<', 0)
@@ -1879,8 +1879,8 @@ class GlobalController extends Controller
         if (!empty($start_time)) $where[] = ['CreateTime', '>=', $start_time];
         if (!empty($end_time)) $where[] = ['CreateTime', '<=', $end_time];
 
-        $list = DB::table(TableName::agent() . 'UserHeadAuditoria as ua')
-            ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ua.UserID', 'ai.UserID')
+        $list = DB::table(DB::raw(TableName::agent() . 'UserHeadAuditoria as ua WITH (NOLOCK)'))
+            ->join(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'), 'ua.UserID', 'ai.UserID')
             ->select('Image', 'GameID', 'ua.UserID', 'ua.CreateTime')
             ->where($where)->paginate(10);
 

+ 38 - 45
app/Http/Controllers/Admin/RechargeController.php

@@ -51,7 +51,7 @@ class RechargeController extends Controller
         // 操作人筛选:空=全部,0=无操作人,正整数=指定管理员 id
         $operator_admin_id = $request->input('operator_admin_id', '');
 
-        $type_list = DB::table('agent.dbo.admin_configs')->where('type', 'pay')
+        $type_list = DB::table(DB::raw('agent.dbo.admin_configs WITH (NOLOCK)'))->where('type', 'pay')
             ->pluck('name');
 //        $type_list[] = 'TestPay';
         $table = 'order as o';
@@ -59,17 +59,17 @@ class RechargeController extends Controller
             $table = 'order_back as o';
         }
 
-        $build_sql = DB::connection('write')->table($table)
-            ->leftjoin('order_goods as og', 'og.order_id', '=', 'o.id')
-            ->leftjoin('goods as g', 'og.goods_id', '=', 'g.id')
-            ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai', 'o.user_id', '=', 'ai.UserID')
-            ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as ascore', 'o.user_id', '=', 'ascore.UserID')
-            ->leftJoin('QPAccountsDB.dbo.AccountPhone as aphone', 'o.user_id', '=', 'aphone.UserID')
-            ->leftJoin('QPAccountsDB.dbo.AccountsRecord as ar', function ($join) {
+        $build_sql = DB::connection('write')->table(DB::raw($table . ' WITH (NOLOCK)'))
+            ->leftjoin(DB::raw('order_goods as og WITH (NOLOCK)'), 'og.order_id', '=', 'o.id')
+            ->leftjoin(DB::raw('goods as g WITH (NOLOCK)'), 'og.goods_id', '=', 'g.id')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'o.user_id', '=', 'ai.UserID')
+            ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreInfo as ascore WITH (NOLOCK)'), 'o.user_id', '=', 'ascore.UserID')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountPhone as aphone WITH (NOLOCK)'), 'o.user_id', '=', 'aphone.UserID')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsRecord as ar WITH (NOLOCK)'), function ($join) {
                 $join->on('o.id', '=', 'ar.RecordID');
                 $join->where('ar.type', 2);
             })
-            ->leftJoin('agent.dbo.admin_users as au', 'ar.admin_id', '=', 'au.id');
+            ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'ar.admin_id', '=', 'au.id');
 
 
         $where = [];
@@ -194,11 +194,10 @@ class RechargeController extends Controller
                 || (ctype_digit((string)$operator_admin_id) && (int)$operator_admin_id > 0));
 
         $aggregateBase = function () use ($table, $operatorFilterActive) {
-            $q = DB::connection('write')->table($table)
-                ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai', 'o.user_id', '=', 'ai.UserID')
-                ->lock('with(nolock)');
+            $q = DB::connection('write')->table(DB::raw($table . ' WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'o.user_id', '=', 'ai.UserID');
             if ($operatorFilterActive) {
-                $q->leftJoin('QPAccountsDB.dbo.AccountsRecord as ar', function ($join) {
+                $q->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsRecord as ar WITH (NOLOCK)'), function ($join) {
                     $join->on('o.id', '=', 'ar.RecordID');
                     $join->where('ar.type', 2);
                 });
@@ -266,7 +265,6 @@ class RechargeController extends Controller
                 ->selectRaw('o.order_sn,ai.GameID,o.payment_code,o.pay_status,o.amount,pay_at,o.created_at,o.after_amount,au.account,ai.Channel,ascore.Score as score,ascore.MaxScore as MaxScore,ascore.MaxWinScore as MaxWinScore')
                 ->orderByDesc('o.id')
                 ->where($where)
-                ->lock('with(nolock)')
                 ->get();
 
             foreach ($cellData as &$val) {
@@ -297,7 +295,6 @@ class RechargeController extends Controller
 
             $build_sql = $build_sql
                 ->selectRaw('o.*,og.goods_id,og.price as og_price,og.quantity as og_quantity,ai.GameID as ai_GameID,au.account,ar.RecordID,ar.remarks ar_remarks,ascore.Score as score,aphone.PhoneNum as Phone,ascore.MaxScore as MaxScore,ascore.MaxWinScore as MaxWinScore')
-                ->lock('with(nolock)')
                 ->where($where);
             if (!empty($amountSort)) {
                 $build_sql->orderBy('amount', $amountSort);
@@ -345,7 +342,7 @@ class RechargeController extends Controller
             // 充值档位金额从充值档位配置中动态获取,并加缓存(直接使用档位原始金额)
             $chargeMoneyList = Cache::remember('recharge_charge_money_list1', 600, function () {
                 return DB::connection('write')
-                    ->table('agent.dbo.recharge_gear')
+                    ->table(DB::raw('agent.dbo.recharge_gear WITH (NOLOCK)'))
                     ->where('status', 1)
                     ->where('first_pay', 0)
                     ->groupBy('money')
@@ -359,8 +356,8 @@ class RechargeController extends Controller
                 $viewAll=0;
             }
             $operatorOptions = DB::connection('write')
-                ->table('QPAccountsDB.dbo.AccountsRecord as ar')
-                ->join('agent.dbo.admin_users as au', 'ar.admin_id', '=', 'au.id')
+                ->table(DB::raw('QPAccountsDB.dbo.AccountsRecord as ar WITH (NOLOCK)'))
+                ->join(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'ar.admin_id', '=', 'au.id')
                 ->where('ar.type', 2)
                 ->whereNotNull('ar.admin_id')
                 ->select('au.id', 'au.account')
@@ -480,15 +477,15 @@ class RechargeController extends Controller
 //                ->groupBy('o.user_id', 'Recharge', 'a.GameID', 'a.NickName', 'a.LastLogonDate', 'a.RegisterDate', 'a.Experience', 'i.PhoneNum', 'ag.id', 'a.Channel')
 //                ->orderByRaw($order_sql)
 //                ->get();
-            $cellData = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
+            $cellData = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds WITH (NOLOCK)'))
                 ->where('Recharge', '>', 0)
-                ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ds.UserID', 'ai.UserID')
-                ->leftjoin('QPAccountsDB.dbo.AccountPhone as ap', 'ds.UserID', 'ap.UserID')
+                ->join(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'), 'ds.UserID', 'ai.UserID')
+                ->leftjoin(DB::raw('QPAccountsDB.dbo.AccountPhone as ap WITH (NOLOCK)'), 'ds.UserID', 'ap.UserID')
                 ->select('ai.UserID', 'ai.GameID', 'ai.NickName', 'ai.Channel', 'ap.PhoneNum', 'ds.Recharge', 'ai.PlayTimeCount', 'ai.LastLogonDate', 'ai.RegisterDate')
                 ->orderByDesc('Recharge')
                 ->get();
 
-            $pyq = DB::connection('write')->table('QPAccountsDB.dbo.PyqInfo')->select('UserID')->get();
+            $pyq = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.PyqInfo WITH (NOLOCK)'))->select('UserID')->get();
             $pyq_list = [];
             foreach ($pyq as $k => $v) {
                 $pyq_list[$v->UserID] = 1;
@@ -515,10 +512,10 @@ class RechargeController extends Controller
             downloadExcel($cellData, $title, '充值排行榜');
         } else {
 
-            $sql = DB::connection('write')->table('agent.dbo.order as o')
-                ->leftjoin('QPAccountsDB.dbo.AccountsInfo as a', 'o.user_id', '=', 'a.UserID')
-                ->leftjoin('QPAccountsDB.dbo.AccountPhone as i', 'o.user_id', '=', 'i.UserID')
-                ->leftjoin('QPAccountsDB.dbo.YN_VIPAccount as vip', 'o.user_id', '=', 'vip.UserID')
+            $sql = DB::connection('write')->table(DB::raw('agent.dbo.order as o WITH (NOLOCK)'))
+                ->leftjoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as a WITH (NOLOCK)'), 'o.user_id', '=', 'a.UserID')
+                ->leftjoin(DB::raw('QPAccountsDB.dbo.AccountPhone as i WITH (NOLOCK)'), 'o.user_id', '=', 'i.UserID')
+                ->leftjoin(DB::raw('QPAccountsDB.dbo.YN_VIPAccount as vip WITH (NOLOCK)'), 'o.user_id', '=', 'vip.UserID')
                 ->select(DB::raw('null as rank'), 'i.PhoneNum', 'o.user_id', 'a.GameID', 'a.NickName', 'Recharge as money', DB::raw('a.Experience,a.LastLogonDate,a.RegisterDate,DATEDIFF(DAY,a.LastLogonDate,GETDATE()) as time'), 'a.Channel');
 
             if (!empty($todayPayAmount)) {
@@ -542,7 +539,7 @@ class RechargeController extends Controller
             }
 
 
-            $todayPay = DB::connection('write')->table('agent.dbo.order')
+            $todayPay = DB::connection('write')->table(DB::raw('agent.dbo.order WITH (NOLOCK)'))
                 ->whereIn('user_id', $UserIDs)
                 ->where('pay_at', '>=', $pay_at_start_time . ' 00:00:00')
                 ->where('pay_at', '<=', $pay_at_end_time . ' 23:59:59')
@@ -645,21 +642,19 @@ class RechargeController extends Controller
 
         if ($excel && false) {
 
-            $cellData = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
+            $cellData = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds WITH (NOLOCK)'))
                 ->where('Recharge', '>', 0)
                 ->where($where2)
-                ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ds.UserID', 'ai.UserID')
-                ->leftjoin('QPAccountsDB.dbo.AccountPhone as ap', 'ds.UserID', 'ap.UserID')
+                ->join(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'), 'ds.UserID', 'ai.UserID')
+                ->leftjoin(DB::raw('QPAccountsDB.dbo.AccountPhone as ap WITH (NOLOCK)'), 'ds.UserID', 'ap.UserID')
                 ->select('ai.UserID','ai.GameID', 'ai.NickName', 'ai.Channel', 'ap.PhoneNum', 'ai.PlayTimeCount', 'ai.LastLogonDate', 'ai.RegisterDate')
-                ->lock('with(nolock)')
                 ->orderByRaw($order_sql)
                 ->get();
 
-            $rechargeSum = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
+            $rechargeSum = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds WITH (NOLOCK)'))
                 ->where('Recharge', '>', 0)
                 ->where($where)
                 ->selectRaw('sum(ds.Recharge) Recharge,UserID')
-                ->lock('with(nolock)')
                 ->groupBy('UserID')
                 ->pluck('Recharge', 'UserID')->toArray();
 
@@ -692,14 +687,13 @@ class RechargeController extends Controller
             downloadExcel($cellData, $title, '充值排行榜');
         } else {
 
-            $channelUsers=DB::table(TableName::QPAccountsDB() . 'AccountsInfo as ai')->where($channelWhere)->select('UserID');
-            $rechargeSum = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
+            $channelUsers=DB::table(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'))->where($channelWhere)->select('UserID');
+            $rechargeSum = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds WITH (NOLOCK)'))
                 ->where('Recharge', '>', 0)
                 ->where($where)
                 ->whereIn('UserID',$channelUsers)
                 ->selectRaw('sum(ds.Recharge) RechargeAll,UserID')
                 ->groupBy('UserID')
-                ->lock('with(nolock)')
                 ->orderByRaw($order_sql)
                 ->paginate(10);
 
@@ -712,11 +706,10 @@ class RechargeController extends Controller
             }
 
 
-            $list = DB::table(TableName::QPAccountsDB() . 'AccountsInfo as ai')
-                ->leftjoin('QPAccountsDB.dbo.AccountPhone as ap', 'ai.UserID', 'ap.UserID')
+            $list = DB::table(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'))
+                ->leftjoin(DB::raw('QPAccountsDB.dbo.AccountPhone as ap WITH (NOLOCK)'), 'ai.UserID', 'ap.UserID')
                 ->select('ai.UserID', 'ai.GameID', 'ai.NickName', 'ai.Channel', 'ap.PhoneNum', 'ai.PlayTimeCount', 'ai.LastLogonDate', 'ai.RegisterDate')
                 ->whereIn('ai.UserID',$UserIDs)
-                ->lock('with(nolock)')
                 ->get();
 
             foreach ($list as $key => &$value) {
@@ -1062,8 +1055,8 @@ class RechargeController extends Controller
 
     public function methods()
     {
-        $methods = DB::table('agent.dbo.admin_configs')
-            ->leftJoin('agent.dbo.admin_users as u', 'admin_configs.admin_id', '=', 'u.id')
+        $methods = DB::table(DB::raw('agent.dbo.admin_configs WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('agent.dbo.admin_users as u WITH (NOLOCK)'), 'admin_configs.admin_id', '=', 'u.id')
             ->select('admin_configs.*', 'u.account')
             ->where('admin_configs.type', 'pay_method')
             ->get();
@@ -1272,9 +1265,9 @@ class RechargeController extends Controller
     public function ip_white(Request $request)
     {
 
-        $list = DB::connection('write')->table('agent.dbo.admin_configs as ac')
-            ->leftJoin('agent.dbo.recharge_ip as ri', 'ac.id', '=', 'ri.config_id')
-            ->leftJoin('agent.dbo.admin_users as au', 'ri.admin_id', 'au.id')
+        $list = DB::connection('write')->table(DB::raw('agent.dbo.admin_configs as ac WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('agent.dbo.recharge_ip as ri WITH (NOLOCK)'), 'ac.id', '=', 'ri.config_id')
+            ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'ri.admin_id', 'au.id')
             ->where('ac.status', 1)
             ->select('ac.id', 'ac.name', 'ac.config_value', 'ip', 'account', 'last_time', 'ac.status', 'ri.remarks')
             ->paginate(5);
@@ -1468,7 +1461,7 @@ class RechargeController extends Controller
     public function gift_list(Request $request)
     {
         try {
-            $list = DB::connection('write')->table('agent.dbo.recharge_gift')
+            $list = DB::connection('write')->table(DB::raw('agent.dbo.recharge_gift WITH (NOLOCK)'))
                 ->orderBy('id', 'desc')
                 ->paginate(10);
 

+ 3 - 3
app/Http/Controllers/Admin/SignInController.php

@@ -12,7 +12,7 @@ class SignInController
 {
     public function index(Request $request)
     {
-
+        return false;
         $start_time = $request->start_time ?: date('Y-m-d').' 00:00:00';
         $end_time = $request->end_time ?: date('Y-m-d').' 23:59:59';
         $GameID = $request->GameID ?: '';
@@ -45,8 +45,8 @@ class SignInController
         $table = 'QPTreasureDB.dbo.YN_RecordScoreInfo_'.$from_mm;
         //////////////////////
 
-        $list = DB::connection('write')->table($table.' as ri')
-            ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'ri.UserID', 'ai.UserID')
+        $list = DB::connection('write')->table(DB::raw($table.' as ri WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'ri.UserID', 'ai.UserID')
             ->where($where)
             ->selectRaw('ri.*,ai.GameID,ai.NickName,Channel')
             ->orderByDesc('UpdateTime')

+ 67 - 68
app/Http/Controllers/Admin/UserController.php

@@ -42,11 +42,11 @@ class UserController extends Controller
         !empty($nickname) ? $where[] = ['ai.NickName', 'like', '%' . $nickname . '%'] : '';
         !empty($mobile) ? $where[] = ['ap.PhoneNum', '=', $mobile] : '';
         if ($excel) {
-            $cellData = DB::table('QPAccountsDB.dbo.AccountsInfo as ai')
-                ->leftJoin('QPAccountsDB.dbo.AccountsInfo as aci', 'ai.SpreaderID', '=', 'aci.UserID')
-                ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as gi', 'ai.UserID', '=', 'gi.UserID')
-                ->leftJoin('QPAccountsDB.dbo.AccountPhone as ap', 'ai.UserID', '=', 'ap.UserID')
-                ->leftJoin('QPAccountsDB.dbo.YN_VIPAccount as v', 'ai.UserID', '=', 'v.UserID')
+            $cellData = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as aci WITH (NOLOCK)'), 'ai.SpreaderID', '=', 'aci.UserID')
+                ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreInfo as gi WITH (NOLOCK)'), 'ai.UserID', '=', 'gi.UserID')
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountPhone as ap WITH (NOLOCK)'), 'ai.UserID', '=', 'ap.UserID')
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.YN_VIPAccount as v WITH (NOLOCK)'), 'ai.UserID', '=', 'v.UserID')
                 ->select('ai.NickName', 'v.Recharge', 'ai.LastLogonDate', 'ai.GameID', 'ai.MemberOrder', 'ai.RegisterDate', 'ai.UserID', 'gi.Score', 'ai.MemberOverDate', 'ap.PhoneNum', 'gi.BankScore', 'ai.Channel', 'ai.PassPortID', 'gi.InsureScore', 'aci.NickName as SpreaderName', 'ai.Compellation', 'gi.Revenue', 'aci.GameID as SpreaderGameID', 'ai.LastLogonMobile', 'ai.Experience', 'aci.UserID as SpreaderUserID')
                 ->where($where)
                 ->orderBy('ai.UserID', 'ASC')
@@ -77,11 +77,11 @@ class UserController extends Controller
             $cellData = json_decode(json_encode($cellData), true);
             downloadExcel($cellData, $title, '用户查询' . date('YmdHis'));
         } else {
-            $list = DB::table('QPAccountsDB.dbo.AccountsInfo as ai')
-                ->leftJoin('QPAccountsDB.dbo.AccountsInfo as aci', 'ai.SpreaderID', '=', 'aci.UserID')
-                ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as gi', 'ai.UserID', '=', 'gi.UserID')
-                ->leftJoin('QPAccountsDB.dbo.AccountPhone as ap', 'ai.UserID', '=', 'ap.UserID')
-                ->leftJoin('QPAccountsDB.dbo.YN_VIPAccount as v', 'ai.UserID', '=', 'v.UserID')
+            $list = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as aci WITH (NOLOCK)'), 'ai.SpreaderID', '=', 'aci.UserID')
+                ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreInfo as gi WITH (NOLOCK)'), 'ai.UserID', '=', 'gi.UserID')
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountPhone as ap WITH (NOLOCK)'), 'ai.UserID', '=', 'ap.UserID')
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.YN_VIPAccount as v WITH (NOLOCK)'), 'ai.UserID', '=', 'v.UserID')
                 ->select('v.Recharge', 'ai.UserID', 'ai.GameID', 'ai.NickName', 'ai.SpreaderID', 'ai.LastLogonDate', 'ai.Nullity', 'ai.Channel', 'ai.PlayTimeCount', 'ai.RegisterDate', 'ai.MemberOrder', 'ai.MemberOverDate', 'ai.LastLogonMobile', 'ai.Experience', 'aci.NickName as SpreaderName', 'aci.GameID as SpreaderGameID', 'aci.UserID as SpreaderUserID', 'gi.InsureScore', 'gi.Score', 'gi.BankScore', 'gi.Revenue', 'ap.PhoneNum', 'ai.PassPortID', 'ai.Compellation')
                 ->where($where)
                 ->orderBy('ai.UserID', 'ASC')
@@ -124,16 +124,16 @@ class UserController extends Controller
         !empty($end_time) ? $where[] = ['ai.RegisterDate', '<=', date('Y-m-d', strtotime("$end_time+1day"))] : '';
         !empty($goldmin) ? $where[] = ['gi.Score', '<>', $goldmin] : '';
         if ($excel) {
-            $cellData = DB::table('QPAccountsDB.dbo.AccountsInfo as ai')
-                ->leftJoin('QPAccountsDB.dbo.AccountsInfo as aci', 'ai.SpreaderID', '=', 'aci.UserID')
-                ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as gi', 'ai.UserID', '=', 'gi.UserID')
-                ->leftJoin('QPAccountsDB.dbo.YN_VIPAccount as v', 'ai.UserID', '=', 'v.UserID')
+            $cellData = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as aci WITH (NOLOCK)'), 'ai.SpreaderID', '=', 'aci.UserID')
+                ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreInfo as gi WITH (NOLOCK)'), 'ai.UserID', '=', 'gi.UserID')
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.YN_VIPAccount as v WITH (NOLOCK)'), 'ai.UserID', '=', 'v.UserID')
                 ->select('ai.NickName', 'v.Recharge','gi.WinCount','gi.LostCount', 'ai.GameID','ai.LastLogonDate','ai.RegisterDate', 'ai.UserID','gi.Score')
                 ->where($where)
                 ->orderBy('ai.UserID', 'ASC')
                 ->get();
             foreach ($cellData as $key => &$value) {
-                $gameCount = DB::table(TableName::QPRecordDB() . 'RecordUserGameCount')
+                $gameCount = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserGameCount WITH (NOLOCK)'))
                     ->where('UserID',$value->UserID)
                     ->pluck('Cnt', 'GameID')->toArray();
 
@@ -152,16 +152,16 @@ class UserController extends Controller
             $cellData = json_decode(json_encode($cellData), true);
             downloadExcel($cellData, $title, '用户查询' . date('YmdHis'));
         } else {
-            $list = DB::table('QPAccountsDB.dbo.AccountsInfo as ai')
-                ->leftJoin('QPAccountsDB.dbo.AccountsInfo as aci', 'ai.SpreaderID', '=', 'aci.UserID')
-                ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as gi', 'ai.UserID', '=', 'gi.UserID')
-                ->leftJoin('QPAccountsDB.dbo.YN_VIPAccount as v', 'ai.UserID', '=', 'v.UserID')
+            $list = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as aci WITH (NOLOCK)'), 'ai.SpreaderID', '=', 'aci.UserID')
+                ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreInfo as gi WITH (NOLOCK)'), 'ai.UserID', '=', 'gi.UserID')
+                ->leftJoin(DB::raw('QPAccountsDB.dbo.YN_VIPAccount as v WITH (NOLOCK)'), 'ai.UserID', '=', 'v.UserID')
                 ->select('ai.NickName', 'v.Recharge','gi.WinCount','gi.LostCount', 'ai.GameID','ai.LastLogonDate','ai.RegisterDate', 'ai.UserID','gi.Score')
                 ->where($where)
                 ->orderBy('ai.UserID', 'ASC')
                 ->get();
             foreach ($list as $key => &$value) {
-                $gameCount = DB::table(TableName::QPRecordDB() . 'RecordUserGameCount')
+                $gameCount = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserGameCount WITH (NOLOCK)'))
                     ->where('UserID',$value->UserID)
                     ->pluck('Cnt', 'GameID')->toArray();
 
@@ -183,8 +183,8 @@ class UserController extends Controller
     //用户分布
     public function userClassify(Request $request)
     {
-        $player_list = DB::table('QPAccountsDB.dbo.AccountsInfo as ai')
-            ->leftJoin('QPAccountsDB.dbo.YN_VIPAccount as va', 'ai.UserID', '=', 'va.UserID')
+        $player_list = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.YN_VIPAccount as va WITH (NOLOCK)'), 'ai.UserID', '=', 'va.UserID')
             ->where('IsAndroid', 0)
             ->whereIn('LastLogonMobile', ['Android', 'IOS'])
             ->select('ai.LastLogonMobile', 'ai.UserID', 'va.Recharge', 'ai.LastLogonDate', 'ai.Gender')
@@ -283,8 +283,8 @@ class UserController extends Controller
         !empty($order_title) ? $where[] = ['order.order_title', 'like', '%' . $order_title . '%'] : '';
         !empty($order_sn) ? $where[] = ['order.order_sn', '=', $order_sn] : '';
 
-        $list = DB::connection('write')->table('order')
-            ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai', 'order.user_id', '=', 'ai.UserID')
+        $list = DB::connection('write')->table(DB::raw('[order] WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'order.user_id', '=', 'ai.UserID')
             ->select('order.finished_at', 'order.order_sn', 'order.payment_sn', 'order.trade_sn', 'order.order_title', 'order.amount', 'ai.GameID', 'ai.NickName')
             ->where($where)
             ->orderby('order.finished_at', 'desc')
@@ -311,10 +311,10 @@ class UserController extends Controller
         !empty($game) ? $where[] = ['gi.GameID', '=', $game] : '';
         !empty($type) ? $where[] = ['gi.SortID', '=', $type] : '';
 
-        $list = DB::table('QPTreasureDB.dbo.RecordDrawScore as rs')
-            ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai', 'rs.UserID', '=', 'ai.UserID')
-            ->leftJoin('QPTreasureDB.dbo.RecordDrawInfo as ri', 'rs.DrawID', '=', 'ri.DrawID')
-            ->leftJoin('QPPlatformDB.dbo.GameRoomInfo as gi', 'ri.ServerID', '=', 'gi.ServerID')
+        $list = DB::table(DB::raw('QPTreasureDB.dbo.RecordDrawScore as rs WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'rs.UserID', '=', 'ai.UserID')
+            ->leftJoin(DB::raw('QPTreasureDB.dbo.RecordDrawInfo as ri WITH (NOLOCK)'), 'rs.DrawID', '=', 'ri.DrawID')
+            ->leftJoin(DB::raw('QPPlatformDB.dbo.GameRoomInfo as gi WITH (NOLOCK)'), 'ri.ServerID', '=', 'gi.ServerID')
             ->select('rs.DrawID', 'rs.PlayTimeCount', 'rs.Score', 'rs.Revenue', 'rs.InsertTime', 'ai.NickName', 'ai.GameID', 'ri.ServerID', 'gi.ServerName', 'gi.SortID')
             ->where($where)
             ->orderBy('rs.InsertTime', 'desc')
@@ -383,10 +383,10 @@ class UserController extends Controller
         $table = 'QPTreasureDB.dbo.YN_RecordScoreInfo_' . $from_mm;
         //////////////////////
 
-        $list = DB::table($table . ' as si')
-            ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai', 'si.UserID', '=', 'ai.UserID')
-            ->leftJoin('QPPlatformDB.dbo.GameRoomInfo as ri', 'ri.ServerID', '=', 'si.ServerID')
-            ->join('QPRecordDB.dbo.YN_RecordScoreConfig as sc', 'sc.Reason', '=', 'si.Reason')
+        $list = DB::table(DB::raw($table . ' as si WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'si.UserID', '=', 'ai.UserID')
+            ->leftJoin(DB::raw('QPPlatformDB.dbo.GameRoomInfo as ri WITH (NOLOCK)'), 'ri.ServerID', '=', 'si.ServerID')
+            ->join(DB::raw('QPRecordDB.dbo.YN_RecordScoreConfig as sc WITH (NOLOCK)'), 'sc.Reason', '=', 'si.Reason')
             ->select('si.UserID', 'si.BeforeScore', 'si.ChangeScore', 'si.AfterScore', 'si.UpdateTime', 'ai.NickName', 'ai.GameID', 'sc.Describe', 'ri.ServerName', 'ri.SortID')
             ->where($where)
             ->orderBy('UpdateTime', 'desc')
@@ -436,8 +436,8 @@ class UserController extends Controller
         !empty($end_time) ? $where[] = ['si.UpdateTime', '<=', date('Y-m-d', strtotime("$end_time+1day"))] : '';
         !empty($describe) ? $where[] = ['Describe', 'like', '%' . trim($describe, " ") . '%'] : '';
 
-        $list = DB::connection('write')->table('QPRecordDB.dbo.YN_RecordRevenueInfo as si')
-            ->leftJoin('QPRecordDB.dbo.YN_RecordScoreConfig as sc', 'sc.Reason', '=', 'si.Reason')
+        $list = DB::connection('write')->table(DB::raw('QPRecordDB.dbo.YN_RecordRevenueInfo as si WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPRecordDB.dbo.YN_RecordScoreConfig as sc WITH (NOLOCK)'), 'sc.Reason', '=', 'si.Reason')
             ->select('si.*', 'sc.Describe')
             ->where($where)
             ->orderBy('si.UpdateTime', 'desc')
@@ -558,7 +558,7 @@ class UserController extends Controller
         } else {
             $where[] = ['RegisterDate', '<=', $end_time];
         }
-        $user_info = DB::table('QPAccountsDB.dbo.AccountsInfo')
+        $user_info = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->select('NickName', 'UserID')
             ->where('GameID', $game_id)
             ->first();
@@ -568,37 +568,37 @@ class UserController extends Controller
         $user_id = $user_info->UserID;
         !empty($user_id) ? $where[] = ['SpreaderID', '=', $user_id] : '';
         //推广员姓名
-        $name = DB::table('agent')->Where('UserID', $user_id)->value('name');
+        $name = DB::table(DB::raw('agent WITH (NOLOCK)'))->Where('UserID', $user_id)->value('name');
         //推广总用户数
-        $children_count = DB::table('QPAccountsDB.dbo.AccountsInfo')
+        $children_count = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->where($where)
             ->count();
         //活跃用户
-        $live_users = DB::table('QPAccountsDB.dbo.AccountsInfo')
+        $live_users = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->where($where)
             ->where('LastLogonDate', '>=', date('Y-m-d', strtotime('-7 days')))
             ->count();
         //有效用户
-        $eff_user = DB::table('QPAccountsDB.dbo.AccountsInfo')
+        $eff_user = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->where($where)
             ->where('Experience', '>=', 6000)
             ->count();
         //流失用户
-        $sleep_users = DB::table('QPAccountsDB.dbo.AccountsInfo')
+        $sleep_users = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->where($where)
             ->where('LastLogonDate', '<=', date('Y-m-d', strtotime('-7 days')))
             ->count();
         //已提收益
-        $gold = DB::table('QPAccountsDB.dbo.YN_Withdrawal')
+        $gold = DB::table(DB::raw('QPAccountsDB.dbo.YN_Withdrawal WITH (NOLOCK)'))
             ->selectRaw('sum(Gold) as gold')
             ->where('UserID', $user_id)
             ->value('gold');
         //计提收益
-        $revenue = DB::table('QPAccountsDB.dbo.YN_Agent')
+        $revenue = DB::table(DB::raw('QPAccountsDB.dbo.YN_Agent WITH (NOLOCK)'))
             ->where('UserID', $user_id)
             ->value('Revenue');
         //总收益
-        $revenue_sum = DB::table('QPTreasureDB.dbo.YN_HistoryPerformance')
+        $revenue_sum = DB::table(DB::raw('QPTreasureDB.dbo.YN_HistoryPerformance WITH (NOLOCK)'))
             ->select(DB::raw('sum(ProfitGold0+ProfitGold1+ProfitGold2) as revenue_sum'))
             ->where('UserID', $user_id)
             ->where('BalanceDate', '>=', $start_time)
@@ -644,12 +644,12 @@ class UserController extends Controller
         for ($start = $begintime; $start <= $endtime; $start += 24 * 3600) {
             $date_arr[] = ['date' => date("Y-m-d", $start)];
         }
-        $user_info = DB::table('QPAccountsDB.dbo.AccountsInfo')
+        $user_info = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->select('NickName', 'GameID')
             ->where('UserID', $user_id)
             ->first();
         //每日新增
-        $add_users_list = DB::table('QPAccountsDB.dbo.AccountsInfo')
+        $add_users_list = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->selectRaw('CONVERT(varchar(100),RegisterDate,23) as date,count(*) as count')
             ->where($where)
             ->where('SpreaderID', $user_id)
@@ -657,7 +657,7 @@ class UserController extends Controller
             ->get();
         // print_r($add_users_list);exit;
         //每日收益
-        $revenue_sum_list = DB::table('QPTreasureDB.dbo.YN_HistoryPerformance')
+        $revenue_sum_list = DB::table(DB::raw('QPTreasureDB.dbo.YN_HistoryPerformance WITH (NOLOCK)'))
             ->selectRaw('BalanceDate,sum(ProfitGold0+ProfitGold1+ProfitGold2) as revenue_sum')
             ->where('BalanceDate', '>=', $start_time)
             ->where('BalanceDate', '<=', $end_time)
@@ -671,7 +671,7 @@ class UserController extends Controller
         foreach ($add_users_list as $key => $value) {
             $add_users[$value->date] = $value->count;
         }
-        $retain_users = DB::table('QPAccountsDB.dbo.AccountsInfo')
+        $retain_users = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->select('UserID', DB::raw('CONVERT(varchar(100),RegisterDate,23) as date'))
             ->where('SpreaderID', $user_id)
             ->whereIn(DB::raw('CONVERT(varchar(100),RegisterDate,23)'), $date_arr)
@@ -688,7 +688,7 @@ class UserController extends Controller
                 $value['revenue_sum'] = 0;
             }
             $date = $value['date'];
-            $retain_users = DB::table('QPAccountsDB.dbo.AccountsInfo')
+            $retain_users = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
                 ->select('UserID', DB::raw('CONVERT(varchar(100),RegisterDate,23) as date'))
                 ->where('SpreaderID', $user_id)
                 ->where(DB::raw('CONVERT(varchar(100),RegisterDate,23)'), date('Y-m-d', strtotime("$date-2 days")))
@@ -698,14 +698,14 @@ class UserController extends Controller
             $count = 0;
             if ($retain_users) {
                 foreach ($retain_users as $k => $v) {
-                    $count += DB::table('QPAccountsDB.dbo.AccountsInfo')
+                    $count += DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
                         ->where('UserID', $v->UserID)
                         ->where(DB::raw('CONVERT(varchar(100),LastLogonDate,23)'), date('Y-m-d', strtotime("$v->date+1 days")))
                         ->count();
                 }
             }
             //每日流失
-            $sleep_users = DB::table('QPAccountsDB.dbo.AccountsInfo')
+            $sleep_users = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
                 ->where('SpreaderID', $user_id)
                 ->where('LastLogonDate', '<=', date('Y-m-d', strtotime("$date-7 days")))
                 ->count();
@@ -735,12 +735,12 @@ class UserController extends Controller
         } else {
             $where[] = ['ai.RegisterDate', '<=', $end_time];
         }
-        $user_info = DB::table('QPAccountsDB.dbo.AccountsInfo')
+        $user_info = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->select('NickName', 'GameID')
             ->where('UserID', $user_id)
             ->first();
-        $add_users_list = DB::table('QPAccountsDB.dbo.AccountsInfo as ai')
-            ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ais', 'ais.SpreaderID', '=', 'ai.UserID')
+        $add_users_list = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as ais WITH (NOLOCK)'), 'ais.SpreaderID', '=', 'ai.UserID')
             ->selectRaw('ai.UserID,ai.NickName,count(ais.UserID) as count')
             ->where($where)
             ->groupBy('ai.UserID', 'ai.NickName')
@@ -750,7 +750,7 @@ class UserController extends Controller
         // $add_users_val = array_column(json_decode(json_encode($add_users_list),true),'UserID');
         // print_r($add_users_val);
         // 活跃用户
-        $live_list = DB::table('QPAccountsDB.dbo.AccountsInfo')
+        $live_list = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->selectRaw('SpreaderID,count(*) as count')
             ->where('RegisterDate', '>=', $start_time)
             ->where('RegisterDate', '<=', $end_time)
@@ -763,7 +763,7 @@ class UserController extends Controller
             $lives[$value->SpreaderID] = $value->count;
         }
         //收益
-        $revenue_sum = DB::table('QPTreasureDB.dbo.YN_HistoryPerformance')
+        $revenue_sum = DB::table(DB::raw('QPTreasureDB.dbo.YN_HistoryPerformance WITH (NOLOCK)'))
             ->selectRaw('UserID,sum(ProfitGold0+ProfitGold1+ProfitGold2) as revenue_sum')
             ->whereIn('UserID', $add_users_val)
             ->where('BalanceDate', '>=', $start_time)
@@ -811,10 +811,10 @@ class UserController extends Controller
             $where[] = ['code.UpdateTime', '<=', $end_time];
         }
 
-        $list = DB::table('QPAccountsDB.dbo.YN_UniqueCode as code')
-            ->leftJoin('QPAccountsDB.dbo.YN_MatchProp as prop', 'code.PropID', '=', 'prop.PropID')
-            ->leftJoin('QPAccountsDB.dbo.AccountsInfo as account', 'code.UserID', '=', 'account.UserID')
-            ->leftJoin('agent.dbo.agent as agent', 'code.agent_id', '=', 'agent.id')
+        $list = DB::table(DB::raw('QPAccountsDB.dbo.YN_UniqueCode as code WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.YN_MatchProp as prop WITH (NOLOCK)'), 'code.PropID', '=', 'prop.PropID')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as account WITH (NOLOCK)'), 'code.UserID', '=', 'account.UserID')
+            ->leftJoin(DB::raw('agent.dbo.agent as agent WITH (NOLOCK)'), 'code.agent_id', '=', 'agent.id')
             ->selectRaw('account.NickName,prop.PropName,prop.Description,agent.name,code.UpdateTime,code.agent_id')
             ->where($where)
             ->orderBy('code.UpdateTime', 'desc')
@@ -936,9 +936,9 @@ class UserController extends Controller
         !empty($GameID) && $where[] = ['ai.GameID', $GameID];
 
 
-        $list = DB::connection('read')->table('QPAccountsDB.dbo.UserAgent as ua')
-            ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'ua.UserID', 'ai.UserID')
-            ->join('QPAccountsDB.dbo.AccountsInfo as ai1', 'ua.Higher1ID', 'ai1.UserID')
+        $list = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.UserAgent as ua WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'ua.UserID', 'ai.UserID')
+            ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai1 WITH (NOLOCK)'), 'ua.Higher1ID', 'ai1.UserID')
             ->select('ai.GameID', 'ai.UserID', 'ai.RegisterDate', 'ai.LastLogonDate', 'ai1.GameID as SpreaderID', 'ai1.UserID as ai1UserID')
             ->where('Higher1ID', '>', 0)
             ->where($where)
@@ -954,14 +954,13 @@ class UserController extends Controller
 
     public function moneyDeviation(Request $request)
     {
-        $query = DB::table('QPRecordDB.dbo.RecordUserTotalStatistics as ru')
+        $query = DB::table(DB::raw('QPRecordDB.dbo.RecordUserTotalStatistics as ru WITH (NOLOCK)'))
             ->leftJoin(
-                'QPAccountsDB.dbo.AccountsInfo as ai',
+                DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'),
                 'ai.UserID',
                 '=',
                 'ru.UserID'
-            )
-            ->lock('with(nolock)');
+            );
         if ($request->input('sort')) {
             $query->orderByRaw($request->input('sort'));
         }
@@ -1010,7 +1009,7 @@ class UserController extends Controller
                     foreach ($res as $k => $v) {
                         $userInfos[$v->UserID] = $v;
                     }
-                    $res1 = DB::table('QPRecordDB.dbo.RecordUserDataStatisticsNew')->whereIn('UserID', $userIDs)
+                    $res1 = DB::table(DB::raw('QPRecordDB.dbo.RecordUserDataStatisticsNew WITH (NOLOCK)'))->whereIn('UserID', $userIDs)
                         ->where('DateID', date('Ymd'))
                         ->get();
                     $statNew = [];
@@ -1061,7 +1060,7 @@ class UserController extends Controller
             foreach ($res as $k => $v) {
                 $userInfos[$v->UserID] = $v;
             }
-            $res1 = DB::table('QPRecordDB.dbo.RecordUserDataStatisticsNew')->whereIn('UserID', $userIDs)
+            $res1 = DB::table(DB::raw('QPRecordDB.dbo.RecordUserDataStatisticsNew WITH (NOLOCK)'))->whereIn('UserID', $userIDs)
                 ->where('DateID', date('Ymd'))
                 ->get();
             $statNew = [];

+ 60 - 60
app/Http/Controllers/Admin/WithdrawalController.php

@@ -105,7 +105,7 @@ class WithdrawalController extends BaseController
             DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId',$ID)->update(['State'=>1]);
             return json_encode(['id'=>$ID]);
         }
-        $list=DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
+        $list=DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.OrderWithDraw WITH (NOLOCK)'))
             ->where('State','=',5)
             ->get()->toArray();
 //        print_r($list);die;
@@ -173,7 +173,7 @@ class WithdrawalController extends BaseController
         $register_end_time = $request->input('register_end_time');
 
         $list = $this->logic->waitWithdrawal($GameID, $withdraw_search, $withdraw, $state, $start_time, $end_time, $agent, true, '', $orderID, $final_start_time, $final_end_time, $excel, $Channel, $payState, $take_effect, $isEmpty, $register_start_time, $register_end_time, $PackgeName,2);
-        $list['agents'] = DB::table('agent.dbo.admin_configs')
+        $list['agents'] = DB::table(DB::raw('agent.dbo.admin_configs WITH (NOLOCK)'))
             ->where('type', 'cash')
             ->get();
         $list['request'] = $request;
@@ -236,63 +236,63 @@ class WithdrawalController extends BaseController
 //            ->select('StatusValue', 'account', 'create_at')
 //            ->first();
 
-        $fee = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
-            ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
+        $fee = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo as si WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('agent.dbo.SystemStatusInfo_log as log WITH (NOLOCK)'), function($join) {
                 $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
             })
-            ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
+            ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'log.admin_id', '=', 'au.id')
             ->where('si.StatusName', 'WithDrawTax')
             ->select('StatusValue', 'account', 'create_at')
             ->first();
 
-        $artificial = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
-            ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
+        $artificial = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo as si WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('agent.dbo.SystemStatusInfo_log as log WITH (NOLOCK)'), function($join) {
                 $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
             })
-            ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
+            ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'log.admin_id', '=', 'au.id')
             ->where('si.StatusName', 'WithDrawAILimit')
             ->select('StatusValue', 'account', 'create_at')
             ->first();
-        $proportion = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
-            ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
+        $proportion = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo as si WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('agent.dbo.SystemStatusInfo_log as log WITH (NOLOCK)'), function($join) {
                 $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
             })
-            ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
+            ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'log.admin_id', '=', 'au.id')
             ->where('si.StatusName', 'WithDrawRate')
             ->select('StatusValue', 'account', 'create_at')
             ->first();
-        $WithDrawMin = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
-            ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
+        $WithDrawMin = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo as si WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('agent.dbo.SystemStatusInfo_log as log WITH (NOLOCK)'), function($join) {
                 $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
             })
-            ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
+            ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'log.admin_id', '=', 'au.id')
             ->where('si.StatusName', 'WithDrawMin')
             ->select('StatusValue', 'account', 'create_at')
             ->first();
 
-        $WithDrawMax = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
-            ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
+        $WithDrawMax = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo as si WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('agent.dbo.SystemStatusInfo_log as log WITH (NOLOCK)'), function($join) {
                 $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
             })
-            ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
+            ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'log.admin_id', '=', 'au.id')
             ->where('si.StatusName', 'WithDrawMax')
             ->select('StatusValue', 'account', 'create_at')
             ->first();
 
-        $WithDrawPoint = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
-            ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
+        $WithDrawPoint = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo as si WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('agent.dbo.SystemStatusInfo_log as log WITH (NOLOCK)'), function($join) {
                 $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
             })
-            ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
+            ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'log.admin_id', '=', 'au.id')
             ->where('si.StatusName', 'WithDrawPoint')
             ->select('StatusValue', 'account', 'create_at')
             ->first();
 
-        $MaxTXNotRecharge = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
-            ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
+        $MaxTXNotRecharge = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo as si WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('agent.dbo.SystemStatusInfo_log as log WITH (NOLOCK)'), function($join) {
                 $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
             })
-            ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
+            ->leftJoin(DB::raw('agent.dbo.admin_users as au WITH (NOLOCK)'), 'log.admin_id', '=', 'au.id')
             ->where('si.StatusName', 'MaxTXNotRecharge')
             ->select('StatusValue', 'account', 'create_at')
             ->first();
@@ -322,7 +322,7 @@ class WithdrawalController extends BaseController
             return apiReturnSuc('success');
         }
 
-        $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawPoint')->value('StatusValue') / 100 ?? 0;
+        $result = DB::table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo WITH (NOLOCK)'))->where('StatusName', 'WithDrawPoint')->value('StatusValue') / 100 ?? 0;
         return view('admin.Withdrawal.WithDrawPoint', ['info' => $result]);
     }
 
@@ -343,7 +343,7 @@ class WithdrawalController extends BaseController
             return apiReturnSuc('success');
         }
 
-        $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawTax')->value('StatusValue');
+        $result = DB::table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo WITH (NOLOCK)'))->where('StatusName', 'WithDrawTax')->value('StatusValue');
         return view('admin.Withdrawal.fee', ['info' => $result]);
     }
 
@@ -362,7 +362,7 @@ class WithdrawalController extends BaseController
 
             return apiReturnSuc('success');
         }
-        $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawAILimit')->value('StatusValue');
+        $result = DB::table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo WITH (NOLOCK)'))->where('StatusName', 'WithDrawAILimit')->value('StatusValue');
         $result = $result / 100;
 
         return view('admin.Withdrawal.artificial', ['info' => $result]);
@@ -381,7 +381,7 @@ class WithdrawalController extends BaseController
             CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
             return apiReturnSuc('success');
         }
-        $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawRate')->value('StatusValue');
+        $result = DB::table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo WITH (NOLOCK)'))->where('StatusName', 'WithDrawRate')->value('StatusValue');
 
         return view('admin.Withdrawal.proportion', ['info' => $result]);
     }
@@ -399,7 +399,7 @@ class WithdrawalController extends BaseController
             CreateLog::SystemStatusInfo_log($admin_id, 'MaxTXNotRecharge');
             return apiReturnSuc('success');
         } else {
-            $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'MaxTXNotRecharge')->value('StatusValue');
+            $result = DB::table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo WITH (NOLOCK)'))->where('StatusName', 'MaxTXNotRecharge')->value('StatusValue');
 
             $result = $result > 0 ? floatval($result / NumConfig::NUM_VALUE) : 0;
 
@@ -412,7 +412,7 @@ class WithdrawalController extends BaseController
     public function show($sn = '')
     {
 
-        $notify = DB::table('QPAccountsDB.dbo.withdraw_notify')->where('order_sn', $sn)->select('extra')->first()->extra ?? '';
+        $notify = DB::table(DB::raw('QPAccountsDB.dbo.withdraw_notify WITH (NOLOCK)'))->where('order_sn', $sn)->select('extra')->first()->extra ?? '';
 
         if ($notify) {
             $notify = \GuzzleHttp\json_decode($notify);
@@ -434,7 +434,7 @@ class WithdrawalController extends BaseController
             CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
             return apiReturnSuc('success');
         }
-        $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawMax')->value('StatusValue');
+        $result = DB::table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo WITH (NOLOCK)'))->where('StatusName', 'WithDrawMax')->value('StatusValue');
 
         $result /= 100;
         return view('admin.Withdrawal.WithDrawMax', ['info' => $result]);
@@ -453,7 +453,7 @@ class WithdrawalController extends BaseController
             CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
             return apiReturnSuc('success');
         }
-        $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawMin')->value('StatusValue');
+        $result = DB::table(DB::raw('QPAccountsDB.dbo.SystemStatusInfo WITH (NOLOCK)'))->where('StatusName', 'WithDrawMin')->value('StatusValue');
         $result /= 100;
         return view('admin.Withdrawal.WithDrawMin', ['info' => $result]);
     }
@@ -464,27 +464,27 @@ class WithdrawalController extends BaseController
 
         $gear = $request->gear ?: '';
 
-        $info = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-            ->join('QPAccountsDB.dbo.AccountsInfo as ain', 'ai.RegisterIP', 'ain.RegisterIP')
+        $info = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ain WITH (NOLOCK)'), 'ai.RegisterIP', 'ain.RegisterIP')
             ->where('ai.UserID', $UserID)
             ->whereNotNull('ai.RegisterIP')
             ->selectRaw('count(1) count,ai.RegisterIP,ai.RegisterDate,ai.GameID,ai.NickName')
             ->groupBy('ai.GameID', 'ai.NickName', 'ai.RegisterIP', 'ai.RegisterDate')
             ->first();
         // 总对局数
-        $info->playerNum = DB::connection('read')->table(TableName::QPRecordDB() . 'RecordUserGameCount')
+        $info->playerNum = DB::connection('read')->table(DB::raw(TableName::QPRecordDB() . 'RecordUserGameCount WITH (NOLOCK)'))
             ->where('UserID', $UserID)
             ->sum('Cnt');
 
         // 推广佣金已领取 。
-        $info->commission = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew')
+        $info->commission = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserScoreStatisticsNew WITH (NOLOCK)'))
                 ->where('ScoreType', 53)
                 ->where('UserID', $UserID)
                 ->selectRaw('IsNull(sum(Score),0) Score')
                 ->first()->Score / NumConfig::NUM_VALUE ?? 0;
 
         // 推广佣金可领取 。
-        $waitCommission = DB::connection('read')->table('QPAccountsDB.dbo.UserAgent')
+        $waitCommission = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.UserAgent WITH (NOLOCK)'))
                 ->where('UserID', $UserID)
                 ->selectRaw('IsNull((Balance1 + Balance2),0) as  Balance')
                 ->first()->Balance ?? 0;
@@ -492,14 +492,14 @@ class WithdrawalController extends BaseController
 
 
         //今日彩金 -- 今日提现 -- 今日盈利 -- 今日充值
-        $info->today = DB::connection('read')->table('QPRecordDB.dbo.RecordUserDataStatisticsNew')
+        $info->today = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserDataStatisticsNew WITH (NOLOCK)'))
             ->where('UserID', $UserID)
             ->where('DateID', date('Ymd'))
             ->selectRaw('IsNull(sum(Handsel),0)Handsel,IsNull(sum(Withdraw),0) Withdraw,IsNull((sum(WinScore) + sum(LostScore)), 0) Score,sum(Recharge) Recharge')
             ->first();
 
         // 全部彩金 -- 总提现 -- 总盈利 -- 总充值
-        $info->total = DB::connection('read')->table('QPRecordDB.dbo.RecordUserTotalStatistics')
+        $info->total = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserTotalStatistics WITH (NOLOCK)'))
             ->where('UserID', $UserID)
             ->selectRaw('IsNull(sum(Handsel),0)Handsel,IsNull(sum(Withdraw),0) Withdraw,IsNull((sum(WinScore) + sum(LostScore)) , 0) Score,sum(Recharge) Recharge')
             ->first();
@@ -514,14 +514,14 @@ class WithdrawalController extends BaseController
         isset($info->today->Recharge) && $info->today->Recharge = number_float($info->today->Recharge);
 
         // 游戏对局数--分游戏
-        $gameCount = DB::connection('read')->table(TableName::QPRecordDB() . 'RecordUserGameCount')
+        $gameCount = DB::connection('read')->table(DB::raw(TableName::QPRecordDB() . 'RecordUserGameCount WITH (NOLOCK)'))
             ->where('UserID', $UserID)
             ->select('Cnt', 'GameID')
             ->pluck('Cnt', 'GameID')->toArray();
 
 
         // 提现完成时间
-        $info->finalTime = DB::connection('read')->table('QPAccountsDB.dbo.withdraw_notify')->where('user_id', $UserID)->orderByDesc('created_at')->value('finish_at');
+        $info->finalTime = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.withdraw_notify WITH (NOLOCK)'))->where('user_id', $UserID)->orderByDesc('created_at')->value('finish_at');
 
 
         $accountsInfo=new AccountsInfo();
@@ -562,7 +562,7 @@ class WithdrawalController extends BaseController
         switch ($type) {
             case 'RegisterIP':
                 $type = '注册IP';
-                $list = DB::table('QPAccountsDB.dbo.AccountsInfo')
+                $list = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
                     ->where('RegisterIP', $val)
                     ->where('IsAndroid', 0)
                     ->select('GameID', 'UserID')
@@ -570,8 +570,8 @@ class WithdrawalController extends BaseController
                 break;
             case 'BankNo':
                 $type = '卡号';
-                $list = DB::table('QPAccountsDB.dbo.AccountWithDrawInfo as di')
-                    ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
+                $list = DB::table(DB::raw('QPAccountsDB.dbo.AccountWithDrawInfo as di WITH (NOLOCK)'))
+                    ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'di.UserID', 'ai.UserID')
                     ->select('ai.GameID', 'ai.UserID')
                     ->where('di.BankNo', $val)
                     ->where('IsAndroid', 0)
@@ -579,7 +579,7 @@ class WithdrawalController extends BaseController
                 break;
             case 'LastLogonIP':
                 $type = '登录IP';
-                $list = DB::table('QPAccountsDB.dbo.AccountsInfo')
+                $list = DB::table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
                     ->where('LastLogonIP', $val)
                     ->where('IsAndroid', 0)
                     ->select('GameID', 'UserID')
@@ -694,8 +694,8 @@ class WithdrawalController extends BaseController
     // 提现免审
     public function exempt_review()
     {
-        $list = DB::connection('read')->table('agent.dbo.withdrawal_position_config as wp')
-            ->leftJoin('agent.dbo.admin_configs as cf', function ($join) {
+        $list = DB::connection('read')->table(DB::raw('agent.dbo.withdrawal_position_config as wp WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('agent.dbo.admin_configs as cf WITH (NOLOCK)'), function ($join) {
                 $join->on('cf.config_value', '=', 'wp.agent');
                 $join->where('cf.type', 'cash');
             })
@@ -704,7 +704,7 @@ class WithdrawalController extends BaseController
         foreach ($list as $value) {
 //            $value->quota = $value->quota / NumConfig::NUM_VALUE;
 //            $value->total_quota = $value->total_quota / NumConfig::NUM_VALUE;
-            $value->useQuota = DB::connection('read')->table('agent.dbo.withdrawal_position_log')
+            $value->useQuota = DB::connection('read')->table(DB::raw('agent.dbo.withdrawal_position_log WITH (NOLOCK)'))
                     ->whereDate('create_at', date('Y-m-d'))
                     ->where('config_id', $value->id)
                     ->sum('use_quota') / NumConfig::NUM_VALUE;
@@ -720,7 +720,7 @@ class WithdrawalController extends BaseController
     public function exempt_review_add(Request $request)
     {
         if ($request->isMethod('get')) {
-            $agent = DB::table('agent.dbo.admin_configs')
+            $agent = DB::table(DB::raw('agent.dbo.admin_configs WITH (NOLOCK)'))
                 ->where('type', 'cash')
                 ->where('status', 1)
                 ->get();
@@ -771,10 +771,10 @@ class WithdrawalController extends BaseController
         if ($request->isMethod('get')) {
 
             // 获取所有代付渠道配置(包括关闭的)
-            $agent = DB::table('agent.dbo.admin_configs')
+            $agent = DB::table(DB::raw('agent.dbo.admin_configs WITH (NOLOCK)'))
                 ->where('type', 'cash')
                 ->get();
-            $info = DB::table('agent.dbo.withdrawal_position_config')->find($id);
+            $info = DB::table(DB::raw('agent.dbo.withdrawal_position_config WITH (NOLOCK)'))->find($id);
 
             $info->game_time = $info->game_time > 0 ? $info->game_time / 60 : 0;
             return view('admin.Withdrawal.exempt_review_update', [
@@ -823,8 +823,8 @@ class WithdrawalController extends BaseController
     {
         if ($request->isMethod('get')) {
             // 获取所有提现渠道
-            $list = DB::table('agent.dbo.admin_configs')
-                ->leftJoin('agent.dbo.admin_users as u', 'admin_configs.admin_id', '=', 'u.id')
+            $list = DB::table(DB::raw('agent.dbo.admin_configs WITH (NOLOCK)'))
+                ->leftJoin(DB::raw('agent.dbo.admin_users as u WITH (NOLOCK)'), 'admin_configs.admin_id', '=', 'u.id')
                 ->select('admin_configs.*', 'u.account')
                 ->where('admin_configs.type', 'cash')
                 ->orderBy('admin_configs.id', 'asc')
@@ -918,7 +918,7 @@ class WithdrawalController extends BaseController
     public function cashier_channel_update(Request $request, $id)
     {
         if ($request->isMethod('get')) {
-            $info = DB::table('agent.dbo.admin_configs')
+            $info = DB::table(DB::raw('agent.dbo.admin_configs WITH (NOLOCK)'))
                 ->where('id', $id)
                 ->where('type', 'cash')
                 ->first();
@@ -1079,7 +1079,7 @@ class WithdrawalController extends BaseController
             $userID = AccountsInfo::where('GameID', $request->input('GameID'))->value('UserID');
             $query->where('user_id', intval($userID));
         }
-        $officials = DB::table('QPAccountsDB.dbo.IDWhiteUser')->pluck('UserID')->toArray();
+        $officials = DB::table(DB::raw('QPAccountsDB.dbo.IDWhiteUser WITH (NOLOCK)'))->pluck('UserID')->toArray();
 
         $list = $query->orderBy('id', 'desc')->paginate(20);
         return view('admin.Withdrawal.draw_base_change_log', [
@@ -1341,15 +1341,15 @@ class WithdrawalController extends BaseController
 
         if (true) {
 
-            $list = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
+            $list = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds WITH (NOLOCK)'))
                 ->where('Withdraw', '>', 0)
                 ->where($where)
-                ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ds.UserID', 'ai.UserID')
-                ->leftjoin('QPAccountsDB.dbo.AccountPhone as ap', 'ds.UserID', 'ap.UserID')
+                ->join(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'), 'ds.UserID', 'ai.UserID')
+                ->leftjoin(DB::raw('QPAccountsDB.dbo.AccountPhone as ap WITH (NOLOCK)'), 'ds.UserID', 'ap.UserID')
                 ->select('ai.UserID', 'ai.GameID', 'ai.NickName', 'ai.Channel', 'ap.PhoneNum', 'ai.PlayTimeCount', 'ai.LastLogonDate', 'ai.RegisterDate')
                 ->orderByRaw($order_sql)
                 ->paginate(10);
-            $rechargeSum = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
+            $rechargeSum = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds WITH (NOLOCK)'))
                 ->where('Withdraw', '>', 0)
                 ->where($where)
                 ->selectRaw('sum(ds.Withdraw) Withdraw,UserID')
@@ -1399,11 +1399,11 @@ class WithdrawalController extends BaseController
 
 
 
-        $sql = "select nums,BankUserName from (select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw group by BankUserName ) s where nums>1";
+        $sql = "select nums,BankUserName from (select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw WITH (NOLOCK) group by BankUserName ) s where nums>1";
 //        $sql = "select * from OrderWithDraw where BankUserName in (select BankUserName from (select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw group by BankUserName ) s where nums>1) order by BankUserName";
         $multiNames = DB::select($sql);
 
-        $sql="select nums,EmailAddress from (select count(distinct (UserID)) as nums,EmailAddress from QPAccountsDB.dbo.OrderWithDraw group by EmailAddress ) s where nums>1";
+        $sql="select nums,EmailAddress from (select count(distinct (UserID)) as nums,EmailAddress from QPAccountsDB.dbo.OrderWithDraw WITH (NOLOCK) group by EmailAddress ) s where nums>1";
         $multiEmails = DB::select($sql);
 
 //        $res=DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')

+ 61 - 62
app/Http/logic/admin/GlobalLogicController.php

@@ -33,7 +33,7 @@ class GlobalLogicController extends BaseLogicController
     {
 
         // 今日流水,今日税收
-        $todayGameInfo = DB::connection('read')->table('QPRecordDB.dbo.RecordServerDataStatistics')
+        $todayGameInfo = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordServerDataStatistics WITH (NOLOCK)'))
             ->selectRaw('Isnull((sum(WinScore) + abs(sum(LostScore))),0) as flowing_water,Isnull(sum(Revenue),0) as Revenue')
             ->where('DateID', date('Ymd'))
             ->first();
@@ -48,27 +48,27 @@ class GlobalLogicController extends BaseLogicController
         $data['pay_sum'] = Order::today_pay()->today_pay_sum / NumConfig::NUM_VALUE ?? 0;
 
         // 今日总提现
-        $data['today_withdrawal'] = DB::connection('read')->table("QPAccountsDB.dbo.OrderWithDraw as od")
-                ->join('QPAccountsDB.dbo.AccountsRecord as ar', 'od.RecordID', 'ar.RecordID')
+        $data['today_withdrawal'] = DB::connection('read')->table(DB::raw("QPAccountsDB.dbo.OrderWithDraw as od WITH (NOLOCK)"))
+                ->join(DB::raw('QPAccountsDB.dbo.AccountsRecord as ar WITH (NOLOCK)'), 'od.RecordID', 'ar.RecordID')
                 ->whereDate('update_at', date('Y-m-d'))
                 ->where('State', 2)
                 ->selectRaw('IsNull((sum(WithDraw) + sum(ServiceFee)),0) WithDraw')
                 ->first()->WithDraw / NumConfig::NUM_VALUE ?? 0;
 
         //今日彩金
-        $data['cellData'] = DB::connection('read')->table('QPRecordDB.dbo.RecordUserDataStatisticsNew')
+        $data['cellData'] = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserDataStatisticsNew WITH (NOLOCK)'))
                 ->selectRaw('Isnull(SUM(Handsel),0) as Handsel')
                 ->where('DateID', date('Ymd'))
                 ->first()->Handsel / NumConfig::NUM_VALUE ?? 0;
 
         // 今日杀率 => 被控制输的用户在总活跃用户中的占比
         // ---- 控制输的总用户
-        $shu_member = DB::connection('read')->table('QPTreasureDB.dbo.UserScoreControl')
+        $shu_member = DB::connection('read')->table(DB::raw('QPTreasureDB.dbo.UserScoreControl WITH (NOLOCK)'))
             ->where('ControlRadian', '<', 0)
             ->count();
 
         // ---- 总活跃用户占比
-        $huoyue = DB::connection('read')->table('QPAccountsDB.dbo.accountsInfo')
+        $huoyue = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.accountsInfo WITH (NOLOCK)'))
             ->whereRaw("DateDiff(dd,LastLogonDate,getdate())<=7")
             ->count();
 
@@ -102,7 +102,7 @@ class GlobalLogicController extends BaseLogicController
         }
 
         /*                     游戏房间数据              */
-        $gameRoomInfo = DB::connection('read')->table('QPRecordDB.dbo.RecordServerDataStatistics as rds')
+        $gameRoomInfo = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordServerDataStatistics as rds WITH (NOLOCK)'))
             ->where('DateID', '>=', date('Ymd', strtotime($start_time)))
             ->where('DateID', '<=', date('Ymd', strtotime($end_time)))
             ->selectRaw('Isnull((sum(WinScore) + abs(sum(LostScore))),0) as flowing_water,Isnull(sum(Revenue),0) as Revenue,Isnull((sum(WinScore) + abs(sum(LostScore))),0) as win_lose')
@@ -141,23 +141,23 @@ class GlobalLogicController extends BaseLogicController
     public function sum()
     {
         // 玩家身上总金额
-        $totalAmount = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-            ->join('QPTreasureDB.dbo.GameScoreInfo as gi', 'ai.UserID', 'gi.UserID')
-            ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as wu', 'ai.UserID', 'wu.UserID')
+        $totalAmount = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+            ->join(DB::raw('QPTreasureDB.dbo.GameScoreInfo as gi WITH (NOLOCK)'), 'ai.UserID', 'gi.UserID')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.IDWhiteUser as wu WITH (NOLOCK)'), 'ai.UserID', 'wu.UserID')
             ->where('IsAndroid', 0)
             ->where('Nullity', 0)
             ->whereNull('wu.UserID')
             ->sum('Score');
 
         // 官方玩家身上总金额
-        $official = DB::connection('read')->table('QPAccountsDB.dbo.IDWhiteUser as wu')
-            ->join('QPTreasureDB.dbo.GameScoreInfo as gi', 'wu.UserID', 'gi.UserID')
+        $official = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.IDWhiteUser as wu WITH (NOLOCK)'))
+            ->join(DB::raw('QPTreasureDB.dbo.GameScoreInfo as gi WITH (NOLOCK)'), 'wu.UserID', 'gi.UserID')
             ->sum('Score');
 
         // 充值用户身上总金额--排除官方用户
-        $payUser = DB::connection('read')->table('QPAccountsDB.dbo.YN_VIPAccount as vip')
-            ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as gi', 'vip.UserID', 'gi.UserID')
-            ->leftJoin('QPAccountsDB.dbo.IDWhiteUser as wu', 'vip.UserID', 'wu.UserID')
+        $payUser = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.YN_VIPAccount as vip WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreInfo as gi WITH (NOLOCK)'), 'vip.UserID', 'gi.UserID')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.IDWhiteUser as wu WITH (NOLOCK)'), 'vip.UserID', 'wu.UserID')
             ->whereNull('wu.UserID')
             ->selectRaw('sum(Score) as Score')
             ->first()->Score;
@@ -280,9 +280,9 @@ class GlobalLogicController extends BaseLogicController
         // 注册日期--开始时间
         $date = '2021-07-30 00:00:00';
 
-        $silverMemberCount = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('RegisterDate', '>=', $date)->count();
-        $goldMemberCount = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('RegisterDate', '>=', $date)->count();
-        $diamondsMemberCount = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('RegisterDate', '>=', $date)->count();
+        $silverMemberCount = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))->where('RegisterDate', '>=', $date)->count();
+        $goldMemberCount = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))->where('RegisterDate', '>=', $date)->count();
+        $diamondsMemberCount = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))->where('RegisterDate', '>=', $date)->count();
 
         // 白银首充礼包购买率
         $silverBuyRate = ($silver && $silverMemberCount > 0) ? number_float(($silver->TotalCount / $silverMemberCount) * NumConfig::NUM_VALUE) . '%' : 0;
@@ -292,7 +292,7 @@ class GlobalLogicController extends BaseLogicController
         $diamondsBuyRate = ($diamonds && $diamondsMemberCount > 0) ? number_float(($diamonds->TotalCount / $diamondsMemberCount) * NumConfig::NUM_VALUE) . '%' : 0;
 
         // 首充礼包额外赠送总彩金
-        $lottery = DB::connection('read')->table('QPRecordDB.dbo.PD_RecordScoreInfo')
+        $lottery = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.PD_RecordScoreInfo WITH (NOLOCK)'))
             ->where('Reason', 51)
             ->sum('Score');
 
@@ -375,7 +375,7 @@ class GlobalLogicController extends BaseLogicController
         //$givePrice = $TotalReward - $TotalPrice > 0 ? $TotalReward - $TotalPrice : 0;
 
         // 拉起的总单数
-        $totalNum = DB::connection('read')->table('agent.dbo.order')
+        $totalNum = DB::connection('read')->table(DB::raw('agent.dbo.order WITH (NOLOCK)'))
             ->whereIn('GiftsID', [104, 105, 106, 107])
             ->selectRaw('count(id) count,GiftsID')
             ->groupBy('GiftsID')
@@ -410,14 +410,14 @@ class GlobalLogicController extends BaseLogicController
             ->groupBy('ServerID')
             ->pluck('count_u', 'ServerID');
         */
-        $WinUserCount = DB::connection('read')->table('QPRecordDB.dbo.PD_RecordScoreInfo')
+        $WinUserCount = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.PD_RecordScoreInfo WITH (NOLOCK)'))
             ->selectRaw('count(distinct(UserID)) as count_u,ServerID')
             ->where('AtDate', '=', date('Ymd'))
             ->where('Score', '>', 0)
             ->groupBy('ServerID')
             ->pluck('count_u', 'ServerID');
 
-        $LostUserCount = DB::connection('read')->table('QPRecordDB.dbo.PD_RecordScoreInfo')
+        $LostUserCount = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.PD_RecordScoreInfo WITH (NOLOCK)'))
             ->selectRaw('count(distinct(UserID)) as count_u,ServerID')
             ->where('AtDate', '=', date('Ymd'))
             ->where('Score', '<', 0)
@@ -495,7 +495,7 @@ class GlobalLogicController extends BaseLogicController
         }
         if (in_array(4, $data)) {
             $data['checked4'] = 4;
-            $IP = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
+            $IP = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
                 ->selectRaw('LastLogonIP,count(*) as count ')
                 ->groupBy('LastLogonIP')
                 ->havingRaw('count(*) >1')
@@ -616,7 +616,7 @@ class GlobalLogicController extends BaseLogicController
         $shareLastReward = (new Extensions())->register($UserID)['Register'];
 
         // 包名
-        $userInfo->PackgeName = DB::connection('read')->table('QPRecordDB.dbo.RecordPackageName')
+        $userInfo->PackgeName = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordPackageName WITH (NOLOCK)'))
                 ->where('UserID', $UserID)
                 ->select('PackgeName')
                 ->first()->PackgeName ?? '';
@@ -639,11 +639,10 @@ class GlobalLogicController extends BaseLogicController
         }else{
             $userInfo->spreaderID = 0;
         }
-        $Record=DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('UserID', $UserID)->where('State',1)->first();
+        $Record=DB::table(DB::raw('QPAccountsDB.dbo.OrderWithDraw WITH (NOLOCK)'))->where('UserID', $UserID)->where('State',1)->first();
         $WithDrawNow=$Record?($Record->WithDraw):0;
 
-        $AccountWithDrawInfo = DB::table(TableName::QPAccountsDB() . 'AccountWithDrawInfo')
-            ->lock('WITH(NOLOCK)')
+        $AccountWithDrawInfo = DB::table(DB::raw(TableName::QPAccountsDB() . 'AccountWithDrawInfo WITH (NOLOCK)'))
             ->where('UserID', $UserID)
             ->first();
 
@@ -705,28 +704,28 @@ class GlobalLogicController extends BaseLogicController
         // 手机型号
         $data['mobileBand'] = $userInfo->LastLogonMobile;
         // 退款信息
-        $data['refund_flag'] = DB::table('agent.dbo.order')
+        $data['refund_flag'] = DB::table(DB::raw('agent.dbo.order WITH (NOLOCK)'))
             ->where(['user_id' => $UserID, 'pay_status' => 9])
             ->sum('amount');
         $data['refund_total'] = 0;
         $samePhoneUids = [];
         if ($userInfo->phone) {
-            $samePhoneUids = DB::connection('read')->table('QPAccountsDB.dbo.AccountPhone')
+            $samePhoneUids = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountPhone WITH (NOLOCK)'))
                 ->where('PhoneNum', $userInfo->phone)->pluck('UserID')->toArray();
         }
-        $awi = DB::table('QPAccountsDB.dbo.AccountWithDrawInfo')
+        $awi = DB::table(DB::raw('QPAccountsDB.dbo.AccountWithDrawInfo WITH (NOLOCK)'))
             ->where(['UserID' => $UserID])
             ->first();
         $sameEmailUids = [];
         if ($awi && $awi->EmailAddress) {
-            $sameEmailUids = DB::connection('read')->table('QPAccountsDB.dbo.AccountWithDrawInfo')
+            $sameEmailUids = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountWithDrawInfo WITH (NOLOCK)'))
                 ->where('EmailAddress', $awi->EmailAddress)->pluck('UserID')->toArray();
         }
 
         $uids = array_unique(array_merge($samePhoneUids, $sameEmailUids));
         $uids[] = $UserID;
         if (count($uids) > 0) {
-            $data['refund_total'] = DB::table('agent.dbo.order')->lock('WITH(NOLOCK)')
+            $data['refund_total'] = DB::table(DB::raw('agent.dbo.order WITH (NOLOCK)'))
                 ->whereIn('user_id', $uids)
                 ->where('pay_status', 9)
                 ->sum('amount');
@@ -739,10 +738,10 @@ class GlobalLogicController extends BaseLogicController
     {
         $AccountsInfoModel = new AccountsInfo();
         //玩家信息
-        $User = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
-            ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai1', 'ai.SpreaderID', '=', 'ai1.UserID')
-            ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as gi', 'ai.UserID', '=', 'gi.UserID')
-            ->leftJoin('QPAccountsDB.dbo.AccountPhone as ap', 'ai.UserID', 'ap.UserID')
+        $User = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai1 WITH (NOLOCK)'), 'ai.SpreaderID', '=', 'ai1.UserID')
+            ->leftJoin(DB::raw('QPTreasureDB.dbo.GameScoreInfo as gi WITH (NOLOCK)'), 'ai.UserID', '=', 'gi.UserID')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountPhone as ap WITH (NOLOCK)'), 'ai.UserID', 'ap.UserID')
             ->where('ai.UserID', $UserID)
             ->select('ai.*', 'ai1.GameID as SpreaderID', 'ap.PhoneNum', 'gi.Score', 'gi.Revenue', 'gi.InsureScore', 'gi.Score as gi_Score', 'gi.InsureScore as gi_InsureScore')
             ->first();
@@ -763,8 +762,8 @@ class GlobalLogicController extends BaseLogicController
 
 
         // 有没有在房间
-        $User->ServerName = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreLocker as gsl')
-                ->join('QPPlatformDB.dbo.GameRoomInfo as gri', 'gsl.ServerID', 'gri.ServerID')
+        $User->ServerName = DB::connection('read')->table(DB::raw('QPTreasureDB.dbo.GameScoreLocker as gsl WITH (NOLOCK)'))
+                ->join(DB::raw('QPPlatformDB.dbo.GameRoomInfo as gri WITH (NOLOCK)'), 'gsl.ServerID', 'gri.ServerID')
                 ->where('UserID', $UserID)
                 ->whereRaw('datediff(hh,CollectDate,getdate())<=5')
                 ->select('ServerName')
@@ -800,7 +799,7 @@ class GlobalLogicController extends BaseLogicController
             ->pluck('TypeName', 'TabID');
 
         // 走势图
-        $r = DB::connection('game')->table(TableName::QPTreasureDB() . 'YN_RecordScoreInfo_' . date('Ym'))
+        $r = DB::connection('game')->table(DB::raw(TableName::QPTreasureDB() . 'YN_RecordScoreInfo_' . date('Ym') . ' WITH (NOLOCK)'))
             ->selectRaw("Isnull(SUBSTRING(CONVERT(VARCHAR(13),UpdateTime,120),12,5),0) as Stime,Isnull(sum(ChangeScore),0) as Score")
             ->where('UserID', $UserID)
             ->whereDate('UpdateTime', date("Y-m-d"))
@@ -818,7 +817,7 @@ class GlobalLogicController extends BaseLogicController
         $total = $AccountsInfoModel->accountTotalStatistics([$UserID]);
 
         // 未领取邮件金币
-        $mail = DB::connection('read')->table('QPAccountsDB.dbo.PrivateMail')
+        $mail = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.PrivateMail WITH (NOLOCK)'))
             ->where('UserID', $UserID)
             ->where('MailStatus', '<', 3)
             ->select('UserID', 'BonusString')
@@ -857,7 +856,7 @@ class GlobalLogicController extends BaseLogicController
         $Type12 = $accountsTab[0]->Type12 ?? 0;
         $first = in_array($Type12, [1301, 1302, 1303]) ? true : false;
 
-        $AccountWithDrawInfo = DB::connection('read')->table('QPAccountsDB.dbo.AccountWithDrawInfo')
+        $AccountWithDrawInfo = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountWithDrawInfo WITH (NOLOCK)'))
             ->where('UserID', $UserID)
             ->select('Switch')
             ->first();
@@ -869,14 +868,14 @@ class GlobalLogicController extends BaseLogicController
         }
 
         // 关联IP数量-- 注册IP
-        $Ip = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
+        $Ip = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
             ->where('IsAndroid', 0)
             ->where('RegisterIP', $User->RegisterIP)->count();
 
         // 登录IP
-        $LastLogonIP = DB::connection('read')->table('QPRecordDB.dbo.RecordUserLogonStatistics as a')
+        $LastLogonIP = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserLogonStatistics as a WITH (NOLOCK)'))
             ->whereExists(function ($query) {
-                $query->from(TableName::QPRecordDB() . 'RecordUserLogonStatistics as b')
+                $query->from(DB::raw(TableName::QPRecordDB() . 'RecordUserLogonStatistics as b WITH (NOLOCK)'))
                     ->whereRaw('a.LogonIP=b.LogonIP');
             })
             ->where('UserID', $UserID)
@@ -885,8 +884,8 @@ class GlobalLogicController extends BaseLogicController
 
 
         // 关联银行卡数量
-        $BankNo = DB::connection('read')->table('QPAccountsDB.dbo.AccountWithDrawInfo as di')
-            ->join('QPAccountsDB.dbo.AccountWithDrawInfo as dif', 'di.BankNo', 'dif.BankNo')
+        $BankNo = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountWithDrawInfo as di WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.AccountWithDrawInfo as dif WITH (NOLOCK)'), 'di.BankNo', 'dif.BankNo')
             ->where('di.UserID', $UserID)
             ->whereNotNull('di.BankNo')
             ->where('di.BankNo', '<>', '')
@@ -895,7 +894,7 @@ class GlobalLogicController extends BaseLogicController
             ->first();
 
         // 充值奖金  已领
-        $Reward = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreChange')
+        $Reward = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserScoreChange WITH (NOLOCK)'))
                 ->where('Reason', 53)
                 ->where('UserID', $UserID)
                 ->selectRaw('sum(ChangeScore) Score')
@@ -908,7 +907,7 @@ class GlobalLogicController extends BaseLogicController
         $rechargeScore['Reward'] = $Reward;
 
         // 推广赚金 注册已领
-        $reward = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreChange')
+        $reward = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserScoreChange WITH (NOLOCK)'))
                 ->where('Reason', 72)
                 ->where('UserID', $UserID)
                 ->selectRaw('sum(ChangeScore) Score')
@@ -921,21 +920,21 @@ class GlobalLogicController extends BaseLogicController
         $registerScore['verify'] = 0;
         $registerScore['Reward'] = $reward;
 
-        $todayReward = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew')
+        $todayReward = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserScoreStatisticsNew WITH (NOLOCK)'))
                 ->whereIn('ScoreType', [53, 72])
                 ->where('UserID', $UserID)
                 ->selectRaw('sum(Score) Score')
                 ->first()->Score / NumConfig::NUM_VALUE ?? 0;
 
         // 包名
-        $PackgeName = DB::connection('read')->table('QPRecordDB.dbo.RecordPackageName')
+        $PackgeName = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordPackageName WITH (NOLOCK)'))
                 ->where('UserID', $UserID)
                 ->select('PackgeName')
                 ->first()->PackgeName ?? '';
 
         // 个人池控制:
-        $RecordRechargeControl = DB::connection('read')->table('QPRecordDB.dbo.RecordRechargeControl as rc')
-            ->leftJoin('QPTreasureDB.dbo.RechargeControlConfig as cnf', 'rc.State', 'cnf.ID')
+        $RecordRechargeControl = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordRechargeControl as rc WITH (NOLOCK)'))
+            ->leftJoin(DB::raw('QPTreasureDB.dbo.RechargeControlConfig as cnf WITH (NOLOCK)'), 'rc.State', 'cnf.ID')
             ->where('UserID', $UserID)
             ->select('ConfigName', 'State', 'Prob')
             ->first();
@@ -1010,7 +1009,7 @@ class GlobalLogicController extends BaseLogicController
         //   ->selectRaw('Isnull(sum(ABS(Score)),0) as Score')
         //    ->first()->Score;
 
-        $liushui = DB::connection('read')->table('QPRecordDB.dbo.PD_RecordScoreInfo')
+        $liushui = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.PD_RecordScoreInfo WITH (NOLOCK)'))
             ->where($where)
             ->whereNotIn('ServerID', $ServerIDs)
             ->selectRaw('Isnull(sum(ABS(Score)),0) as Score')
@@ -1080,9 +1079,9 @@ class GlobalLogicController extends BaseLogicController
 
         !empty($Type) && $where[] = ['ua.Type', $Type];
 
-        $list = DB::connection('read')->table('QPRecordDB.dbo.RecordUserAgent as ua')
-            ->join('QPAccountsDB.dbo.accountsInfo as ai', 'ua.UserID', '=', 'ai.UserID')
-            ->leftJoin('QPAccountsDB.dbo.accountsInfo as ain', 'ain.UserID', '=', 'ai.SpreaderID')
+        $list = DB::connection('read')->table(DB::raw('QPRecordDB.dbo.RecordUserAgent as ua WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.accountsInfo as ai WITH (NOLOCK)'), 'ua.UserID', '=', 'ai.UserID')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.accountsInfo as ain WITH (NOLOCK)'), 'ain.UserID', '=', 'ai.SpreaderID')
             ->select('ua.Id', 'ai.GameID', 'ain.GameID as SpreaderID', 'DirectRebate', 'SendTime', 'SourceUserID', 'OrderSn', 'ua.UserID', 'ua.Level', 'ua.Type', 'ua.orderIds')
             ->where($where)
             ->orderBy('SendTime', 'desc')
@@ -1119,14 +1118,14 @@ class GlobalLogicController extends BaseLogicController
     public function winloser($GameID, $UniqueCode, $room, $start_time, $end_time, $excel, $id_list, $ChangeScoreMin, $ChangeScoreMax, $ChangeScoreSort, $afterScoreSort, $searchGame)
     {
         $where = [];
-        $UserID = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')
+        $UserID = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.AccountsInfo WITH (NOLOCK)'))
                 ->where('GameID', $GameID)
                 ->select('UserID')
                 ->first()->UserID ?? '';
 
         if (!empty($id_list) && empty($start_time)) {
-            $withDrawFinal = DB::connection('read')->table('QPAccountsDB.dbo.OrderWithDraw as ow')
-                    ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'ow.UserID', 'ai.UserID')
+            $withDrawFinal = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.OrderWithDraw as ow WITH (NOLOCK)'))
+                    ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'ow.UserID', 'ai.UserID')
                     ->where('ow.State', 2)
                     ->where('ai.GameID', $GameID)
                     ->where('finishDate', '>=', date('Y-m-d 00:00:00'))
@@ -1210,7 +1209,7 @@ class GlobalLogicController extends BaseLogicController
             ->pluck('ServerName', 'ServerID')
             ->toArray();
 
-        $build_sql = DB::connection('game')->table($table . ' as ri')
+        $build_sql = DB::connection('game')->table(DB::raw($table . ' as ri WITH (NOLOCK)'))
             ->where($where);
 
         // 游戏列表
@@ -1264,7 +1263,7 @@ class GlobalLogicController extends BaseLogicController
         $getGameIDs = $this->getGameIDs($list);
 
         // +----------------房间总输赢------------------+
-        $total = DB::connection('game')->table($table . ' as ri')
+        $total = DB::connection('game')->table(DB::raw($table . ' as ri WITH (NOLOCK)'))
             ->where($where)
             ->selectRaw('IsNull(sum(abs(ChangeScore)),0) as water,count(distinct(UserID)) as UserID,sum(ChangeScore) as ChangeScore,sum(Revenue) as Revenue')
             ->first();
@@ -1315,7 +1314,7 @@ class GlobalLogicController extends BaseLogicController
     public function game_record($UniqueCode, $gameId, $month)
     {
         $where[] = ['UniqueCode', '=', $UniqueCode];
-        $list = DB::connection('game')->table(TableName::QPTreasureDB() . 'YN_RecordScoreInfo_' . $month . ' as ri')
+        $list = DB::connection('game')->table(DB::raw(TableName::QPTreasureDB() . 'YN_RecordScoreInfo_' . $month . ' as ri WITH (NOLOCK)'))
             ->where($where)
             ->whereNotNull('UniqueCode')
             ->orderBy('UpdateTime', 'desc')

+ 24 - 29
app/Http/logic/admin/WithdrawalLogic.php

@@ -34,7 +34,7 @@ class WithdrawalLogic extends BaseLogicController
 
     public function __construct()
     {
-        $this->agent = DB::table('agent.dbo.admin_configs')
+        $this->agent = DB::table(DB::raw('agent.dbo.admin_configs WITH (NOLOCK)'))
             ->where('type', 'cash')
             ->where('status', 1)
             ->get();
@@ -44,15 +44,15 @@ class WithdrawalLogic extends BaseLogicController
     public function waitWithdrawal($GameID, $withdraw_search, $withdraw, $state, $start_time, $end_time, $agent = '', $flag = false, $create_time_sort = '', $orderID = '', $final_start_time = '', $final_end_time = '', $excel = '', $Channel = '', $payState = '', $take_effect = '', $isEmpty = 0, $register_start_time = '', $register_end_time = '', $PackgeName = '',$firstWithDraw=0)
     {
 
-        $SQL = DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw as ow')
-            ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'ow.UserID', 'ai.UserID')
-            ->leftJoin('QPAccountsDB.dbo.withdraw_notify as wn', 'ow.OrderID', '=', 'wn.order_sn')
-            ->leftJoin('QPAccountsDB.dbo.AccountsRecord as ar', function ($join) {
+        $SQL = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.OrderWithDraw as ow WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'ow.UserID', 'ai.UserID')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.withdraw_notify as wn WITH (NOLOCK)'), 'ow.OrderID', '=', 'wn.order_sn')
+            ->leftJoin(DB::raw('QPAccountsDB.dbo.AccountsRecord as ar WITH (NOLOCK)'), function ($join) {
                 $join->on('ow.RecordID', 'ar.RecordID');
                 $join->where('ar.type', 1);
             });
         if($firstWithDraw<2){
-            $SQL->join(TableName::QPRecordDB() . 'RecordUserTotalStatistics as rds', function ($join) use ($firstWithDraw) {
+            $SQL->join(DB::raw(TableName::QPRecordDB() . 'RecordUserTotalStatistics as rds WITH (NOLOCK)'), function ($join) use ($firstWithDraw) {
                 $join->on('rds.UserID', 'ow.UserID');
                 $join->where('rds.Withdraw', $firstWithDraw>0?'=':'<>',0);
             });
@@ -104,7 +104,7 @@ class WithdrawalLogic extends BaseLogicController
         !empty($start_time) && $where[] = ['CreateDate', '>=', str_replace('T', ' ', $start_time)];
         !empty($end_time) && $where[] = ['CreateDate', '<=', str_replace('T', ' ', $end_time)];
         if (!empty($agent)) {
-            $SQL = $SQL->join('agent.dbo.admin_configs as ac', 'ow.agent', '=', 'ac.id');
+            $SQL = $SQL->join(DB::raw('agent.dbo.admin_configs as ac WITH (NOLOCK)'), 'ow.agent', '=', 'ac.id');
             $where[] = ['agent', $agent];
         }
         !empty($orderID) && $where[] = ['OrderID', $orderID];
@@ -126,22 +126,22 @@ class WithdrawalLogic extends BaseLogicController
         }
         (!empty($Channel) || $Channel === '0') && $where[] = ['ai.Channel', $Channel];
         if ($payState == 1) {
-            $SQL = $SQL->join('QPRecordDB.dbo.RecordUserTotalStatistics as rs', 'ow.UserID', 'rs.UserID')->where('Recharge', '>', 0);
+            $SQL = $SQL->join(DB::raw('QPRecordDB.dbo.RecordUserTotalStatistics as rs WITH (NOLOCK)'), 'ow.UserID', 'rs.UserID')->where('Recharge', '>', 0);
         }
         if ($take_effect == -1) {
-            $SQL = $SQL->join('agent.dbo.withdrawal_position_log as log', function ($join) {
+            $SQL = $SQL->join(DB::raw('agent.dbo.withdrawal_position_log as log WITH (NOLOCK)'), function ($join) {
                 $join->on('log.order_sn', '=', 'ow.OrderID');
             });
         } else {
             if (!empty($take_effect)) {
-                $SQL = $SQL->Join('agent.dbo.admin_users as us', 'ar.admin_id', '=', 'us.id');
+                $SQL = $SQL->Join(DB::raw('agent.dbo.admin_users as us WITH (NOLOCK)'), 'ar.admin_id', '=', 'us.id');
                 $where[] = ['ar.admin_id', '=', $take_effect];
             }
         }
         !empty($register_start_time) && $where[] = ['RegisterDate', '>=', str_replace('T', ' ', $register_start_time) ];
         !empty($register_end_time) && $where[] = ['RegisterDate', '<=', str_replace('T', ' ', $register_end_time)];
         if (!empty($PackgeName)) {
-            $SQL = $SQL->leftJoin('QPRecordDB.dbo.RecordPackageName as rn', 'ai.UserID', 'rn.UserID');
+            $SQL = $SQL->leftJoin(DB::raw('QPRecordDB.dbo.RecordPackageName as rn WITH (NOLOCK)'), 'ai.UserID', 'rn.UserID');
             $where[] = ['PackgeName', $PackgeName];
         }
         $adminChannels=session('admin_channels');
@@ -166,7 +166,6 @@ class WithdrawalLogic extends BaseLogicController
 
             $list = $SQL
                 ->where($where)
-                ->lock('with(nolock)')
                 ->select($field)
                 ->selectRaw('ar.update_at, CreateDate')
                 ->orderBy('ow.RecordID', 'desc')
@@ -175,22 +174,20 @@ class WithdrawalLogic extends BaseLogicController
             // 申请人数,笔数,金额
             $applyUserCount = $SQL1
                 ->where($where)
-                ->lock('with(nolock)')
-                ->selectRaw('count(distinct(ow.UserID)) userCount,(sum(cast(ow.WithDraw as bigint))+sum(cast(ow.ServiceFee as bigint))) WithDraw,count(ow.RecordID) count')->lock('with(nolock)')->first();
+                ->selectRaw('count(distinct(ow.UserID)) userCount,(sum(cast(ow.WithDraw as bigint))+sum(cast(ow.ServiceFee as bigint))) WithDraw,count(ow.RecordID) count')->first();
             if (isset($applyUserCount->WithDraw)) {
                 $applyUserCount->WithDraw = number_float($applyUserCount->WithDraw / NumConfig::NUM_VALUE);
             }
 
             // 到账人数,金额
             $overUserCount = $SQL2->where($where)->where('ow.State', 2)->selectRaw('count(distinct(ow.UserID)) userCount,sum(cast(ow.WithDraw as bigint)) WithDraw,count(ow.RecordID) count')
-                ->lock('with(nolock)')
                 ->first();
             if (isset($overUserCount->WithDraw)) {
                 $overUserCount->WithDraw = number_float($overUserCount->WithDraw / NumConfig::NUM_VALUE);
             }
 
             // 手续费汇总(当前筛选条件下)
-            $totalWithdrawFeeRow = $SQL3->where($where)->selectRaw('sum(cast(ISNULL(ow.withdraw_fee,0) as bigint)) as total_withdraw_fee')->lock('with(nolock)')->first();
+            $totalWithdrawFeeRow = $SQL3->where($where)->selectRaw('sum(cast(ISNULL(ow.withdraw_fee,0) as bigint)) as total_withdraw_fee')->first();
             $totalWithdrawFee = isset($totalWithdrawFeeRow->total_withdraw_fee) ? number_float($totalWithdrawFeeRow->total_withdraw_fee / NumConfig::NUM_VALUE) : 0;
 
             $userIDs = [];
@@ -216,11 +213,11 @@ class WithdrawalLogic extends BaseLogicController
             }
             unset($val);
 
-            $agentName = DB::connection('write')->table('agent.dbo.admin_configs')
+            $agentName = DB::connection('write')->table(DB::raw('agent.dbo.admin_configs WITH (NOLOCK)'))
                 ->whereIn('id', $agentIDs)
                 ->pluck('name', 'id')->toArray();
 
-            $adminName = DB::connection('write')->table('agent.dbo.admin_users')
+            $adminName = DB::connection('write')->table(DB::raw('agent.dbo.admin_users WITH (NOLOCK)'))
                 ->whereIn('id', $adminIDs)
                 ->pluck('account', 'id')->toArray();
             $userIDs = array_unique($userIDs);
@@ -230,9 +227,8 @@ class WithdrawalLogic extends BaseLogicController
             $IP = $model->ip($userIDs);
 
 
-            $orders = DB::connection('read')->table('QPAccountsDB.dbo.YN_VIPAccount')->whereIn('UserID', $userIDs)
+            $orders = DB::connection('read')->table(DB::raw('QPAccountsDB.dbo.YN_VIPAccount WITH (NOLOCK)'))->whereIn('UserID', $userIDs)
                 ->selectRaw('Recharge,UserID')
-                ->lock('with(nolock)')
                 ->pluck('Recharge', 'UserID')->toArray();
 
             $Withdrawal_M = new Withdrawal();
@@ -279,10 +275,10 @@ class WithdrawalLogic extends BaseLogicController
         $final_end_time = Helper::timeChange($final_end_time);
 
         // 提现管理员
-        $withdrawal_administrator = DB::connection('write')->table('agent.dbo.withdrawal_administrator')->pluck('account', 'admin_id');
+        $withdrawal_administrator = DB::connection('write')->table(DB::raw('agent.dbo.withdrawal_administrator WITH (NOLOCK)'))->pluck('account', 'admin_id');
 
         // 获取包名
-        $ChannelPackageName = DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')
+        $ChannelPackageName = DB::connection('write')->table(DB::raw('QPPlatformDB.dbo.ChannelPackageName WITH (NOLOCK)'))
             ->select('PackageName', 'Channel')
             ->pluck('PackageName', 'Channel');
 
@@ -295,11 +291,10 @@ class WithdrawalLogic extends BaseLogicController
         $id_arr = explode(',', $ids);
 
         $order = ['WithDraw', 'ServiceFee', 'ow.RecordID', 'ai.GameID', 'ai.UserID', 'ai.Channel','PixType'];
-        $list = DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw as ow')
-            ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'ow.UserID', 'ai.UserID')
+        $list = DB::connection('write')->table(DB::raw('QPAccountsDB.dbo.OrderWithDraw as ow WITH (NOLOCK)'))
+            ->join(DB::raw('QPAccountsDB.dbo.AccountsInfo as ai WITH (NOLOCK)'), 'ow.UserID', 'ai.UserID')
             ->whereIn('RecordID', $id_arr)
             ->select($order)
-            ->lock('with(nolock)')
             ->paginate(10);
         $channelConfigs = [];
         $res = WithdrawalChannelPositionConfig::where('status', 1)->get();
@@ -490,9 +485,9 @@ class WithdrawalLogic extends BaseLogicController
         !empty($gameID) && $where[] = ['GameID', $gameID];
         (!empty($channel) || $channel === 0) && $where[] = ['Channel', $channel];
 
-        $buildSql = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as rn')
+        $buildSql = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as rn WITH (NOLOCK)'))
             ->where($where)
-            ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rn.UserID', 'ai.UserID')
+            ->join(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'), 'rn.UserID', 'ai.UserID')
             ->select('GameID', 'rn.UserID', 'Withdraw', 'Recharge')
             ->orderBy('Withdraw', 'desc');
         // 昨天的提现用户,昨日提现多少,昨日充值多少,历史充值多少,历史提现多少
@@ -503,7 +498,7 @@ class WithdrawalLogic extends BaseLogicController
             $UserIDs[] = $value->UserID;
         }
 
-        $total = DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics')
+        $total = DB::table(DB::raw(TableName::QPRecordDB() . 'RecordUserTotalStatistics WITH (NOLOCK)'))
             ->whereIn('UserID', $UserIDs)
             ->select('Withdraw', 'Recharge', 'UserID')
             ->get();
@@ -526,7 +521,7 @@ class WithdrawalLogic extends BaseLogicController
             return;
         } else {
 
-            $channelList = DB::table(TableName::QPPlatformDB().'ChannelPackageName')
+            $channelList = DB::table(DB::raw(TableName::QPPlatformDB().'ChannelPackageName WITH (NOLOCK)'))
                 ->select('Channel')
                 ->groupBy('Channel')
                 ->pluck('Channel','Channel')->toArray();