爆币后台接口开发提交

This commit is contained in:
2025-12-21 20:01:47 +08:00
parent 444a2c59e8
commit bf3b69da7d
5 changed files with 150 additions and 19 deletions

View File

@@ -1362,17 +1362,14 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
// 1001 => [2001 => 0.5],
//测试数据
// 20060 => [$selected_gift_id => 2],
// 在这里可以添加更多规则 【正式规则】
21222 => [$selected_gift_id => 6],
21259 => [$selected_gift_id => 6],
21222 => [$selected_gift_id => 6],//10012
21259 => [$selected_gift_id => 6],//10049
];
// 如果没有指定用户或该用户没有特殊概率调整,则直接返回原数组
if ($user_id <= 0 || !isset($probability_adjustments[$user_id])) {
return $gifts;
}
$adjusted_gifts = [];
foreach ($gifts as $gift) {
$adjusted_gift = $gift;
@@ -1380,19 +1377,15 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
if (isset($probability_adjustments[$user_id][$gift['foreign_id']])) {
// 降低该礼物的剩余数量权重(相当于降低被抽中的概率)
$reduction_factor = $probability_adjustments[$user_id][$gift['foreign_id']];
// $adjusted_gift['remaining_number'] = max(1, intval($gift['remaining_number'] * $reduction_factor));
//从数组中随机取出一个数
//概率数组
$pros[0] = 1;
for ($i = 1; $i <= $reduction_factor; $i++) {
$pros[$i] = 0;
// 使用更合理的概率降低方式
// reduction_factor为6表示只有原来的1/6概率即降低5/6概率
if (mt_rand(1, $reduction_factor) != 1) {
// 按概率移除此礼物将其剩余数量设为0
$adjusted_gift['remaining_number'] = 0;
}
$prosandomKey = array_rand($pros);
$adjusted_gift['remaining_number'] = $pros[$prosandomKey];
}
$adjusted_gifts[] = $adjusted_gift;
}
return $adjusted_gifts;
}