Tree преди 21 часа
родител
ревизия
a8cdb1613a
променени са 2 файла, в които са добавени 24 реда и са изтрити 35 реда
  1. 9 24
      app/Http/Controllers/Game/PayRechargeController.php
  2. 15 11
      app/Services/OrderServices.php

+ 9 - 24
app/Http/Controllers/Game/PayRechargeController.php

@@ -1220,14 +1220,7 @@ class PayRechargeController extends Controller
             }
             }
         }
         }
 
 
-        // 5. 检查是否已经买过 305 礼包
-        $hasBought = DB::table('agent.dbo.order')
-            ->where('user_id', $userId)
-            ->where('GiftsID', 305)
-            ->where('pay_status', 1)
-            ->exists();
-
-        // 6. 查询 7 日礼包记录状态
+        // 5. 查询最近一条 7 日礼包记录状态(用于判断是否进入新一轮)
         $record = DB::table('agent.dbo.inactive_vip_gift_records')
         $record = DB::table('agent.dbo.inactive_vip_gift_records')
             ->where('user_id', $userId)
             ->where('user_id', $userId)
             ->where('gift_id', 305)
             ->where('gift_id', 305)
@@ -1245,20 +1238,12 @@ class PayRechargeController extends Controller
         $status = 1;
         $status = 1;
         $timeLeft = 0; // 倒计时剩余秒数
         $timeLeft = 0; // 倒计时剩余秒数
         
         
-        if ($hasBought) {
-            if (!$record) {
-                $status = 2;
-            } else {
-                // 检查 7 天礼包是否已过期
-                if (strtotime($record->expired_at) < time()) {
-                    $status = 4; // 7天礼包已过期
-                } else {
-                    // 检查 7 天是否全部领完:claimed_days_mask 的低 7 位全部为 1
-                    $allClaimedMask = (1 << 7) - 1; // 0b1111111
-                    $status = (($record->claimed_days_mask & $allClaimedMask) == $allClaimedMask) ? 3 : 2;
-                }
-            }
+        if ($record && strtotime($record->expired_at) >= time()) {
+            // 当前轮次仍有效:根据领取进度展示状态
+            $allClaimedMask = (1 << 7) - 1; // 0b1111111
+            $status = (($record->claimed_days_mask & $allClaimedMask) == $allClaimedMask) ? 3 : 2;
         } else {
         } else {
+            // 无记录 or 上一轮已过期:可进入新一轮,走未充值倒计时逻辑
             // 满足条件但未充值:检查24小时倒计时(每天重置)
             // 满足条件但未充值:检查24小时倒计时(每天重置)
             $today = date('Y-m-d');
             $today = date('Y-m-d');
             $timerKey = "vip_inactive_gift_timer_{$userId}_{$today}";
             $timerKey = "vip_inactive_gift_timer_{$userId}_{$today}";
@@ -1295,9 +1280,9 @@ class PayRechargeController extends Controller
 //            'avg_recharge' => round($avgRecharge, 2),
 //            'avg_recharge' => round($avgRecharge, 2),
             'time_left' => $timeLeft,
             'time_left' => $timeLeft,
             'expire_at' => $timeLeft > 0 ? (time() + $timeLeft) : null,
             'expire_at' => $timeLeft > 0 ? (time() + $timeLeft) : null,
-            'message' => $status == 1 ? __('web.gift.vip_inactive_can_recharge') : 
-                        ($status == 2 ? __('web.gift.vip_inactive_claimed_partial') : 
-                        ($status == 3 ? __('web.gift.vip_inactive_claimed_all') : 
+            'message' => $status == 1 ? __('web.gift.vip_inactive_can_recharge') :
+                        ($status == 2 ? __('web.gift.vip_inactive_claimed_partial') :
+                        ($status == 3 ? __('web.gift.vip_inactive_claimed_all') :
                         __('web.gift.vip_inactive_seven_days_expired')))
                         __('web.gift.vip_inactive_seven_days_expired')))
         ];
         ];
 
 

+ 15 - 11
app/Services/OrderServices.php

@@ -188,22 +188,24 @@ class  OrderServices
                 }
                 }
 
 
             }else if ($GiftsID == 305) { // 连续未充值 VIP 新礼包
             }else if ($GiftsID == 305) { // 连续未充值 VIP 新礼包
-                // 检查用户是否已经充值过 305 礼包
-                $hasPurchased305 = DB::connection('write')->table('agent.dbo.order')
+                // 305 改为按“轮次”判断:上一轮过期后可再次充值并获得新一轮奖励
+                $latestRecord = DB::connection('write')->table('agent.dbo.inactive_vip_gift_records')
                     ->where('user_id', $user_id)
                     ->where('user_id', $user_id)
-                    ->where('GiftsID', 305)
-                    ->where('pay_status', 1)
-                    ->exists();
-                
-                if ($hasPurchased305) {
-                    // 已经充值过 305 礼包,只发放本金(不发放奖励)
+                    ->where('gift_id', 305)
+                    ->orderBy('id', 'desc')
+                    ->first();
+
+                $canStartNewRound = !$latestRecord || (strtotime($latestRecord->expired_at) < time());
+
+                if (!$canStartNewRound) {
+                    // 当前轮次未过期:只发放本金(不发放奖励)
                     $Recharge = $payAmt;
                     $Recharge = $payAmt;
                     $give = 0;
                     $give = 0;
                     $favorable_price = $Recharge + $give;
                     $favorable_price = $Recharge + $give;
                     $czReason = 1;
                     $czReason = 1;
                     $cjReason = 45;
                     $cjReason = 45;
                 } else {
                 } else {
-                    // 首次充值 305 礼包,发放 120% 奖励(固定120%,不从配置读取)
+                    // 开启新一轮 305:发放 120% 立即奖励并创建新的 7 日礼包记录
                     $favorable_price = round($payAmt * 120 / 100, 2);
                     $favorable_price = round($payAmt * 120 / 100, 2);
                     $give = $favorable_price - $payAmt;
                     $give = $favorable_price - $payAmt;
                     $Recharge = $payAmt;
                     $Recharge = $payAmt;
@@ -545,9 +547,11 @@ class  OrderServices
                         'Score' => 0,                         // Score置0
                         'Score' => 0,                         // Score置0
                         'ScoreChange' => 1,                   // ScoreChange设置成1
                         'ScoreChange' => 1,                   // ScoreChange设置成1
                         'MaxScore' => 0,                      // MaxScore清0
                         'MaxScore' => 0,                      // MaxScore清0
-                        'MaxWinScore' => 0                    // MaxWinScore清0
+                        'MaxWinScore' => 0,                    // MaxWinScore清0
+                        'PlayTimeCount' => 0,                   //重置游戏时间
+                        'OnLineTimeCount' => $scoreInfo->PlayTimeCount, //赋值免费游戏时间
                     ]);
                     ]);
-
+                //TODO
                 \Log::info('GameScoreInfo切换成功', [
                 \Log::info('GameScoreInfo切换成功', [
                     'user_id' => $user_id,
                     'user_id' => $user_id,
                     'original_score' => $scoreInfo->Score,
                     'original_score' => $scoreInfo->Score,