天空之镜加概率限制

This commit is contained in:
2026-01-16 23:53:06 +08:00
parent aaea1c429a
commit 30461d6986

View File

@@ -50,7 +50,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
return $validationResult; return $validationResult;
} }
//2.预计算抽奖结果 //2.预计算抽奖结果
$precomputeResult = $this->precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods ); $precomputeResult = $this->precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods,$user_id );
$precomputedResults = $precomputeResult['precomputedResults']; //预计算结果集 $precomputedResults = $precomputeResult['precomputedResults']; //预计算结果集
$availableGiftss = $precomputeResult['precomputedResultss']; //可用礼物/需更新的礼物/需更新 $availableGiftss = $precomputeResult['precomputedResultss']; //可用礼物/需更新的礼物/需更新
@@ -136,7 +136,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
/** /**
* 预计算抽奖结果 * 预计算抽奖结果
*/ */
private function precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods) private function precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods,$user_id)
{ {
$pan_total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id); //总抽奖次数 $pan_total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id); //总抽奖次数
$pan_total_remaining = $this->getCachedPanTotalRemaining($gift_bag_id); //剩余数量 $pan_total_remaining = $this->getCachedPanTotalRemaining($gift_bag_id); //剩余数量
@@ -244,6 +244,23 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
$selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew); $selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew);
} }
$gift = $giftInfoMap[$selectedGift['foreign_id']]??[]; $gift = $giftInfoMap[$selectedGift['foreign_id']]??[];
//防止过高爆率,检查本期用户概率
//当前用户在本期的(补偿 防止漏洞 超过预期 把盘拉平)
//总抽奖金额(支出)
$total_money = db::name('vs_gift_bag_receive_log')->where(['gift_bag_id' => $gift_bag_id,'user_id' => $user_id,'periods'=>$periods])->sum('bag_price');
//总礼物价值(收入)
$total_gift_money = db::name('vs_gift_bag_receive_log')->where(['gift_bag_id' => $gift_bag_id,'user_id' => $user_id,'periods'=>$periods])->sum('gift_price');
if($total_money>0 && $total_gift_money>0){
$ratio =round(($total_gift_money / $total_money),3) ?? 0;
if($ratio > 1.03){
$gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
if($gift_bag_detail_duo){
$gift_bag_detail = $gift_bag_detail_duo;
}
}
}
$precomputedResults[] = [ $precomputedResults[] = [
'gift_user_id' => $giftUserId, 'gift_user_id' => $giftUserId,
'gift_bag_detail' => $selectedGift, 'gift_bag_detail' => $selectedGift,