Преглед на файлове

1、fix并发bug
2、fix日志多记录了

Tree преди 1 седмица
родител
ревизия
71d58296bb
променени са 2 файла, в които са добавени 23 реда и са изтрити 16 реда
  1. 6 6
      app/Game/Services/OuroGameService.php
  2. 17 10
      app/Http/Controllers/Game/LoginController.php

+ 6 - 6
app/Game/Services/OuroGameService.php

@@ -70,12 +70,12 @@ class OuroGameService
         $NowScore=$OrgScore+$GiftScore;
         RecordScoreInfo::addScore($UserID, $GiftScore, $reason, $OrgScore); #赠送彩金
 
-        if($reason){
-            DB::connection('sqlsrv')->unprepared("
-            SET NOCOUNT ON;
-            use QPRecordDB;
-            exec QPRecordDB.dbo.GSP_YN_GR_RecordGameScore $UserID,$GiftScore,$reason,0,'',0,0");
-        }
+//        if($reason){
+//            DB::connection('sqlsrv')->unprepared("
+//            SET NOCOUNT ON;
+//            use QPRecordDB;
+//            exec QPRecordDB.dbo.GSP_YN_GR_RecordGameScore $UserID,$GiftScore,$reason,0,'',0,0");
+//        }
         if(!$notify){
             return [$OrgScore,$NowScore];
         }

+ 17 - 10
app/Http/Controllers/Game/LoginController.php

@@ -189,7 +189,7 @@ class LoginController extends Controller
         $SendGold = SystemStatusInfo::OnlyGetCacheValue('BindPhoneReward') ?? 500;
         DB::table('QPRecordDB.dbo.LogProp')->insert(['UserID' => $UserID, 'PropID' => 30000, 'PropNum' => $SendGold, 'Source' => 11, 'Param' => null]);
 
-        OuroGameService::AddScore($UserID, $SendGold, OuroGameService::REASON_BindPhone);
+        OuroGameService::AddScore($UserID, $SendGold, OuroGameService::REASON_BindPhone,false);
 
         $RecordPlatformDataModel = new \App\Models\RecordPlatformData();
         $RecordPlatformDataModel->BindToday($Channel,$user->RegisterDate);
@@ -667,16 +667,23 @@ class LoginController extends Controller
                         }
                         GlobalUserInfo::$me = $user;
                         if (intval($request->input('pwa', 0)) == 1) {
-                            if (intval($user->PwaInstalled) == 0) {
-                                $user->update(['PwaInstalled' => 1]);
-                                $config = RouteService::getChannelConfig($request);
-                                if($config->BONUS_PWA()>0){
-                                    OuroGameService::AddScore($user->UserID,$config->BONUS_PWA(),OuroGameService::REASON_PwaBonus,false);
+                            $redisKey = 'pwa_install_bonus_' . $user->UserID;
+                            if (SetNXLock::getExclusiveLock($redisKey, 10)) {
+                                try {
+                                    if (intval($user->PwaInstalled) == 0) {
+                                        $user->update(['PwaInstalled' => 1]);
+                                        $config = RouteService::getChannelConfig($request);
+                                        if($config->BONUS_PWA()>0){
+                                            OuroGameService::AddScore($user->UserID,$config->BONUS_PWA(),OuroGameService::REASON_PwaBonus,false);
+                                        }
+                                        if(date('Ymd',strtotime($user->RegisterDate)) == date('Ymd')){
+                                            $RecordPlatformDataModel = new \App\Models\RecordPlatformData();
+                                            $RecordPlatformDataModel->PwaToday($user->Channel);
+                                        }
+                                    }
+                                } finally {
+                                    SetNXLock::release($redisKey);
                                 }
-
-                                $RecordPlatformDataModel = new \App\Models\RecordPlatformData();
-
-                                $RecordPlatformDataModel->PwaToday($user->Channel);
                             }
                         }
                         return $user;