allen 3 lat temu
rodzic
commit
c4b8602ad6
1 zmienionych plików z 3 dodań i 3 usunięć
  1. 3 3
      app/index/controller/Index.php

+ 3 - 3
app/index/controller/Index.php

@@ -505,7 +505,8 @@ class Index extends Controller
         $gifts = Db::table('awards_gift')->where('type', 1)->select();
         $logCount = Db::table('awards_user_task_log')->distinct('uid')->count('id');
 
-        $userRate = rand(0, 5000);
+        $limit = 2;
+        $userRate = rand(0, $limit);
         $giftId = 0;
         foreach ($gifts as $gift) {
             $orderCount = Db::table('awards_order')->where('type', 1)->where('gift_id', $gift['id'])->count('id');
@@ -514,7 +515,6 @@ class Index extends Controller
             }
 
             // 如果参与活动人数 5000人内 有人中奖过,那么不在计算。
-            $limit = 2;
             $total = $logCount + 1;
             if ($orderCount == floor($total/$limit)) {
                 $isWinAward = 0;
@@ -523,7 +523,7 @@ class Index extends Controller
             }
 
             for ($i=0;$i<$gift['count'];$i++) {
-                $giftRage = rand(0, 5000);
+                $giftRage = rand(0, $limit);
                 if ($userRate == $giftRage) {
                     $isWinAward = 1;
                     $giftId = $gift['id'];