update crmeb/app/services/activity/lottery/LuckPrizeServices.php.

抽奖随机bug,当随机数=$totalChance时,无法取到随机,应减1。
0到$totalChance-1
这样才能跟“if ($prizeChance >= $startChance && $prizeChance < $newStartChance) {” 这行的$prizeChance < $newStartChance 匹配为true
This commit is contained in:
寒冰 2021-11-18 07:56:29 +00:00 committed by Gitee
parent db681497a0
commit a8d0d4c9d5

View File

@ -173,7 +173,7 @@ class LuckPrizeServices extends BaseServices
if (!$totalChance) return $prize;
$startChance = 0;
mt_srand();
$prizeChance = rand(0, $totalChance);
$prizeChance = rand(0, $totalChance-1);
$newPrize = array_combine(array_column($data, 'type'), $data);
foreach ($data as $item) {
$newStartChance = $item['chance'] + $startChance;