Tree hai 4 días
pai
achega
45f7a1fbb1
Modificáronse 1 ficheiros con 24 adicións e 16 borrados
  1. 24 16
      app/dao/RecordPlatformData/RecordPlatformData.php

+ 24 - 16
app/dao/RecordPlatformData/RecordPlatformData.php

@@ -13,9 +13,10 @@ class RecordPlatformData
     // 申请提现金额,申请人数,申请笔数【分渠道】
     public function ApplyWithDraw($date)
     {
-        return DB::connection('sqlsrv')->table(TableName::QPAccountsDB() . 'OrderWithDraw as od')
-            ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ai.UserID', 'od.UserID')
-            ->whereDate('CreateDate', $date->format('Y-m-d'))
+        return DB::connection('sqlsrv')->table(DB::raw(TableName::QPAccountsDB() . 'OrderWithDraw as od WITH (NOLOCK)'))
+            ->join(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'), 'ai.UserID', '=', 'od.UserID')
+            ->where('CreateDate', '>=', $date->format('Y-m-d'))
+            ->where('CreateDate', '<', $date->copy()->addDay()->format('Y-m-d'))
             ->selectRaw('IsNull(sum(WithDraw),0) + IsNull(sum(ServiceFee),0) WithDraw,count(distinct(od.UserID)) UserCount,count(RecordID) CountBi,Channel')
             ->groupBy('Channel')
             ->get();
@@ -24,8 +25,9 @@ class RecordPlatformData
     // 总申请提现金额【分渠道】
     public function TotalOrderWithDraw($date)
     {
-        return DB::connection('sqlsrv')->table(TableName::QPAccountsDB() . 'OrderWithDraw')
-            ->whereDate('CreateDate', $date->format('Y-m-d'))
+        return DB::connection('sqlsrv')->table(DB::raw(TableName::QPAccountsDB() . 'OrderWithDraw WITH (NOLOCK)'))
+            ->where('CreateDate', '>=', $date->format('Y-m-d'))
+            ->where('CreateDate', '<', $date->copy()->addDay()->format('Y-m-d'))
             ->selectRaw('IsNull(sum(WithDraw),0) + IsNull(sum(ServiceFee),0) WithDraw,count(distinct(UserID)) UserCount,count(RecordID) CountBi')
             ->first();
     }
@@ -33,10 +35,9 @@ class RecordPlatformData
     // 提现成功的手续费【分渠道】
     public function WithDrawOkFree($DateID)
     {
-        return DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as rn')
-            ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ai.UserID', 'rn.UserID')
+        return DB::connection('sqlsrv')->table(DB::raw(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as rn WITH (NOLOCK)'))
+            ->join(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'), 'ai.UserID', '=', 'rn.UserID')
             ->where('DateID', $DateID)
-            ->select('Channel')
             ->selectRaw('Channel,sum(ServiceFee) ServiceFee')
             ->groupBy('Channel')
             ->get();
@@ -45,8 +46,8 @@ class RecordPlatformData
     // 游戏人数【分渠道】
     public function GameUserCount($DateID)
     {
-        return DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordUserGameDayCount as rc')
-            ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ai.UserID', 'rc.UserID')
+        return DB::connection('sqlsrv')->table(DB::raw(TableName::QPRecordDB() . 'RecordUserGameDayCount as rc WITH (NOLOCK)'))
+            ->join(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'), 'ai.UserID', '=', 'rc.UserID')
             ->where('DateID', $DateID)
             ->selectRaw('count(distinct(rc.UserID)) UserCount,Channel')
             ->groupBy('Channel')
@@ -56,9 +57,10 @@ class RecordPlatformData
     // 新增游戏人数【分渠道】
     public function NewGameUserCount($date)
     {
-        return DB::connection('sqlsrv')->table(TableName::QPAccountsDB() . 'AccountsInfo as ai')
-            ->whereDate('RegisterDate', $date->format('Y-m-d'))
-            ->join(TableName::QPRecordDB() . 'RecordUserGameDayCount as rd', 'ai.UserID', 'rd.UserID')
+        return DB::connection('sqlsrv')->table(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'))
+            ->where('ai.RegisterDate', '>=', $date->format('Y-m-d'))
+            ->where('ai.RegisterDate', '<', $date->copy()->addDay()->format('Y-m-d'))
+            ->join(DB::raw(TableName::QPRecordDB() . 'RecordUserGameDayCount as rd WITH (NOLOCK)'), 'ai.UserID', '=', 'rd.UserID')
             ->where('DateID', $date->format('Ymd'))
             ->selectRaw('count(distinct(rd.UserID)) UserCount,Channel')
             ->groupBy('Channel')
@@ -69,9 +71,10 @@ class RecordPlatformData
     // 新增游戏人数打到了提现额度【分渠道】
     public function NewGameWinTopCount($date)
     {
-        return DB::connection('sqlsrv')->table(TableName::QPAccountsDB() . 'AccountsInfo as ai')
-            ->whereDate('ai.RegisterDate', $date->format('Y-m-d'))
-            ->join(TableName::QPTreasureDB() . 'GameScoreInfo as rd', 'ai.UserID', '=', 'rd.UserID')
+        return DB::connection('sqlsrv')->table(DB::raw(TableName::QPAccountsDB() . 'AccountsInfo as ai WITH (NOLOCK)'))
+            ->where('ai.RegisterDate', '>=', $date->format('Y-m-d'))
+            ->where('ai.RegisterDate', '<', $date->copy()->addDay()->format('Y-m-d'))
+            ->join(DB::raw(TableName::QPTreasureDB() . 'GameScoreInfo as rd WITH (NOLOCK)'), 'ai.UserID', '=', 'rd.UserID')
             ->whereRaw('(ISNULL(rd.Score,0) + ISNULL(rd.InsureScore,0)) > ?', [4000])
             ->selectRaw('COUNT(ai.UserID) AS UserCount, ai.Channel')
             ->groupBy('ai.Channel')
@@ -102,6 +105,7 @@ class RecordPlatformData
     public function RechargeWinnings($dateID)
     {
         return DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordUserScoreChangeStatistics as rc')
+            ->lock('with(nolock)')
             ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rc.UserID', 'ai.UserID')
             ->where('DateID', $dateID)
             ->whereIn('ScoreType', [45, 51, 59])
@@ -114,6 +118,7 @@ class RecordPlatformData
     public function ShareWinnings($dateID)
     {
         return DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordUserScoreChangeStatistics as rc')
+            ->lock('with(nolock)')
             ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rc.UserID', 'ai.UserID')
             ->where('DateID', $dateID)
             ->whereIn('ScoreType', [36, 53, 72])
@@ -126,6 +131,7 @@ class RecordPlatformData
     public function dibao($dateID)
     {
         return DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordUserScoreChangeStatistics as rc')
+            ->lock('with(nolock)')
             ->where('DateID', $dateID)
             ->where('ScoreType', 13)
             ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rc.UserID', 'ai.UserID')
@@ -137,6 +143,7 @@ class RecordPlatformData
     public function payDibao($dateID)
     {
         return DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordUserScoreChangeStatistics as rc')
+            ->lock('with(nolock)')
             ->where('DateID', $dateID)
             ->where('ScoreType', 13)
             ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rc.UserID', 'ai.UserID')
@@ -149,6 +156,7 @@ class RecordPlatformData
     public function signIn($dateID)
     {
         return DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordUserScoreChangeStatistics as rc')
+            ->lock('with(nolock)')
             ->where('DateID', $dateID)
             ->where('ScoreType', 44)
             ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rc.UserID', 'ai.UserID')