Explorar o código

fix superball

laowu hai 18 horas
pai
achega
56ce9a852b
Modificáronse 1 ficheiros con 14 adicións e 22 borrados
  1. 14 22
      app/Services/SuperballActivityService.php

+ 14 - 22
app/Services/SuperballActivityService.php

@@ -57,7 +57,7 @@ class SuperballActivityService
         if ($canUpgrade && $userTask->status != 1) {
             $tierConfigs = $this->getTierConfig();
             $up = null;
-            foreach ($tierConfigs as $c) {
+            foreach (array_reverse($tierConfigs) as $c) {
                 if ($c['recharge_required'] < $rechargeToday && $c['turnover_required'] < $turnoverDisplay) {
                     continue;
                 }
@@ -326,10 +326,10 @@ class SuperballActivityService
         $tierConfigs = $this->getTierConfig();
         $ballCount = 0;
         foreach ($tierConfigs as $config) {
-            if ($config['sort_index'] > $tierConfig->sort_index) {
-                $ballCount += (int) $config['ball_count'];
+            if ($config['sort_index'] < $tierConfig->sort_index) {
+                continue;
             }
-            if ($config['sort_index'] == $tierConfig->sort_index && $complete) {
+            if ($config['recharge_required'] <= $rechargeToday && $config['turnover_required'] <= ($turnoverToday / NumConfig::NUM_VALUE)) {
                 $ballCount += (int) $config['ball_count'];
             }
         }
@@ -365,7 +365,7 @@ class SuperballActivityService
 
     public function claimIfHasVipReward(int $userId, $vipFreeBalls): bool
     {
-        $key = 'claim_vip_reward_' . $userId;
+        $key = sprintf('claim_vip_reward_%s_%s', $userId, date('Ymd'));
         if (Redis::exists($key)) {
             return false;
         }
@@ -377,7 +377,7 @@ class SuperballActivityService
                 'updated_at' => now()->format('Y-m-d H:i:s'),
             ]);
         Redis::set($key, $vipFreeBalls);
-        Redis::expireAt($key, strtotime('today +1 day'));
+        Redis::expire($key, 86400);
         return true;
     }
 
@@ -387,13 +387,12 @@ class SuperballActivityService
      */
     public function submitNumbers(int $userId, array $numbers): array
     {
-        $key = 'claim_vip_reward_' . $userId;
+        $key = sprintf('claim_vip_reward_%s_%s', $userId, date('Ymd'));
         $vipFreeBalls = (int) Redis::get($key);
-        if ($vipFreeBalls == 0) {
-            $vipLevel = $this->getUserVipLevel($userId);
-            $level = VipService::getVipByField('VIP', $vipLevel);
-            $vipFreeBalls = $level ? ($level->SuperballNum ?? 0) : 0;
-        }
+        $vipLevel = $this->getUserVipLevel($userId);
+        $level = VipService::getVipByField('VIP', $vipLevel);
+        $vipFreeBalls2 = $level ? ($level->SuperballNum ?? 0) : 0;
+        $vipFreeBalls = max($vipFreeBalls, $vipFreeBalls2);
         $today = Carbon::today()->format('Y-m-d');
         $task = $this->getUserTask($userId, $today);
 
@@ -401,20 +400,13 @@ class SuperballActivityService
         $tierConfig = $this->getTierConfigByTier($task->tier);
         $rechargeToday = $this->getUserRechargeForDate($userId, $today);
         $turnoverToday = $this->getUserTotalBetForDate($userId, $today);
-        $rechargeOk = ($rechargeToday) >= (int) $tierConfig->recharge_required;
-        $turnoverOk = ($turnoverToday / NumConfig::NUM_VALUE) >= (int) $tierConfig->turnover_required;
-        $complete = 1;
-        if (!$rechargeOk || !$turnoverOk) {
-            // 本档没完成
-            $complete = 0;
-        }
         if ($task && $task->status == 1) {
             $tierConfigs = $this->getTierConfig();
             foreach ($tierConfigs as $config) {
-                if ($config['sort_index'] > $tierConfig->sort_index) {
-                    $ballCount += (int) $config['ball_count'];
+                if ($config['sort_index'] < $tierConfig->sort_index) {
+                    continue;
                 }
-                if ($config['sort_index'] == $tierConfig->sort_index && $complete) {
+                if ($config['recharge_required'] <= $rechargeToday && $config['turnover_required'] <= ($turnoverToday / NumConfig::NUM_VALUE)) {
                     $ballCount += (int) $config['ball_count'];
                 }
             }