Răsfoiți Sursa

fix submit numbers

laowu 1 zi în urmă
părinte
comite
11d5de7611
1 a modificat fișierele cu 21 adăugiri și 2 ștergeri
  1. 21 2
      app/Services/SuperballActivityService.php

+ 21 - 2
app/Services/SuperballActivityService.php

@@ -389,17 +389,32 @@ class SuperballActivityService
     {
         $key = 'claim_vip_reward_' . $userId;
         $vipFreeBalls = (int) Redis::get($key);
+        if ($vipFreeBalls == 0) {
+            $vipLevel = $this->getUserVipLevel($userId);
+            $level = VipService::getVipByField('VIP', $vipLevel);
+            $vipFreeBalls = $level ? ($level->SuperballNum ?? 0) : 0;
+        }
         $today = Carbon::today()->format('Y-m-d');
         $task = $this->getUserTask($userId, $today);
+
         $ballCount = 0;
         $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 && $task->complete) {
+                if ($config['sort_index'] == $tierConfig->sort_index && $complete) {
                     $ballCount += (int) $config['ball_count'];
                 }
             }
@@ -415,7 +430,11 @@ class SuperballActivityService
             return ['success' => false, 'message' => ['web.superball.number_count_mismatch', 'no ball']];
         }
         if (count($numbers) + $existing > $ballCount) {
-            return ['success' => false, 'message' => ['web.superball.number_count_mismatch', 'Number count mismatch']];
+            $remain = $ballCount - $existing;
+            if ($remain < 1) {
+                return ['success' => false, 'message' => ['web.superball.number_count_mismatch', 'Number count mismatch']];
+            }
+            $numbers = array_slice($numbers, 0, $remain);
         }
 
         DB::connection('write')->transaction(function () use ($userId, $today, $numbers) {